Commits

Christian Specht  committed 3d70c1d

filter by category

  • Participants
  • Parent commits af4b0ae

Comments (0)

Files changed (2)

File src/Tasko.Server/Controllers/TasksController.cs

     {
         Task[] tasks = new Task[]
         {
-            new Task { Id = 1, Description = "task1" },
-            new Task { Id = 2, Description = "task2" }
+            new Task { Id = 1, Description = "task1", Categories= new List<string> { "CatA" } }, 
+            new Task { Id = 2, Description = "task2", Categories= new List<string> { "CatA", "CatB" } }            
         };
 
         public IEnumerable<Task> Get()
             return tasks;
         }
 
+        public IEnumerable<Task> Get(string category)
+        {
+            return tasks.Where(t => t.Categories.Any(c => c.Contains(category)));
+        }
+
         public Task Get(int id)
         {
             var task = tasks.SingleOrDefault(t => t.Id == id);

File src/Tasko.Server/Models/Task.cs

-
+using System.Collections.Generic;
+
 namespace Tasko.Server.Models
 {
     public class Task
     {
         public int Id { get; set; }
         public string Description { get; set; }
+        public List<string> Categories { get; set; }
     }
 }