public BrewingControl(Models.Recipe recipe) { InitializeComponent(); BrewingViewModel dataContext = new BrewingViewModel(recipe); DataContext = dataContext; }
public BrewingControl() { InitializeComponent(); BrewingViewModel dataContext = new BrewingViewModel(); DataContext = dataContext; }
public BrewingViewModel PrepareForBrewing(int id, List <int> brewers) { var recipe = context.Recipes.Single(t => t.Id == id); var drinkers = context.Brewers.Where(t => brewers.Contains(t.Id)); var model = new BrewingViewModel(); model.Recipe = new RecipeViewModel(recipe); model.AmberRequired = drinkers.Where(t => t.FavouriteBeerType == BeerType.Amber).Sum(t => t.Upkeep); model.LagerRequired = drinkers.Where(t => t.FavouriteBeerType == BeerType.Lager).Sum(t => t.Upkeep); model.WeissRequired = drinkers.Where(t => t.FavouriteBeerType == BeerType.Wiess).Sum(t => t.Upkeep); return(model); }