public async Task HandleAsync(UpdateAssignmentCommand command) { var assignment = await _repository.GetById(command.Id); if (assignment == null) { throw new EntityNotFoundException($"Assignment with ID '{command.Id}' Not Found."); } if (!string.IsNullOrEmpty(command.Title)) { assignment.Title = command.Title; } if (!string.IsNullOrEmpty(command.Description)) { assignment.Description = command.Description; } if (command.PublishAt != null) { assignment.PublishAt = command.PublishAt; } if (command.DeadlineAt != null) { assignment.DeadlineAt = command.DeadlineAt; } await _repository.Update(assignment); await _commandStoreService.PushAsync(command); }
public async Task <IActionResult> Update([FromBody] UpdateAssignmentCommand command) { await Mediator.Send(command); return(NoContent()); }