Example #1
0
 public void Post([FromBody] TakeOffDTO takeOff)
 {
     if (ModelState.IsValid)
     {
         Response.StatusCode = 200;
         takeOffService.CreateTakeOff(takeOff);
     }
     else
     {
         Response.StatusCode = 400;
     }
 }
Example #2
0
 public void Put(int id, [FromBody] TakeOffDTO takeOff)
 {
     if (ModelState.IsValid)
     {
         Response.StatusCode = 200;
         takeOffService.UpdateTakeOff(id, takeOff);
     }
     else
     {
         Response.StatusCode = 400;
     }
 }
Example #3
0
        public async Task <IActionResult> Get(int id)
        {
            TakeOffDTO temp = await takeOffService.GetTakeOffById(id);

            if (temp != null)
            {
                return(Ok(temp));
            }
            else
            {
                return(NotFound(temp));
            }
        }
Example #4
0
        public TakeOffDTO Get(int id)
        {
            TakeOffDTO temp = takeOffService.GetTakeOffById(id);

            if (temp != null)
            {
                Response.StatusCode = 200;
            }
            else
            {
                Response.StatusCode = 404;
            }

            return(temp);
        }
Example #5
0
        public void CreateTakeOff(TakeOffDTO item)
        {
            TakeOff temp = Mapper.Map <TakeOffDTO, TakeOff>(item);

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

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

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

            if (temp.CrewId != null && temp.PlaneId != null && temp.FlightNum != null)
            {
                IunitOfWork.TakeOffRepository.Create(temp);
            }
        }
 public void UpdateTakeOff(int id, TakeOffDTO item)
 {
     IunitOfWork.TakeOffRepository.Update(id, Mapper.Map <TakeOffDTO, TakeOff>(item));
 }
Example #7
0
 public void UpdateTakeOff(int id, TakeOffDTO item)
 {
     takeOffRepo.Update(id, Mapper.Map <TakeOffDTO, TakeOff>(item));
 }
Example #8
0
 public void CreateTakeOff(TakeOffDTO item)
 {
     takeOffRepo.Create(Mapper.Map <TakeOffDTO, TakeOff>(item));
 }
        public void TakeOffCreate()
        {
            TakeOffService takeOffService = new TakeOffService(unitOfWork);

            TakeOffDTO takeOffDTO = new TakeOffDTO()
            {
                Date      = new DateTime(1, 2, 3),
                FlightNum = new FlightDTO()
                {
                    DeperturePlace = "testing",
                    ArrivalPlace   = "test",
                    DepartureTime  = new DateTime(1, 4, 3),
                    ArrivalTime    = new DateTime(1, 3, 4)
                },
                PlaneId = new PlaneDTO()
                {
                    Name         = "test",
                    Made         = new DateTime(1, 2, 3),
                    Exploitation = new TimeSpan(0, 1, 2),
                    Type         = new PlaneTypeDTO()
                    {
                        Model         = "test",
                        CarryCapacity = 12,
                        Places        = 15
                    }
                },
                CrewId = new CrewDTO()
                {
                    PilotId = new PilotDTO()
                    {
                        Name       = "pilotCreateTest",
                        Surname    = "pilotCreateTest",
                        Birth      = new DateTime(1990, 1, 1),
                        Experience = new TimeSpan(1, 2, 3)
                    },
                    StewardessIds = new StewardessDTO[]
                    {
                        new StewardessDTO()
                        {
                            Name    = "stewCreateTest1",
                            Surname = "stewCreateTest1",
                            Birth   = new DateTime(1990, 1, 1)
                        },
                        new StewardessDTO()
                        {
                            Name    = "stewCreateTest2",
                            Surname = "stewCreateTest2",
                            Birth   = new DateTime(1990, 1, 1)
                        }
                    }
                }
            };


            takeOffService.CreateTakeOff(takeOffDTO);
            TakeOff takeOff = fakeTakeOffRepository.Get(1);

            Assert.AreEqual(takeOff.Date, takeOffDTO.Date);
            Assert.AreEqual(takeOff.PlaneId.Name, takeOffDTO.PlaneId.Name);
            Assert.AreEqual(takeOff.CrewId.PilotId.Name, takeOffDTO.CrewId.PilotId.Name);
        }