public Result Update(int meetupId, UpdateMeetupRequest request) { Result result = Result.Successful; var meetup = _repository.Load(meetupId); if (!meetup.Name.Equals(request.Name, StringComparison.InvariantCulture)) { result = meetup.UpdateName(request.Name); if (!result.Success) { return(result); } } if (meetup.TotalAvailableSeats != request.SeatsAvailable) { result = meetup.UpdateAvailableSeats(request.SeatsAvailable); if (!result.Success) { return(result); } } _repository.Commit(); return(result); }
public IActionResult Update(int id, UpdateMeetupRequest request) { var result = _applicationService.Update(id, request); if (result.Success) { return(Ok()); } else { return(BadRequest(new { error = result.ErrorMessage })); } }
public IActionResult Update(Guid id, UpdateMeetupRequest request) { var result = _commandDispatcher .Handle <UpdateMeetupCommand, Result>( new UpdateMeetupCommand(id, request.Name, request.SeatsAvailable)); if (result.Success) { return(Ok()); } else { return(BadRequest(new { error = result.ErrorMessage })); } }