コード例 #1
0
        public void SetUp()
        {
            UserDAO     daoUser = DAOFactory.GetFactory(DAOFactory.Type.Postgres).GetUserDAO();
            List <Role> roles   = new List <Role>();

            roles.Add(new Role(1, "Client"));
            _user = EntityFactory.CreateUser(0, 25964266, "Fernando", "Consalvo", "*****@*****.**", "123456789",
                                             roles);
            _user = daoUser.AddUser(_user);
            dao   = DAOFactory.GetFactory(DAOFactory.Type.Postgres).GetReservationVehicleDAO();
        }
コード例 #2
0
        /// <summary>
        /// Guarda una reservación de vehículo en la base de datos mediente el DAO de reservación de vehículo
        /// </summary>
        /// <exception cref="ReservationHasNoUserException">Se retorna cuando el ID del usaurio es menor o igual a 0</exception>
        /// <exception cref="ReservationHasNoVehicleException">Se retorna cuando el ID del vehiculo es menor o igual a 0</exception>
        /// <exception cref="ReservationHasNoCheckInException">Se retorna cuando no se recibe la fecha de checkin</exception>
        /// <exception cref="ReservationHasNoCheckOutException">Se retorna cuando no se revibe la fecha de checkout</exception>
        public void Execute()
        {
            if (_reservationAutomobile.UserId <= 0)
            {
                throw new ReservationHasNoUserException();
            }
            if (_reservationAutomobile.VehicleId <= 0)
            {
                throw new ReservationHasNoVehicleException();
            }
            if (_reservationAutomobile.CheckIn.Equals(DateTime.MinValue))
            {
                throw new ReservationHasNoCheckInException();
            }
            if (_reservationAutomobile.CheckOut.Equals(DateTime.MinValue))
            {
                throw new ReservationHasNoCheckOutException();
            }

            IReservationVehicleDAO dao = DAOFactory.GetFactory(DAOFactory.Type.Postgres).GetReservationVehicleDAO();

            _reservationAutomobile = dao.AddReservation(_reservationAutomobile);
        }