当前位置: 首页>>代码示例>>C#>>正文


C# IRepository.OfType方法代码示例

本文整理汇总了C#中IRepository.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.OfType方法的具体用法?C# IRepository.OfType怎么用?C# IRepository.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.OfType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public static EmailTemplateListViewModel Create(IRepository repository, int? templateId, int? callForProposalId)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new EmailTemplateListViewModel();

            if (templateId != null  && templateId != 0)
            {
                viewModel.IsTemplate = true;
                viewModel.EmailTemplateList = repository.OfType<EmailTemplate>().Queryable.Where(a => a.Template != null && a.Template.Id == templateId);
                viewModel.TemplateId = templateId;
            }
            else if (callForProposalId != null && callForProposalId != 0)
            {
                viewModel.IsCallForProposal = true;
                viewModel.EmailTemplateList = repository.OfType<EmailTemplate>().Queryable.Where(a => a.CallForProposal != null && a.CallForProposal.Id == callForProposalId);
                viewModel.CallForProposalId = callForProposalId;
            }
            viewModel.DescriptionDict = new Dictionary<EmailTemplateType, string>(7);
            viewModel.DescriptionDict.Add(EmailTemplateType.InitialCall, StaticValues.InitialCall);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalApproved, StaticValues.ProposalApproved);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalConfirmation, StaticValues.ProposalConfirmation);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalDenied, StaticValues.ProposalDenied);
            viewModel.DescriptionDict.Add(EmailTemplateType.ReadyForReview, StaticValues.ReadyForReview);
            viewModel.DescriptionDict.Add(EmailTemplateType.ReminderCallIsAboutToClose, StaticValues.ReminderCallIsAboutToClose);
            viewModel.DescriptionDict.Add(EmailTemplateType.ProposalUnsubmitted, StaticValues.ProposalUnsubmitted);

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:28,代码来源:EmailTemplateViewModels.cs

示例2: Create

        public static QuestionViewModel Create(IRepository repository, int? templateId, int? callForProposalId)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new QuestionViewModel
            {
                Question = new Question(),
                QuestionTypes = repository.OfType<QuestionType>().GetAll(),
                Validators = repository.OfType<Validator>().GetAll()
            };

            if (templateId != null && templateId != 0)
            {
                viewModel.IsTemplate = true;
                viewModel.TemplateId = templateId;
            }
            else if (callForProposalId != null && callForProposalId != 0)
            {
                viewModel.IsCallForProposal = true;
                viewModel.CallForProposalId = callForProposalId;
            }

            Check.Require(viewModel.IsTemplate || viewModel.IsCallForProposal, "Must have either a template or a call for proposal");

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:25,代码来源:QuestionViewModels.cs

示例3: Create

        public static QuestionViewModel Create(IRepository repository)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new QuestionViewModel()
            {
                QuestionTypes = repository.OfType<QuestionType>().GetAll(),
                Validators = repository.OfType<Validator>().GetAll()
            };

            return viewModel;
        }
开发者ID:ucdavis,项目名称:CRP,代码行数:12,代码来源:QuestionViewModel.cs

示例4: Create

        public static WorkgroupAccountModel Create(IRepository repository, Workgroup workgroup, WorkgroupAccount workgroupAccount = null)
        {
            Check.Require(repository != null, "repo null");
            Check.Require(workgroup != null, "workgroup null");

            var viewModel = new WorkgroupAccountModel { Workgroup = workgroup, WorkgroupAccount = workgroupAccount ?? new WorkgroupAccount()};

            viewModel.WorkGroupPermissions = repository.OfType<WorkgroupPermission>().Queryable.Where(a => a.Workgroup == workgroup && (!a.IsAdmin || (a.IsAdmin && a.IsFullFeatured))).ToList();
            viewModel.Accounts = workgroup.Organizations.SelectMany(x => x.Accounts).Distinct().ToList();

            viewModel.Approvers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.Approver).Select(x => x.User).Distinct().ToList();
            viewModel.AccountManagers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.AccountManager).Select(x => x.User).Distinct().ToList();
            viewModel.Purchasers = viewModel.WorkGroupPermissions.Where(x => x.Role.Id == Role.Codes.Purchaser).Select(x => x.User).Distinct().ToList();

            if (viewModel.WorkgroupAccount.Approver == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.Approver && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.Approver = approver.User;
                }
            }

            if (viewModel.WorkgroupAccount.AccountManager == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.AccountManager && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.AccountManager = approver.User;
                }
            }

            if (viewModel.WorkgroupAccount.Purchaser == null)
            {
                var approver = repository.OfType<WorkgroupPermission>().Queryable.SingleOrDefault(
                        a =>
                        a.Workgroup == workgroup && a.Role.Id == Role.Codes.Purchaser && !a.IsAdmin &&
                        a.IsDefaultForAccount);
                if (approver != null)
                {
                    viewModel.WorkgroupAccount.Purchaser = approver.User;
                }
            }

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Purchasing,代码行数:52,代码来源:WorkgroupAccountModel.cs

示例5: Create

        public static AdminRegisterForStudentViewModel Create(IRepository repository, RegistrationModel registrationModel)
        {
            Check.Require(repository != null, "Repository is required.");
            Check.Require(registrationModel != null, "registrationModel is required.");

            var viewModel = new AdminRegisterForStudentViewModel()
            {
                RegistrationModel = registrationModel,
                Majors = repository.OfType<MajorCode>().GetAll(),
                Ceremonies = repository.OfType<Ceremony>().Queryable.Where(a=>a.TermCode == TermService.GetCurrent()).ToList(),
            };

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:14,代码来源:AdminRegisterForStudentViewModel.cs

示例6: BeginReportRequest

        public static void BeginReportRequest(IRepository repository, HonorsPostModel honorsModel, string userId)
        {
            var parameters = new Dictionary<string, string>();
            var reportName = "/Commencement/Honors";

            parameters.Add("CollegeId", honorsModel.College.Id);
            parameters.Add("TermCode", honorsModel.TermCode);
            parameters.Add("Honors4590", honorsModel.Honors4590.ToString());
            parameters.Add("HighHonors4590", honorsModel.HighHonors4590.ToString());
            parameters.Add("HighestHonors4590", honorsModel.HighestHonors4590.ToString());
            parameters.Add("Honors90135", honorsModel.Honors90135.ToString());
            parameters.Add("HighHonors90135", honorsModel.HighHonors90135.ToString());
            parameters.Add("HighestHonors90135", honorsModel.HighestHonors90135.ToString());
            parameters.Add("Honors135", honorsModel.Honors135.ToString());
            parameters.Add("HighHonors135", honorsModel.HighHonors135.ToString());
            parameters.Add("HighestHonors135", honorsModel.HighestHonors135.ToString());

            var hr = honorsModel.Convert();
            hr.User = repository.OfType<vUser>().Queryable.FirstOrDefault(a => a.LoginId == userId);

            // start the transaction just so we can record the request
            using (var ts = new TransactionScope())
            {
                // create the history object, plus this will also set the request date time
                repository.OfType<HonorsReport>().EnsurePersistent(hr);
                ts.CommitTransaction();
            }

            // make the call to get the report, then save it and email the user
            using (var ts = new TransactionScope())
            {
                // get the actual report itself
                hr.Contents = GetHonorsReport(parameters); //Get(reportName, parameters);

                // persist the object
                repository.OfType<HonorsReport>().EnsurePersistent(hr);
                ts.CommitTransaction();

                // email the user
                //var message = new MailMessage();
                //message.To.Add(hr.User.Email);
                //message.Subject = "Commencement - Honors Report Completed";
                //message.Body = "Your honors report request has completed.";
                //message.IsBodyHtml = true;

                //// settings are set in the web.config
                //var client = new SmtpClient();
                //client.Send(message);
            }
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:50,代码来源:ReportRequestHandler.cs

示例7: Create

        public static RequirementViewModel Create(IRepository repository, Project project)
        {
            Check.Require(repository != null, "Repository must be supplied");
            Check.Require(project != null, "project is required.");

            var viewModel = new RequirementViewModel
                                {
                                    Requirement = new Requirement(),
                                    Project = project,
                                    RequirementTypes = repository.OfType<RequirementType>().GetAll(),
                                    PriorityTypes = repository.OfType<PriorityType>().GetAll(),
                                    RequirementCategories = project.RequirementCategories.Where(a => a.IsActive).ToList()
                                };

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Dogbert,代码行数:16,代码来源:RequirementViewModel.cs

示例8: Create

        public static AddEditorViewModel Create(IRepository repository, Template template, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new AddEditorViewModel()
            {
                Template = template,
                CallForProposal = callForProposal,
                Users = repository.OfType<User>().Queryable.OrderBy(a => a.LastName).ToList()
            };
            if (template != null)
            {
                viewModel.IsTemplate = true;
                viewModel.TemplateId = template.Id;
            }
            else if (callForProposal != null)
            {
                viewModel.IsCallForProposal = true;
                viewModel.CallForProposalId = callForProposal.Id;
            }

            Check.Require(viewModel.IsTemplate || viewModel.IsCallForProposal, "Must have either a template or a call for proposal");

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:25,代码来源:EditorViewModels.cs

示例9: Create

        public static AdminExtraTicketPetitionViewModel Create(IRepository repository, ICeremonyService ceremonyService, IPetitionService petitionService, IPrincipal currentUser, TermCode termCode, int? ceremonyId, bool? viewAll)
        {
            Check.Require(repository != null, "Repository is required.");

            // set the default to false
            viewAll = viewAll ?? false;

            var ceremonies = ceremonyService.GetCeremonies(currentUser.Identity.Name, termCode);
            //var ceremonyIds = ceremonies.Select(a => a.Id).ToList();

            var viewModel = new AdminExtraTicketPetitionViewModel()
                                {
                                    Ceremonies = ceremonies,
                                    Ceremony = ceremonyId.HasValue ? repository.OfType<Ceremony>().GetNullableById(ceremonyId.Value) : null,
                                    ViewAll = viewAll.Value
                                };

            // has a ceremony been selected and does the current user have access
            if (ceremonyId.HasValue && ceremonyService.HasAccess(ceremonyId.Value, currentUser.Identity.Name))
            {
                if (viewAll.Value)
                {
                    viewModel.RegistrationParticipations = viewModel.Ceremony.RegistrationParticipations.Where(a => a.ExtraTicketPetition != null).ToList();
                }
                else
                {
                    viewModel.RegistrationParticipations = petitionService.GetPendingExtraTicket(currentUser.Identity.Name, ceremonyId.Value, termCode);
                }

            }

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:33,代码来源:AdminExtraTicketPetitionViewModel.cs

示例10: Create

        public static EmailQueueListViewModel Create(IRepository repository, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new EmailQueueListViewModel{CallForProposal = callForProposal};
            viewModel.EmailQueues = repository.OfType<EmailQueue>().Queryable.Where(a => a.CallForProposal == callForProposal);

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:9,代码来源:EmailQueueViewModels.cs

示例11: Create

        public static ActiveSurveyViewModel Create(IRepository repository, bool isPublic)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ActiveSurveyViewModel { IsPublic = isPublic};
            viewModel.Surveys = repository.OfType<Survey>().Queryable.Where(a => a.IsActive);

            return viewModel;
        }
开发者ID:ucdavis,项目名称:NuSurvey,代码行数:9,代码来源:SurveyResponseController.cs

示例12: Create

        public static EmailsForCallSendViewModel Create(IRepository repository, CallForProposal callForProposal)
        {
            Check.Require(repository != null, "Repository must be supplied");
            var viewModel = new EmailsForCallSendViewModel {CallForProposal = callForProposal, Immediate = false};

            viewModel.EmailsForCallList = repository.OfType<EmailsForCall>().Queryable.Where(a => a.CallForProposal != null && a.CallForProposal == callForProposal);

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Gramps,代码行数:9,代码来源:EmailsForCallViewModels.cs

示例13: Create

        public static AdminStudentViewModel Create(IRepository repository, IMajorService majorService, ICeremonyService ceremonyService, TermCode termCode, string studentid, string lastName, string firstName, string majorCode, string college, string userId)
        {
            Check.Require(repository != null, "Repository is required.");

            // build a list of majors that the current user has assigned to their ceremonies
            var ceremonies = ceremonyService.GetCeremonies(userId, TermService.GetCurrent());
            var majors = ceremonies.SelectMany(a => a.Majors).Where(a => a.ConsolidationMajor == null && a.IsActive).ToList();
            var colleges = ceremonies.SelectMany(a => a.Colleges).Distinct().ToList();

            var viewModel = new AdminStudentViewModel()
                                {
                                    MajorCodes = majors,
                                    studentidFilter = studentid,
                                    lastNameFilter = lastName,
                                    firstNameFilter = firstName,
                                    majorCodeFilter = majorCode,
                                    Colleges = colleges
                                };

            var query = repository.OfType<Student>().Queryable.Where(a =>
                    a.TermCode == termCode
                    && (a.StudentId.Contains(string.IsNullOrEmpty(studentid) ? string.Empty : studentid.Trim()))
                    && (a.LastName.Contains(string.IsNullOrEmpty(lastName) ? string.Empty : lastName.Trim()))
                    && (a.FirstName.Contains(string.IsNullOrEmpty(firstName) ? string.Empty : firstName.Trim()))
                    );

            // get the list of students with optional filters
            var students = query.ToList();

            if (colleges.Count == 1)
            {
                var coll = colleges.First();
                students = students.Where(a => a.StrColleges.Contains(coll.Id)).ToList();
            }

            if (!string.IsNullOrEmpty(majorCode)) students = students.Where(a => a.StrMajorCodes.Contains(majorCode)).ToList();
            if (!string.IsNullOrEmpty(college)) students = students.Where(a => a.StrColleges.Contains(college)).ToList();

            // get all active registrations
            var reg = repository.OfType<RegistrationParticipation>().Queryable.Where(
                    a => a.Ceremony.TermCode == termCode).// && !a.Registration.Student.SjaBlock && !a.Registration.Cancelled).
                    ToList();

            var regStudents = reg.Select(a => a.Registration.Student);

            viewModel.StudentRegistrationModels = new List<StudentRegistrationModel>();

            foreach(var s in students.Distinct().ToList())
            {
                var reged = regStudents.Any(a => a == s);

                viewModel.StudentRegistrationModels.Add(new StudentRegistrationModel(s, reged));
            }

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Commencement,代码行数:56,代码来源:AdminStudentViewModel.cs

示例14: Create

        public static CreateReportViewModel Create(IRepository repository, Item item)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new CreateReportViewModel() {Item = item};
            viewModel.QuestionTypeNoAnswer =
                repository.OfType<QuestionType>().Queryable.Where(a => a.Name == QuestionTypeText.STR_NoAnswer).
                    FirstOrDefault();

            return viewModel;
        }
开发者ID:ucdavis,项目名称:CRP,代码行数:11,代码来源:ReportViewModel.cs

示例15: Create

        public static MyTasksViewModel Create(IRepository repository, string loginId)
        {
            Check.Require(repository != null, "repository is required.");

            var tasks = repository.OfType<Task>().Queryable.Where(a => a.Worker.LoginId == loginId && !a.Complete);
            var projects = tasks.Where(a => !a.Complete ).Select(a => a.Project).Distinct();

            var viewModel = new MyTasksViewModel() {Tasks = tasks, Projects = projects};

            return viewModel;
        }
开发者ID:ucdavis,项目名称:Dogbert,代码行数:11,代码来源:TaskViewModel.cs


注:本文中的IRepository.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。