Ejemplo n.º 1
0
        public SelectedProductsVM GetSelectedProductsByCID(int cid) // REDO FÖR TESTING
        {
            var selectedProducts = context.Customer
                                   .Where(c => c.CustomerId == cid)
                                   .SelectMany(c => c.Order.OrderToProduct.Select(otp => otp.Product))
                                   .ToArray();

            var viewModel = new SelectedProductsVM
            {
                Shower         = GetProductName(PCategory.Shower, selectedProducts),
                ShowerPrice    = GetProductPrice(PCategory.Shower, selectedProducts),
                Toilet         = GetProductName(PCategory.Toilet, selectedProducts),
                ToiletPrice    = GetProductPrice(PCategory.Toilet, selectedProducts),
                Sink           = GetProductName(PCategory.Sink, selectedProducts),
                SinkPrice      = GetProductPrice(PCategory.Sink, selectedProducts),
                Cabinet        = GetProductName(PCategory.Cabinet, selectedProducts),
                CabinetPrice   = GetProductPrice(PCategory.Cabinet, selectedProducts),
                Faucet         = GetProductName(PCategory.Faucet, selectedProducts),
                FaucetPrice    = GetProductPrice(PCategory.Faucet, selectedProducts),
                Lightning      = GetProductName(PCategory.Lighting, selectedProducts),
                LightningPrice = GetProductPrice(PCategory.Lighting, selectedProducts),
                Tile           = GetProductName(PCategory.Tile, selectedProducts),
                TilePrice      = GetProductPrice(PCategory.Tile, selectedProducts),
                Clinker        = GetProductName(PCategory.Clinker, selectedProducts),
                ClinkerPrice   = GetProductPrice(PCategory.Clinker, selectedProducts),
            };

            viewModel.TotalProductCost = CalculateCustomerTotalProductCost(viewModel, cid);

            return(viewModel);
        }
Ejemplo n.º 2
0
        private decimal CalculateCustomerTotalProductCost(SelectedProductsVM productList, int cid) // TODO: Måste provas.
        {
            var squareMeters = context.Customer
                               .Where(c => c.CustomerId == cid)
                               .Select(c => c.Order.SquareMeter).Single();

            return
                ((productList.ShowerPrice) +
                 (productList.ToiletPrice) +
                 (productList.SinkPrice) +
                 (productList.CabinetPrice) +
                 (productList.FaucetPrice) +
                 (productList.LightningPrice) +
                 (productList.TilePrice * squareMeters) +
                 (productList.ClinkerPrice * squareMeters));
        }