Beispiel #1
0
        public void DeleteFood(string Food)
        {
            var db      = new GymDietManagementEntities1();
            var oldFood = db.Dishes.Find(Food);

            db.Dishes.Remove(oldFood);
            db.SaveChanges();
        }
Beispiel #2
0
        public void UpdateFood(string Food, string Amount, int Calori, string Type, Nullable <float> Li, Nullable <float> Gl, Nullable <float> Pr, Nullable <float> Cel)
        {
            var db      = new GymDietManagementEntities1();
            var oldFood = db.Dishes.Find(Food);

            oldFood.Food      = Food;
            oldFood.Amount    = Amount;
            oldFood.Calori    = Calori;
            oldFood.Lipid     = Li;
            oldFood.Glucid    = Gl;
            oldFood.Protein   = Pr;
            oldFood.Cellulose = Cel;
            var meal = db.Meals.Where(p => p.Type == Type).Single();

            oldFood.Meal_id = meal.id;

            db.Entry(oldFood).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Beispiel #3
0
        public void AddFood(string Food, string Amount, int Calori, string Type, Nullable <int> Li, Nullable <int> Gl, Nullable <int> Pr, Nullable <int> Cel)
        {
            var NewFood = new Dish();

            NewFood.Food      = Food;
            NewFood.Amount    = Amount;
            NewFood.Calori    = Calori;
            NewFood.Lipid     = Li;
            NewFood.Glucid    = Gl;
            NewFood.Protein   = Pr;
            NewFood.Cellulose = Cel;
            NewFood.Meal_id   = int.Parse(Type);


            var db = new GymDietManagementEntities1();

            db.Dishes.Add(NewFood);
            db.SaveChanges();
        }