public async Task <IActionResult> Put(long id, [FromBody] EditPriceViewModel model) { if (model == null) { return(BadRequest()); } if (id != model.Id) { return(BadRequest()); } var price = await _priceRepo.GetAsync(id); if (price == null) { return(NotFound(Resources.Items.ItemResource.PriceNotFound)); } if (await _priceRepo.IsExistNameAsync(price.Id, model.Name)) { ModelState.AddModelError("Name", Resources.Global.Common.ThisNameExist); return(BadRequest(ModelState.GetWithErrorsKey())); } price.Name = model.Name; var affectedRows = await _priceRepo.EditAsync(price); if (affectedRows > 0) { var viewModel = AutoMapper.Mapper.Map <PriceViewModel>(price); return(Ok(viewModel)); } return(BadRequest()); }