Ejemplo n.º 1
0
        public ActionResult Delete(int Id)
        {
            var RightList = userRightRepo.GetMany(o => o.RoleId == Id);

            RightList.ToList().ForEach(o => userRightRepo.Delete(o));
            userRightRepo.SaveChanges();
            var entity = userRoleRepo.GetById(Id);

            userRoleRepo.Delete(entity);
            userRoleRepo.SaveChanges();
            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Delete(UserRoleDTO userRole)
 {
     MethodBase method = MethodBase.GetCurrentMethod();
     try
     {
         if (userRole.Id > 0)
         {
             UserRole delUserRole = Mapper.Map<UserRole>(userRole);
             UserRoleRepo.Delete(delUserRole);
             CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information);
             return Ok(true);
         }
         else
         {
             CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Information);
             return BadRequest();
         }
     }
     catch (Exception ex)
     {
         return HandleError(ex.Message, GetMethodCode(method));
     }
 }