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 })); } }
public async Task <IActionResult> UpdateCity(Guid id, [FromBody] UpdateCityDTO city) { return(await _mediator.Send(new UpdateCityRequest() { Id = id, City = city })); }
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); }
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 })); } }
public void Update(UpdateCityDTO model) { var city = _mapper.Map <UpdateCityCommand>(model); _bus.SendCommand(city); }