Ejemplo n.º 1
0
        public ActionResult RoleDelete(string ids)
        {
            AjaxResult result;

            try
            {
                int[]                    idArray    = ids.Split(',').Select(o => int.Parse(o)).ToArray();
                FluentModel              db         = Session.GetFluentModel();
                SuncereRoleRepository    repository = new SuncereRoleRepository(db);
                IQueryable <SuncereRole> query      = repository.Query(idArray);
                foreach (SuncereRole role in query)
                {
                    foreach (SuncereUser user in role.SuncereUsers)
                    {
                        user.SuncereRoles.Remove(role);
                    }
                    foreach (SuncerePermission permission in role.SuncerePermissions)
                    {
                        permission.SuncereRoles.Remove(role);
                    }
                    role.SuncereUsers.Clear();
                    role.SuncerePermissions.Clear();
                }
                db.Delete(query);
                db.SaveChanges();
                result = AjaxResult.GetDeleteAjaxResult(true);
            }
            catch (Exception e)
            {
                result = AjaxResult.GetDeleteAjaxResult(false);
            }
            return(Json(result, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 2
0
        public ActionResult RoleList(DateTime?startTime, DateTime?endTime, string keyword)
        {
            FluentModel           db         = Session.GetFluentModel();
            SuncereRoleRepository repository = new SuncereRoleRepository(db);
            List <SuncereRole>    list       = repository.Query(startTime, endTime, keyword).ToList();

            ViewData["startTime"] = startTime;
            ViewData["endTime"]   = endTime;
            ViewData["keyword"]   = keyword;
            return(View(list));
        }