public int AddEditTask(TaskModel taskModel, int createdUserId) { taskModel.CreatedUserId = createdUserId; if (taskModel.Id == -1) { return CreateTask(taskModel); } else { return EditTask(taskModel); } }
public int CreateTask(TaskModel taskModel) { Task task = new Task(); task.Summary = taskModel.Summary; task.Description = taskModel.Description; task.Completed = taskModel.Completed; task.CreatedUserId = taskModel.CreatedUserId; task.DueDate = taskModel.DueDate; entities.Tasks.Add(task); entities.SaveChanges(); return task.TaskId; }
public JsonResult EditTask(TaskModel task) { return Json(oper.AddEditTask(task, HttpUserData.Get().Id), JsonRequestBehavior.DenyGet); }
private int EditTask(TaskModel taskModel) { Task task = entities.Tasks.First(t => t.TaskId == taskModel.Id); task.Summary = taskModel.Summary; task.Description = taskModel.Description; task.DueDate = taskModel.DueDate; SaveChanges(); return task.TaskId; }