// ReSharper restore InconsistentNaming
        public override void SetupTeam()
        {
            this.SetUpCob();
            this.SetUpTermsNCondition();
            this.SetUpLinks();
            this.SetUpUser();

            QuoteTemplate01 = _consoleRepository.Query<QuoteTemplate>(qtmpl => qtmpl.Name == "Construction - Indication").SingleOrDefault();
            QuoteTemplate01 = QuoteTemplate01 ?? new QuoteTemplate { Name = "Construction - Indication", RdlPath = "/Underwriting/Console/QuoteSheet_CO" };

            SubmissionType01 = _consoleRepository.Query<SubmissionType>(styp => styp.Id == "CO").SingleOrDefault();
            SubmissionType01 = SubmissionType01 ?? new SubmissionType { Id = "CO", Title = "Construction_Submission" };

            Team01 = _consoleRepository.Query<Team>(team => team.Title == "Construction").SingleOrDefault();

            if (Team01 == null)
            {
                Team01 = new Team
                {
                    Title = "Construction",
                    QuoteExpiryDaysDefault = 30,
                    RelatedCOBs = new List<COB> { COB_AG, COB_CC },
                    Links = new List<Link> { Link_01,Link_02,Link_03,Link_04,Link_05,Link_06,Link_07,Link_08,Link_09,Link_10,Link_11,Link_12,Link_13,Link_14,Link_15,Link_16,Link_17,Link_18,Link_19 },
                    RelatedQuoteTemplates = new List<QuoteTemplate> { QuoteTemplate01 },
                    Memberships = new Collection<TeamMembership> { new TeamMembership { StartDate = DateTime.Now, User = User01 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User02 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User03 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User04 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User05 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User06 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User07 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User08 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User09 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User10 },
                    },
                    RelatedOffices = new List<Office>
                        {
                            _consoleRepository.Query<Office>(off => off.Id == "LON").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "MIA").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "LAB").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "NYC").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "SNG").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "DUB").Single(),
                        },
                    CreatedBy = "InitialSetup",
                    CreatedOn = DateTime.Now,
                    ModifiedBy = "InitialSetup",
                    ModifiedOn = DateTime.Now,
                    SubmissionTypeId = SubmissionType01.Id,
                    DefaultPolicyType = "NONMARINE"
                };
               
                //filters
                foreach (var teamMembership in Team01.Memberships)
                {
                    var membershipLocal = teamMembership;
                    _consoleRepository.Query<User>(u => u.Id == membershipLocal.User.Id, u => u.FilterMembers,
                                                   u => u.FilterCOBs, u => u.FilterOffices).FirstOrDefault();

                    if (teamMembership.User.FilterMembers == null) teamMembership.User.FilterMembers = new Collection<User>();
                    foreach (var membership in Team01.Memberships)
                    {
                        if (teamMembership.User.FilterMembers.All(fm => fm.DomainLogon != membership.User.DomainLogon))
                            teamMembership.User.FilterMembers.Add(membership.User);
                    }

                    if (teamMembership.User.FilterCOBs == null) teamMembership.User.FilterCOBs = new Collection<COB>();
                    foreach (var relatedCoB in Team01.RelatedCOBs)
                    {
                        if (teamMembership.User.FilterCOBs.All(fc => fc.Id != relatedCoB.Id))
                            teamMembership.User.FilterCOBs.Add(relatedCoB);
                    }

                    if (teamMembership.User.FilterOffices == null) teamMembership.User.FilterOffices = new Collection<Office>();
                    foreach (var relatedOffice in Team01.RelatedOffices)
                    {
                        if (teamMembership.User.FilterOffices.All(fo => fo.Id != relatedOffice.Id))
                            teamMembership.User.FilterOffices.Add(relatedOffice);
                    }

                }
                _consoleRepository.Add(Team01);
            }
            _consoleRepository.SaveChanges();
        }
Пример #2
0
        // ReSharper restore InconsistentNaming
        public override void SetupTeam()
        {
            this.SetUpCob();
            this.SetUpTermsNCondition();
            this.SetUpLinks();
            this.SetUpUser();

            QuoteTemplate01 = _consoleRepository.Query<QuoteTemplate>(qtmpl => qtmpl.Name == "Marine&Energy").SingleOrDefault();
            QuoteTemplate01 = QuoteTemplate01 ?? new QuoteTemplate { Name = "Marine&Energy", RdlPath = "/Underwriting/Console/QuoteSheet_ME" };

            SubmissionType01 = _consoleRepository.Query<SubmissionType>(styp => styp.Id == "ME").SingleOrDefault();
            SubmissionType01 = SubmissionType01 ?? new SubmissionType { Id = "ME", Title = "Marine&EnergyLiabilities_Submission" };

            Team01 = _consoleRepository.Query<Team>(team => team.Title == "Marine & Energy Liability").SingleOrDefault();
            if (Team01 == null)
            {
                Team01 = new Team
                {
                    Title = "Marine & Energy Liability",
                    QuoteExpiryDaysDefault = 30,
                    RelatedCOBs = new List<COB> { COB_CL, COB_CR},
                    Links = new List<Link> { Link_01, Link_02, Link_03, Link_04, Link_05, Link_06, Link_07, Link_08, Link_09, Link_10, Link_11, Link_12, Link_13, Link_14, Link_15 },
                    RelatedQuoteTemplates = new List<QuoteTemplate> { QuoteTemplate01 },
                    Memberships = new Collection<TeamMembership> { new TeamMembership { StartDate = DateTime.Now, User = User01 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User02 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User03 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User04 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User05 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User06 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User07 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User08 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User09 }, 
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User10 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User11 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User12 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User13 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User14 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User15 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User16 },
                                                                   new TeamMembership { StartDate = DateTime.Now, User = User17 },
                    },
                    RelatedOffices = new List<Office>
                        {
                            _consoleRepository.Query<Office>(off => off.Id == "LON").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "MIA").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "LAB").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "NYC").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "SNG").Single(),
                            _consoleRepository.Query<Office>(off => off.Id == "DUB").Single(),
                        },
                    CreatedBy = "InitialSetup",
                    CreatedOn = DateTime.Now,
                    ModifiedBy = "InitialSetup",
                    ModifiedOn = DateTime.Now,
                    SubmissionTypeId = SubmissionType01.Id,
                    DefaultPolicyType = "MARINE"
                };
                var teamOfficeSetting01 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "LON").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };
                var teamOfficeSetting02 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "MIA").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };
                var teamOfficeSetting03 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "LAB").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };
                var teamOfficeSetting04 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "NYC").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };
                var teamOfficeSetting05 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "SNG").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };
                var teamOfficeSetting06 = new TeamOfficeSetting
                {
                    Team = Team01,
                    Office = _consoleRepository.Query<Office>(off => off.Id == "DUB").Single(),
                    TermsNConditionWordingSettings =
                        new Collection<TermsNConditionWordingSetting>
                                {
                                    new TermsNConditionWordingSetting {DisplayOrder = 1, TermsNConditionWording = TnC01},
                                    new TermsNConditionWordingSetting {DisplayOrder = 2, TermsNConditionWording = TnC02},
                                    new TermsNConditionWordingSetting {DisplayOrder = 3, TermsNConditionWording = TnC03},
                                    new TermsNConditionWordingSetting {DisplayOrder = 4, TermsNConditionWording = TnC04},
                                    new TermsNConditionWordingSetting {DisplayOrder = 5, TermsNConditionWording = TnC05}
                                }
                };

                Team01.TeamOfficeSettings = new Collection<TeamOfficeSetting> { teamOfficeSetting01, 
                    teamOfficeSetting02, 
                    teamOfficeSetting03, 
                    teamOfficeSetting04, 
                    teamOfficeSetting05, 
                    teamOfficeSetting06};
                //filters
                foreach (var teamMembership in Team01.Memberships)
                {
                    var membershipLocal = teamMembership;
                    _consoleRepository.Query<User>(u => u.Id == membershipLocal.User.Id, u => u.FilterMembers,
                                                   u => u.FilterCOBs, u => u.FilterOffices).FirstOrDefault();

                    if (teamMembership.User.FilterMembers == null) teamMembership.User.FilterMembers = new Collection<User>();
                    foreach (var membership in Team01.Memberships.Where(membership => membershipLocal.User.DomainLogon != membership.User.DomainLogon))
                    {
                        if (teamMembership.User.FilterMembers.All(fm => fm.DomainLogon != membership.User.DomainLogon))
                            teamMembership.User.FilterMembers.Add(membership.User);
                    }

                    if (teamMembership.User.FilterCOBs == null) teamMembership.User.FilterCOBs = new Collection<COB>();
                    foreach (var relatedCoB in Team01.RelatedCOBs)
                    {
                        if (teamMembership.User.FilterCOBs.All(fc => fc.Id != relatedCoB.Id))
                            teamMembership.User.FilterCOBs.Add(relatedCoB);
                    }

                    if (teamMembership.User.FilterOffices == null) teamMembership.User.FilterOffices = new Collection<Office>();
                    foreach (var relatedOffice in Team01.RelatedOffices)
                    {
                        if (teamMembership.User.FilterOffices.All(fo => fo.Id != relatedOffice.Id))
                            teamMembership.User.FilterOffices.Add(relatedOffice);
                    }

                }
                _consoleRepository.Add(Team01);
            }
            _consoleRepository.SaveChanges();
        }