Beispiel #1
0
 public IHttpActionResult Create([FromBody]CreateRequestModel model)
 {
     var taskList = taskListService.GetById(model.TaskListId);
     if (!taskListService.CheckRight(taskList, CurrentUser.UserName, "create-tasks"))
     {
         return Unauthorized();
     }
     Priority priority = Priority.Normal;
     switch (model.Priority)
     {
         case "High": priority = Priority.High; break;
         case "Low": priority = Priority.Low; break;
         case "Normal": priority = Priority.Normal; break;
     }
     var task = new Task
     {
         Description = model.Description,
         EndDateTime = model.EndDateTime,
         Priority = priority,
         Title = model.Title,
         TaskListId = model.TaskListId
     };
     taskService.Add(task);
     return Created(Request.RequestUri, task);
 }
Beispiel #2
0
 public void Delete(Task item)
 {
     db.Tasks.Remove(item);
     db.SaveChanges();
 }
Beispiel #3
0
 public void Update(Task item)
 {
     db.Entry(item).State = EntityState.Modified;
     db.SaveChanges();
 }
Beispiel #4
0
 public void Add(Task item)
 {
     db.Tasks.Add(item);
     db.SaveChanges();
 }