Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department)
        {
            if (id != department.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Ejemplo n.º 2
0
 public void Update(Seller seller)
 {
     if (!_context.Seller.Any(x => x.Id == seller.Id))
     {
         throw new NotFoundException("Id Not Found");
     }
     try {
         _context.Update(seller);
         _context.SaveChanges();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
Ejemplo n.º 3
0
        public async Task UpdateAsync(Saller obj)
        {
            bool hasAny = await _context.Saller.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new NotFoundException("ID not found");
            }

            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbConcurrencyExceprion(e.Message);
            }
        }