public async Task <IActionResult> Edit(int id, [Bind("Id,Name,BirthDate,Email,BaseSalary,DepartmentId")] Seller seller)
        {
            if (id != seller.Id)
            {
                return(RedirectToAction(nameof(Error), new { message = String.Format("No seller found with id of {0}.", id) }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _sellerServices.Update(seller);
                }
                catch (Exception e)
                {
                    if (e is DbUpdateConcurrencyException || e is DBConcurrencyException)
                    {
                        return(View(seller));
                    }

                    throw;
                }
            }

            ViewData["DepartmentId"] = new SelectList(await _departmentServices.FindAll(), "ID", "ID", seller.DepartmentId);
            return(View(seller));
        }
예제 #2
0
 public IActionResult Edit(int id, Seller seller)
 {
     if (id != seller.Id)
     {
         return(BadRequest());
     }
     try
     {
         _sellerService.Update(seller);
         return(RedirectToAction(nameof(Index)));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
     catch (DbConcurrencyException)
     {
         return(BadRequest());
     }
 }