Esempio n. 1
0
 /// <summary>
 ///     Home Controller
 /// </summary>
 /// <param name = "applicationDatabaseContext" ></param>
 /// <param name = "logProvider" ></param>
 /// <param name = "lookupProvider" ></param>
 public HomeController(ApplicationDatabaseContext applicationDatabaseContext, ILogProvider logProvider, LookupProvider lookupProvider, CurriculumVitaeManager cvManager)
 {
     _logProvider                = logProvider;
     _lookupProvider             = lookupProvider;
     _applicationDatabaseContext = applicationDatabaseContext;
     _curriculumVitaeManager     = cvManager;
 }
        public void Process(object args)
        {
            var whois = new LookupProvider().GetInformationByIp("");

            if (whois != null)
            {
                Sitecore.Analytics.Tracker.Current.Interaction.SetGeoData(whois);
            }
        }
Esempio n. 3
0
        public JsonResult Update(string model)
        {
            string typeName = string.Empty;
            string reason   = string.Empty;
            string message  = string.Empty;

            try
            {
                Lookup item = JsonConvert.DeserializeObject <Lookup>(model);
                typeName = item.Type;
                LookupProvider provider = new LookupProvider(_dbContext);

                // check to make sure the lookup name is not used anywhere
                LookupType type;
                if (Enum.TryParse(typeName, out type))
                {
                    // make sure the original one is not in used
                    Lookup oldItem = provider.Retrieve(item.Id);
                    if (provider.InUse(type, oldItem.Name)) // old lookup name is in used; can't change it
                    {
                        reason  = "Conflict";
                        message = string.Format("Cannot change {0} type of '{1}' that is still in used.", typeName, oldItem.Name);
                    }
                    else if (provider.Exist(type, item.Name) || provider.InUse(type, item.Name)) // new lookup name is in used; can't change it
                    {
                        reason  = "Conflict";
                        message = InUseMessage(typeName, item.Name);
                    }
                    else
                    {
                        provider.Update(item.Id, item);
                        provider.Commit();
                        return(Json(item, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    reason  = "Bad Type";
                    message = TypeNotFound(typeName);
                }
            }
            catch (Exception ex)
            {
                reason  = "Server Error";
                message = ex.Message + " " + ex.InnerException.Message;
            }

            // assemble custom error for kendo CRUD operation
            Response.StatusCode = (int)System.Net.HttpStatusCode.OK; // custom error return 200 code
            var exception = new                                      // custom response body indicated by the 'errors' field
            {
                errors = CrudError("Update", typeName, reason, message)
            };

            return(Json(exception, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonResult GetCategoryList()
        {
            if (!AuthorizationProvider.CanViewRevenue())
            {
                return(Forbidden());
            }

            var provider = new LookupProvider(_dbContext);
            var data     = provider.GetLookupText(LookupType.ExpenseCategory);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
 public JsonResult Retrieve(string type)
 {
     try
     {
         LookupProvider provider = new LookupProvider(_dbContext);
         var            allItems = provider.All(type);
         return(Json(allItems, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
         return(Json("Retrieve " + type + " lookup table fails. " + ex.Message, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 6
0
        public JsonResult Delete(string model)
        {
            string typeName = string.Empty;
            string reason   = string.Empty;
            string message  = string.Empty;

            try
            {
                Lookup item = JsonConvert.DeserializeObject <Lookup>(model);
                typeName = item.Type;
                LookupProvider provider = new LookupProvider(_dbContext);

                // check to make sure the lookup exists and is not used anywhere
                LookupType type;
                if (Enum.TryParse(typeName, out type))
                {
                    if (provider.InUse(type, item.Name))
                    {
                        reason  = "Conflict";
                        message = InUseMessage(typeName, item.Name);
                    }
                    else
                    {
                        provider.Delete(item.Id);
                        provider.Commit();
                        return(Json(string.Empty, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    reason  = "Bad Type";
                    message = TypeNotFound(typeName);
                }
            }
            catch (Exception ex)
            {
                reason  = "Server Error";
                message = ex.Message + " " + ex.InnerException.Message;
            }

            // assemble custom error for kendo CRID operation
            Response.StatusCode = (int)System.Net.HttpStatusCode.OK; // custom error return 200 code
            var exception = new                                      // custom response body indicated by the 'errors' field
            {
                errors = CrudError("Delete", typeName, reason, message)
            };

            return(Json(exception, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
        /// <summary>
        ///     Creates the and configure application di container.
        /// </summary>
        /// <returns>A StructureMap Container.</returns>
        protected virtual IContainer CreateAndConfigureApplicationDiContainer()
        {
            var nidaAssessFurtherType          = typeof(NidaAssessFurther); // todo: better way to copy dll to mvc project
            var gpraInterviewType              = typeof(GpraInterview);
            var gainShortScreenerType          = typeof(GainShortScreener);
            var pediatricSymptomChecklist      = typeof(PediatricSymptonChecklist);
            var youthPediatricSymptomChecklist = typeof(YouthPediatricSymptonChecklist);
            var nihType = typeof(NihHealthBehaviorsAssessment);
            var nidaSingleQuestionScreener = typeof(NidaSingleQuestionScreener);
            var drugAbuseScreeningTest     = typeof(DrugAbuseScreeningTest);

            _logger.Trace(nidaAssessFurtherType.FullName);
            _logger.Trace(gpraInterviewType.FullName);
            _logger.Trace(gainShortScreenerType.FullName);
            _logger.Trace(pediatricSymptomChecklist.FullName);
            _logger.Trace(youthPediatricSymptomChecklist.FullName);
            _logger.Trace(nihType.FullName);
            _logger.Trace(nidaSingleQuestionScreener.FullName);
            _logger.Trace(drugAbuseScreeningTest.FullName);

            var lookupProvider   = new LookupProvider();
            var resourcesManager = new ResourcesManager();

            ObjectFactory.Configure(x =>
                                    x.Scan(scanner =>
            {
                scanner.AssembliesFromApplicationBaseDirectory(assembly => assembly.GetName().Name.StartsWith("ProCenter."));
                scanner.AddAllTypesOf <IOrderedBootstrapperTask> ();
                scanner.AddAllTypesOf <IPermissionDescriptor> ();
                scanner.AddAllTypesOf <IHandleMessage> ();
                scanner.AddAllTypesOf <ICompletenessRuleCollection <AssessmentInstance> > ()
                .NameBy(type => type.Name.Replace("ReportCompletenessRuleCollection", string.Empty));

                scanner.WithDefaultConventions();

                scanner.LookForRegistries();

                scanner.Convention <WorkflowEngineConvention> ();
                scanner.Convention <ReportEngineConvention> ();

                scanner.With(new LookupPrimitiveResourceConvention(lookupProvider, resourcesManager));

                scanner.AddAllTypesOf <IScoringEngine> ().NameBy(type => type.Name.Replace("ScoringEngine", string.Empty));
                scanner.AddAllTypesOf <IAssessmentRuleCollection> ().NameBy(type => type.Name.Replace("RuleCollection", string.Empty));

                scanner.ConnectImplementationsToTypesClosing(typeof(IDomainEventHandler <>));
                scanner.ConnectImplementationsToTypesClosing(typeof(IRuleCollection <>));
            }));

            //Note: scan default conventions first to avoid constructing singleton twice
            ObjectFactory.Configure(c => c.For <IMessageCollector> ().HybridHttpOrThreadLocalScoped().Use <MessageCollector> ());
            ObjectFactory.Configure(c => c.For <IResourcesManager> ().Singleton().Use(resourcesManager));
            ObjectFactory.Configure(c => c.For <ILookupProvider> ().Singleton().Use(lookupProvider));
            ObjectFactory.Configure(c => c.For <IAssessmentCompletenessManager> ().Singleton().Use <AssessmentCompletenessManager> ());
            ObjectFactory.Configure(
                c =>
                c.For <IConnectionStringConfigurationProvider> ()
                .Singleton()
                .Use(new ConnectionStringConfigurationProvider(WebConfigurationManager.ConnectionStrings)));
            ObjectFactory.Configure(c => c.For <IConfigurationPropertiesProvider> ().Singleton().Use(new AppSettingsConfiguration(WebConfigurationManager.AppSettings)));
            ObjectFactory.Configure(c => c.For <IDbConnectionFactory> ().Singleton().Use <SqlConnectionFactory> ());
            ObjectFactory.Configure(c => c.For <ICompletenessRuleCollection <AssessmentInstance> > ().MissingNamedInstanceIs.IsThis(new EmptyCompletenessRuleCollection()));
            ObjectFactory.Configure(c => c.For <ISupportedBrowser>().HttpContextScoped().Use <SupportedBrowser>());
            ObjectFactory.Configure(c => c.For <IEmailNotifier>().Use <EmailNotifier>());

            return(ObjectFactory.Container);
        }
        public DNQReferralStatus GetDNQReferralStatus()
        {
            var visitable = this as IBusinessLogicVisitable;
            DNQReferralStatus.DNQReason reason = DNQReferralStatus.DNQReason.None;
            if (string.Compare(visitable.Quote.DNQReasons, "The Property is not owner occupied.", true) == 0)
                reason = DNQReferralStatus.DNQReason.NonOwnerOccupied;
            if (string.Compare(visitable.Quote.DNQReasons, "Mobile and Manufactured homes are ineligible for coverage.", true) == 0)
                reason = DNQReferralStatus.DNQReason.MobileManufactured;

            DNQReferralStatus status = new DNQReferralStatus()
            {
                CanRefer = false,
                ReferredPartnerName = null,
                Reason = reason
            };

            if (reason != DNQReferralStatus.DNQReason.None)
            {
                LookupProvider lookup = new LookupProvider();
                bool? exclude = true;
                string DNQMessage = "";

                // add Partner functionality lookup
                if (lookup.CheckPartnerFunction(lookup.GetPartnerInfoByPartnerID((int)visitable.Quote.PartnerId).ContactPartnerid, "DNQReferral"))
                {
                    // exclusion lookup
                    Homesite.IQuote.Data.LookupDataProviderTableAdapters.QueriesTableAdapter
                        adp = new Homesite.IQuote.Data.LookupDataProviderTableAdapters.QueriesTableAdapter();
                    adp.CheckDNQReferralExclusions(visitable.PropertyAddress.PostalCode, visitable.Quote.DNQReasons, ref exclude, ref DNQMessage);

                    if (((int)visitable.Quote.PartnerId == 1220) && ((bool)!exclude))
                    {
                        XElement partner = ConfigurationCache.StaticCollection.GetDNQReferralPartner("AMIG");
                        var query =
                            from el in partner.Descendants("ElephantStates").Elements()
                            where (string)el.Value.ToString() == (string)visitable.QHeader.State
                            select el.Value;
                        if (query.Count() > 0)
                            exclude = false;
                        else
                            exclude = true;
                    }
                }

                if (exclude == false)
                {
                    string groupName = GetABTestGroup("DNQ Referral");
                    if (groupName != "Do Not Refer")
                    {
                        status.CanRefer = true;
                        status.ReferredPartnerName = groupName;
                    }
                }
            }
            return status;
        }
        public BillingOptions GetBillingOptions()
        {
            this.Log("GetBillingOptions - Start... Inspection Result value = " + this.BusinessLogic().Quote.InspectionResult.ToString());

            BusinessLogicPurchaseProcessor Purchase = new BusinessLogicPurchaseProcessor();
            this.Accept<BusinessLogicPurchaseProcessor>(Purchase);

            BusinessLogicSessionDataBinder data = new BusinessLogicSessionDataBinder();
            this.Accept<BusinessLogicSessionDataBinder>(data);

            data.RefreshDataObjects();

            this.Log("GetBillingOptions - DataObjects refreshed... Inspection Result value = " + this.BusinessLogic().Quote.InspectionResult.ToString());

            int propertyType = 0;

            Structure structure = Structure.GetStructure(QHeader.SessionId);

            if (!String.IsNullOrEmpty(structure.PropertyType))
            {
                propertyType = Convert.ToInt32(structure.PropertyType);
            }
            //QC#285 - getting RatingDate
            DateTime? policyEffectiveDt = Convert.ToDateTime(data.Coverage.PolicyEffDate);
            LookupProvider lookupProvider = new LookupProvider();
            DateTime? ratingDate = lookupProvider.GetRatingDate(policyEffectiveDt,
                                                      data.Quote.InitialQuoteRequestDt,
                                                      QHeader.State);

            Homesite.IQuote.Data.ISODataProvider.hssp_GetInstallmentDataDataTable installmentDataTable =
                QuoteServices.GetInstallmentDataTable(data.Quote.CompanysQuoteNumber, QHeader.State, Convert.ToDecimal(data.Quote.PolicyPremiumAmt),
                Convert.ToDateTime(ratingDate), propertyType);

            BillingOptions billingOptions = new BillingOptions();

            foreach (Homesite.IQuote.Data.ISODataProvider.hssp_GetInstallmentDataRow row in installmentDataTable.Rows)
            {
                if (row.NumOfInstallments == 0)
                {
                    billingOptions.FullPremium = String.Format("{0:$###,###,##0.00}", row.NewDownPayment);
                }
                else if (row.NumOfInstallments == 1)
                {
                    billingOptions.DownPayment_2Pay = String.Format("{0:$###,###,##0.00}", row.NewDownPayment);
                    billingOptions.PaymentAmt_2Pay = String.Format("{0:$###,###,##0.00}", row.Installment);
                }
                else if (row.NumOfInstallments == 3)
                {
                    billingOptions.DownPayment_4Pay = String.Format("{0:$###,###,##0.00}", row.NewDownPayment);
                    billingOptions.PaymentAmt_4Pay = String.Format("{0:$###,###,##0.00}", row.Installment);
                }
                else if (row.NumOfInstallments == 9)
                {
                    billingOptions.DownPayment_10Pay = String.Format("{0:$###,###,##0.00}", row.NewDownPayment);
                    billingOptions.PaymentAmt_10Pay = String.Format("{0:$###,###,##0.00}", row.Installment);
                }
                else if (row.NumOfInstallments == 11)
                {
                    billingOptions.DownPayment_12Pay = String.Format("{0:$###,###,##0.00}", row.NewDownPayment);
                    billingOptions.PaymentAmt_12Pay = String.Format("{0:$###,###,##0.00}", row.Installment);
                }
            }

            this.Log("GetBillingOptions - end... Inspection Result value = " + this.BusinessLogic().Quote.InspectionResult.ToString());

            return billingOptions;
        }