Esempio n. 1
0
        public IActionResult Update(int id, UpdateCityDTO updateCityDTO)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                _cityAppService.Update(updateCityDTO);

                _generalAppService.CommitTransaction();

                return(Ok(new Response {
                    Message = "City updated"
                }));
            }
            catch (Exception ex)
            {
                _generalAppService.RollbackTransaction();

                return(BadRequest(new Response {
                    Message = ex.Message
                }));
            }
        }
Esempio n. 2
0
 public async Task <IActionResult> UpdateCity(Guid id, [FromBody] UpdateCityDTO city)
 {
     return(await _mediator.Send(new UpdateCityRequest()
     {
         Id = id, City = city
     }));
 }
Esempio n. 3
0
        public bool Update(UpdateCityDTO updateCityDTO)
        {
            if (updateCityDTO == null)
            {
                throw new ArgumentNullException();
            }

            bool result = false;
            City city   = Mapper.Map <City>(updateCityDTO);

            TheUnitOfWork.CityRepo.Update(city);
            result = TheUnitOfWork.SaveChanges() > new int();
            return(result);
        }
Esempio n. 4
0
 public ActionResult Put([FromBody] UpdateCityDTO updateCityDTO)
 {
     try
     {
         _cityService.Update(updateCityDTO);
         return(Ok());
     }
     catch (Exception e)
     {
         string errors = e.Message;
         return(ValidationProblem(new ValidationProblemDetails()
         {
             Type = "Model Validation Error",
             Detail = errors
         }));
     }
 }
Esempio n. 5
0
        public void Update(UpdateCityDTO model)
        {
            var city = _mapper.Map <UpdateCityCommand>(model);

            _bus.SendCommand(city);
        }