Esempio n. 1
0
        public async Task <IHttpActionResult> GetAccountHistory(int acctid, int days)
        {
            DateTime fromDate       = DateTime.Now.AddDays(days * (-1));
            string   fromDateString = fromDate.ToString("MM-dd-yyyy");
            string   userId         = RequestContext.Principal.Identity.GetUserId();
            Guid     fiId           = Guid.Parse(fiIdString);

            try
            {
                string   encryptedPin = db.PINs.Where(p => p.FinancialInstitutionID == fiId && p.UserID == userId).Select(p => p.Pin).First();
                string   decryptedPin = Helpers.StringCipher.Decrypt(encryptedPin, userId);
                var      acct         = db.AssociatedAccounts.Where(p => p.UserID == userId && p.AssociatedAccountID == acctid).First();
                string[] rows         = await COB.GetAccountHistory(acct.AccountNumber, acct.MemberID, decryptedPin, fromDateString);

                string xml = string.Empty;
                foreach (string row in rows)
                {
                    string[] parts = row.Split(new string[] { "\t1" }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length > 1)
                    {
                        xml += parts[1];
                    }
                }
                xml = "<HISTORY>" + xml + "</HISTORY>";
                XElement history = XElement.Parse(xml);
                return(Ok(history));
            }
            catch (Exception ex)
            {
                return(Ok(ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <AccountBalance[]> GetAccountBalanceArray(string acctnums)
        {
            List <AccountBalance> balanceList = new List <AccountBalance>();

            string[] acctnumArray = acctnums.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            string   userId       = RequestContext.Principal.Identity.GetUserId();
            Guid     fiId         = Guid.Parse(fiIdString);
            string   encryptedPin = db.PINs.Where(p => p.FinancialInstitutionID == fiId && p.UserID == userId).Select(p => p.Pin).First();
            string   decryptedPin = Helpers.StringCipher.Decrypt(encryptedPin, userId);

            foreach (string acctnum in acctnumArray)
            {
                string[] balance = await COB.GetAccountBalance(acctnum, decryptedPin);

                if (balance.Length > 1)
                {
                    balanceList.Add(new AccountBalance {
                        AccountNumber = acctnum, CurrentBalance = balance[0], AvailableBalance = balance[1]
                    });
                }
                else
                {
                    balanceList.Add(new AccountBalance {
                        AccountNumber = acctnum, CurrentBalance = "Error", AvailableBalance = "Error"
                    });
                }
            }
            return(balanceList.ToArray());
        }
        private COB COB_AR; //AR:  Direct Energy Rig

        // ReSharper restore InconsistentNaming
        public override void SetUpCob()
        {
            COB_CL = ResolveCob("CL", "Direct - Casualty - Marine Liability");
            COB_CR = ResolveCob("CR", "Direct Casualty Energy Liability");
            COB_AT = ResolveCob("AT", "Direct - Property - Hul");
            COB_AV = ResolveCob("AV", "Direct Property Cargo");
            COB_AW = ResolveCob("AW", "Direct - Property - War");
            COB_AR = ResolveCob("AR", "Direct Energy Rig");
        }
Esempio n. 4
0
        protected COB ResolveCob(string id, string narrative)
        {
            var cob = _consoleRepository.Query <COB>(c => c.Id == id).SingleOrDefault();

            if (cob == null)
            {
                cob = new COB {
                    Id = id, Narrative = narrative, CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now
                };
                _consoleRepository.Add(cob);
            }
            return(cob);
        }
        public static void Setup(TestContext t)
        {            
            using (IConsoleRepository _rep = new ConsoleRepository())
            {
                Team teamA = new Team() { Title = "Team A", DefaultPolicyType = "MARINE", QuoteExpiryDaysDefault = 30 };
                _rep.Add<Team>(teamA);
                Team teamB = new Team() { Title = "Team B", DefaultPolicyType = "MARINE", QuoteExpiryDaysDefault = 30 };
                _rep.Add<Team>(teamB);
                
                COB aa = new COB() { Id = "AA", Narrative = "AA" };
                COB bb = new COB() { Id = "BB", Narrative = "BB" };
                COB xx = new COB() { Id = "XX", Narrative = "XX" };
                COB yy = new COB() { Id = "YY", Narrative = "YY" };
                COB zz = new COB() { Id = "ZZ", Narrative = "ZZ" };
                _rep.Add<COB>(aa);
                _rep.Add<COB>(bb);
                _rep.Add<COB>(xx);
                _rep.Add<COB>(yy);
                _rep.Add<COB>(zz);

                teamA.RelatedCOBs = new List<COB>();
                teamA.RelatedCOBs.Add(aa);
                teamA.RelatedCOBs.Add(bb);
                teamA.RelatedCOBs.Add(xx);

                teamB.RelatedCOBs = new List<COB>();
                teamB.RelatedCOBs.Add(xx);
                teamB.RelatedCOBs.Add(yy);
                teamB.RelatedCOBs.Add(zz);

                User user1 = new User() { DomainLogon = @"talbot\user1", UnderwriterCode = "AED" };
                _rep.Add<User>(user1);

                _rep.SaveChanges();
                newUserId = user1.Id;
                TeamAId = teamA.Id;
                TeamBId = teamB.Id;
            }
            
            context = new Mock<ICurrentHttpContext>();
            var user = @"talbotdev\MurrayE";
            
            context.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(user), null));
            context.Setup(h => h.Context).Returns(MvcMockHelpers.FakeHttpContextWithSession());            
        }
Esempio n. 6
0
        public async Task <AccountBalance> GetAccountBalance(string acctnum)
        {
            string userId       = RequestContext.Principal.Identity.GetUserId();
            Guid   fiId         = Guid.Parse(fiIdString);
            string encryptedPin = db.PINs.Where(p => p.FinancialInstitutionID == fiId && p.UserID == userId).Select(p => p.Pin).First();
            string decryptedPin = Helpers.StringCipher.Decrypt(encryptedPin, userId);

            string[] balance = await COB.GetAccountBalance(acctnum, decryptedPin);

            if (balance.Length > 1)
            {
                return new AccountBalance {
                           AccountNumber = acctnum, CurrentBalance = balance[0], AvailableBalance = balance[1]
                }
            }
            ;

            return(new AccountBalance {
                AccountNumber = acctnum, CurrentBalance = "Error", AvailableBalance = "Error"
            });
        }
Esempio n. 7
0
        private COB COB_CL; //CL:   Direct - Casualty - Marine Liability
        // ReSharper restore InconsistentNaming
        public override void SetUpCob()
        {
            COB_AY = _consoleRepository.Query <COB>(cob => cob.Id == "AY").SingleOrDefault();
            COB_AY = COB_AY ?? new COB {
                Id = "AY", Narrative = "Direct - Property - Yachts", CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now
            };

            COB_AT = _consoleRepository.Query <COB>(cob => cob.Id == "AT").SingleOrDefault();
            COB_AT = COB_AT ?? new COB {
                Id = "AT", Narrative = "Direct - Property - Hull", CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now
            };

            COB_AW = _consoleRepository.Query <COB>(cob => cob.Id == "AW").SingleOrDefault();
            COB_AW = COB_AW ?? new COB {
                Id = "AW", Narrative = "Direct - Property - War", CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now
            };

            COB_CL = _consoleRepository.Query <COB>(cob => cob.Id == "CL").SingleOrDefault();
            COB_CL = COB_CL ?? new COB {
                Id = "CL", Narrative = "Direct - Casualty - Marine Liability", CreatedBy = "InitialSetup", CreatedOn = DateTime.Now, ModifiedBy = "InitialSetup", ModifiedOn = DateTime.Now
            };
        }
Esempio n. 8
0
 // ReSharper restore InconsistentNaming
 public override void SetUpCob()
 {
     COB_AK = ResolveCob("AK", "Direct - Property - Political Risk");
 }
 public AmtCollection CoordinationofBenefits(COB) TotalNon - Covered = new AmtCollection();
 public AmtCollection CoordinationofBenefits(COB) PayerPaidAmount    = new AmtCollection();
        public void Setup()
        {
            _rep = new FakeConsoleRepository();

            COB c = new COB() { Id = "CA", Narrative = "Cargo" };
            Office off = new Office() { Id = "LON", Title = "London" };
            List<User> users = new List<User>();
            User u = new User() { DomainLogon = @"talbotdev\murraye" };
            u.FilterCOBs = new List<COB>();
            u.AdditionalCOBs = new List<COB>();
            u.FilterOffices = new List<Office>();
            u.AdditionalOffices = new List<Office>();
            u.FilterMembers = new List<User>();
            u.AdditionalUsers = new List<User>();

            u.AdditionalCOBs.Add(c);

            users.Add(u);
            _rep.Users = users.AsQueryable();

            List<globalVM::Validus.Models.Submission> subs = new List<globalVM::Validus.Models.Submission>();

            for (int i = 0; i < 15; i++)
			{
                subs.Add(new globalVM::Validus.Models.Submission()
                {
                    Id = i,
                    CreatedBy = "InitialSetup",
                    CreatedOn = DateTime.Now,
                    ModifiedBy = "InitialSetup",
                    ModifiedOn = DateTime.Now,
                    InsuredName = (i == 3 || i == 6 ? "Fergus Baillie" : "ALLAN MURRAY"),
                    BrokerCode = String.Format("11{0}", i),
                    BrokerPseudonym = "AAA",
                    BrokerSequenceId = 822,
                    InsuredId = 182396,                    
                    Brokerage = 1,
                    BrokerContact = "ALLAN MURRAY",
                    
                    UnderwriterCode = "AED",
                    UnderwriterContactCode = "JAC",
                    QuotingOfficeId = "LON",
                    Leader = "AG",
                    Domicile = "AD",
                    Title = "Unit Test Submission",
                    Options = new List<Option>()                    
                });
            }

            List<Option> options = new List<Option>();
            Option o = new Option() { Title = "Test", SubmissionId = 3, Submission = subs[3] };
            options.Add(o);

            List<OptionVersion> optionVersions = new List<OptionVersion>();
            OptionVersion ov = new OptionVersion() { Title = "Test", Option = o };
            optionVersions.Add(ov);

            List<Quote> quotes = new List<Quote>();
            Quote q = new Quote() { 
                COB = c, COBId = c.Id, 
                OriginatingOffice = off, 
                OriginatingOfficeId = off.Id, 
                EntryStatus = "PARTIAL",
                OptionVersion = ov,
                SubscribeReference = "BAN169784A13"
            };
            
            quotes.Add(q);

            ov.Quotes = quotes;
            o.OptionVersions = optionVersions;

            for (int i = 0; i < 15; i++)
            {
                subs[i].Options = options;
            }

            _rep.Submissions = subs.AsQueryable();            

            var mockSubscribeService = new Mock<IPolicyService>();
            mockSubscribeService.Setup(s => s.CreateQuote(It.IsAny<CreateQuoteRequest>()))
                                .Returns(new CreateQuoteResponse
                                    {
                                        CreateQuoteResult = new StandardOutput { OutputXml = MvcMockHelpers.CreateQuoteResponseXml() },
                                        objInfoCollection = new InfoCollection { PolId = "BAN165118A13" }
                                    });
            mockSubscribeService.Setup(s => s.GetReference(It.IsAny<GetReferenceRequest>()))
                                .Returns(new GetReferenceResponse
                                    {
                                        GetReferenceResult =
                                            new StandardOutput {OutputXml = MvcMockHelpers.CreateGetReferenceResponseXml()}
                                    });
            var mockPolicyData = new Mock<IPolicyData>();
            var context = new Mock<ICurrentHttpContext>();
            var user = @"talbotdev\murraye";
            //user = user.Replace(@"\\", @"\");
            context.Setup(h => h.CurrentUser).Returns(new GenericPrincipal(new GenericIdentity(user), null));
            context.Setup(h => h.Context).Returns(MvcMockHelpers.FakeHttpContextWithSession());

            _webSiteModuleManager = new WebSiteModuleManager(_rep, context.Object);
            _submissionModule = new SubmissionModule(_rep, mockSubscribeService.Object, new LogHandler(), context.Object, _webSiteModuleManager, mockPolicyData.Object);
            //_submissionModule = new SubmissionModule(rep, null, null, cont);
        }
Esempio n. 12
0
 public override void SetUpCob()
 {
     COB_AD = ResolveCob("AD", "Direct - Property - Contingency");
 }
 private COB COB_CC; //CR:  Direct Casualty Energy Liability
 public override void SetUpCob()
 {
     COB_AG = ResolveCob("AG", "Direct - Property - Construction");
     COB_CC = ResolveCob("CC", "Direct - Casualty - Construction");
 }
 // ReSharper restore InconsistentNaming
 public override void SetUpCob()
 {
     COB_AH = ResolveCob("AH", "Direct - Property - Accident and Health");
 }
Esempio n. 15
0
        public async Task <IHttpActionResult> PostAssociateAccounts(string memberId, string pin)
        {
            string userId = RequestContext.Principal.Identity.GetUserId();
            Guid   fiId   = Guid.Parse(fiIdString);

            COBAccount[] memberAccountList = await COB.GetMemberAccountList(memberId, pin);

            if (memberAccountList.Length > 0)
            {
                string encryptedPin = Helpers.StringCipher.Encrypt(pin, userId);
                var    userPin      = db.PINs.Where(p => p.FinancialInstitutionID == fiId && p.UserID == userId).FirstOrDefault();
                if (userPin == null)
                {
                    userPin = new PIN
                    {
                        PINID = Guid.NewGuid(),
                        FinancialInstitutionID = fiId,
                        UserID  = userId,
                        Pin     = encryptedPin,
                        Updated = DateTime.Now
                    };
                    db.PINs.Add(userPin);
                }
                else
                {
                    userPin.Pin     = encryptedPin;
                    userPin.Updated = DateTime.Now;
                }
                db.SaveChanges();

                //Gather existing associated accounts
                var existingAccounts = db.AssociatedAccounts.Where(p => p.UserID == userId);

                //Identify default account if exists
                bool defaultSpecified = existingAccounts.Where(p => p.DefaultAccount).Count() > 0;

                //only link accounts which do not currently exist
                var newAccounts = from p in memberAccountList
                                  where !existingAccounts.Select(q => q.AccountNumber).Contains(p.AcctNbr) &&
                                  p.AcctStatusCode.Equals("ACT")
                                  select new AssociatedAccount
                {
                    FinancialInstitutionID = fiId,
                    MemberID       = memberId,
                    UserID         = userId,
                    AccountNumber  = p.AcctNbr,
                    AccountType    = p.MajorTypeDesc,
                    DefaultAccount = false,
                    Description    = p.ProductCategoryDesc,
                    Description2   = p.MinorTypeDesc,
                    Description3   = p.MinorCustDesc,
                    Created        = DateTime.Now,
                    Status         = "Active",
                    Updated        = DateTime.Now
                                     //################################################
                                     //      TEST CODE
                                     //################################################
                    ,
                    Verified = DateTime.Now
                               //################################################
                };

                //Reactivate all existing accounts
                foreach (AssociatedAccount acct in existingAccounts)
                {
                    acct.Status  = "Active";
                    acct.Updated = DateTime.Now;
                }

                db.AssociatedAccounts.AddRange(newAccounts);
                db.SaveChanges();

                var userAccounts = db.AssociatedAccounts.Where(p => p.UserID == userId && !COBExcludedAcctTypes.Contains(p.Description2));

                //If no default account exists, create it
                if (!defaultSpecified)
                {
                    var newDefault = userAccounts.Where(p => p.AccountType == "Savings" && p.Description2.Equals("Deposits")).OrderByDescending(p => p.Created).FirstOrDefault();
                    if (newDefault != null)
                    {
                        newDefault.DefaultAccount = true;
                        db.SaveChanges();
                    }
                }

                MailSender.SendMessage(User.Identity.GetUserName(), "E-Pay - Account(s) Linked", "We have successfully linked one or more accounts to your profile.");
                return(Ok(userAccounts));
            }

            return(Ok("No Accounts have been found."));
        }