public async Task <IActionResult> Create([Bind("ID,Name")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("ID,Name,Units")] PartType partType) { if (ModelState.IsValid) { _context.Add(partType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(partType)); }
public async Task <IActionResult> Create([Bind("ID,Address")] Stock stock) { if (ModelState.IsValid) { _context.Add(stock); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } PopulatePositionsData(stock); return(View(stock)); }
public async Task <IActionResult> Create([Bind("ID,PartID,StockID,ArrDate,Quantity")] Left left) { if (ModelState.IsValid) { _context.Add(left); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PartID"] = new SelectList(_context.Parts, "ID", "ID", left.PartID); ViewData["StockID"] = new SelectList(_context.Stocks, "ID", "ID", left.StockID); return(View(left)); }
public async Task <IActionResult> Create([Bind("CustomerID,SignDate")] Contract contract) { if (ModelState.IsValid) { _context.Add(contract); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["CustomerID"] = new SelectList(_context.Customers, "ID", "ID", contract.CustomerID); PopulateCustomersDropDownList(); return(View(contract)); }
public async Task <IActionResult> Create([Bind("FirstName,Surname")] Employee employee) { try { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (Exception ex) { ModelState.AddModelError("", "Виникла помилка під час збереження даних. " + ex.Message); } return(View(employee)); }