public async Task <IActionResult> PutTask(int id, EditTaskModel model) { var task = _mapper.Map <ProjectTask>(model); var dbTask = await _context.Tasks.SingleOrDefaultAsync(t => t.Id == id); if (dbTask == null) { return(BadRequest()); } dbTask.Name = task.Name; dbTask.TimeSpent = task.TimeSpent; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
public async Task <TaskModel> UpdateTask([FromBody] EditTaskModel input) { var result = await _taskService.UpdateTaskAsync(input.IdTask); if (result == null) { throw new NullReferenceException("This task is not update!!!"); } return(result); }
public ActionResult EditTask(int id) { var task = _bookWorkTaskService.GetBookWorkTask(id); if (task == null) { return(RedirectToAction("Index")); } var model = new EditTaskModel(); SetEditTaskParam(model, task); return(View(model)); }
private void SetEditTaskParam(EditTaskModel model, BookWorkTask task) { if (task == null) { return; } model.StatusItemList.Add(new SelectListItem() { Text = "录入", Value = ((int)TaskStatus.Entry).ToString() }); model.StatusItemList.Add(new SelectListItem() { Text = "标定", Value = ((int)TaskStatus.Mark).ToString() }); model.StatusItemList.Add(new SelectListItem() { Text = "审核", Value = ((int)TaskStatus.Check).ToString() }); model.StatusItemList.Add(new SelectListItem() { Text = "回撤", Value = ((int)TaskStatus.Revert).ToString() }); model.StatusItemList.Add(new SelectListItem() { Text = "完成", Value = ((int)TaskStatus.Complete).ToString() }); if (model.TaskId == 0) { model.TaskStatus = task.Status; } model.TaskId = task.Id; model.CheckCustomerName = model.CheckCustomerName ?? task.CheckCustomer.Username; model.EntryCustomerName = model.EntryCustomerName ?? task.EntryCustomer.Username; model.EntryCustomerId = model.EntryCustomerId ?? task.EntryCustomerId; model.CheckCustomerId = model.CheckCustomerId ?? task.CheckCustomerId; }
public ActionResult EditTask(EditTaskModel model) { var task = _bookWorkTaskService.GetBookWorkTask(model.TaskId); if (task == null) { return(RedirectToAction("Index")); } if (!ModelState.IsValid) { SetEditTaskParam(model, task); return(View("EditTask", model)); } task.EntryCustomerId = model.EntryCustomerId; task.MarkCustomerId = model.EntryCustomerId; task.CheckCustomerId = model.CheckCustomerId; task.Status = model.TaskStatus; _bookWorkTaskService.UpdateBookWorkTask(task); return(RedirectToAction("Index")); }