Пример #1
0
        public ServiceResult GetRole(RoleCriteria cri = null)
        {
            var result = new ServiceResult();

            try
            {
                using (var db = new AgnosDBContext())
                {
                    var rows = db.Roles
                               .Where(w => 1 == 1);

                    if (cri != null)
                    {
                        if (cri.Role_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Role_ID == cri.Role_ID);
                        }
                    }
                    result.Object = rows.OrderByDescending(o => o.Role_Name).ToList();
                    result.Code   = ReturnCode.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                result.Code      = ReturnCode.ERROR_DB;
                result.Exception = ex;
            }
            return(result);
        }
Пример #2
0
        public ServiceResult GetPageRole(RoleCriteria cri = null)
        {
            var result = new ServiceResult();

            try
            {
                using (var db = new AgnosDBContext())
                {
                    var rows = db.Page_Role
                               .Include(i => i.Role)
                               .Include(i => i.Page)
                               .Where(w => 1 == 1 && w.Record_Status != Record_Status.Delete);

                    if (cri != null)
                    {
                        if (cri.Page_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Page_ID == cri.Page_ID);
                        }

                        if (cri.Role_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Role_ID == cri.Role_ID);
                        }

                        if (cri.Page_Role_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Page_Role_ID == cri.Page_Role_ID);
                        }
                    }
                    result.Object = rows.OrderBy(o => o.Role_ID).ThenBy(o => o.Page.Page_Code).ToList();
                    result.Code   = ReturnCode.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                result.Code      = ReturnCode.ERROR_DB;
                result.Exception = ex;
            }
            return(result);
        }