示例#1
0
        public void InitFromRestaurant(RestaurantModel restaurant)
        {
            Size  = restaurant.Sizes.Where(x => x.ID == SizeID).Select(y => y.Name).First();
            Crust = restaurant.Crusts.Where(x => x.ID == CrustID).Select(y => y.Name).First();
            if (PresetID != null)
            {
                Preset     = restaurant.Presets.Where(x => x.ID == PresetID).Select(y => y.Name).First();
                ToppingIDs = restaurant.Presets.Where(x => x.ID == PresetID).First().Toppings.Select(y => y.ID).ToList();
            }
            if (ToppingIDs == null)
            {
                ToppingIDs = new List <int>();
            }
            Toppings = restaurant.Toppings.Join(ToppingIDs, x => x.ID, y => y, (x, y) => new { X = x, Y = y }).Select(z => z.X.Name).ToList();

            Price = Library.BusinessLogic.CalcCost(ModelMapper.Map(this));
        }