public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department)
        {
            if (id != department.Id)
            {
                return(RedirectToAction(nameof(Error), new { message = "diferent objects, cannot make update" }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(RedirectToAction(nameof(Error), new { message = "object is diferent, cannot be update" }));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
예제 #2
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());
                    }
                    throw;
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(department));
        }
예제 #3
0
 public async Task UpdateAsync(Departament departament)
 {
     if (!await DepartamentExists(departament.ID))
     {
         throw new NotFoundException("ID not found!");
     }
     try
     {
         _context.Update(departament);
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
예제 #4
0
 public async Task UpdateAsync(Seller seller)
 {
     try
     {
         if (!_context.Seller.Any(x => x.Id == seller.Id))
         {
             throw new NotFoundException("Id not found");
         }
         _context.Update(seller);
         _context.SaveChanges();
     }
     catch (DbUpdateConcurrencyException ex)
     {
         throw new DbConcurrencyException(ex.Message);
     }
 }
예제 #5
0
 public async Task UpdateAsync(Seller seller)
 {
     if (!await SellerExists(seller.ID))
     {
         throw new NotFoundException("ID not found!");
     }
     try
     {
         _context.Update(seller);
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
예제 #6
0
        public void Update(Seller obj)
        {
            if (!_context.Seller.Any(x => x.Id == obj.Id))
            {
                throw new NotFoundException("Id not found");
            }

            try
            {
                _context.Update(obj);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }
        public async Task UpdateAsync(Seller obj)
        {
            if (!await _context.Seller.AnyAsync(x => x.Id == obj.Id))
            {
                throw new DllNotFoundException("Id not found");
            }

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