示例#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;
        }
 public RecipeControl()
 {
     InitializeComponent();
     this.DataContext = this;
     Prices = new PriceData() { PriceLow = 0, PriceMed = 0, PriceHigh = 0 };
 }