private bool TrySavePolicies()
 {
     if (_isDataUpToDate.GetValueOrDefault(false))
     {
         PolicyDataService.Save(_insurancePolicies.Select(s => s.InsurancePolicy).ToList());
         return(true);
     }
     else
     {
         ApplicationService.Alert("You must refresh before you can save.");
         return(false);
     }
 }
        public object GetPolicyDetailsByPolId(string polId)
        {
            var policy = PolicyDataService.GetPolicyAsync(polId).Result;
            var resp   = SubscribePolicyService.GetReference(new SubscribeService.GetReferenceRequest()
            {
                strPolId = polId
            });

            var polAsSubscribe = Utility.XmlDeserializeFromString <SubscribeService.PolicyContract>(resp.GetReferenceResult.OutputXml);
            var cob            = PolicyData.GetCOB(polAsSubscribe.COB);

            polAsSubscribe.COB = cob.Id + " : " + cob.Narrative;

            var broker = PolicyData.GetBroker(polAsSubscribe.BkrSeqId);

            return(new { Pol = polAsSubscribe, Ldr = policy.Ldr, LdrNo = policy.LdrNo, Broker = broker });
        }
        public RenewalPolicyDetailed GetRenewalPolicyDetailsByPolId(string polId)
        {
            var policy = PolicyData.GetRenewalPolicies(false).SingleOrDefault(p => p.PolicyId == polId);

            if (policy != null && !string.IsNullOrEmpty(policy.PolicyId))
            {
                using (var client = new DocumentServiceClient())
                {
                    policy.RelatedDocumentCount = client.GetDocumentsCountForPolicy(policy.PolicyId);
                }

                var renewalCalc = PolicyDataService.GetPolicyRenewalCalc(policy.PolicyId);

                policy.IsRenewable = renewalCalc.IsRenewable;
            }

            return(policy);
        }
        public async Task <RiskPreviewDto> RiskPreview(string polId)
        {
            if (string.IsNullOrEmpty(polId))
            {
                return(new RiskPreviewDto());
            }

            var response = await PolicyDataService.GetPolicyAsync(polId);

            var renewalCalc = await PolicyDataService.GetPolicyRenewalCalcAsync(polId);

            if (response == null)
            {
                return(new RiskPreviewDto());
            }

            using (var docService = new DocumentService.DocumentServiceClient())
            {
                var count = await docService.GetDocumentsCountForPolicyAsync(response.PolId);

                var quote = PolicyData.GetQuote(response.PolId);

                return(new RiskPreviewDto
                {
                    PolicyId = response.PolId,
                    InsuredName = response.InsdNm,
                    Description = response.Dsc,
                    EntryStatus = response.EntSt,
                    PolicyStatus = response.St,
                    SubmissionStatus = response.SubmSt,
                    BrokerGroupCode = response.BkrGrpCd,
                    PSU = response.BkrPsu,
                    CD = response.BkrCd,
                    Contact = response.BkrCtc,
                    UMR = response.UMR,
                    Underwriter = response.Uwr,
                    SubscribeNotes = response.Nt,
                    ConsoleQuoteNotes = (quote != null) ? quote.Description : string.Empty,
                    DMSCount = count.ToString(),
                    IsRenewable = renewalCalc.IsRenewable
                });
            }
        }
 private List <InsurancePolicy> GetPolicies()
 {
     // Always do a refresh, as this will merge new entries not saved yet with the entries that
     // are loaded
     return(PolicyDataService.RefreshPolicies(InsurancePolicies.Select(s => s.InsurancePolicy).ToList()));
 }