public Task <IHttpActionResult> EditCity(int id, [FromBody] CityCommands.CityCreateModel model) { if (!ModelState.IsValid) { throw new BadRequestException(ModelState.ToMessage()); } return(_mediator.Send(new CityCommands.EditCityCommand(id, model)) .ContinueWith <IHttpActionResult>(t => Ok(t.Result))); }
public Task <IHttpActionResult> AddCity(CityCommands.CityCreateModel model) { if (!ModelState.IsValid) { throw new BadRequestException(ModelState.ToMessage()); } return(_mediator.Send(new CityCommands.CreateCityCommand(model)) .ContinueWith <IHttpActionResult>(t => Created(Url.SecureLink("Default", new { controller = nameof(CitiesApiController), action = nameof(GetCityById) }), t.Result))); }
public EditCityCommand(int id, CityCreateModel model) { Id = id; Model = model; }
public CreateCityCommand(CityCreateModel model) { Model = model; }
public Commands.CreateResultViewModel <City> CreateCity(CityCommands.CityCreateModel city) => _mediator .Send(new CityCommands.CreateCityCommand(city)) .ResultOrThrow();
public CityQueries.CityViewModel UpdateCity(int id, CityCommands.CityCreateModel city) => _mediator .Send(new CityCommands.EditCityCommand(id, city)) .ResultOrThrow();