Ejemplo n.º 1
0
        public Rezerv CancelRezervVehicle(Rezerv rezervVehicle)
        {
            Rezerv rezerv = null;

            try
            {
                VehicleRepository vehicleRepository = new VehicleRepository();
                Vehicle           vehicle           = vehicleRepository.SelectedByNumber(rezervVehicle.vehiclenumber);

                if (vehicle == null)
                {
                    throw new Exception("CustomerBisuness::RentVehicle: Vehcile Is Not Found! \n");
                }



                //Rezerv Update
                RezervRepository rezervRepository = new RezervRepository();
                rezervVehicle.isactive = 0;
                rezervRepository.Update(rezervVehicle);
                //Rezerv Get
                rezerv = rezervRepository.SelectedByVehicleAndMember(rezervVehicle.vehiclenumber, rezervVehicle.membernumber);

                //Vehicle Update
                vehicle.istaken = 0;
                vehicleRepository.Update(vehicle);
            }
            catch (Exception ex)
            {
                throw new Exception("CustomerBisuness::RentVehicle: Error occured.\n", ex);
            }
            return(rezerv);
        }
Ejemplo n.º 2
0
        public Rezerv RezervVehicle(Rezerv rezervVehicle)
        {
            Rezerv rezerv = null;

            try
            {
                VehicleRepository vehicleRepository = new VehicleRepository();
                Vehicle           vehicle           = vehicleRepository.SelectedByNumber(rezervVehicle.vehiclenumber);

                if (vehicle == null)
                {
                    throw new Exception("CustomerBisuness::RentVehicle: Vehcile Is Not Found! \n");
                }

                MemberRepository repository   = new MemberRepository();
                Member           isHaveMember = repository.SelectedByNumber(rezervVehicle.membernumber);

                if (isHaveMember == null)
                {
                    throw new Exception("CustomerBisuness::RentVehicle: Customer Is Not Found! \n");
                }

                if (vehicleRepository.VehicleIsTaken(rezervVehicle.vehiclenumber))
                {
                    throw new Exception("CustomerBisuness::RentVehicle: Vehicle Is Not Available! \n");
                }

                //Rezerv Insert
                RezervRepository rezervRepository = new RezervRepository();
                rezervRepository.Insert(rezervVehicle);
                //Rezerv Get
                rezerv = rezervRepository.SelectedByVehicleAndMember(rezervVehicle.vehiclenumber, rezervVehicle.membernumber);

                //Vehicle Update
                vehicle.istaken = 1;
                vehicleRepository.Update(vehicle);
            }
            catch (Exception ex)
            {
                throw new Exception("CustomerBisuness::RentVehicle: Error occured.\n", ex);
            }
            return(rezerv);
        }