public async Task <ActionResult> Update(int id, UpdateCalendarEventCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task <IActionResult> Update([FromBody] CalendarEventModel model) { var user = await _userManagerWrapper.FindByNameAsync(User.Identity.Name); model.UserId = user.Id; var updateCalendarEventCommand = new UpdateCalendarEventCommand { Model = model }; await _endpointInstance.Send("LifeManager.Calendar", updateCalendarEventCommand).ConfigureAwait(false); return(Ok()); }
public async Task HandleUpdate_ShouldCallUpdateOnService() { // Data var updateCalendarEventCommand = new UpdateCalendarEventCommand { Model = new CalendarEventModel() }; // Setup _mockCalendarService.Setup(x => x.UpdateEvent(It.Is <CalendarEventModel>(y => y == updateCalendarEventCommand.Model))) .Returns(Task.CompletedTask).Verifiable(); // Test var handler = new CalendarEventHandler(_mockCalendarService.Object); await handler.Handle(updateCalendarEventCommand, _mockMessageHandlerContext.Object); // Analysis _mockCalendarService.Verify(); }
public async Task Handle(UpdateCalendarEventCommand message, IMessageHandlerContext context) { await _calendarService.UpdateEvent(message.Model); }