public ProviderResponseScheme(Response response, ProviderPortfolio providerPortfolio, ConsumerPortfolio consumerPortfolio, ConsumerMember consumerMember = null)
        {
            this.Id = response.Id;
            this.ConsumerPortfolioId = response.ConsumerPortfolioId;
            this.ProviderPortfolioId = response.ProviderPortfolioId;

            this.Distance    = response.Distance;
            this.Quote       = response.Quote;
            this.DepositDue  = response.DepositDue;
            this.DepositPaid = response.DepositPaid;
            this.BalanceDue  = response.BalanceDue;
            this.BalancePaid = response.BalancePaid;

            this.Agreement = response.Agreement;
            this.Alternate = response.Alternate;

            this.Created = response.Created;
            this.Current = response.Current;
            this.Pending = response.Pending;

            this.Member     = GetConsumerMember(response, consumerMember);                                           // only show if winning bidder
            this.Principal  = (response.Current.IsAccepted ? consumerPortfolio.Principal : new ConsumerPrincipal()); // only show if winning bidder
            this.Preference = consumerPortfolio.Preference.Clone();
            this.Schedule   = consumerPortfolio.Schedule.Clone();
            this.Request    = consumerPortfolio.Request;

            this.CanBecomeAvailable = response.CanBecomeAvailable;
            this.CanBecomePending   = response.CanBecomePending;
            this.CanBecomeDismissed = response.CanBecomeDismissed;
        }
Exemplo n.º 2
0
        public ProviderPortfolioScheme(ProviderPortfolio providerPortfolio)
        {
            this.Id            = providerPortfolio.Id;
            this.AccountStatus = providerPortfolio.AccountStatus;

            this.Principal = providerPortfolio.Principal;
            this.Profile   = providerPortfolio.Profile;

            this.Members = new List <ProviderMember>();

            this.Created  = providerPortfolio.Created;
            this.Modified = providerPortfolio.Modified;
        }
        public bool HasChanged(ProviderPortfolio portfolio)
        {
            if (this.Principal.HasChanged(portfolio.Principal))
            {
                return(true);
            }

            if (this.Profile.HasChanged(portfolio.Profile))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public ProviderMember AddMemberPortfolio(string memberId, ProviderPortfolio portfolio)
        {
            // get the member
            var member = GetProviderMember(memberId);

            if (!member.PortfolioIds.Contains(portfolio.Id))
            {
                // add the portfolio
                member.PortfolioIds.Add(portfolio.Id);

                // set as the current portfolio
                member.PortfolioId = portfolio.Id;

                // update in the DB
                Update(member);
            }

            return(member);
        }
Exemplo n.º 5
0
        public List <Response> GenerateResponses(ProviderPortfolio providerPortfolio)
        {
            var responses = new List <Response>();

            // extract the longitude and latitude
            var longitude = providerPortfolio.Principal.Address.Longitude.Value;
            var latitude  = providerPortfolio.Principal.Address.Latitude.Value;

            // find all consumers with a pending request
            var query = Query.EQ("Request.State", RequestReceiptStates.Pending);

            // get all consumers within the specified area
            var geoResults = this.ConsumerPortfolios.GeoNear(query, longitude, latitude, UNLIMITED_RESULTS, CreateGeoNearOptions(MI_MAX_DISTANCE));

            // iterate over each geo result hit
            foreach (var hit in geoResults.Hits)
            {
                // get the consumer portfolio
                var consumerPortfolio = hit.Document;

                if (!ResponseExists(consumerPortfolio, providerPortfolio) && hit.Distance <= consumerPortfolio.Preference.MaxDistance)
                {
                    // generate a response for each consumer portfolio
                    var response = new Response(providerPortfolio.Id, consumerPortfolio.Id, null);

                    // set the calculated distance
                    response.Distance = Math.Round(hit.Distance, 1);

                    // save in the DB
                    this.Responses.Save(response);

                    // add this to the list of generated responses
                    responses.Add(response);
                }
            }

            return(responses);
        }
        public ConsumerResponseScheme(Response response, ConsumerPortfolio consumerPortfolio, ProviderPortfolio providerPortfolio)
        {
            this.Id = response.Id;
            this.ConsumerPortfolioId = response.ConsumerPortfolioId;
            this.ProviderPortfolioId = response.ProviderPortfolioId;
            this.Distance            = response.Distance;
            this.Quote       = response.Quote;
            this.DepositDue  = response.DepositDue;
            this.DepositPaid = response.DepositPaid;
            this.BalanceDue  = response.BalanceDue;
            this.BalancePaid = response.BalancePaid;

            this.Agreement = response.Agreement;
            this.Alternate = response.Alternate;

            this.Principal = (response.Current.IsAccepted ? providerPortfolio.Principal : new ProviderPrincipal());
            this.Profile   = (response.Current.IsAccepted ? providerPortfolio.Profile : new ProviderProfile()
            {
                BusinessEstablished = providerPortfolio.Profile.BusinessEstablished,
                FacilityAge = providerPortfolio.Profile.FacilityAge,
                FacilityStyle = providerPortfolio.Profile.FacilityStyle,
                FuneralDirectorExperience = providerPortfolio.Profile.FuneralDirectorExperience,
                TransportationFleetAge = providerPortfolio.Profile.TransportationFleetAge
            });

            this.Preference = consumerPortfolio.Preference;
            this.Schedule   = consumerPortfolio.Schedule;

            this.Created = response.Created;
            this.Current = response.Current;
            this.Pending = response.Pending;

            this.CanAccept = (consumerPortfolio.Request.IsAcceptAllowed && response.CanBecomeAccepted);
            this.CanReject = (consumerPortfolio.Request.IsRejectAllowed && response.CanBecomeRejected);
        }
 public static IRuleBuilderOptions <T, string> IsCurrentProviderPortfolio <T>(this IRuleBuilder <T, string> rule, ProviderPortfolio instance)
 {
     return(rule.Must(id =>
     {
         using (var db = new MongoDbContext())
         {
             var portfolio = db.GetProviderPortfolio(id);
             if (portfolio != null)
             {
                 // verify the modified timestamps match
                 if (instance.Modified.On == portfolio.Modified.On)
                 {
                     return true;
                 }
             }
         }
         return false;
     }));
 }
Exemplo n.º 8
0
 public void Update(ProviderPortfolio portfolio)
 {
     this.ProviderPortfolios.Save(portfolio);
 }
Exemplo n.º 9
0
 private bool ResponseExists(ConsumerPortfolio consumerPortfolio, ProviderPortfolio providerPortfolio)
 {
     return(this.Responses.FindAll().Any(item => (item.ConsumerPortfolioId == consumerPortfolio.Id && item.ProviderPortfolioId == providerPortfolio.Id)));
 }
Exemplo n.º 10
0
 public Response FindProviderResponse(ProviderPortfolio providerGroup)
 {
     return(FindProviderResponse(providerGroup.Id));
 }