public async Task <int> Insert(EditableStewardessFields createStewardessRequest) { var entityToUpdate = _mapper.Map <Stewardess>(createStewardessRequest); await _unitOfWork.StewardessRepository.Insert(entityToUpdate); await _unitOfWork.SaveChangesAsync(); return(entityToUpdate.Id); }
public async Task <ActionResult> Post([FromBody] EditableStewardessFields createStewardessRequest) { var insertedId = await _stewardessService.Insert(createStewardessRequest); var result = await _stewardessService.GetById(insertedId); var url = Url.Link("GetStewardess", new { id = result.Id }); return(Created(url, result)); }
public async Task <bool> Update(int id, EditableStewardessFields updateStewardessRequest) { var stewardessToUpdate = _mapper.Map <Stewardess>(updateStewardessRequest); stewardessToUpdate.Id = id; var result = await _unitOfWork.StewardessRepository.Update(stewardessToUpdate); await _unitOfWork.SaveChangesAsync(); return(result); }
public async Task <ActionResult> Put(int id, [FromBody] EditableStewardessFields updateStewardessRequest) { var success = await _stewardessService.Update(id, updateStewardessRequest); if (success) { return(Ok()); } return(BadRequest()); }