public void GeneratePolicy(Quote quoteObj)
        {
            var result = new MobileHoome.Insure.ExtService.CalculateHomePremiumService();

            result.GetPremiumDetail(quoteObj, true);
            saveQuote(quoteObj);
        }
        public decimal generateQuote(DateTime EffectiveDate, decimal PersonalProperty, decimal Deductible,
                                     decimal Liability, int CustomerId, int NoOfInstallments,
                                     bool SendLandlord, ref int quoteId, out string ProposalNo,
                                     out decimal premiumChargedToday, out decimal installmentFee, out decimal processingFee,
                                     out decimal totalChargedToday)
        {
            decimal Premium  = 0;
            Quote   quoteObj = null;

            if (quoteId == 0)
            {
                //saving quote generated
                quoteObj = new Quote
                {
                    EffectiveDate    = EffectiveDate,
                    ExpiryDate       = EffectiveDate.AddYears(1),
                    PersonalProperty = PersonalProperty,
                    Deductible       = Deductible,
                    Liability        = Liability,
                    Premium          = Premium,
                    CustomerId       = CustomerId,
                    NoOfInstallments = NoOfInstallments,
                    CreationDate     = DateTime.Now,
                    SendLandLord     = SendLandlord,
                    CompanyId        = 1,
                    IsActive         = true
                };
                _context.Quotes.Add(quoteObj);
            }
            else
            {
                quoteObj = _context.Quotes.Find(quoteId);

                //Initializing Premium Values again
                quoteObj.ProcessingFee       = 0;
                quoteObj.InstallmentFee      = 0;
                quoteObj.PremiumChargedToday = 0;
                quoteObj.PremiumChargedToday = 0;
                quoteObj.Premium             = 0;
                quoteObj.EffectiveDate       = EffectiveDate;
                quoteObj.PersonalProperty    = PersonalProperty;
                quoteObj.Deductible          = Deductible;
                quoteObj.Liability           = Liability;
                quoteObj.Premium             = Premium;
                quoteObj.CustomerId          = CustomerId;
                quoteObj.NoOfInstallments    = NoOfInstallments;
                quoteObj.CreationDate        = DateTime.Now;
                quoteObj.SendLandLord        = SendLandlord;
                quoteObj.IsActive            = (quoteObj.IsActive ? quoteObj.IsActive : !quoteObj.IsActive);

                _context.Entry(quoteObj).State = System.Data.Entity.EntityState.Modified;
            }

            //Get Premium calculation service result
            var result = new MobileHoome.Insure.ExtService.CalculateHomePremiumService();

            quoteObj.Premium = Premium = result.GetPremiumDetail(quoteObj);

            var customerObj = GetCustomerById(CustomerId);

            if (quoteObj.NoOfInstallments.HasValue && quoteObj.NoOfInstallments.Value != 0 && quoteObj.NoOfInstallments.Value != 1)
            {
                quoteObj.InstallmentFee      = getInstallmentFee(customerObj.State.Abbr);
                quoteObj.PremiumChargedToday = quoteObj.Premium / quoteObj.NoOfInstallments.Value;
                quoteObj.TotalChargedToday   = quoteObj.InstallmentFee + quoteObj.PremiumChargedToday;
            }
            else
            {
                quoteObj.PremiumChargedToday = Premium;
                quoteObj.ProcessingFee       = (Premium * Convert.ToDecimal(System.Configuration.ConfigurationManager.AppSettings["RentalProcessingFee"]) / 100);
                quoteObj.TotalChargedToday   = quoteObj.ProcessingFee + quoteObj.PremiumChargedToday;
            }

            premiumChargedToday = quoteObj.PremiumChargedToday.HasValue ? Math.Ceiling(quoteObj.PremiumChargedToday.Value * 100) * 0.01M : 0;
            processingFee       = Convert.ToDecimal(quoteObj.ProcessingFee);
            installmentFee      = Convert.ToDecimal(quoteObj.InstallmentFee);
            totalChargedToday   = Convert.ToDecimal(quoteObj.TotalChargedToday);
            ProposalNo          = string.Empty;

            quoteObj.ProposalNumber = string.Empty;

            _context.SaveChanges();

            quoteId = quoteObj.Id;
            return(Premium);
        }