コード例 #1
0
        // GET: Approvals
        public ActionResult Index(ApprovalSearch search)
        {
            ApprovalIndexDto       dto  = new ApprovalIndexDto();
            IEnumerable <Approval> list = db.Approvals.Where(a => a.status == ApprovalStatus.Request);

            if (search.requestbegindt != null)
            {
                list = list.Where(a => a.createdate >= search.requestbegindt);
            }
            if (search.requestenddt != null)
            {
                list = list.Where(a => a.createdate <= search.requestenddt);
            }
            if (!string.IsNullOrEmpty(search.owner))
            {
                list = list.Where(a => a.creater.Contains(search.owner));
            }
            if (!string.IsNullOrEmpty(search.name))
            {
                list = list.Where(a => a.privacy.IND_FULL_NAME.Contains(search.name));
            }

            dto.Approvals = list.ToList();
            dto.Search    = search;

            ViewBag.CompaniesList = GetCompanyList.GetCompany();

            return(View(dto));
        }
コード例 #2
0
        // GET: Approvals
        public ActionResult History(ApprovalSearch search)
        {
            string currentuser = !string.IsNullOrEmpty(User?.Identity?.Name) ? User.Identity.Name.ToUpper() : "Anonymous";

            currentuser = currentuser.Substring(currentuser.IndexOf('\\') + 1).Replace("\\", "").ToUpper();



            ApprovalIndexDto       dto  = new ApprovalIndexDto();
            IEnumerable <Approval> list = db.Approvals.Where(a => 1 == 1);

            if (search.sp != null)
            {
                list = list.Where(p => p.privacy.IND_SP.Contains(search.sp));
            }
            if (search.hospital != null)
            {
                list = list.Where(p => p.privacy.WKP_NAME.Contains(search.hospital));
            }

            if (!MyRoleManager.hasRole(MyRoleManager.RoleType.SYSTEMADMIN) && !MyRoleManager.hasRole(MyRoleManager.RoleType.DCEADMIN))
            {
                list = list.Where(p => p.creater.Equals(currentuser));
            }
            else if (search.owner != null)
            {
                list = list.Where(p => p.creater.Equals(search.owner));
            }

            if (search.status != null && !search.status.Equals("total"))
            {
                if (search.status.Equals("approved"))
                {
                    list = list.Where(p => p.status.Equals(ApprovalStatus.Approved));
                }
                else if (search.status.Equals("rejected"))
                {
                    list = list.Where(p => p.status.Equals(ApprovalStatus.Rejected));
                }
                else if (search.status.Equals("request"))
                {
                    list = list.Where(p => p.status.Equals(ApprovalStatus.Request));
                }
            }
            else
            {
                list = list.Where(p => p.status != ApprovalStatus.Request);
            }
            if (search.requestbegindt != null)
            {
                list = list.Where(a => a.createdate >= search.requestbegindt);
            }
            if (search.requestenddt != null)
            {
                list = list.Where(a => a.createdate <= search.requestenddt);
            }

            if (search.approvalbegindt != null)
            {
                list = list.Where(a => a.modifieddate >= search.approvalbegindt);
            }
            if (search.approvalenddt != null)
            {
                list = list.Where(a => a.modifieddate <= search.approvalenddt);
            }

            if (!string.IsNullOrEmpty(search.owner))
            {
                list = list.Where(a => a.creater.Contains(search.owner));
            }
            if (!string.IsNullOrEmpty(search.name))
            {
                list = list.Where(a => a.privacy.IND_FULL_NAME.Contains(search.name));
            }

            dto.Approvals = list.ToList();
            dto.Search    = search;

            ViewBag.CompaniesList = GetCompanyList.GetCompany();

            return(View(dto));
        }