Exemplo n.º 1
0
        public static AutoApprovalListModel Create(IRepository<AutoApproval> autoApprovalRepository, string userName, bool showAll)
        {
            Check.Require(autoApprovalRepository != null, "repository null");
            Check.Require(!string.IsNullOrWhiteSpace(userName), "user name");

            var viewModel = new AutoApprovalListModel {ShowAll = showAll};
            var temp = autoApprovalRepository.Queryable.Where(a => a.User != null && a.User.Id == userName);
            if (!showAll)
            {
                temp = temp.Where(a => a.IsActive && (a.Expiration == null || a.Expiration >= DateTime.UtcNow.ToPacificTime().Date));
            }

            viewModel.AutoApprovals = temp.ToList();

            return viewModel;
        }
        public static AutoApprovalListModel Create(IRepository <AutoApproval> autoApprovalRepository, string userName, bool showAll)
        {
            Check.Require(autoApprovalRepository != null, "repository null");
            Check.Require(!string.IsNullOrWhiteSpace(userName), "user name");

            var viewModel = new AutoApprovalListModel {
                ShowAll = showAll
            };
            var temp = autoApprovalRepository.Queryable.Where(a => a.User != null && a.User.Id == userName);

            if (!showAll)
            {
                temp = temp.Where(a => a.IsActive && (a.Expiration == null || a.Expiration >= DateTime.UtcNow.ToPacificTime().Date));
            }

            viewModel.AutoApprovals = temp.ToList();

            return(viewModel);
        }