예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("DepId,DepName")] Departements departements)
        {
            if (id != departements.DepId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //_context.Update(departements);
                    //await _context.SaveChangesAsync();
                    iDepatementService.Update(departements);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartementsExists(departements.DepId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(departements));
        }
예제 #2
0
 public bool UpdateDepartement(Departement DeptEdit)
 {
     try
     {
         _deptService.Update(DeptEdit);
         return(true);
     }
     catch (Exception ex)
     {
         ValidationMessage = ex.ToString();
         return(false);
     }
 }