Example #1
0
        public void ShouldSaveTheInvestment()
        {
            Repository chapter6InvestmentRepo = new Repository();

            Investment LICInvestment = new LifeInsurance(10000);

            chapter6InvestmentRepo.SaveInvestment(LICInvestment);
            Assert.AreEqual(LICInvestment.GetAmount(), chapter6InvestmentRepo.GetInvestmentDetails(LICInvestment.Id).GetAmount());
        }
Example #2
0
        public Result Delete(LifeInsurance lifeInsurance)
        {
            var result = new Result();

            try
            {
                LifeInsuranceService lifeInsuranceService = new LifeInsuranceService();
                lifeInsuranceService.Delete(lifeInsurance);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
 internal bool Add(LifeInsurance lifeInsurance)
 {
     try
     {
         FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
         string          apiurl          = Program.WebServiceUrl + "/" + ADD_LIFEINSURANCE_API;
         RestAPIExecutor restApiExecutor = new RestAPIExecutor();
         var             restResult      = restApiExecutor.Execute <LifeInsurance>(apiurl, lifeInsurance, "POST");
         return(true);
     }
     catch (Exception ex)
     {
         StackTrace st = new StackTrace();
         StackFrame sf = st.GetFrame(0);
         MethodBase currentMethodName = sf.GetMethod();
         LogDebug(currentMethodName.Name, ex);
         return(false);
     }
 }
Example #4
0
        public void ShouldSaveTheInvestmentAlongWithTaxStatement()
        {
            var          taxPayer = new User(0, true, Gender.Female);
            TaxSlabs     ts       = TaxSlabs.GetInstance();
            AnnualSalary asal     = new AnnualSalary
            {
                Basic = 600000,
                Hra   = 100000
            };
            TaxStatement stmt = new TaxStatement(asal, taxPayer);

            stmt.Chapter6Investments = new Chapter6Investments();
            LifeInsurance LICInvestment = new LifeInsurance(10000);

            stmt.Chapter6Investments.Add(LICInvestment);
            LICInvestment.TaxStatement = stmt;

            Repository taxStatementRepo = new Repository();

            taxStatementRepo.Save(stmt);

            Assert.AreEqual(LICInvestment.GetAmount(), taxStatementRepo.GetInvestmentDetails(stmt.Id).GetAmount());
        }
        public ActionResult CreateContract(int InsurancePackageId, string name, string email, string address, DateTime Date_Iden, string Place_Iden, string phone, string Job, string IdentityCard, string MaritalStatus)
        {
            var insurancepackage = db.InsurancePackages.Find(InsurancePackageId);

            var contract = new Contract
            {
                TotalPrice     = insurancepackage.Price,
                UserID         = User.Identity.GetUserId(),
                InsuranceId    = 2,
                LifeInsurances = new List <LifeInsurance>()
            };


            var lifeInsurance = new LifeInsurance()
            {
                InsurancePackageId = insurancepackage.Id,
                ContractId         = contract.Id,
                Name                = name,
                PhoneNumber         = phone,
                Email               = email,
                Address             = address,
                IdentityCard        = IdentityCard,
                DateOfIdentityCard  = Date_Iden,
                PlaceOfIdentityCard = Place_Iden,
                MaritalStatus       = MaritalStatus,
                Job       = Job,
                Quantity  = 1,
                UnitPrice = insurancepackage.Price
            };

            contract.LifeInsurances.Add(lifeInsurance);
            db.Contracts.Add(contract);


            db.SaveChanges();

            var transaction = db.Database.BeginTransaction();

            try
            {
                var    em            = db.Users.Where(x => x.Id == contract.UserID).FirstOrDefault();
                var    senderemail   = new MailAddress("*****@*****.**", "Insurance Company");
                var    receivermail  = new MailAddress(em.Email, "Insurance Company");
                var    passwordemail = "vtacl123";
                var    subject       = "Notification Order";
                string body          = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
                body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">" +
                        "<style>table, td, th {border: 1px solid black; font-size: 15px}</style>" +
                        "<style> p {font-size: 18px}</style>"
                ;
                body += "<p>" + "Your order information is : " + "</p>"
                        + "<p>" + "Name Insurance : LifeInsurance</p>"
                        + "<p>" + "Total Price :" + contract.TotalPrice + "$" + "</p>" +
                        "<br>";
                body += "</HEAD><BODY>" +
                        "<tr>" +
                        "<th>Package Insurance</th>" +
                        "<th>Name</th>" +
                        "<th>PhoneNumber</th>" +
                        "<th>Email</th>" +
                        "<th>Address</th>" +
                        "<th>IdentityCard</th>" +
                        "<th>DateOfIdentityCard</th>" +
                        "<th>PlaceOfIdentityCard</th>" +
                        "<th>Job</th>" +
                        "<th>Quantity</th>" +
                        "<th>UnitPrice</th>" +
                        "</tr>";
                body +=
                    "<tr>" +
                    "<td>" + insurancepackage.Name + "</td>" +
                    "<td>" + name + "</td>" +
                    "<td>" + phone + "</td>" +
                    "<td>" + email + "</td>" +
                    "<td>" + address + "</td>" +
                    "<td>" + IdentityCard + "</td>" +
                    "<td>" + Date_Iden + "</td>" +
                    "<td>" + Place_Iden + "</td>" +
                    "<td>" + Job + "</td>" +
                    "<td>" + 1 + "</td>" +
                    "<td>" + insurancepackage.Price + "</td>" +
                    "</tr>";
                var smtp = new SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    EnableSsl             = true,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(senderemail.Address, passwordemail)
                };
                using (var mess = new MailMessage(senderemail, receivermail)
                {
                    IsBodyHtml = true,
                    Subject = subject,
                    Body = body
                }
                       )
                {
                    smtp.Send(mess);
                };
                transaction.Commit();
            }
            catch (Exception e)
            {
                transaction.Rollback();
            }
            return(Redirect("/OrderNotice/Index"));
        }
Example #6
0
        public void ShouldSaveTheInvestmentAlongWithTaxStatement()
        {
            var taxPayer = new User(0, true, Gender.Female);
            TaxSlabs ts = TaxSlabs.GetInstance();
            AnnualSalary asal = new AnnualSalary
            {
                Basic = 600000,
                Hra = 100000
            };
            TaxStatement stmt = new TaxStatement(asal, taxPayer);
            stmt.Chapter6Investments=  new Chapter6Investments();
            LifeInsurance LICInvestment=new LifeInsurance(10000);
            stmt.Chapter6Investments.Add(LICInvestment);
            LICInvestment.TaxStatement = stmt;

            Repository taxStatementRepo=new Repository();
            taxStatementRepo.Save(stmt);

            Assert.AreEqual(LICInvestment.GetAmount(), taxStatementRepo.GetInvestmentDetails(stmt.Id).GetAmount());
        }
Example #7
0
        public void ShouldSaveTheInvestment()
        {
            Repository chapter6InvestmentRepo = new Repository();

            Investment LICInvestment = new LifeInsurance(10000);
            chapter6InvestmentRepo.SaveInvestment(LICInvestment);
            Assert.AreEqual(LICInvestment.GetAmount(), chapter6InvestmentRepo.GetInvestmentDetails(LICInvestment.Id).GetAmount());
        }