Exemplo n.º 1
0
        private UpdateSelectedProductsVM GetSelectedProductsUpdate(int id)
        {
            var selectedProducts = context.Customer
                                   .Where(c => c.CustomerId == id)
                                   .SelectMany(c => c.Order.OrderToProduct.Select(otp => otp.Product))
                                   .ToArray();

            var m = new UpdateSelectedProductsVM
            {
                Shower   = GetProductNameUpdate(PCategory.Shower, selectedProducts),
                Toilet   = GetProductNameUpdate(PCategory.Toilet, selectedProducts),
                Sink     = GetProductNameUpdate(PCategory.Sink, selectedProducts),
                Cabinet  = GetProductNameUpdate(PCategory.Cabinet, selectedProducts),
                Faucet   = GetProductNameUpdate(PCategory.Faucet, selectedProducts),
                Lighting = GetProductNameUpdate(PCategory.Lighting, selectedProducts),
                Tile     = GetProductNameUpdate(PCategory.Tile, selectedProducts),
                Clinker  = GetProductNameUpdate(PCategory.Clinker, selectedProducts),
            };

            m.ShowerItems   = SetSelectItemUpdate(PCategory.Shower);
            m.ToiletItems   = SetSelectItemUpdate(PCategory.Toilet);
            m.SinkItems     = SetSelectItemUpdate(PCategory.Sink);
            m.CabinetItems  = SetSelectItemUpdate(PCategory.Cabinet);
            m.FaucetItems   = SetSelectItemUpdate(PCategory.Faucet);
            m.LightingItems = SetSelectItemUpdate(PCategory.Lighting);
            m.TileItems     = SetSelectItemUpdate(PCategory.Tile);
            m.ClinkerItems  = SetSelectItemUpdate(PCategory.Clinker);

            return(m);
        }
Exemplo n.º 2
0
        private decimal CalculateCustomerTotalProductCost(UpdateSelectedProductsVM 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));
        }