public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductId,IngredientId,Quantity")] ProductIngredient productIngredient) { if (id != productIngredient.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productIngredient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductIngredientExists(productIngredient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IngredientId"] = new SelectList(_context.Ingredient, "Id", "Name", productIngredient.IngredientId); ViewData["ProductId"] = new SelectList(_context.Product, "Id", "Name", productIngredient.ProductId); return(View(productIngredient)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Description,Title,Value,CreationData,DueData,PayData")] Register register) { if (id != register.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(register); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegisterExists(register.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(register)); }
//[ValidateAntiForgeryToken] public async Task <Object> Edit(Guid id, [FromBody] Student student) { var StudentEx = await _context.Student.FindAsync(id); StudentEx.StudentName = student.StudentName; StudentEx.DateOfBirth = student.DateOfBirth; StudentEx.Gpa = student.Gpa; StudentEx.Email = student.Email; StudentEx.ClassId = student.ClassId; _context.Update(StudentEx); await _context.SaveChangesAsync(); ViewData["ClassId"] = new SelectList(_context.Class, "ClassId", "ClassId", student.ClassId); return(Ok(StudentEx)); }