public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["SalesPersonId"] = new SelectList(_context.SalesPerson, "Id", "FirstName"); ViewData["StoreItemId"] = new SelectList(_context.Set <StoreItem>(), "Id", "ItemName"); return(Page()); } _context.Attach(Sale).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SaleExists(Sale.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["DepartmentId"] = new SelectList(_context.Department, "Id", "DepartmentName"); return(Page()); } _context.Attach(StoreItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreItemExists(StoreItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Department).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(Department.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }