Exemplo n.º 1
0
        public async Task <IActionResult> Edit(long id, [Bind("OutletID,OutletName")] Outlets outlets)
        {
            if (id != outlets.OutletID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(outlets);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OutletsExists(outlets.OutletID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(outlets));
        }
Exemplo n.º 2
0
        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"));
        }