public async Task <ActionResult> DeleteFilterRule(long id)
        {
            var result = new JsonModel {
                statusCode = 300, message = "删除失败,记录不存在!", closeCurrent = false
            };

            if (id < 1)
            {
                return(Json(result));
            }
            var model = await UserRole2FilterRepository.GetUnDeleteByIdAsync(id);

            if (model == null)
            {
                return(Json(result));
            }
            await UserRole2FilterRepository.Delete(model);

            UserRoleSvc.ClearRoleUserCache(model.RoleId);
            await LogRepository.Insert(TableSource.UserRole2Filter, OperationType.Delete, "删除角色数据规则" + model.Name, id);

            result.statusCode = 200;
            result.message    = "删除成功!";
            return(Json(result));
        }
        public ActionResult Edit(UserRoleModel model)
        {
            var      result = new JsonModel();
            var      opType = OperationType.Insert;
            UserRole role   = null;

            if (model.Id > 0)
            {
                role = UserRoleRepository.Get(model.Id);
                if (role == null)
                {
                    result.msg = $"找不到id为{0}的角色";
                    return(Json(result));
                }
                opType = OperationType.Update;
            }
            else
            {
                role = new UserRole();
            }
            Mapper.Map(model, role);
            UserRoleSvc.SaveList(role, model.MenuIds);
            LogRepository.Insert(TableSource.UserRole, opType, role.Id);
            result.code = JsonModelCode.Succ;
            ShowSuccMsg("保存成功!");
            return(Json(result));
        }
Beispiel #3
0
        /// <summary>
        /// 我的路线(针对导游)
        /// </summary>
        /// <returns></returns>
        public ActionResult MyLines(long userid)
        {
            var user    = UserSvc.GetById((long)userid);//user表
            var roleids = UserRoleSvc.GetById(user.Id);
            int i       = Array.IndexOf(roleids, 6);

            if (i == -1)
            {
                return(Redirect("~/Guide/RegisterGuide"));
            }
            else
            {
                var guide = GuideSvc.GetByUid(user.Id);
                var lids  = GuidLinesSvc.GetLid(guide.Id);
                var lines = LineSvc.GetByLids(lids);

                var            uids  = GuideUserSvc.GetUid(guide.Id);
                List <UserDTO> users = new List <UserDTO>();
                //List<OrderUserDTO> ou = new List<OrderUserDTO>();
                foreach (var id in uids)
                {
                    users.Add(UserSvc.GetById(id));
                }
                LinesAndUser model = new LinesAndUser();

                //ViewBag.Time=
                model.Line       = lines;
                model.User       = users.ToArray();
                ViewBag.phonenum = user.PhoneNum;
                ViewBag.gid      = guide.Id;
                return(View(model));
            }
        }
Beispiel #4
0
        public ActionResult Add(UserAddModel model)
        {
            if (!ModelState.IsValid)
            {
                string msg = mvchelper.GetValiMsg(ModelState);
                return(Json(new AjaxResult {
                    status = "error", errorMsg = msg
                }));
            }
            //服务器端的校验必不可少
            bool exists = UserSvc.GetByPhoneNum(model.phonenum) != null;

            if (exists)
            {
                return(Json(new AjaxResult
                {
                    status = "error",
                    errorMsg = "手机号已经存在"
                }));
            }

            long userId = UserSvc.AddUser(model.account, model.nickname,
                                          model.phonenum, model.gender, model.password, model.email);

            UserRoleSvc.AddUserRole(userId, model.RoleIds);
            //roleService.AddRoleIds(userId, model.RoleIds);
            return(Json(new AjaxResult {
                status = "ok"
            }));
        }
        public ActionResult SetFilterRule(long roleId)
        {
            //Source、FilterGroup
            var list = UserRoleSvc.GetFilterList(roleId);

            ViewBag.roleId = roleId;
            return(PartialView(list));
        }
        public async Task <ActionResult> SetMenus(long id, string menuIds)
        {
            var result = new JsonModel();
            await UserRoleSvc.SaveListAsync(id, menuIds);

            result.message = "保存成功!";
            return(Json(result));
        }
Beispiel #7
0
 public ActionResult Edit(UserEditModel model)
 {
     UserSvc.UpdateUser(model.id, model.nickname, model.phonenum
                        , model.gender, model.password, model.email);
     UserRoleSvc.AddUserRole(model.id, model.RoleIds);
     return(Json(new AjaxResult {
         status = "ok"
     }));
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public ApiBaseController()
        {
            //Inicializa instancia de Mapper
            mapper = AutoMapperConfig.Instance.MapperConfiguration.CreateMapper();

            userSvc      = IoC.Resolve <UserSvc>();
            userGroupSvc = IoC.Resolve <UserGroupSvc>();
            userRoleSvc  = IoC.Resolve <UserRoleSvc>();
            newsSvc      = IoC.Resolve <NewsSvc>();
            newsSentSvc  = IoC.Resolve <NewsSentSvc>();
        }
        private async Task GetRoleUsers(List <WfActivitySelectModel> model, WfActivity act)
        {
            var users = await UserRoleSvc.GetUserListByRoleIds(act.roleIds);

            if (users != null && users.Count > 0)
            {
                model.Add(new WfActivitySelectModel()
                {
                    Activity = act,
                    UserList = users
                });
            }
        }
        public ActionResult SaveButtons(long id, string btnIds)
        {
            var result = new JsonModel();

            if (string.IsNullOrEmpty(btnIds))
            {
                result.msg = "请选择按钮!";
                return(Json(result));
            }
            UserRole2MenuRepository.SaveRole2MenuButtons(id, btnIds);
            UserRoleSvc.ClearRoleUserCache(id);
            result.msg  = "保存成功!";
            result.code = JsonModelCode.Succ;
            return(Json(result));
        }
        public async Task <ActionResult> SetButtons(long roleId, string btnIds)
        {
            var result = new JsonModel();

            if (string.IsNullOrEmpty(btnIds))
            {
                result.statusCode = 300;
                result.message    = "请选择按钮!";
                return(Json(result));
            }
            await UserRole2MenuRepository.SaveRole2MenuButtons(roleId, btnIds);

            UserRoleSvc.ClearRoleUserCache(roleId);
            result.message = "保存成功!";
            return(Json(result));
        }
        public async Task <ActionResult> SetFilterRule(long id, string filterGroup, string name, string source, long roleId)
        {
            var result = new JsonModel();
            var exist  = await UserRole2FilterRepository.ExistSourceAsync(id, source);

            if (exist)
            {
                result.statusCode = 300;
                result.message    = $"已存在资源为{source}的角色数据规则!";
                return(Json(result));
            }
            UserRole2Filter userFilter = null;

            if (id > 0)
            {
                userFilter = await UserRole2FilterRepository.GetByIdAsync(id);

                if (userFilter == null)
                {
                    result.statusCode = 300;
                    result.message    = $"找不到Id为{id}的角色数据规则关联数据!";
                    return(Json(result));
                }
            }
            else
            {
                userFilter = DbFactory.CreateUserRole2Filter();
            }
            userFilter.RoleId       = roleId;
            userFilter.Name         = name;
            userFilter.Source       = source;
            userFilter.FilterGroups = filterGroup;
            await UserRole2FilterRepository.SaveAsync(userFilter);

            UserRoleSvc.ClearRoleUserCache(userFilter.RoleId);
            result.message = "保存成功!";
            var propModelList = GetPropertyList(source);

            userFilter.SourceProperties = propModelList;
            result.Data = userFilter;
            return(Json(result));
        }
        public async Task <ActionResult> GetCurrResources(FilterCurrent curr)
        {
            var list = await UserRoleSvc.GetResListAsync(curr);

            return(Json(list));
        }