Exemplo n.º 1
0
 public ActionResult Create(RoleModel model)
 {
     if (_roleService.List().Count(m => m.Title == model.Title) > 0)
     {
         _result = "failed";
         return Content(_result);
     }
     var role = model.ToEntity();
     model.AddTime = DateTime.Now;
     _roleService.Add(role);
     SaveRoleApps(role, StringToArray(model.RoleAppTag));
     SaveUsers(role, StringToArray(model.UserTag));
     SaveUserFancies(StringToArray(model.RoleAppTag), StringToArray(model.UserTag));
     _result = "success";
     return Content(_result);
 }
Exemplo n.º 2
0
 public ActionResult Edit(RoleModel model)
 {
     var role = this._roleService.Get(model.Id);
     role = model.ToEntity(role);
     this._roleService.Update(role);
    var d= this._userProfileService.List().Where(m => m.RoleId == role.Id).ToList().Select(m =>
    {
        var t=m;
        t.RoleId = 2;
        return t;
    });
     this._userProfileService.Update(d.ToList());
     var s = this._roleAppService.GetRoleAppByRoleId(role.Id).ToList();
     this._roleAppService.Delete(s);
     SaveRoleApps(role, StringToArray(model.RoleAppTag));           
     ReSetFancyApp(model, d);
     SaveUsers(role, StringToArray(model.UserTag)); 
     _result = "success";
     return Content(_result);
 }
Exemplo n.º 3
0
        private void PrepareNoAddedUser(RoleModel model, Role role)
        {
            var data = from t in _userProfileService.List()
                //2代码默认权限
                where t.RoleId == 2
                orderby t.Id
                select t;
            var list = data.ToList().Select(m => m.ToModel());
;
            model.NoAddedUser = list.ToList();
        }
Exemplo n.º 4
0
 private void ReSetFancyApp(RoleModel model, IEnumerable<UserProfile> d)
 {
     var oldUserTag = d.Select(m => m.Id).ToList();
     oldUserTag.ForEach(m =>
     {
         var c = this._userFancyAppService.GetUserFancyAppByUserId(m).ToList();
         this._userFancyAppService.Delete(c);
     });
     SaveUserFancies(StringToArray(model.RoleAppTag), StringToArray(model.UserTag));
 }
Exemplo n.º 5
0
 private void PrepareAddedUser(RoleModel model, Role role)
 {
     var userList = this._userProfileService.List().Where(m => m.RoleId == role.Id).ToList();
     var roleAppListsModel = userList
         .Select(x =>x.ToModel());
     model.AddedUser = roleAppListsModel.ToList();
 }
Exemplo n.º 6
0
 private void PrepareNoAddedApp(RoleModel model, Role role)
 {
     List<int> noAddedAppList = GetNoAddedApp(role.Id);
     var data = from t in _appService.List()
                where noAddedAppList.Any(m => m == t.Id)
                orderby t.Id
                select new RoleModel.RoleAppModel
                {
                    AppId = t.Id,
                    AppName = t.Name,
                    AppUrl = t.RouteUrl
                };
     model.NoAddedApp = data.ToList();
 }
Exemplo n.º 7
0
 private void PrepareAddedApp(RoleModel model, Role role)
 {
     var roleAppList = _roleAppService.GetRoleAppByRoleId(role.Id);
     var roleAppListsModel = roleAppList
         .Select(x =>
             new RoleModel.RoleAppModel
             {
                 RoleId = x.RoleId,
                 AppId = x.AppId,
                 AppName = x.App.Name,
                 DisplayOrder = x.DisplayOrder,
                 AppUrl = x.App.RouteUrl
             });
     model.AddedApp = roleAppListsModel.ToList();
 }