예제 #1
0
        public TargetingTypeGroupModel SerializeTargetingTypeGroup(TargetingTypeGroup model)
        {
            var result = new TargetingTypeGroupModel(
                model.Id,
                model.Name,
                model.BenchmarkIdOpt,
                this.SerializeTargetingTypes(model.GetTargetingTypes())
                );

            return(result);
        }
예제 #2
0
        public TargetingGroupModel TransformToGroup(TargetingTypeGroup groupModel, IEnumerable <UsernameBasketInfo> baskets)
        {
            var result = new TargetingGroupModel(
                groupModel.Id,
                groupModel.Name,
                groupModel.GetTargetingTypes()
                .SelectMany(x => this.basketExtractor.ExtractBaskets(x))
                .GroupBy(x => x.Id)                         // getting rid of the same baskets
                .Select(x => new BasketModel(x.Key, this.basketRenderer.RenderBasketOnceResolved(x.First()))),
                baskets);

            return(result);
        }
예제 #3
0
 public IEnumerable <IBasket> ExtractBaskets(TargetingTypeGroup targetingTypeGroup)
 {
     return(targetingTypeGroup.GetTargetingTypes().SelectMany(x => this.ExtractBaskets(x)).Distinct());
 }