コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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));
        }