示例#1
0
        /// <summary>
        /// Creates a shallow copy of a <see cref="PricingEveryday"/> to be used as a payload container.
        /// </summary>
        /// <param name="source">The original PricingEveryday object.</param>
        /// <returns>The PricingEveryday object. with only the payload-relevant properties populated.</returns>
        public static PricingEveryday ToPayload(this PricingEveryday source)
        {
            var payload = new PricingEveryday {
                Id = source.Id, SearchGroupId = source.SearchGroupId
            };

            return(payload);
        }
        public PricingEverydayStrategyViewModel(PricingEveryday priceRoutine)
        {
            if (priceRoutine == null)
            {
                throw new ArgumentNullException("priceRoutine");
            }

            PriceRoutine = priceRoutine;
            InitializeCommands();
        }
示例#3
0
        public PricingEverydayPriceListListViewModel(PricingEveryday priceRoutine)
        {
            if (priceRoutine == null)
            {
                throw new ArgumentNullException("priceRoutine");
            }

            PriceRoutine = priceRoutine;
            PriceRoutine.UpdatePriceListGroups();

            InitializeCommands();
        }
        public static PricingEveryday GetSamplePricingEveryday(int id)
        {
            var result = new PricingEveryday {
                Id = id + 1
            };

            result.Identity = GetPricingIdentity(_pricingEverydayNames[id], _ownerNames[id]);

            var filterGroups = MockFilterGenerator.GetFilterGroupsComplete();

            result.FilterGroups = new ReactiveList <FilterGroup>(filterGroups);

            //Price lists
            result.PricingModes = GetPricingModes();
            foreach (PricingMode mode in result.PricingModes)
            {
                result.PriceListGroups = GetEverydayPriceListGroups(mode);
            }

            result.KeyPriceListRule = new PricingKeyPriceListRule {
                DollarRangeLower = 10.25M, DollarRangeUpper = 115.00M, RoundingRules = GetRoundingRules()
            };
            result.LinkedPriceListRules = GetLinkedPriceListRules(result);

            var drivers = GetEverydayValueDrivers();

            result.ValueDrivers = new ReactiveList <PricingEverydayValueDriver>(drivers);

            //Value drivers
            PricingEverydayValueDriver keyDriver = result.ValueDrivers.FirstOrDefault(driver => driver.IsKey);

            if (keyDriver != null)
            {
                PricingEverydayKeyValueDriver key = GetEverydayKeyValueDriver(keyDriver);
                result.KeyValueDriver = key;
            }
            var selectedNonKey = result.ValueDrivers.Where(driver => !driver.IsKey && driver.IsSelected);
            var linkedDrivers  = GetEverydayLinkedValueDrivers(selectedNonKey);

            result.LinkedValueDrivers = new ObservableCollection <PricingEverydayLinkedValueDriver>(linkedDrivers);

            //Results
            result.Results = GetEverydayResults();

            //Select default item for display purposes.
            result.SelectedFilterGroup = result.FilterGroups.FirstOrDefault();

            return(result);
        }
示例#5
0
        //TODO: finish
        public static PricingEveryday Copy(this PricingEveryday source)
        {
            PricingEveryday copy = new PricingEveryday();

            copy.Id             = 0;
            copy.SearchGroupKey = source.SearchGroupKey;

            copy.Identity.AnalyticsId = 0;

            DateTime createdDate = DateTime.Now;

            copy.Identity.Created   = createdDate;
            copy.Identity.Edited    = createdDate;
            copy.Identity.Refreshed = createdDate;

            string copySuffix = " (Copy)";

            copy.Identity.Description = source.Identity.Description + copySuffix;
            copy.Identity.Editor      = source.Identity.Editor;
            copy.Identity.Name        = source.Identity.Name + copySuffix;
            copy.Identity.Notes       = source.Identity.Notes + copySuffix;

            copy.Identity.Active = source.Identity.Active;
            copy.Identity.Author = source.Identity.Author;
            copy.Identity.Owner  = source.Identity.Owner;
            copy.Identity.Shared = source.Identity.Shared;

            foreach (FilterGroup filterGroup in source.FilterGroups)
            {
                FilterGroup filterGroupCopy = filterGroup.Copy();
                copy.FilterGroups.Add(filterGroupCopy);
            }

            foreach (PricingEverydayValueDriver driver in source.ValueDrivers)
            {
                PricingEverydayValueDriver driverCopy = driver.Copy();
                copy.ValueDrivers.Add(driverCopy);
            }

            foreach (PricingEverydayPriceListGroup priceListGroup in source.PriceListGroups)
            {
                PricingEverydayPriceListGroup priceListGroupCopy = priceListGroup.Copy();
                copy.PriceListGroups.Add(priceListGroupCopy);
            }

            copy.IsDirty = true;

            return(copy);
        }
示例#6
0
        private Session <T> CreateDisplayResponse <T>(DTO.Session <DTO.PricingEveryday> response)  where T : class
        {
            PricingEveryday display = response.Data != null?response.Data.ToDisplayEntity() : null;

            return(new Session <T>
            {
                Authenticated = response.Authenticated,
                SqlAuthorization = response.SqlAuthorization,
                ClientMessage = response.ClientMessage ?? null,
                Data = display,
                ServerMessage = response.ServerMessage ?? null,
                SessionOk = response.SessionOk,
                User = response.User != null?response.User.ToDisplayEntity() : null,
            });
        }
        private static List <PricingLinkedPriceListRule> GetLinkedPriceListRules(PricingEveryday priceRoutine)
        {
            var rules = new List <PricingLinkedPriceListRule>();

            var uniquePriceListIds = priceRoutine.PriceListGroups.SelectMany(grp => grp.PriceLists).Select(pl => pl.Id).Distinct();

            foreach (int id in uniquePriceListIds)
            {
                int percentChange = _random.Next(3, 15);
                var roundingRules = GetRoundingRules();
                var rule          = new PricingLinkedPriceListRule {
                    PercentChange = percentChange, PriceListId = id, RoundingRules = roundingRules
                };
                rules.Add(rule);
            }
            return(rules);
        }
示例#8
0
        public PricingEverydayRoundingViewModel(PricingEveryday priceRoutine)
        {
            if (priceRoutine == null)
            {
                throw new ArgumentNullException("priceRoutine");
            }

            PriceRoutine = priceRoutine;
            PriceRoutine.UpdatePriceListGroups();

            InitializeObservables();

            //Select the first price list by default.
            if (PriceRoutine.RoundingRulePriceLists.Count > 0)
            {
                SelectedPriceList = PriceRoutine.RoundingRulePriceLists[0];
            }
        }