public static ShoppingListViewModel OrganizeShoppingList(ShoppingListViewModel shopListVM)
 {
     int cnt = shopListVM.OnlineSnacksAlwaysPurchased.Count();
     //Only Ten Snacks Can Be Chosen
     if (cnt >= 10)
     {
         shopListVM.OnlineSnacksShoppingList = shopListVM.OnlineSnacksAlwaysPurchased.Take(10);
     }
     else
     {
         int leftOver = 10 - cnt;
         if (leftOver > 1)
         {
             // TODO: Join Voting Tables To Suggestions and Sort
             //shopListVM.OnlineSnacksSuggested
             shopListVM.OnlineSnacksShoppingList =
                         shopListVM.OnlineSnacksAlwaysPurchased.Take(cnt)
                             .Concat(shopListVM.OnlineSnacksSuggested.Take(leftOver));
         }
         else
         {
             //With only one record to add on, don't bother sorting
             shopListVM.OnlineSnacksShoppingList =
                         shopListVM.OnlineSnacksAlwaysPurchased.Take(cnt)
                             .Concat(shopListVM.OnlineSnacksSuggested.Take(leftOver));
         }
     }
     return shopListVM;
 }
        public ActionResult ShoppingList()
        {
            ShoppingListViewModel shopListVM = new ShoppingListViewModel();

            //Make Web Service Request
            string serviceURL = "https://api-snacks.nerderylabs.com/v1/snacks/";
            var client = new RestClient(serviceURL, HttpVerb.GET);
            var json = client.MakeSnackRequest("");

            //Parse JSON Into PRoper Payload Structure
            List<RestDataModel.GetSnacks> payload = JsonConvert.DeserializeObject<List<RestDataModel.GetSnacks>>(json);

            shopListVM.OnlineSnacksSuggested = payload.Where(x => x.optional == true);
            shopListVM.OnlineSnacksAlwaysPurchased = payload.Where(x => x.optional == false);

            shopListVM.votList = (from a in db.Votes
                                  select a).ToList();

            shopListVM = ShoppingListViewLogic.OrganizeShoppingList(shopListVM);

            return View(shopListVM);
        }