Esempio n. 1
0
        public static PriceData GetPrices(RecipeDTO r, SizeDTO[] sizes)
        {
            PriceData result = new PriceData() { PriceLow =  BASE_PRICE * sizes[0].SizeValue,
                PriceMed = BASE_PRICE * sizes[1].SizeValue, PriceHigh = BASE_PRICE * sizes[2].SizeValue };
            if (r.Ingredients == null)
                return result;

            foreach (var i in r.Ingredients)
            {
                if (sizes.Count() != 3) throw new Exception("Invalid sizes collection");
                result.PriceLow += i.NormalWeight * (double)i.Price * sizes[0].SizeValue;
                result.PriceMed += i.NormalWeight * (double)i.Price * sizes[1].SizeValue;
                result.PriceHigh += i.NormalWeight * (double)i.Price* sizes[2].SizeValue;
            }
            return result;
        }
Esempio n. 2
0
        public RecipeDTO ToSimpleDto(Recipe r)
        {
            RecipeDTO rDto = new RecipeDTO { Name = r.Name, RecipeID = r.RecipeID };

            if (r.Ingredients != null)
            {
                List<OrderIngredientDTO> ingDtos = new List<OrderIngredientDTO>();

                foreach (var ing in r.Ingredients)
                {
                    ingDtos.Add(new IngredientAssembler().ToOrderIngredientDto(ing));
                }
                rDto.Ingredients = ingDtos;
            }

            return rDto;
        }