public async Task <IActionResult> Create([Bind("ID,Name,Adress,Salary")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("ID,NumeDistribuitor,Adresa")] Distribuitor distribuitor) { if (ModelState.IsValid) { _context.Add(distribuitor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(distribuitor)); }
public async Task <IActionResult> Create([Bind("Denumire,Furnizor,Pret")] Produs produs) { try { if (ModelState.IsValid) { _context.Add(produs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(produs)); }