public ActionResult Edit() { TasksEditVM model = new TasksEditVM(); TryUpdateModel(model); Task task; if (model.ID == 0) { task = new Task(); } else { task = new TasksRepository().GetByID(model.ID); } task.ID = model.ID; task.Caption = model.Caption; task.Body = model.Body; task.Date = model.Date; task.Time = model.Time; new TasksRepository().Save(task); return(RedirectToAction("List")); }
private string PrepareStatusChange(TasksEditVM model) { var action = "was updated"; if (model.Status.ToString() != model.OldStatus.ToString()) { action = $@"updated status from {model.OldStatus.GetDescription()} to {model.Status.GetDescription()}"; } return($"'{model.Name}' {action}"); }
public IActionResult Post([FromForm] TasksEditVM model) { if (model == null) { return(BadRequest()); } var entity = new TaskEditDto(); _mapper.Map(model, entity); var changes = PrepareStatusChange(model); _tasksService.SaveTicket(entity); _messageHubService.Clients.All.GetMessage(changes); return(Ok(entity)); }
public ActionResult Edit(int?id) { TasksEditVM model = new TasksEditVM(); Task task; if (id.HasValue) { task = new TasksRepository().GetByID(id.Value); } else { task = new Task(); } model.ID = task.ID; model.Body = task.Body; model.Caption = task.Caption; model.Date = task.Date; model.Time = task.Time; return(View(model)); }