public IHttpActionResult UpdateTasksGroup(TasksAction tasksAction) { Dictionary <string, object> result = new Dictionary <string, object>(); if (!isTokenValid(tasksAction.token)) { result.Add("code", HttpStatusCode.ExpectationFailed); result.Add("message", "Token is not valid."); result.Add("time", DateTime.Now.ToString("ddd, dd MMMM yyyy H:mm:ss tt")); return(Ok(result)); } TasksForGroups tasksForGroup = db.TasksForGroups.FirstOrDefault(c => c.Id == tasksAction.taskId); if (tasksForGroup != null) //add { //TasksForUser tasksForUser = db.TasksForUser.FirstOrDefault(c => c.Id == id); bool complete = true; tasksForGroup.isComplite = complete; db.SaveChanges(); result.Add("code", HttpStatusCode.Accepted); result.Add("message", "GTask was updated"); result.Add("user", tasksForGroup); } else { result.Add("code", HttpStatusCode.Found); result.Add("message", "GTask wasn't found in db."); } result.Add("time", DateTime.Now.ToString("ddd, dd MMMM yyyy H:mm:ss tt")); return(Ok(result)); }
public ActionResult UpdateTaskGroup(int id) { _context = new ApplicationDbContext(); TasksForGroups tasksForUser = _context.TasksForGroups.FirstOrDefault(c => c.Id == id); bool complete = true; tasksForUser.isComplite = complete; _context.SaveChanges(); return(RedirectToAction("Index", "MyTask")); }