public async Task <IActionResult> Create([Bind("OutletID,OutletName")] Outlets outlets) { if (ModelState.IsValid) { _context.Add(outlets); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(outlets)); }
public async Task <IActionResult> Create(List <Customers> item) { if (item != null) { foreach (Customers model in item) { bool exist_id = _context.Customers.Where(x => x.CustomerID.Equals(model.CustomerID)).Any(); if (!exist_id) { _context.Add(model); } else { _context.Update(model); } } await _context.SaveChangesAsync(); } return(RedirectToAction("Index")); }