Пример #1
0
 private List <RentalRequests> ListAllRentalRequestOfEmployeesCompany(int companyid)
 {
     try
     {
         using (var companyBusiness = new CompanyBusiness())
         {
             List <RentalRequests> rentalRequests = new List <RentalRequests>();
             foreach (var responsedRequests in companyBusiness.GetByID(companyid).RentalRequests)
             {
                 RentalRequests castedRequests = new RentalRequests()
                 {
                     RentalRequestId            = responsedRequests.RentalRequestId,
                     RentalRequestCustomerId    = responsedRequests.RentalRequestCustomerId,
                     RequestedSupplierCompanyId = responsedRequests.RequestedSupplierCompanyId,
                     RequestedVehicleId         = responsedRequests.RequestedVehicleId,
                     RequestedPickUpDate        = responsedRequests.RequestedPickUpDate,
                     RequestedDropOffDate       = responsedRequests.RequestedDropOffDate
                 };
                 rentalRequests.Add(castedRequests);
             }
             return(rentalRequests);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("There isn't any request to show.");
     }
 }
Пример #2
0
 private bool MakeRentalRequest(RentalRequests rentalRequests)
 {
     try
     {
         using (var business = new RentalRequestBusiness())
         {
             business.Insert(rentalRequests);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #3
0
 public ActionResult MakeARentalRequest(RentalRequests rentalRequests)
 {
     try
     {
         string returnView = "CustomerRentalPageView";
         if (MakeRentalRequest(rentalRequests))
         {
             return(View(returnView));
         }
         else
         {
             return(View("MakeARentalRequestView"));
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("Request doesn't exists.");
     }
 }
Пример #4
0
 private bool ApproveAndAdd(int ID)
 {
     try
     {
         using (var rentalRequesBusiness = new RentalRequestBusiness())
         {
             RentalRequests rentalreq   = rentalRequesBusiness.GetByID(ID);
             var            rentingtime = Convert.ToInt32(rentalreq.RequestedDropOffDate.Date - rentalreq.RequestedPickUpDate.Date);
             using (var vehicleBusiness = new VehicleBusiness())
             {
                 Vehicles reqvehicle = vehicleBusiness.GetByID(rentalreq.RequestedVehicleId);
                 using (var rentedvehicleBusiness = new RentedVehicleBusiness())
                 {
                     RentedVehicles rentvehicle = new RentedVehicles()
                     {
                         RentalPrice       = reqvehicle.DailyRentalPrice * rentingtime,
                         DropOffDate       = rentalreq.RequestedDropOffDate,
                         PickUpDate        = rentalreq.RequestedPickUpDate,
                         VehiclesPickUpKm  = reqvehicle.VehiclesInstantKm,
                         VehiclesDropOffKm = reqvehicle.VehiclesInstantKm + (reqvehicle.KmLimitPerDay * rentingtime),
                         SupplierCompanyId = rentalreq.RequestedSupplierCompanyId,
                         RentedVehicleId   = rentalreq.RequestedVehicleId,
                         DriverCustomerId  = rentalreq.RentalRequestCustomerId
                     };
                     DeleteRequest(ID);
                     return(rentedvehicleBusiness.Insert(rentvehicle));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log(LogTarget.File, ExceptionHelper.ExceptionToString(ex), true);
         throw new Exception("Request doesn't exists.");
     }
 }