protected FoodItemViewModel GetTestFoodItemViewModel(int id = 0) { var viewModel = new FoodItemViewModel { FoodItemId = id, Title = "Yummy", Description = "Seriously, this is amazing!" }; return viewModel; }
/// <summary> /// Get an event view model for testing purposes /// </summary> /// <param name="id">The id of the view model (default = 0)</param> protected EditEventViewModel GetTestEventViewModel(int id = 0) { //People var theHost = new PersonViewModel { PersonId = 1 }; var guestOne = new PersonViewModel{ PersonId = 2 }; var guestTwo = new PersonViewModel { PersonId = 3 }; var theInvitees = new List<PersonViewModel> { guestOne, guestTwo }; //Food var burgers = new FoodItemViewModel { FoodItemId = 1, Title = "Hambergers", Description = "Apple bacon smoked burgers for 10 people." }; var coke = new FoodItemViewModel { FoodItemId = 2, Title = "Coke", Description = "Two 6 packs" }; var cheese = new FoodItemViewModel { FoodItemId = 3, Title = "Cheese", Description = "Good with crackers" }; var foodForTheParty = new List<FoodItemViewModel> { coke, cheese }; //Games var settlers = new GameViewModel { GameId = 1, Title = "Settlers of Catan", Description = "The best game ever for up to four people" }; var blockus = new GameViewModel { GameId = 2, Title = "Blockus", Description = "Fun game of shape fitting for up four people." }; var gamesForTheParty = new List<GameViewModel> { settlers,blockus }; var viewModel = new EditEventViewModel { EventId = id, Title = "My Test Event", Description = "This is a fun test event", Location = "My House", StartDate = DateTime.Now, StartTime = "5:00 PM", EndTime = "2:00 AM", WillBringTheseFoodItems = foodForTheParty, WillBringTheseGames = gamesForTheParty, PeopleInvited = theInvitees }; return viewModel; }
/// <summary> /// Get the food items that have been added to the event but no one is bringing yet. /// </summary> /// <param name="eventFoodItemIds">A list of all food item ids that are associated to the event</param> /// <param name="personFoodItemIds">A list of all the food ids that the person is bringing personally</param> /// <param name="eventId">An event id</param> /// <returns></returns> private List<FoodItemViewModel> GetNonSelectedFoodItems(List<int> eventFoodItemIds, List<int> personFoodItemIds, int eventId) { var foodList = new List<FoodItemViewModel>(); var selectedFoodItemIds = personFoodItemIds.Where(x => !eventFoodItemIds.Contains(x)); var remainingFoodItems = _foodRepository.GetAll() .Where(x => selectedFoodItemIds.Contains(x.FoodItemId)) .OrderBy(x => x.Title).ToList(); remainingFoodItems.ForEach(x => { var viewModel = new FoodItemViewModel(x); viewModel.Index = remainingFoodItems.IndexOf(x); viewModel.EventId = eventId; foodList.Add(viewModel); }); return foodList; }