public IHttpActionResult CreateMeal(MealModels.MealInputModel mealModel)
        {
            var userId = HttpContext.Current.User.Identity.GetUserId();
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var restaurant = this.Data.Restaurants.All().FirstOrDefault(r => r.Id == mealModel.restaurantId);
            if (restaurant.OwnerId != userId)
            {
                return this.Unauthorized();
            }

            Meal newMeal = new Meal
            {
                Name = mealModel.name,
                Price = mealModel.price,
                TypeId = mealModel.typeId,
                RestaurantId = (int)mealModel.restaurantId
            };

            this.Data.Meals.Add(newMeal);
            this.Data.SaveChanges();

            var outputData = this.Data.Meals.All().Where(x => x.Id == newMeal.Id).Select(MealModels.MealOutputModel.Parse);

            return this.Created(Location + newMeal.Id, outputData);
        }
Example #2
0
 public void SetMeal(string name, int price, string description)
 {
     Meal meal = new Meal();
     meal.SetName(name);
     meal.SetPrice(price);
     meal.SetDescription(description);
     _mealList.Add(meal);
 }
        public Meal PrepareNonVeganMeal()
        {
            var meal = new Meal();

            meal.AddItem(new ChickenBurger());
            meal.AddItem(new Pepsi());

            return meal;
        }
        public Meal PrepareVeganMeal()
        {
            var meal = new Meal();

            meal.AddItem(new VeganBurger());
            meal.AddItem(new Coke());

            return meal;
        }
Example #5
0
 public void FindInsulinByMeal_IfTwoInsulinsInHour_ReturnsCloserInsulin()
 {
     var insulin1 = new Insulin { DateTime = DateTime.Now.AddHours(0.9) };
     var insulin2 = new Insulin { DateTime = DateTime.Now.AddHours(-0.8) };
     factories.Setup(f => f.Insulins).Returns(new List<Insulin> { insulin1, insulin2 });
     var finder = new FinderImpl(factories.Object);
     var meal = new Meal { DateTime = DateTime.Now };
     var insulin = finder.FindInsulinByMeal(meal);
     Assert.AreSame(insulin2, insulin);
 }
Example #6
0
 public void FindInsulinByMeal_IfNoInsulinsInHour_ReturnsNull()
 {
     var insulin1 = new Insulin { DateTime = DateTime.Now.AddHours(1.1) };
     var insulin2 = new Insulin { DateTime = DateTime.Now.AddHours(-1.1) };
     factories.Setup(f => f.Insulins).Returns(new List<Insulin> { insulin1, insulin2 });
     var finder = new FinderImpl(factories.Object);
     var meal = new Meal { DateTime = DateTime.Now };
     var insulin = finder.FindInsulinByMeal(meal);
     Assert.IsNull(insulin);
 }
        public async Task<bool> DeleteMeal(Meal meal)
        {
            var request = new RestRequest(string.Format("/meals/{0}", meal.Id), Method.DELETE);
            var success = await this.restClient.ExecuteTaskAsync(request);

            if (success.StatusCode == HttpStatusCode.OK)
                return true;

            return false;
        }
        public async Task<bool> AddMeal(Meal meal)
        {
            var request = new RestRequest("/meals", Method.POST);
            request.AddParameter("Name", meal.Name);
            var success = await this.restClient.ExecuteTaskAsync(request);

            if (success.StatusCode == HttpStatusCode.OK)
                return true;

            return false;
        }
Example #9
0
        public IHttpActionResult Create([FromBody]CreateMealBindingModel model)
        {
            if (model == null)
            {
                return this.BadRequest();
            }

            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var type = this.Data.MealTypes
                .FirstOrDefault(mt => mt.Id == model.TypeId);

            if (type == null)
            {
                return this.BadRequest();
            }

            var restaurant = this.Data.Restaurants
                .FirstOrDefault(r => r.Id == model.RestaurantId);

            if (restaurant == null)
            {
                return this.BadRequest();
            }

            string userId = this.User.Identity.GetUserId();

            if (restaurant.OwnerId != userId)
            {
                return this.Unauthorized();
            }

            var newMeal = new Meal()
            {
                Name = model.Name,
                Price = model.Price,
                TypeId = model.TypeId,
                RestaurantId = model.RestaurantId
            };

            this.Data.Meals.Add(newMeal);
            this.Data.SaveChanges();

            var mealViewModel = this.Data.Meals
                .Where(m => m.Id == newMeal.Id)
                .Select(MealViewModel.Create);

            return this.CreatedAtRoute("DefaultApi", new { id = newMeal.Id }, mealViewModel);
        }
        public ActionResult Create(Meal meal)
        {
            if (ModelState.IsValid)
            {
                db.Meals.Add(meal);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MealTypeId = new SelectList(db.MealTypes, "Id", "Name", meal.MealTypeId);
            ViewBag.RestaurantId = new SelectList(db.Restaurants, "Id", "Name", meal.RestaurantId);
            return View(meal);
        }
        public InsertView(Meal meal)
            : this()
        {
            currentMeal = meal;
            NewReceipt.Text = meal.Name;
            DeleteButton.IsVisible = true;

            DeleteButton.Clicked += async (sender, args) =>
            {
                await App.MealManager.DeleteMeal(this.currentMeal);
                await Navigation.PopAsync();
            };
        }
        public EditMealWindow(Meal meal, TimeSpan time, DateTime date, NewDailyMealInscriptionWindow newDailyMealInscriptionWindow, int index, DailyServer authorisation)
        {
            InitializeComponent();

            this._authorisation = authorisation;
            this._meal = meal;
            this._dateOfInscription = date;
            this._newDailyMealInscriptionWindow = newDailyMealInscriptionWindow;
            this._indexEditedMealInLView = index;

            EditMealW_MealName_TBox.Text = _meal.MName;
            EditMealW_HoursSlider_Slider.Value = time.Hours;
            EditMealW_MinutesSlider_Slider.Value = time.Minutes;
        }
Example #13
0
        public static int AddMeal(string name, string groupName)
        {
            using (Model1Container db = new Model1Container())
            {
                var groupId = (from groups in db.GroupMeal
                              where groups.Name.Equals(groupName)
                              select groups.GroupMealPK).FirstOrDefault();

                Meal newM = db.Meal.Where(c => c.Name == name).FirstOrDefault();
                newM = new Meal() { Name = name, GroupMealFK = groupId};
                db.Meal.Add(newM);
                db.SaveChanges();
                db.MealProducts.Add(new MealProducts() { MealFK = newM.MealPK });
                db.SaveChanges();
                return newM.MealPK;
            }
        }
		public async Task<bool> UpdateMeal(Meal meal)
		{
			var request = new RestRequest(string.Format("/meals/{0}", meal.Id), Method.PUT);
			request.AddParameter ("Name", meal.Name);
			try
			{
				var success = await this.restClient.ExecuteTaskAsync(request);

				if (success.StatusCode == HttpStatusCode.OK)
					return true;
			}
			catch(Exception)
			{
			}

			return false;
		}
Example #15
0
        public void TestMealMultiples()
        {
            var meal = new Meal(new TimeOfDay("morning"));
            meal.AddMealItem(1);
            Assert.IsTrue(meal.IsValid);
            meal.AddMealItem(1);
            Assert.IsFalse(meal.IsValid);

            var meal2 = new Meal(new TimeOfDay("night"));
            meal2.AddMealItem(3);
            Assert.IsTrue(meal2.IsValid);
            meal2.AddMealItem(3);
            Assert.IsFalse(meal2.IsValid);

            var meal3 = new Meal(new TimeOfDay("morning"));
            meal3.AddMealItem(3);
            Assert.IsTrue(meal3.IsValid);
            meal3.AddMealItem(3);
            Assert.IsTrue(meal3.IsValid);
        }
        public Meal CreateMeal(string name, string[] mealData)
        {
            Meal requestedMeal;
            if (!availableMeals.ContainsKey(name))
            {
                requestedMeal = new Meal(name, (MealType)int.Parse(mealData[1]));
                //add ingredients;
                for (int i = 2; i < mealData.Length; i += 2)
                {
                    requestedMeal.Add(ProductFlyweightFactory.Factory.MakeProduct(mealData[i], mealData), int.Parse(mealData[i + 1]));
                }
                availableMeals.Add(name, requestedMeal);
            }
            else
            {
                requestedMeal = availableMeals[name];
            }

            return requestedMeal;
        }
Example #17
0
        //{
        //    get
        //    {
        //        return Meals;
        //    }
        //    set
        //    {
        //        this.Meals.Add(ParseByXMLDocument());
        //    }
        //}
        //public void PopulateClass
        //{
        //   Meals.Add (ParseByXMLDocument());
        //}
        // Parse the XML Document using XMLDocument Class
        public Meal ParseByXMLDocument()
        {
            var aMeal = new Meal();
            XmlDocument doc = new XmlDocument();
            doc.Load(xmlUrl1);

            XmlNode MealNode = doc.SelectSingleNode("/Breakfast");
            aMeal.mealName = MealNode.Name;
            XmlNodeList LineNodeList = MealNode.SelectNodes("Line");
            //XmlNodeList LineNodeList = doc.ChildNodes;
            foreach (XmlNode node in LineNodeList)
            {
                Line aLine = new Line();
                aLine.lineName = node.FirstChild.InnerText;
                //XmlNode LineNode =
                //node.SelectSingleNode("Item");
                XmlNodeList ItemNodeList = node.ChildNodes;

                //XmlNodeList ItemNodeList2 = doc.SelectNodes("Item");
                foreach (XmlNode node2 in ItemNodeList)
                {
                    Item aItem =new Item();
                    aItem.itemName = node2.InnerText;
                    aItem.foodName = node2.InnerText;
                    aItem.foodServingSize = node2.InnerText;
                    aItem.foodCalories = node2.InnerText;
                    aItem.foodFat = node2.InnerText;
                    aItem.foodCholesterol = node2.InnerText;
                    aItem.foodSodium = node2.InnerText;
                    aItem.foodPotassium = node2.InnerText;
                    aItem.foodProtein = node2.InnerText;

                    aLine.ItemList.Add(aItem);
                }

                aMeal.Lines.Add(aLine);
            }

            return aMeal;
        }
Example #18
0
 public Result submitMealPlan(Meal userInput)
 {
     submitMeal(userInput);
     return response;
 }
Example #19
0
 public ActionResult Post([FromBody] Meal value)
 {
     _mealRepository.InsertMeal(value);
     return(Ok(_mealRepository.Save()));
 }
Example #20
0
 public async Task Insert(Meal meal)
 {
     await firebase.Child(node).PostAsync(meal);
 }
Example #21
0
 public ActionResult Put([FromBody] Meal value)
 {
     _mealRepository.Update(value);
     return(Ok(_mealRepository.Save()));
 }
Example #22
0
 public void FinishCooking()
 {
     Debug.Log("Finished Cooking");
     Owner.Inventory.Add("meal", 1, Meal.GetMeal("meal"));
 }
Example #23
0
        private void LoadMeals()
        {
            //prevent appendage
            mealsFound.Children.Clear();

            for (int i = 0; i < meals.Count; i++)
            {
                Grid mealGrid = new Grid();
                mealGrid.ColumnDefinitions.Add(new ColumnDefinition());
                mealGrid.ColumnDefinitions.Add(new ColumnDefinition());
                mealGrid.ColumnDefinitions.Add(new ColumnDefinition());
                mealGrid.RowDefinitions.Add(new RowDefinition());
                mealGrid.RowDefinitions.Add(new RowDefinition());

                mealGrid.RowDefinitions[1].Height = new GridLength(0.5, GridUnitType.Star);

                mealGrid.BackgroundColor = Color.FromHex("2196F3");
                mealGrid.Padding         = new Thickness(10, 10);

                //save index number per foodItem... To fix a bug
                meals[i].index = i;

                Meal meal = meals[i];

                Label lblName = new Label();
                lblName           = CardCreator.CreateLabelTemplate(lblName, LayoutOptions.Start, 0, 1, 3, meal.mealName);
                lblName.TextColor = Color.White;

                mealGrid.Children.Add(lblName);

                StackLayout stack = new StackLayout();
                stack.Orientation = StackOrientation.Horizontal;
                Grid.SetColumnSpan(stack, 3);
                stack.HorizontalOptions = LayoutOptions.End;

                Button btnEdit = new Button()
                {
                    Text            = "Edit",
                    FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Button)),
                    BackgroundColor = Color.DarkGoldenrod,
                    TextColor       = Color.White,
                    HeightRequest   = 35,
                    WidthRequest    = 50,
                    CornerRadius    = 5
                };

                Button btnDelete = new Button()
                {
                    Text            = "Del",
                    FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Button)),
                    BackgroundColor = Color.DarkRed,
                    TextColor       = Color.White,
                    HeightRequest   = 35,
                    WidthRequest    = 50,
                    CornerRadius    = 5
                };

                btnEdit.Clicked += async(sender, args) =>
                {
                    MasterModel.tempMeal = meals[meal.index];
                    await Navigation.PushAsync(new AddMealPage());
                };

                btnDelete.Clicked += async(sender, args) =>
                {
                    //meals.RemoveAt(meal.index);
                    MasterModel.currentUser.Meals.RemoveAt(meal.index);
                    await MasterModel.DAL.SaveMealV2();

                    RefreshPage();
                };

                stack.Children.Add(btnEdit);
                stack.Children.Add(btnDelete);

                mealGrid.Children.Add(stack);

                //mealsFound.Children.Add(mealGrid);
                mealsFound.Children.Insert(0, mealGrid);
            }
        }
        public ServiceOperation UpdateMeal(Meal meal)
        {
            string query = "UPDATE tblMeals SET MealName=\"{0}\" WHERE MealID={1}";

            return(SendNonQuery(String.Format(query, meal.Name, meal.ID)));
        }
Example #25
0
 public List <MealFood> GetMealFoods(Meal meal)
 {
     return(fakeDB.Values.SingleOrDefault(m => m.Id == meal.Id).Foods);
 }
Example #26
0
        public void EditMealDetails(int id, Meal meal)
        {
            using (SQLiteConnection con = new SQLiteConnection(conString))
            {
                // I make a bunch of sql calls here to populate the meal.
                // I didn't know how to make one call and populate the Meal object with all the data.
                using (SQLiteCommand cmd = new SQLiteCommand(con))
                {
                    con.Open();
                    if (meal.MealName == null)
                    {
                        meal.MealName = "";
                    }
                    cmd.CommandText = "UPDATE Meals SET MealName = @MealName WHERE mealID = " + id;
                    cmd.Parameters.Add("@MealName", System.Data.DbType.String);
                    cmd.Parameters["@MealName"].Value = meal.MealName;
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException ex)
                    {
                        Console.WriteLine(ex);
                    }

                    if (meal.MealIngredients == null)
                    {
                        meal.MealIngredients = "";
                    }
                    cmd.CommandText = "UPDATE Meals SET MealIngredients = @MealIngredients WHERE mealID = " + id;
                    cmd.Parameters.Add("@MealIngredients", System.Data.DbType.String);
                    cmd.Parameters["@MealIngredients"].Value = meal.MealIngredients;
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException ex)
                    {
                        Console.WriteLine(ex);
                    }
                    if (meal.MealInstructions == null)
                    {
                        meal.MealInstructions = "";
                    }
                    cmd.CommandText = "UPDATE Meals SET MealInstructions = @MealInstructions WHERE mealID = " + id;
                    cmd.Parameters.Add("@MealInstructions", System.Data.DbType.String);
                    cmd.Parameters["@MealInstructions"].Value = meal.MealInstructions;
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException ex)
                    {
                        Console.WriteLine(ex);
                    }
                    if (meal.MealNotes == null)
                    {
                        meal.MealNotes = "";
                    }
                    cmd.CommandText = "UPDATE Meals SET MealNotes = @MealNotes WHERE mealID = " + id;
                    cmd.Parameters.Add("@MealNotes", System.Data.DbType.String);
                    cmd.Parameters["@MealNotes"].Value = meal.MealNotes;
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException ex)
                    {
                        Console.WriteLine(ex);
                    }
                    if (meal.MealRisks == null)
                    {
                        meal.MealRisks = "";
                    }
                    cmd.CommandText = "UPDATE Meals SET MealRisks = @MealRisks WHERE mealID = " + id;
                    cmd.Parameters.Add("@MealRisks", System.Data.DbType.String);
                    cmd.Parameters["@MealRisks"].Value = meal.MealRisks;
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException ex)
                    {
                        Console.WriteLine(ex);
                    }
                    con.Close();
                }
            }
            return;
        }
Example #27
0
        public async Task <DailyMealViewModel> BuildDailyMealViewModel(byte cycleDay, ClaimsPrincipal user, Meal newMeal = null)
        {
            var mealList = await GetMealListByCycleDayAndUserDayAsync(cycleDay, user);

            var recipeList = await recipeService.GetAllRecipe();

            var dailyMealViewModel = new DailyMealViewModel
            {
                Meals    = mealList,
                Recipes  = recipeList,
                cycleDay = cycleDay,
                NewMeal  = newMeal
            };

            return(dailyMealViewModel);
        }
Example #28
0
    private void OnEnable()
    {
        //SONIDO DE EMPEZAR MINIJUEGO
        //CHECA SCRIPT DE ROTACION

        Debug.Log("Empieza EMPLATADO.");
        quesadillaImagen.SetActive(false);
        sopaDeTomateImagen.SetActive(false);
        guacamoleImagen.SetActive(false);
        sincronizadasImagen.SetActive(false);
        sopaDeTortillaImagen.SetActive(false);
        flautasImagen.SetActive(false);
        molletesImagen.SetActive(false);
        tacosImagen.SetActive(false);
        gorditasImagen.SetActive(false);
        chilesEnNogadaImagen.SetActive(false);
        tostadasImagen.SetActive(false);
        enchiladasImagen.SetActive(false);
        moleImagen.SetActive(false);
        pozoleImagen.SetActive(false);
        chilaquilesImagen.SetActive(false);

        mealToPlate = cheffy.mealToDeliver;

        Debug.Log(mealToPlate);

        if (mealToPlate.name == "Sincronizadas")
        {
            sincronizadasImagen.SetActive(true);
        }

        if (mealToPlate.name == "Quesadillas")
        {
            quesadillaImagen.SetActive(true);
        }

        if (mealToPlate.name == "Sopatomate")
        {
            sopaDeTomateImagen.SetActive(true);
        }

        if (mealToPlate.name == "Guacamole")
        {
            guacamoleImagen.SetActive(true);
        }

        if (mealToPlate.name == "Sopatortilla")
        {
            sopaDeTortillaImagen.SetActive(true);
        }

        if (mealToPlate.name == "Flautas")
        {
            flautasImagen.SetActive(true);
        }

        if (mealToPlate.name == "Gorditas")
        {
            gorditasImagen.SetActive(true);
        }

        if (mealToPlate.name == "Tacos")
        {
            tacosImagen.SetActive(true);
        }

        if (mealToPlate.name == "Molletes")
        {
            molletesImagen.SetActive(true);
        }
        if (mealToPlate.name == "ChilesEnNogada")
        {
            chilesEnNogadaImagen.SetActive(true);
        }
        if (mealToPlate.name == "Enchiladas")
        {
            enchiladasImagen.SetActive(true);
        }
        if (mealToPlate.name == "Tostadas")
        {
            tostadasImagen.SetActive(true);
        }
        if (mealToPlate.name == "Mole")
        {
            moleImagen.SetActive(true);
        }
        if (mealToPlate.name == "Chilaquiles")
        {
            chilaquilesImagen.SetActive(true);
        }
        if (mealToPlate.name == "Pozole")
        {
            pozoleImagen.SetActive(true);
        }
    }
Example #29
0
 public MealDetails(Meal meal, MealType mealType)
 {
     _meal     = meal;
     _mealType = mealType;
 }
Example #30
0
        public void Update(MealDTO mealDto)
        {
            var meal = new Meal
            {
                Id          = mealDto.Id,
                Name        = mealDto.Name,
                NameForeign = mealDto.NameForeign
            };

            _mealRepository.Update(meal, mealDto.ImageBase64);

            var ingredients = new List <Ingredient>();

            foreach (var item in mealDto.Ingredients)
            {
                ingredients.Add(new Ingredient
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    NameForeign = item.NameForeign
                });
            }
            _ingredientRepository.Add(ingredients);

            var allergens = new List <Allergen>();

            foreach (var item in mealDto.Allergens)
            {
                allergens.Add(new Allergen
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    NameForeign = item.NameForeign
                });
            }
            _allergenRepository.Add(allergens);

            _ingredientRepository.DeleteMealIngredients(meal.Id);
            _allergenRepository.DeleteMealAllergens(meal.Id);

            var mealIngredients = new List <MealIngredient>();

            foreach (var item in ingredients)
            {
                mealIngredients.Add(new MealIngredient
                {
                    MealId       = meal.Id,
                    IngredientId = item.Id
                });
            }
            _ingredientRepository.AddMealIngredients(mealIngredients);

            var mealAllergens = new List <MealAllergen>();

            foreach (var item in allergens)
            {
                mealAllergens.Add(new MealAllergen
                {
                    MealId     = meal.Id,
                    AllergenId = item.Id
                });
            }
            _allergenRepository.AddMealAllergens(mealAllergens);
        }
Example #31
0
        /// <summary>
        /// save meal in database after user added connected food
        /// </summary>
        /// <param name="meal"></param>
        public void saveMeal(Meal meal)
        {
            saveFood(meal.FoodName);

            MyDal.saveMeal(meal);
        }
Example #32
0
 public override bool IsValid(Meal meal)
 {
     return(base.IsValid(meal) && ((Pizza)meal).Diameter > 0);
 }
 public WeirdView()
 {
     Happy = new Meal();
 }
Example #34
0
        public Model GetDataAndCreateModel()
        {
            const string GetLunchPlansQuery        = "SELECT * from LunchPlans";
            const string GetMessagesQuery          = "SELECT * from Messages";
            const string GetMealsVsLunchPlansQuery = "SELECT * from MealsVsLunchPlans";
            const string GetMealsQuery             = "SELECT * from Meals";
            var          lunchPlans = new ObservableCollection <LunchPlan>();
            var          messages   = new ObservableCollection <Message>();
            var          mealsVsLunchPlansCollection = new ObservableCollection <MealsVsLunchPlans>();
            var          meals = new ObservableCollection <Meal>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    if (conn.State == System.Data.ConnectionState.Open)
                    {
                        using (SqlCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = GetMealsVsLunchPlansQuery;
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var mealsVsLunchPlans = new MealsVsLunchPlans();
                                    mealsVsLunchPlans.Id          = reader.GetInt32(0);
                                    mealsVsLunchPlans.LunchPlanId = reader.GetInt32(1);
                                    mealsVsLunchPlans.MealId      = reader.GetInt32(2);
                                    mealsVsLunchPlans.Weekday     = reader.GetString(3);
                                    mealsVsLunchPlansCollection.Add(mealsVsLunchPlans);
                                }
                            }
                            cmd.CommandText = GetLunchPlansQuery;
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var lunchPlan = new LunchPlan();
                                    lunchPlan.Id   = reader.GetInt32(0);
                                    lunchPlan.Week = reader.GetInt32(1);
                                    lunchPlans.Add(lunchPlan);
                                }
                            }
                            cmd.CommandText = GetMessagesQuery;
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var message = new Message();
                                    message.Id      = reader.GetInt32(0);
                                    message.AdminId = reader.GetInt32(1);
                                    message.Date    = reader.GetDateTime(2);
                                    message.Text    = reader.GetString(3);
                                    message.Header  = reader.GetString(4);
                                    messages.Add(message);
                                }
                            }
                            cmd.CommandText = GetMealsQuery;
                            using (SqlDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    var meal = new Meal();
                                    meal.Id          = reader.GetInt32(0);
                                    meal.Description = reader.GetString(1);
                                    meal.TimesChosen = reader.GetInt32(2);
                                    meals.Add(meal);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception eSql)
            {
                Debug.WriteLine("Exception: " + eSql.Message);
            }
            Model model = new Model(lunchPlans, messages, meals, mealsVsLunchPlansCollection);

            return(model);
        }
Example #35
0
 private Meal DetermineMealToMake()
 {
     return(Meal.GetMeal("meal"));
 }
Example #36
0
        public ActionResult GenerateMeals(MenuViewModel model, int noOfMeals)
        {
            var user         = repo.GetUser(User.Identity.GetUserId());
            var userCalories = user.GetCalorieIntake();
            var nutrients    = repo.GetNutrientsPerMeal(noOfMeals);

            MenuViewModel menu = null;

            if (model.Meals.Count == noOfMeals)
            {
                ModelState.Clear();
                var checkedMeals = model.Meals.Where(m => m.IsChecked).Select(m => m.MealNameId).ToList();

                foreach (var meal in model.Meals)
                {
                    //fill meals and ingredients info
                    var npm = nutrients.Where(n => n.MealId == meal.MealNameId).First();
                    meal.Name = nutrients.Where(n => n.MealId == meal.MealNameId).Select(n => n.MealName).First();
                    meal.Ingredients.ToList().ForEach(ing =>
                    {
                        ing.BindIngredient(repo.GetIngredient(ing.Id));
                        var units          = repo.GetUnitsOfMesurement(ing.Id);
                        ing.BaseUnitEnergy = units;

                        var calorieForType = npm.GetCalorieForType(ing.Type, userCalories);
                        ing.FillCalculatedEnergyList(calorieForType);
                    });



                    if (checkedMeals.Contains(meal.MealNameId))
                    {
                        continue;
                    }
                    var ingredients = new List <IngredientViewModel>();
                    meal.Ingredients
                    .Where(ing => !ing.IsChecked)
                    .ToList()
                    .ForEach(ing =>
                    {
                        var newIng               = GenerateIngredientViewModel(ing.TypeId, npm, userCalories);
                        ing.Id                   = newIng.Id;
                        ing.Name                 = newIng.Name;
                        ing.Type                 = newIng.Type;
                        ing.TypeId               = newIng.TypeId;
                        ing.BaseUnitEnergy       = newIng.BaseUnitEnergy;
                        ing.CalculatedUnitEnergy = newIng.CalculatedUnitEnergy;
                    });
                }
            }
            else
            {
                //Generate new menu
                menu = new MenuViewModel()
                {
                    User = user
                };

                foreach (var npm in nutrients)
                {
                    Meal meal = new Meal
                    {
                        CaloriePercent = npm.PercentCalorie,
                        Name           = npm.MealName,
                        MealNameId     = npm.MealId
                    };

                    repo.GetAllIngredientTypes().ToList()
                    .ForEach(entry =>
                    {
                        var ingViewModel = GenerateIngredientViewModel(entry.Value, npm, userCalories);
                        meal.Ingredients.Add(ingViewModel);
                    });

                    menu.Meals.Add(meal);
                }
            }

            ViewBag.userCalories = userCalories;

            var returnMenu = menu ?? model;

            return(PartialView("_Menu", returnMenu));
        }
Example #37
0
 public bool AddMealFood(Meal meal)
 {
     return(mealDao.AddMealFood(meal));
 }
        public static void Initialize(NsContext context)
        {
            context.Database.EnsureCreated();

            if (context.Measurements.Any())
            {
                return;
            }

            // measurements

            var names = new List <string> {
                "piece", "gram", "liter"
            };
            var shortNames = new List <string> {
                "pc", "gr", "l"
            };
            int index = 0;

            foreach (string s in names)
            {
                var m = new Measurement
                {
                    Name      = names[index],
                    ShortName = shortNames[index]
                };

                context.Add(m);
                index++;
            }

            context.SaveChanges();

            // generic products

            index = 0;

            names = new List <string> {
                "Ground beef", "Onion", "Mushrooms", "Tomato paste", "Mozzarella cheese", "Eggs", "Lasagna noodles"
            };

            var gram  = context.Measurements.Where(x => x.ShortName == "gr").First();
            var piece = context.Measurements.Where(x => x.ShortName == "pc").First();

            var measurements = new List <Measurement> {
                gram, gram, gram, gram, gram, piece, gram
            };

            foreach (string n in names)
            {
                var gp = new GenericProduct
                {
                    Name        = n,
                    Measurement = measurements[index]
                };
                context.Add(gp);
                index++;
            }

            context.SaveChanges();

            // products

            index = 0;
            Random rnd = new Random();

            var prod = new Product()
            {
                Name           = "Black Canyon",
                Barcode        = rnd.Next(1, 100),
                Price          = rnd.Next(100, 7000),
                GenericProduct = context.GenericProducts.Where(x => x.Name == "Ground beef").First()
            };

            context.Add(prod);

            names = new List <string> {
                "Thousand Hills", "Lusk", "Monterey", "Hunts", "Kraft", "Happy", "Barilla"
            };

            foreach (string n in names)
            {
                var p = new Product
                {
                    Name           = n,
                    Barcode        = rnd.Next(1, 100),
                    Price          = rnd.Next(100, 7000),
                    GenericProduct = context.GenericProducts.ToList()[index]
                };

                context.Add(p);
                index++;
            }

            context.SaveChanges();

            //ingredients

            index = 0;

            var ing0 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[0],
                Amount         = 450
            };

            context.Add(ing0);

            var ing1 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[1],
                Amount         = 50
            };

            context.Add(ing1);

            var ing2 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[2],
                Amount         = 100
            };

            context.Add(ing2);

            var ing3 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[3],
                Amount         = 800
            };

            context.Add(ing3);

            var ing4 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[4],
                Amount         = 650
            };

            context.Add(ing4);

            var ing5 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[5],
                Amount         = 2
            };

            context.Add(ing5);

            var ing6 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[6],
                Amount         = 450
            };

            context.Add(ing6);

            var ing7 = new Ingredient()
            {
                GenericProduct = context.GenericProducts.ToList()[4],
                Amount         = 100
            };

            context.Add(ing7);

            context.SaveChanges();

            //meal

            index = 0;

            names = new List <string> {
                "Lasagna", "French omelet"
            };

            var meal_Lasagna = new Meal()
            {
                Id              = new Guid(),
                Name            = names[0],
                PreparationTime = rnd.Next(20, 120),
                Instructions    = "Preheat oven to 350 degrees F (175 degrees C).\n" +
                                  "In a large skillet,\n" +
                                  "cook and stir ground beef until brown.Add mushrooms and onions; saute until onions are transparent.Stir in pasta sauce, and heat through.\n" +
                                  "In a medium size bowl, combine cottage cheese, ricotta cheese, grated Parmesan cheese, and eggs.\n" +
                                  "Spread a thin layer of the meat sauce in the bottom of a 13x9 inch pan.Layer with uncooked lasagna noodles, cheese mixture, mozzarella cheese, and meat sauce.Continue layering until all ingredients are used, reserving 1 / 2 cup mozzarella. Cover pan with aluminum foil.\n" +
                                  "Bake in preheated oven for 45 minutes.Uncover, and top with remaining half cup of mozzarella cheese.Bake for an additional 15 minutes.Remove from oven, and let stand 10 to 15 minutes before serving.",
                Ingredients = new List <Ingredient>()
                {
                    ing0, ing1, ing2, ing3, ing4, ing5, ing6
                }
            };

            context.Add(meal_Lasagna);

            var meal_Omelet = new Meal()
            {
                Id              = new Guid(),
                Name            = names[1],
                PreparationTime = rnd.Next(7, 10),
                Instructions    = "BEAT eggs, 2 tbsp of water, 1/8 tsp of salt and a dash of pepper in small bowl until blended.\n" +
                                  "HEAT 1 tsp of butter in 6 to 8-inch nonstick omelet pan or skillet over medium - high heat until hot.TILT pan to coat bottom.POUR IN egg mixture.Mixture should set immediately at edges.\n" +
                                  "GENTLY PUSH cooked portions from edges toward the center with inverted turner so that uncooked eggs can reach the hot pan surface.CONTINUE cooking,\n" +
                                  "tilting pan and gently moving cooked portions as needed.\n" +
                                  "When top surface of eggs is thickened and no visible liquid egg remains,\n" +
                                  "PLACE the mozzarella on one side of the omelet.FOLD omelet in half with turner.With a quick flip of the wrist,\n" +
                                  "turn pan and INVERT or SLIDE omelet onto plate.SERVE immediately.\n",
                Ingredients = new List <Ingredient>()
                {
                    ing5, ing7
                }
            };

            context.Add(meal_Omelet);

            var normal_eggs = new Meal()
            {
                Id              = new Guid(),
                Name            = "Eggs",
                PreparationTime = rnd.Next(7, 10),
                Instructions    = "Only for the sake of having more meals.",
                Ingredients     = new List <Ingredient>()
                {
                    ing5
                }
            };

            context.Add(normal_eggs);

            context.SaveChanges();

            //week

            var week1 = new Week()
            {
                Id        = new Guid(),
                StartDate = new DateTime(2019, 2, 4),
                EndDate   = new DateTime(2019, 2, 10)
            };

            context.Add(week1);
            context.SaveChanges();

            //var week1 = new Week()
            //{
            //    StartDate = new DateTime(2019, 2, 4),
            //    EndDate = new DateTime(2019, 2, 10),
            //    MealsMonday = new List<Meal>() { meal_Lasagna },
            //    MealsTuesday = new List<Meal>() { normal_eggs },
            //    MealsWednesday = new List<Meal>() { meal_Lasagna },
            //    MealsThursday = new List<Meal>() { meal_Omelet },
            //    MealsFriday = new List<Meal>() { meal_Lasagna },
            //    MealsSaturday = new List<Meal>() { meal_Omelet },
            //    MealsSunday = new List<Meal>() { normal_eggs }
            //};
            //context.Add(week1);

            //context.SaveChanges();


            WeekMeal wMon = new WeekMeal()
            {
                WeekId = context.Weeks.AsNoTracking().First().Id,
                MealId = context.Meals.AsNoTracking().First(m => m.Name == "Lasagna").Id,
                Day    = 0
            };

            context.Add(wMon);


            WeekMeal wMonTwo = new WeekMeal()
            {
                WeekId = context.Weeks.AsNoTracking().First().Id,
                MealId = context.Meals.AsNoTracking().FirstOrDefault(m => m.Name == "Eggs").Id,
                Day    = 0
            };

            context.Add(wMonTwo);


            WeekMeal wTue = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "Eggs").Id,
                Day    = 1
            };

            context.Add(wTue);

            WeekMeal wWed = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "French omelet").Id,
                Day    = 2
            };

            context.Add(wWed);

            WeekMeal wThu = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "Lasagna").Id,
                Day    = 3
            };

            context.Add(wThu);

            WeekMeal wFri = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "French omelet").Id,
                Day    = 4
            };

            context.Add(wFri);

            WeekMeal wSat = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "Eggs").Id,
                Day    = 5
            };

            context.Add(wSat);

            WeekMeal wSun = new WeekMeal()
            {
                WeekId = context.Weeks.First().Id,
                MealId = context.Meals.FirstOrDefault(m => m.Name == "Eggs").Id,
                Day    = 6
            };

            context.Add(wSun);

            context.SaveChanges();
        }
Example #39
0
 private int GetCookingTime(Meal meal, Person person)
 {
     return(MinutesMatrix[(int)meal - 1, (int)person - 1]);
 }
 public async Task<bool> UpdateMeal(Meal meal)
 {
     throw new NotImplementedException();
 }
 public UpdateMealResponse(Meal meal)
 {
     Meal   = meal;
     Result = UpdateMealResponseEnum.Success;
 }
		public async Task UpdateMealAsync(long id, string name, string description, decimal price, int category)
		{
			var meal = new Meal { Id = id, Name = name, Description = description, Category = category, Price = price };
			using (var database = _foodOrderingDbFactory.GetDatabase())
			{
				database.Meals.Attach(meal);
				database.Entry(meal).Property(x => x.Name).IsModified = true;
				database.Entry(meal).Property(x => x.Category).IsModified = true;
				database.Entry(meal).Property(x => x.Description).IsModified = true;
				database.Entry(meal).Property(x => x.Price).IsModified = true;
				await database.SaveChangesAsync();
			}
		}
Example #43
0
        public void LoadDailyMealToListView()
        {
            LView_MealList.Clear();
            LView_ProductsOfMealList.Clear();

            var myDailyMeal = _authorisation.GetMeals(DailyWindow.Me.UserId, DailyW_DailyCalendar_Calendar.SelectedDate.Value);

            foreach (var myMeal in myDailyMeal)
            {
                var LView_Meal = new Meal
                {
                    MealId = myMeal.DMealId,
                    MName = myMeal.DMealName,
                    Time = myMeal.Time.TimeOfDay,
                    CaloriesSupplied = myMeal.CaloriesSupplied
                };
                LView_MealList.Add(LView_Meal);
            }
            DailyW_MealInscription_LView.SelectedIndex = 0;
        }
Example #44
0
        public void CreateMeal(string input)
        {
            Logger.Info("Input: " + input);
                
            this._meal = (Meal)this._cache.Get(input);

            if (this._meal == null)
            {
                #region Create Meal
                MealType meal = MealType.NOTAVAILABLE;
                var validator = new OrderingValidator();
                if (validator.isInputValid(input, out meal))
                {
                    if (meal != MealType.NOTAVAILABLE)
                    {
                        #region Create Meal
                        this._meal = MealFactory.CreateMeal(meal);

                        var listDishes = validator.GetListDishes().OrderBy(x => x).GroupBy(x => x);
                        bool hasError = false;

                        foreach (var item in listDishes)
                        {
                            DishType? currentDishType = validator.GetToDishType(item.Key);
                            int dishRepetition = item.Count();

                            if (currentDishType != null)
                            {
                                var dish = this._meal.Dishes.Where(x => x.DishType == currentDishType).FirstOrDefault();
                                if (dishRepetition > 1)
                                {
                                    if (dish.HasMultipleOrder())
                                    {
                                        dish.HasOrdered = true;
                                        dish.Order(dishRepetition);
                                    }
                                    else
                                        dish = new ErrorDish();
                                }
                                else
                                {
                                    if (dish != null)
                                    {
                                        dish.HasOrdered = true;
                                        dish.Order(1);
                                    }

                                    if (currentDishType == DishType.DESERT && meal == MealType.MORNING)
                                    {
                                        this._meal.Add(new ErrorDish());
                                    }
                                }
                            }
                            else
                            {
                                if (!hasError)
                                    this._meal.Add(new ErrorDish());
                            }
                        }

                        //Check if there is any previous dish that isn't ordered
                        ValidOrder();
                        #endregion

                        #region Adding Meal to Cache
                        this._cache.Set(input, this._meal);
                        #endregion
                    }
                    else
                    {
                        #region Meal Type Not Found
                        this._meal = new Meal("Error");
                        this._meal.Add(new ErrorDish());
                        #endregion
                    }
                }
                #endregion
            }
        }
Example #45
0
    public void submitMeal(Meal request)
    {
        DateTime mealDate = Convert.ToDateTime(request.Date);
        string fruits = request.Fruits;
        string veggies = request.Veggies;
        string grains = request.Grains;
        string dairy = request.Dairy;
        string proteins = request.Proteins;
        string email = request.Email;
        string completedDiet = request.CompletedDiet;

        using (SqlConnection sqlCon = new SqlConnection(connectionstring))
        {
            string sql = "INSERT INTO Meals (Date,Fruit,Vegetable,Grain,Dairy,Proteins,Email,CompletedDiet) VALUES ('" + mealDate + "','" + fruits + "', '" + veggies + "' , '" + grains + " ', '"+ dairy  + "','" + proteins + "' , '"+email +"','N')";

            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommand command = new SqlCommand(sql, sqlCon);
            try
            {
                sqlCon.Open();
                da.InsertCommand = new SqlCommand(sql, sqlCon);
                int noOfRows = da.InsertCommand.ExecuteNonQuery();

                if (noOfRows > 0)
                {
                    response.status = "success";
                    response.message = "Meal plan created.";
                    updateMealPlanEnteredForTomorrowValueForUser(email,'Y');
                }
                else
                {
                    response.status = "error";
                    response.message = "There was an error adding your mealPlan";
                }

            }
            catch (Exception ex)
            {
                response.status = "error";
                response.message = "There was an error inserting" + ex;
            }
            sqlCon.Close();
        }
    }
Example #46
0
 public void Feed(Meal meal)
 {
     stomach.fulness += meal.fullnessMod;
     soul.happiness  += meal.hapinnesMod;
     brain.intellect += meal.intellectMod;
 }
 public ActionResult Edit(Meal meal)
 {
     if (ModelState.IsValid)
     {
         db.Entry(meal).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MealTypeId = new SelectList(db.MealTypes, "Id", "Name", meal.MealTypeId);
     ViewBag.RestaurantId = new SelectList(db.Restaurants, "Id", "Name", meal.RestaurantId);
     return View(meal);
 }
Example #48
0
 public void FindMealByInsulin_IfMealInHourAfter_ReturnsMeal()
 {
     var meal1 = new Meal { DateTime = DateTime.Now.AddHours(0.9) };
     var meal2 = new Meal { DateTime = DateTime.Now.AddHours(-1.1) };
     factories.Setup(f => f.Meals).Returns(new List<Meal> { meal1, meal2 });
     var finder = new FinderImpl(factories.Object);
     var insulin = new Insulin { DateTime = DateTime.Now };
     var meal = finder.FindMealByInsulin(insulin);
     Assert.AreSame(meal1, meal);
 }
 private void ShowAddMealBar()
 {
     MealToAdd         = new Meal(new List <Component>());
     AddMealVisibility = true;
 }
Example #50
0
        /// <summary>
        /// Function create meal from given dishes
        /// in case of eating single component it is needed to create virtual dish connected by Conncetor list in dish with component, but without adding it to Context
        /// Dishes should be given without connectors but when they are virtual it should ahve Connector list
        /// not tested cause UI not prepared YET
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="weigth"></param>
        /// <param name="mealType"></param>
        /// <param name="dishesList"></param>
        /// <returns></returns>
        internal static bool AddMeal(string userLogin, long weigth, Enums.MealType mealType, List <Dish> dishesList)
        {
            int userId;

            try
            {
                userId = GetUserByUserName(userLogin);
            }
            catch (ArgumentException e)
            {
                Console.Write("Missing user name" + e);
                return(false);
            }
            catch (Exception e)
            {
                Console.Write("User not exist" + e);
                return(false);
            }

            if (userId == 0 || weigth == 0 || dishesList.Count == 0)
            {
                return(false);
            }

            AteDatabase entity = new AteDatabase();

            try
            {
                Meal meal = new Meal()
                {
                    FKUserId = userId,
                    Weigth   = weigth,
                    MealType = (short)mealType,
                    MealDate = DateTime.Now
                };
                List <Dish> tempDish = new List <Dish>();
                foreach (Dish dish in dishesList)
                {
                    if (dish.Connectors.Count == 0)
                    {
                        tempDish.Add(entity.Dishes.Where(w => w.DishId == dish.DishId).Single());
                    }
                    else
                    {
                        tempDish.Add(dish);
                    }
                }
                foreach (var dish in tempDish)
                {
                    foreach (Connector con in dish.Connectors)
                    {
                        meal.Connectors.Add(new Connector()
                        {
                            FK_ComponentId  = con.FK_ComponentId,
                            ComponentWeigth = con.ComponentWeigth
                        });
                    }
                }
                entity.Meals.Add(meal);
                entity.SaveChanges();
            }
            catch (Exception e)
            {
                Console.Write("AddMeal error" + e);
                return(false);
            }

            return(true);
        }
Example #51
0
    public void submitDietCompletionForUser(Meal userInput)
    {
        using (SqlConnection sqlCon = new SqlConnection(connectionstring))
        {

            string userName = userInput.Email;
            DateTime mealDate = Convert.ToDateTime(userInput.Date);

            string sql = "Update Meals SET CompletedDiet = 'Y' WHERE Email = '" + userName + "' and Date = '"+ mealDate+"'";

            SqlCommand command = new SqlCommand(sql, sqlCon);
            SqlDataAdapter da = new SqlDataAdapter(command);
            try
            {
                sqlCon.Open();
                da.UpdateCommand = new SqlCommand(sql, sqlCon);
                int noOfRows = da.UpdateCommand.ExecuteNonQuery();
                if (noOfRows > 0)
                {
                    response.status = "success";
                    response.message = "Meal Plan successfully marked as complete";
                }
                else
                {
                    response.status = "error";
                    response.message = "There was an error updating your Meal Plan";

                }

            }
            catch (Exception ex)
            {
                response.status = "error";
                response.message = "There was an error updating your Meal Plan" + ex;
            }
            sqlCon.Close();
        }
    }
Example #52
0
 /// <summary>
 /// There is no need for this implementation for the FakeMealDao
 /// </summary>
 /// <param name="meal"></param>
 /// <returns></returns>
 public bool AddMealFood(Meal meal)
 {
     return(true);
 }
		public async Task DeleteMealAsync(long mealId)
		{
			var meal = new Meal { Id = mealId };
			using (var database = _foodOrderingDbFactory.GetDatabase())
			{
				database.Meals.Attach(meal);
				database.Meals.Remove(meal);
				await database.SaveChangesAsync();
			}
		}
Example #54
0
        public void GetMeal_returnContent()
        {
            Meal searchResult = _repo.GetItemByName("FOD");

            Assert.AreEqual(searchResult.Name, "FOD");
        }
Example #55
0
 public MealDetails(Meal meal, MealType mealType)
 {
     _meal = meal;
         _mealType = mealType;
 }
 public CreateMealResponse(Meal meal)
 {
     Meal = meal;
 }
        private void Generate_Menu_Button_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <System.Windows.Controls.CheckBox> childs =
                TypeMealsCheckBox.Children.OfType <CheckBox>(); // the key for the baraka is here :D

            childs            = childs.Where(x => x.IsChecked == true).ToList();
            selectedTypeMeals = childs.Select(x => x.Content).ToList();

            try
            {
                var filtredMeals = new List <Meal>();
                var menuItems    = new List <KeyValuePair <Meal, int> >();
                foreach (var meal in selectedTypeMeals)
                {
                    string table = meal as String;
                    var    test  = new List <Meal>();
                    var    raw   = new List <Meal>();
                    using (var ctx = new HealthBuddyContext())
                    {
                        string query = string.Format("SELECT *FROM {0}s", table);
                        raw = ctx.Database.SqlQuery <Meal>(query, table).ToList(); // TODO: Edit to IQuerable<Meal>

                        List <string> strings = unSelectedIngrediants.Select(c => c.ToString()).ToList();
                        //test = raw.Where(x => strings.Any(y => x.Ingredients.Split(' ').Contains(y))).ToList();  // Ivaylo Kenov

                        test = raw.Where(x => Meal.Filter(x, unSelectedIngrediants)).Select(x => x).ToList();
                    }
                    filtredMeals = filtredMeals.Concat(test).ToList();
                }

                SimplexMealGenerator simplex = new SimplexMealGenerator(filtredMeals, userCalories);
                simplex.Generate();
                for (int i = 0; i < filtredMeals.Count; i++)
                {
                    if (simplex.MealPortions[i] != 0)
                    {
                        var menuItem = new KeyValuePair <Meal, int>(filtredMeals[i], simplex.MealPortions[i]);
                        menuItems.Add(menuItem);
                    }
                }

                //TODO: Event for the scrollbar
                ClearMenuInfoBar();

                PrintMenuInfo(menuItems);

                // Add to History
                var newHistory = new History();
                if (Calendar.SelectedDate.HasValue)
                {
                    newHistory.Date = Calendar.SelectedDate.Value;
                }
                else
                {
                    newHistory.Date = DateTime.Now.Date;
                }// TODO: Change with value from calendar
                newHistory.Menu = menuItems;
                var date = Calendar.SelectedDate.Value;
                AllHistory.Remove(AllHistory.Where(x => x.Date == date).Select(z => z).FirstOrDefault());
                AllHistory.Add(newHistory);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #58
0
        public ActionResult <Meal> Create(Meal meal)
        {
            _mealRepository.Create(meal);

            return(CreatedAtRoute("GetMeal", new { id = meal.id.ToString() }, meal));
        }
Example #59
0
 // GET: Meal
 public ActionResult AddMeal(Meal meal)
 {
     _mealLogic.AddMeal(meal);
     return(Json(true));
 }
Example #60
0
 public Result submitDietCompletion(Meal userInput)
 {
     submitDietCompletionForUser(userInput);
     return response;
 }