public RecipeComment DeleteRecipeComment(int recipeCommentId) { RecipeComment dbEntry = context.RecipeComments .FirstOrDefault(p => p.RecipeCommentId == recipeCommentId); if (dbEntry != null) { context.RecipeComments.Remove(dbEntry); //context.SaveChanges(); } return(dbEntry); }
public void SaveRecipeComment(RecipeComment recipeComment) { if (recipeComment.RecipeCommentId == 0) { context.RecipeComments.Add(recipeComment); System.Diagnostics.Debug.WriteLine("Adding Recipe Comment"); } else { RecipeComment dbEntry = context.RecipeComments .FirstOrDefault(p => p.RecipeCommentId == recipeComment.RecipeCommentId); if (dbEntry != null) { System.Diagnostics.Debug.WriteLine("Editing Recipe"); dbEntry.RecipeCommentId = recipeComment.RecipeCommentId; dbEntry.Comments = recipeComment.Comments; dbEntry.UserId = recipeComment.UserId; dbEntry.CommentDateTime = DateTime.Today; } } context.SaveChanges(); }