public Allergens CreateAllergen(Allergens allergen) { //Clone allergensInMenu to new location in memory, so they are not overridden on Attach var newAllergenInMenu = new List <AllergensInMenu>(allergen.AllergensInMenu); //Attach ingredient so basic properties are updated _ctx.Attach(allergen).State = EntityState.Added; //Remove all recipelines with updated order information _ctx.AllergensInMenu.RemoveRange( _ctx.AllergensInMenu.Where(ol => ol.MainFoodId == allergen.Id) ); //Add all orderlines with updated order information foreach (var ol in newAllergenInMenu) { _ctx.Entry(ol).State = EntityState.Added; } // Save it _ctx.SaveChanges(); //Return it return(allergen); }
public Ingredients CreateIngredient(Ingredients ingredient) { _ctx.Attach(ingredient).State = EntityState.Added; _ctx.SaveChanges(); return(ingredient); }
public SpecialOffers CreateSpecialOffers(SpecialOffers specialOffers) { _ctx.Attach(specialOffers).State = EntityState.Added; _ctx.SaveChanges(); return(specialOffers); }
public MainFood CreateMainFood(MainFood mainFood) { _ctx.Attach(mainFood).State = EntityState.Added; _ctx.SaveChanges(); return(mainFood); }
public MOTD CreateMOTD(MOTD motd) { _ctx.Attach(motd).State = EntityState.Added; _ctx.SaveChanges(); return(motd); }
public void Add(Users user) { _ctx.Users.Add(user); _ctx.SaveChanges(); }