Esempio n. 1
0
        public async Task <ActionResult> Query(RoleQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (RoleServiceClient client = new RoleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.RoleName))
                            {
                                where.AppendFormat("Key LIKE '{0}%'", model.RoleName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            Where = where.ToString()
                        };
                        MethodReturnResult <IList <Role> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.RoleList     = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_RoleListPartial"));
        }
Esempio n. 2
0
 public IList <Role> GetRoles()
 {
     using (RoleServiceClient client = new RoleServiceClient())
     {
         PagingConfig cfg = new PagingConfig()
         {
             IsPaging = false
         };
         MethodReturnResult <IList <Role> > result = client.Get(ref cfg);
         if (result.Code == 0)
         {
             return(result.Data);
         }
     }
     return(new List <Role>());
 }
Esempio n. 3
0
        //
        // GET: /RBAC/Role/
        /// <summary>
        /// Indexes this instance.
        /// </summary>
        /// <returns>Task&lt;ActionResult&gt;.</returns>
        public async Task <ActionResult> Index()
        {
            using (RoleServiceClient client = new RoleServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig();
                    MethodReturnResult <IList <Role> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.RoleList     = result.Data;
                    }
                });
            }
            return(View());
        }
Esempio n. 4
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (RoleServiceClient client = new RoleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Role> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.RoleList     = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_RoleListPartial"));
        }
Esempio n. 5
0
        public RoleDto Get(string id = null, string name = null)
        {
            RoleDto role = roleServiceClient.Get(id, name);

            return(role);
        }