public void Execute()
        {
            DAOFactory         daoFactory    = DAOFactory.GetFactory(DAOFactory.Type.Postgres);
            PostgresCruiserDAO layoverDao    = (PostgresCruiserDAO)daoFactory.GetCruiserDAO();
            LayoverMapper      layoverMapper = MapperFactory.CreateLayoverMapper();
            Layover            layover       = (Layover)layoverMapper.CreateEntity(_layoverDTO);

            _layoverDTO = layoverMapper.CreateDTO(layoverDao.AddLayover(layover));
        }
예제 #2
0
        public void DeleteLayoversTest()
        {
            var result = _cruiserController.PostCruiser(_cruiserDTO).Value;

            _addedcruiserList.Add(result.Id);
            _layoverDTO               = new LayoverDTO();
            _layoverDTO.CruiserId     = result.Id;
            _layoverDTO.DepartureDate = "2019-12-2";
            _layoverDTO.ArrivalDate   = "2019-12-6";
            _layoverDTO.Price         = 250;
            _layoverDTO.LocDeparture  = 1;
            _layoverDTO.LocArrival    = 2;
            var layover = _cruiserController.PostLayover(_layoverDTO).Value;

            Assert.IsInstanceOf <OkObjectResult>(_cruiserController.DeleteLayover(layover.Id));
        }
예제 #3
0
 public ActionResult <LayoverDTO> PostLayover([FromBody] LayoverDTO layover)
 {
     try
     {
         AddLayoverCommand addLayoverCommand = CommandFactory.CreateAddLayoverCommand(layover);
         addLayoverCommand.Execute();
         LayoverDTO savedLayover = addLayoverCommand.GetResult();
         _logger?.LogError("Post method for layover executed succesfully");
         return(savedLayover);
     }
     catch (CruiserNotFoundException e)
     {
         _logger?.LogError(e, "Database exception when trying to create a new layover for a given cruiser");
         return(BadRequest(new ErrorMessage(e.Message)));
     }
 }
예제 #4
0
        public void PostLayoverTest()
        {
            var result = _cruiserController.PostCruiser(_cruiserDTO).Value;

            _addedcruiserList.Add(result.Id);
            _layoverDTO               = new LayoverDTO();
            _layoverDTO.CruiserId     = result.Id;
            _layoverDTO.DepartureDate = "2019-12-2";
            _layoverDTO.ArrivalDate   = "2019-12-6";
            _layoverDTO.Price         = 250;
            _layoverDTO.LocDeparture  = 1;
            _layoverDTO.LocArrival    = 2;
            var layover = _cruiserController.PostLayover(_layoverDTO).Value;

            _layoverDTO.Id = layover.Id;
            _idABorrar     = layover.Id;
            Assert.AreEqual(_layoverDTO.CruiserId, layover.CruiserId);
        }
예제 #5
0
 public static AddLayoverCommand CreateAddLayoverCommand(LayoverDTO layoverDto)
 {
     return(new AddLayoverCommand(layoverDto));
 }
 public AddLayoverCommand(LayoverDTO layoverDTO)
 {
     _layoverDTO = layoverDTO;
 }
 public void CreateLayoverDTOTest()
 {
     _layoverDTO = _layoverMapper.CreateDTO(_layover);
     _layoverDTOList.Add(_layoverDTO);
     Assert.AreEqual(_layoverDTO.DepartureDate, _layover.DepartureDate);
 }