using System; using System.Collections.Generic; namespace Sample.Silverlight.WCF.Web.Services { public class TaskService : ITaskService { static readonly List<Task> tasks = new List<Task> { new Task { Id = Guid.NewGuid(), Description = "Task 1"}, new Task { Id = Guid.NewGuid(), Description = "Task 2", IsCompleted = true} }; public Task[] GetAll() { return tasks.ToArray(); } public Task Create(string description) { var task = new Task { Id = Guid.NewGuid(), Description = description, Created = DateTime.Now, Completed = DateTime.Now }; tasks.Add(task); return task; } public Task MarkComplete(Guid id) { Task task = tasks.Find(x => x.Id == id); task.IsCompleted = true; task.Completed = DateTime.Now; return task; } public void Delete(Guid id) { Task existent = tasks.Find(x => x.Id == id); tasks.Remove(existent); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The MIT License