Exemple #1
0
        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)));
        }
Exemple #2
0
        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)));
        }
Exemple #3
0
 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();