public void CheckSeedData() { using (IConsoleRepository rep = new ConsoleRepository()) { var tempTotalMarketWording = rep.Query<MarketWording>(mw => true).Count(); Assert.AreEqual(_totalMarketWording, tempTotalMarketWording); var temptermsNConditionWording = rep.Query<TermsNConditionWording>(mw => true).Count(); Assert.AreEqual(_totalTermsNConditionWording, temptermsNConditionWording); var tempsubjectToClauseWording = rep.Query<SubjectToClauseWording>(mw => true).Count(); Assert.AreEqual(_totalSubjectToClauseWording, tempsubjectToClauseWording); } }
public string CreateQuoteSheet(CreateQuoteSheetDto dto, out Submission submission) { // TODO: use the correct quote sheet... var quoteSheetTemplateId = dto.QuoteSheetTemplateId; dto.QuoteSheetTemplateUrl = this.ConsoleRepository.Query<QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).RdlPath; dto.QuoteSheetTemplateName = this.ConsoleRepository.Query<QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).Name; submission = this.SubmissionModule.GetSubmissionById(dto.SubmissionId); //todo this is done to clear previous context. has to be fixed once softdelet is fixed. using (IConsoleRepository consoleRepository = new ConsoleRepository()) { if (submission == null) throw new KeyNotFoundException(string.Format(this.NotFoundMessage, dto.SubmissionId)); consoleRepository.Attach(submission); var currentUser = consoleRepository.Query<User>() .FirstOrDefault(u => u.DomainLogon == this.HttpContext.CurrentUser.Identity.Name); if (currentUser == null) throw new ApplicationException("Current user could not be found"); var quotesheet = new QuoteSheet { Title = string.Format(this.QuoteSheetTitle, submission.Title, submission.InsuredName, DateTime.Now), IssuedBy = currentUser, IssuedById = currentUser.Id, IssuedDate = DateTime.Now, ObjectStore = "Underwriting" }; var content = this.QuoteSheetData.CreateQuoteSheetPdf(dto); quotesheet.Guid = this.QuoteSheetData.SaveQuoteSheetToDMS(quotesheet, content, submission); var versions = (from version in submission.Options.SelectMany(o => o.OptionVersions) from option in dto.OptionList where version.OptionId == option.OptionId from versionNumber in option.OptionVersionNumberList where version.VersionNumber == versionNumber select version).ToList(); quotesheet.OptionVersions = versions; foreach (var quote in versions.SelectMany(ov => ov.Quotes)) { quote.OptionVersion.IsLocked = true; quote.SubmissionStatus = "QUOTED"; } consoleRepository.Add(quotesheet); consoleRepository.SaveChanges(); return string.Format(this.QuoteSheetUrl, ConfigurationManager.AppSettings["UWDmsFileDownloadURL"], quotesheet.Guid); } }
public static void Setup(TestContext t) { using (IConsoleRepository rep = new ConsoleRepository()) { _totalMarketWording = rep.Query<MarketWording>(mw => true).Count(); _totalTermsNConditionWording = rep.Query<TermsNConditionWording>(mw => true).Count(); _totalSubjectToClauseWording = rep.Query<SubjectToClauseWording>(mw => true).Count(); var lon = rep.Query<Office>(off => off.Id == "LON").First(); var team = new Team { Title = "TestTeam", QuoteExpiryDaysDefault = 30, CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now, SubmissionTypeId = null, DefaultPolicyType = "MARINE", RelatedOffices = new List<Office> { lon }, TeamOfficeSettings = new List<TeamOfficeSetting> { new TeamOfficeSetting { Office = lon, MarketWordingSettings = new List<MarketWordingSetting>(), TermsNConditionWordingSettings = new List<TermsNConditionWordingSetting>(), SubjectToClauseWordingSettings = new List<SubjectToClauseWordingSetting>() } } }; rep.Add(team); rep.SaveChanges(); } _httpContext = new Mock<ICurrentHttpContext>(); const string user = @"talbotdev\MurrayE"; _httpContext.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(user), null)); _httpContext.Setup(h => h.Context).Returns(MvcMockHelpers.FakeHttpContextWithSession()); }
public string CreateQuoteSheet(CreateQuoteSheetDto dto, out Submission submission) { // TODO: use the correct quote sheet... var quoteSheetTemplateId = dto.QuoteSheetTemplateId; dto.QuoteSheetTemplateUrl = this.ConsoleRepository.Query<QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).RdlPath; dto.QuoteSheetTemplateName = this.ConsoleRepository.Query<QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).Name; submission = this.SubmissionModule.GetSubmissionById(dto.SubmissionId); //todo this is done to clear previous context. has to be fixed once softdelet is fixed. using (IConsoleRepository consoleRepository = new ConsoleRepository()) { if (submission == null) throw new KeyNotFoundException(string.Format(this.NotFoundMessage, dto.SubmissionId)); consoleRepository.Attach(submission); var currentUser = consoleRepository.Query<User>() .FirstOrDefault(u => u.DomainLogon == this.HttpContext.CurrentUser.Identity.Name); if (currentUser == null) throw new ApplicationException("Current user could not be found"); var versions = (from version in submission.Options.SelectMany(o => o.OptionVersions) from option in dto.OptionList where version.OptionId == option.OptionId from versionNumber in option.OptionVersionNumberList where version.VersionNumber == versionNumber select version).ToList(); var isDeclinature = false; var submSt = submission.Options.Select(s => s) .SelectMany(o => o.OptionVersions) .SelectMany(ov => ov.Quotes) .Where(q => q.IsSubscribeMaster).Select(s => s.SubmissionStatus).Distinct().ToList(); if ((submSt.Count == 1) && (submSt.FirstOrDefault().Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString()))) isDeclinature = true; var quotesheet = new QuoteSheet {//Todo: S2Q Title = string.Format(this.QuoteSheetTitle, submission.Title, versions.SelectMany(ov => ov.Quotes).First().InsuredName, DateTime.Now), IssuedBy = currentUser, IssuedById = currentUser.Id, IssuedDate = DateTime.Now, ObjectStore = Settings.Default["DMSObjectStore"].ToString(), DocumentClass = Settings.Default["DMSDocumentClass"].ToString(), DocumentType = isDeclinature ? Settings.Default["DeclinatureDocType"].ToString() : Settings.Default["QuoteDocType"].ToString() }; var content = this.QuoteSheetData.CreateQuoteSheetPdf(dto, isDeclinature); quotesheet.Guid = this.QuoteSheetData.SaveQuoteSheetToDMS(quotesheet, content, submission, isDeclinature); quotesheet.OptionVersions = versions; if (!isDeclinature) { foreach (var quote in versions.SelectMany(ov => ov.Quotes)) { if (!quote.SubmissionStatus.Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString())) { quote.OptionVersion.IsLocked = true; quote.SubmissionStatus = "QUOTED"; } } } consoleRepository.Add(quotesheet); consoleRepository.SaveChanges(); return string.Format(this.QuoteSheetUrl, ConfigurationManager.AppSettings["UWDmsFileDownloadURL"], quotesheet.Guid); } }
public void AddMarketWording() { using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); adminModuleManager.CreateMarketWording(new MarketWording { WordingRefNumber = "MTEST01", Title = "MTEST01" }); } using (IConsoleRepository rep = new ConsoleRepository()) { var tempTotalMarketWording = rep.Query<MarketWording>(mw => true).Count(); Assert.AreEqual(_totalMarketWording + 1, tempTotalMarketWording); _totalMarketWording = tempTotalMarketWording; } }
public void SaveSubjectToClauseWordingsForTeamOffice() { using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); adminModuleManager.CreateSubjectToClauseWording(new SubjectToClauseWording { WordingRefNumber = "STEST04", Title = "STEST04" }); } using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST04").First(); var subjectToClauseWordingSettingDto = new SubjectToClauseWordingSettingDto { Id = tempSubjectToClauseWording.Id, DisplayOrder = 1, Title = "STEST04" }; var teamSubjectToClauseWordingsDto = new TeamSubjectToClauseWordingsDto { TeamId = rep.Query<Team>(t => t.Title == "TestTeam").First().Id, OfficeId = "LON", SubjectToClauseWordingSettingDtoList = new List<SubjectToClauseWordingSettingDto> { subjectToClauseWordingSettingDto } }; adminModuleManager.SaveSubjectToClauseWordingsForTeamOffice(teamSubjectToClauseWordingsDto); } using (IConsoleRepository rep = new ConsoleRepository()) { var team = rep.Query<Team>(t => t.Title == "TestTeam", t => t.TeamOfficeSettings.Select(tos => tos.SubjectToClauseWordingSettings.Select(sw => sw.SubjectToClauseWording))).First(); Assert.AreEqual("STEST04", team.TeamOfficeSettings.First().SubjectToClauseWordingSettings.First().SubjectToClauseWording.Title); _totalSubjectToClauseWording = _totalSubjectToClauseWording + 1; } }
public void DeleteSubjectToClauseWording() { using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); adminModuleManager.CreateSubjectToClauseWording(new SubjectToClauseWording { WordingRefNumber = "STEST03", Title = "STEST03" }); } using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST03").First(); adminModuleManager.DeleteSubjectToClauseWording(tempSubjectToClauseWording); } using (IConsoleRepository rep = new ConsoleRepository()) { var tempTotalSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => true).Count(); var tempSubjectToClauseWording = rep.Query<SubjectToClauseWording>(sw => sw.Title == "STEST03").FirstOrDefault(); Assert.AreEqual(_totalSubjectToClauseWording, tempTotalSubjectToClauseWording); Assert.IsNull(tempSubjectToClauseWording); } }
public void EditTermsNConditionWording() { using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); adminModuleManager.CreateTermsNConditionWording(new TermsNConditionWording { WordingRefNumber = "TTEST02", Title = "TTEST02" }); } using (IConsoleRepository rep = new ConsoleRepository()) { var adminModuleManager = new AdminModuleManager(rep, new LogHandler(), _httpContext.Object, new WebSiteModuleManager(rep, _httpContext.Object)); var tempTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02").First(); tempTermsNConditionWording.Title = "TTEST02_Changed"; adminModuleManager.EditTermsNConditionWording(tempTermsNConditionWording); } using (IConsoleRepository rep = new ConsoleRepository()) { var tempTotalTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => true).Count(); var tempTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02_Changed").First(); var tempOldTermsNConditionWording = rep.Query<TermsNConditionWording>(tnc => tnc.Title == "TTEST02").FirstOrDefault(); Assert.AreEqual(_totalTermsNConditionWording + 1, tempTotalTermsNConditionWording); Assert.IsNotNull(tempTermsNConditionWording); Assert.IsNull(tempOldTermsNConditionWording); _totalTermsNConditionWording = tempTotalTermsNConditionWording; } }