public async Task <IActionResult> Put(int id, [FromBody] InputPlaneDTO plane) { if (ModelState.IsValid) { //Response.StatusCode = 200; await planeService.UpdatePlane(id, plane); return(Ok(plane)); } else { return(BadRequest()); } }
public async Task UpdatePlane(int id, InputPlaneDTO item) { Plane temp = Mapper.Map <InputPlaneDTO, Plane>(item); temp.Type = await IunitOfWork.PlaneTypeRepository.Get(item.Type); if (temp.Type != null) { await IunitOfWork.PlaneRepository.Update(id, temp); } else { throw new Exception(); } }
public async Task CreatePlane(InputPlaneDTO item) { Plane temp = Mapper.Map <InputPlaneDTO, Plane>(item); temp.Type = await IunitOfWork.PlaneTypeRepository.Get(item.Type); if (temp.Type != null) { await IunitOfWork.PlaneRepository.Create(temp); } else { throw new Exception(); } //await IunitOfWork.PlaneRepository.Create(Mapper.Map<PlaneDTO, Plane>(item)); }