예제 #1
0
        public async Task <IActionResult> Put(int id, [FromBody] InputTakeOffDTO takeOff)
        {
            if (ModelState.IsValid)
            {
                //Response.StatusCode = 200;
                await takeOffService.UpdateTakeOff(id, takeOff);

                return(Ok(takeOff));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #2
0
        public async Task UpdateTakeOff(int id, InputTakeOffDTO item)
        {
            TakeOff temp = Mapper.Map <InputTakeOffDTO, TakeOff>(item);

            temp.CrewId = await IunitOfWork.CrewRepository.Get(item.CrewId);

            temp.FlightNum = await IunitOfWork.FlightRepository.Get(item.FlightNum);

            temp.PlaneId = await IunitOfWork.PlaneRepository.Get(item.PlaneId);

            if (temp.CrewId != null && temp.PlaneId != null && temp.FlightNum != null)
            {
                await IunitOfWork.TakeOffRepository.Update(id, temp);
            }
            else
            {
                throw new Exception();
            }
        }