public async Task <IActionResult> Put(Guid key, string values) { var newModel = new SalesPerson(); JsonConvert.PopulateObject(values, newModel); var oldModel = _salesRepo.GetByUid(key); if (oldModel == null) { return(StatusCode(409, "Sales person of the branch not found.")); } if (await ChangeEmailAsync(oldModel, newModel)) { JsonConvert.PopulateObject(values, oldModel); if (!TryValidateModel(oldModel)) { return(BadRequest(GetFullErrorMessage(ModelState))); } _salesRepo.Update(oldModel); return(_uow.Commit() ? Ok() : StatusCode(StatusCodes.Status500InternalServerError)); } else { return(BadRequest(GetFullErrorMessage(this.ModelState))); } }
public async Task <IActionResult> PutSalesPersons(int id, SalesPersons salesPersons) { if (id != salesPersons.SalesPersonsId) { return(BadRequest()); } await _salesPersonRepository.Update(salesPersons); return(NoContent()); }