public Favourite Add(Favourite favourite) { if (context.Favourites.Where(x => x.UserId == favourite.UserId && x.RecipeObserverdId == favourite.RecipeObserverdId).FirstOrDefault() == null) { context.Favourites.Add(favourite); context.SaveChanges(); } return(favourite); }
public Favourite Remove(int favouriteId) { Favourite favourite = context.Favourites.Find(favouriteId); if (favourite != null) { context.Favourites.Remove(favourite); context.SaveChanges(); } return(favourite); }