Ejemplo n.º 1
0
        //当前企业的角色列表
        public ActionResult GetRoleList()
        {
            string _enterpriseID = GetSession().User.EnterpriseID;
            var    result        = new StandardJsonResult <List <EnterpriseRoleViewModel> >();

            result.Try(() =>
            {
                List <EnterpriseRoleDto> list = _entRoleService.GetEnterpriseRoleByEnterpriseID(_enterpriseID);

                List <EnterpriseRoleViewModel> rlist = new List <EnterpriseRoleViewModel>();
                foreach (var role in list)
                {
                    var rvm = new EnterpriseRoleViewModel
                    {
                        RoleID   = role.RoleID + "",
                        RoleName = role.Name
                    };
                    rlist.Add(rvm);
                }
                result.Value = rlist;
            });
            if (result.Success)
            {
                return(new OringinalJsonResult <List <EnterpriseRoleViewModel> > {
                    Value = result.Value
                });
            }
            else
            {
                return(new OringinalJsonResult <List <EnterpriseRoleViewModel> > {
                    Value = new List <EnterpriseRoleViewModel>()
                });
            }
        }
Ejemplo n.º 2
0
        public ActionResult GetEnterpriseRoleByList(EnterpriseRoleViewModel model)
        {
            var result = new StandardJsonResult <DataGridResultModelBase <EnterpriseRoleDto> >();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var service = Ioc.GetService <IEnterpriseRoleManagementService>();
                int count   = 0;//test
                List <EnterpriseRoleDto> list = new List <EnterpriseRoleDto>();
                list               = service.GetEnterpriseRoleList(model.EnterpriseName, model.Name, model.rows, model.page, out count);
                result.Value       = new DataGridResultModelBase <EnterpriseRoleDto>();
                result.Value.total = count;//赋值

                // result.Value.rows = Serializer.ToJson(list);
                result.Value.rows = list;
            });
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }