public async Task <PersonnelResponse> UpdateAsync(int id, Personnel category) { var existingPersonnel = await _personnelRepository.FindByIdAsync(id); if (existingPersonnel == null) { return(new PersonnelResponse("Personnel not found.")); } existingPersonnel.Name = category.Name; existingPersonnel.Surname = category.Surname; try { _personnelRepository.Update(existingPersonnel); await _unitOfWork.CompleteAsync(); return(new PersonnelResponse(existingPersonnel)); } catch (Exception ex) { // Do some logging stuff return(new PersonnelResponse($"An error occurred when updating the personnel: {ex.Message}")); } }
public IActionResult Put([FromBody] Model.Personnel personnel) { if (personnel == null) { return(BadRequest()); } bool isSuccess = _personnelRepository.Update(ModelToTable(personnel)); if (!isSuccess) { return(BadRequest()); } return(Ok()); }
public async Task <IActionResult> Update(PersonnelVM vm) { if (ModelState.IsValid) { try { var obj = (await objRep.Update(vm)); if (obj.Successed) { if (obj.ResultObject.PersonnelId > 0) { return(Ok(obj)); } else { return(NotFound()); } } else { return(NotFound(obj)); } } catch (Exception ex) { if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException") { return(NotFound()); } return(BadRequest()); } } return(BadRequest()); }
public string Put(int id, [FromBody] Personnel entity) { return(_dataRepository.Update(id, entity)); }
public void Update(Personnel_API entity) { _repo.Update(entity.ToDAL()); }