コード例 #1
0
 private decimal CalculateFinalTotalWorkCost(FinalOfferVM x)
 {
     return
         ((x.DemolitionHours * x.HourlyRateDemolition) +
          (x.DrainHours * x.HourlyRateDrain) +
          (x.VentilationHours * x.HourlyRateVentilation) +
          (x.TileHours * x.HourlyRateTile) +
          (x.ElectricityHours * x.HourlyRateElectricity) +
          (x.MountingHours * x.HourlyRateMounting));
 }
コード例 #2
0
 private int CalculateFinalTotalAmountOfHours(FinalOfferVM x)
 {
     return
         ((x.DemolitionHours) +
          (x.DrainHours) +
          (x.VentilationHours) +
          (x.TileHours) +
          (x.ElectricityHours) +
          (x.MountingHours));
 }
コード例 #3
0
 private decimal CalculateFinalTotalProductCost(FinalOfferVM x)
 {
     return
         ((x.ShowerPrice) +
          (x.ToiletPrice) +
          (x.SinkPrice) +
          (x.CabinetPrice) +
          (x.FaucetPrice) +
          (x.LightningPrice) +
          (x.TilePrice * x.SquareMeter) +
          (x.ClinkerPrice * x.SquareMeter));
 }
コード例 #4
0
        public FinalOfferVM GetFinalOffer(int id)
        {
            var cust = context.Customer
                       .Include(c => c.Order)
                       .Include(c => c.Order.OrderToProduct)
                       .Include(c => c.Order.OrderToWork)
                       .FirstOrDefault(c => c.CustomerId == id);

            var selectedProducts = context.Customer
                                   .Where(c => c.CustomerId == id)
                                   .SelectMany(c => c.Order.OrderToProduct.Select(otp => otp.Product))
                                   .ToArray();

            var selectedWork = context.Work.Select(w => w).ToArray();

            var x = new FinalOfferVM
            {
                #region Customer Information

                FirstName = cust.FirstName,
                LastName  = cust.LastName,
                Email     = cust.Email,
                Phone     = cust.Phone,
                Street    = cust.Street,
                Zip       = cust.Zip,
                City      = cust.City,

                #endregion

                #region Project Specific Information

                TextBox              = cust.Order.CustomerMessage,
                SelectedProjectType  = cust.Order.ProjectType,
                SelectedPropertyType = cust.Order.PropertyType,
                SquareMeter          = cust.Order.SquareMeter,
                ViableROTCandidates  = cust.Order.ViableRotcandidates,
                RequestedStartDate   = cust.Order.RequestedStartDate,
                TravelCost           = cust.Order.TravelCost,
                WorkDiscount         = cust.Order.WorkDiscount,

                #endregion

                #region Product Information


                Shower      = GetProductName(PCategory.Shower, selectedProducts),
                ShowerPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Shower),

                Toilet      = GetProductName(PCategory.Toilet, selectedProducts),
                ToiletPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Toilet),

                Sink      = GetProductName(PCategory.Sink, selectedProducts),
                SinkPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Sink),

                Cabinet      = GetProductName(PCategory.Cabinet, selectedProducts),
                CabinetPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Cabinet),

                Faucet      = GetProductName(PCategory.Faucet, selectedProducts),
                FaucetPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Faucet),

                Lightning      = GetProductName(PCategory.Lighting, selectedProducts),
                LightningPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Lighting),

                Tile      = GetProductName(PCategory.Tile, selectedProducts),
                TilePrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Tile),

                Clinker      = GetProductName(PCategory.Clinker, selectedProducts),
                ClinkerPrice = GetFinalProductPrice(cust, selectedProducts, PCategory.Clinker),

                #endregion

                #region Work Information

                DemolitionHours      = GetFinalAmountOfHours(WorkType.Demolition, cust, selectedWork),
                HourlyRateDemolition = GetHourlyRate(WorkType.Demolition, cust, selectedWork),

                DrainHours      = GetFinalAmountOfHours(WorkType.Drain, cust, selectedWork),
                HourlyRateDrain = GetHourlyRate(WorkType.Drain, cust, selectedWork),

                VentilationHours      = GetFinalAmountOfHours(WorkType.Ventilation, cust, selectedWork),
                HourlyRateVentilation = GetHourlyRate(WorkType.Ventilation, cust, selectedWork),

                TileHours      = GetFinalAmountOfHours(WorkType.Tile, cust, selectedWork),
                HourlyRateTile = GetHourlyRate(WorkType.Tile, cust, selectedWork),

                ElectricityHours      = GetFinalAmountOfHours(WorkType.Electricity, cust, selectedWork),
                HourlyRateElectricity = GetHourlyRate(WorkType.Electricity, cust, selectedWork),

                MountingHours      = GetFinalAmountOfHours(WorkType.Mounting, cust, selectedWork),
                HourlyRateMounting = GetHourlyRate(WorkType.Mounting, cust, selectedWork),

                #endregion
            };

            #region Total Calculations

            x.TotalWorkCost           = CalculateFinalTotalWorkCost(x);
            x.TotalProductCost        = CalculateFinalTotalProductCost(x);
            x.TotalAmountOfHours      = CalculateFinalTotalAmountOfHours(x);
            x.ROTDiscount             = CalculateFinalRotDiscount(x.TotalWorkCost, x.ViableROTCandidates);
            x.TotalPrice              = x.TotalWorkCost + x.TotalProductCost + x.TravelCost;
            x.TotalPriceAfterDiscount = x.TotalPrice - x.ROTDiscount - x.WorkDiscount;

            x.DemlitionTotal   = x.DemolitionHours * x.HourlyRateDemolition;
            x.VentilationTotal = x.VentilationHours * x.HourlyRateVentilation;
            x.ElectricityTotal = x.ElectricityHours * x.HourlyRateElectricity;
            x.TileTotal        = x.TileHours * x.HourlyRateTile;
            x.DrainTotal       = x.DrainHours * x.HourlyRateDrain;
            x.MountingTotal    = x.MountingHours * x.HourlyRateMounting;

            x.TileTotalCost    = x.SquareMeter * x.TilePrice;
            x.ClinkerTotalCost = x.SquareMeter * x.ClinkerPrice;

            #endregion

            return(x);
        }