Пример #1
0
        /*GET list of packages with the given
         * car id, no of days, rental type, meal,
         * fuel and permission
         */
        public List <PackageTable> getPackageList(int CarId, int days, int rentType, int meals, int fuel, int isAuthorize)
        {
            int     RentType        = rentType;
            int     rsvRentType     = RentType;
            int     rsvDays         = days;
            int     rsvIncludeMeals = meals;
            int     rsvIncludeFuel  = fuel;
            decimal TotalRate       = 1;
            int     adjDays         = (rsvDays - 1); //subtract 1 day for the fuel calculation

            List <PackageTable>   packages    = new List <PackageTable>();
            List <CarRatePackage> packageList = db.CarRatePackages.Where(c => c.Status == "ACT" || c.Status == "SYS").ToList();

            //list of package
            foreach (var pkg in packageList)
            {
                //package rates of car unit
                var carRatePackage = pkg.CarRateUnitPackages.Where(c => c.CarUnitId == CarId && c.CarRatePackage.Id == pkg.Id).FirstOrDefault();

                //handle meals
                decimal MealsRate    = getMealsCalc(rsvIncludeMeals, pkg.DailyMeals, pkg.DailyRoom, adjDays, rsvRentType);
                string  MealsRateTxt = getMealsCalcTxt(rsvIncludeMeals, pkg.DailyMeals, pkg.DailyRoom, adjDays, rsvRentType, isAuthorize);

                //handle fuel
                decimal FuelRate    = getFuelCalc(rsvIncludeFuel, carRatePackage.FuelDaily, carRatePackage.FuelLonghaul, rsvDays, rsvRentType, pkg.Id);
                string  FuelRateTxt = getFuelCalcTxt(rsvIncludeFuel, carRatePackage.FuelDaily, carRatePackage.FuelLonghaul, rsvDays, rsvRentType, pkg.Id, isAuthorize);

                //handle unit Rate
                decimal carRate    = getCarRateCalc(CarId, days, (decimal)carRatePackage.DailyAddon, carRatePackage.DailyRate);
                string  carRatetxt = getCarRateCalcTxt(CarId, days, (decimal)carRatePackage.DailyAddon, carRatePackage.DailyRate, isAuthorize);

                //handle total Rate
                TotalRate = MealsRate + FuelRate + carRate;

                PackageTable newPkg = new PackageTable();
                newPkg.Id          = pkg.Id;
                newPkg.Description = pkg.Description;
                newPkg.Fuel        = FuelRate;
                newPkg.Meals       = (MealsRate);
                newPkg.Days        = (rsvDays);
                newPkg.Rate        = TotalRate;
                newPkg.TextMeals   = MealsRateTxt;
                newPkg.TextFuel    = FuelRateTxt;

                if (isAuthorize == 1)    //guest user
                {
                    newPkg.TextRate = carRatetxt + " + m: " + MealsRate + " + f: " + FuelRate;
                }
                else       //guest user
                {
                    newPkg.TextRate = carRatetxt;
                }

                packages.Add(newPkg);
            }

            return(packages);
        }
Пример #2
0
        //Get the selected package by package ID
        public PackageTable getPackageSummary(int CarId, int days, int rentType, int meals, int fuel, int selectedPkgId, int isAuthorize)
        {
            int     RentType        = rentType;
            int     rsvRentType     = RentType;
            int     rsvDays         = days;
            int     rsvIncludeMeals = meals;
            int     rsvIncludeFuel  = fuel;
            decimal TotalRate       = 1;
            int     adjDays         = (rsvDays - 1); //subtract 1 day for the fuel calculation

            PackageTable   packages = new PackageTable();
            CarRatePackage pkg      = db.CarRatePackages.Where(c => c.Id == selectedPkgId).FirstOrDefault();

            //package rates of car unit
            var carRatePackage = pkg.CarRateUnitPackages.Where(c => c.CarUnitId == CarId && c.CarRatePackage.Id == pkg.Id).FirstOrDefault();

            //handle meals
            decimal MealsRate    = getMealsCalc(rsvIncludeMeals, pkg.DailyMeals, pkg.DailyRoom, adjDays, rsvRentType);
            string  MealsRateTxt = getMealsCalcTxt(rsvIncludeMeals, pkg.DailyMeals, pkg.DailyRoom, adjDays, rsvRentType, isAuthorize);
            //handle fuel
            decimal FuelRate    = getFuelCalc(rsvIncludeFuel, carRatePackage.FuelDaily, carRatePackage.FuelLonghaul, rsvDays, rsvRentType, pkg.Id);
            string  FuelRateTxt = getFuelCalcTxt(rsvIncludeFuel, carRatePackage.FuelDaily, carRatePackage.FuelLonghaul, rsvDays, rsvRentType, pkg.Id, isAuthorize);

            //handle unit Rate
            decimal carRate    = getCarRateCalc(CarId, days, (decimal)carRatePackage.DailyAddon, carRatePackage.DailyRate);
            string  carRatetxt = getCarRateCalcTxt(CarId, days, (decimal)carRatePackage.DailyAddon, carRatePackage.DailyRate, isAuthorize);

            //handle total Rate
            TotalRate = MealsRate + FuelRate + carRate;

            PackageTable newPkg = new PackageTable();

            newPkg.Id          = pkg.Id;
            newPkg.Description = pkg.Description;
            newPkg.Fuel        = FuelRate;
            newPkg.Meals       = (MealsRate);
            newPkg.Days        = (rsvDays);
            newPkg.Rate        = TotalRate;
            newPkg.TextMeals   = MealsRateTxt;
            newPkg.TextFuel    = FuelRateTxt;

            if (isAuthorize == 1)   // admin user
            {
                newPkg.TextRate = carRatetxt + " + m: " + MealsRate + " + f: " + FuelRate;
            }
            else                    // guest user
            {
                newPkg.TextRate = carRatetxt;
            }


            packages = newPkg;

            return(packages);
        }