public async Task <IActionResult> OnPostAsync(Guid recid) { RecipeFood.UpdateDateTime = DateTime.UtcNow; if (!ModelState.IsValid) { return(Page()); } RecipeFood rf = _context.RecipeFood.Where(r => r.FoodId == RecipeFood.FoodId && r.RecipeId == RecipeFood.RecipeId).FirstOrDefault(); if (rf != null) { rf.Grams += RecipeFood.Grams; _context.RecipeFood.Attach(rf).State = EntityState.Modified; } else { _context.RecipeFood.Add(RecipeFood); } await _context.SaveChangesAsync(); return(RedirectToPage("/Recipe/Edit", new Dictionary <string, string> { { "id", recid.ToString() } })); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(AspNetUsers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AspNetUsersExists(AspNetUsers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.AspNetUsers.Add(AspNetUsers); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (Recipe.RecipeId == null) { Recipe.RecipeId = Guid.NewGuid(); } Recipe.UpdateDateTime = DateTime.UtcNow; if (!ModelState.IsValid) { return(Page()); } if (RecipesExists(Recipe.RecipeId)) { _context.Attach(Recipe).State = EntityState.Modified; } else { _context.Recipes.Add(Recipe); } foreach (RecipeFood rf in _context.RecipeFood.Where(r => r.RecipeId == Recipe.RecipeId).ToList()) { RecipeFood RF2 = RecipeFoods.Where(f => f.FoodId == rf.FoodId && f.RecipeId == rf.RecipeId && f.Grams != rf.Grams).FirstOrDefault(); if (RF2 != null) { rf.Grams = RF2.Grams; _context.Attach(rf).State = EntityState.Modified; } } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipesExists(Recipe.RecipeId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid recid) { RecipeFood.UpdateDateTime = DateTime.UtcNow; if (!ModelState.IsValid) { return(Page()); } _context.DayRecipeFood.Add(RecipeFood); await _context.SaveChangesAsync(); return(RedirectToPage("/User/DayRecipe/Edit", new Dictionary <string, string> { { "id", recid.ToString() } })); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } RecipeFood = await _context.RecipeFood.FindAsync(id); if (RecipeFood != null) { _context.RecipeFood.Remove(RecipeFood); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } AspNetUsers = await _context.AspNetUsers.FindAsync(id); if (AspNetUsers != null) { _context.AspNetUsers.Remove(AspNetUsers); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } FoodGroup = await _context.FoodGroup.FindAsync(id); if (FoodGroup != null) { _context.FoodGroup.Remove(FoodGroup); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(Guid?id) { if (id == null) { return(NotFound()); } UserGoals = await _context.UserGoals.FindAsync(id); if (UserGoals != null) { _context.UserGoals.Remove(UserGoals); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }