public void UpdateFoodandMedicine(FoodandMedicine foodandMedicine) { using (var context = new EAContext()) { context.Entry(foodandMedicine).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void CreateFoodandMedicine(FoodandMedicine foodandMedicine) { using (var context = new EAContext()) { context.Entry(foodandMedicine.Category).State = EntityState.Unchanged; context.FoodandMedicines.Add(foodandMedicine); context.SaveChanges(); } }
public ActionResult Create(NewFoodandMedicinesViewModel model) { var newFoodChart = new FoodandMedicine(); newFoodChart.Month = model.Month; newFoodChart.MinWeight = model.MinWeight; newFoodChart.MaxWeight = model.MaxWeight; newFoodChart.Food = model.Food; newFoodChart.Medicine = model.Medicine; newFoodChart.Category = CategoryService.Instance.GetCategory(model.CategoryID); foodandMedicineService.CreateFoodandMedicine(newFoodChart); //return View(); return(RedirectToAction("FoodandMedicineTable")); }