Exemple #1
0
        public static VariantBoosts GetVariantBoosts(int variantID)
        {
            VariantBoosts details = null;

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user       = FormsAuthenticationWrapper.User;
                        var     getRequest = new GetVariantBoostsRequest()
                        {
                            User = user, VariantID = variantID
                        };
                        var getResponse = _certonaService.GetVariantBoosts(getRequest);

                        if (getResponse.Success)
                        {
                            details = new VariantBoosts {
                                VariantID = variantID
                            };

                            details.VariantDetails = new VariantDetails()
                            {
                                PoolFactor    = getResponse.VariantDetails.PoolFactor,
                                SubjectWeight = getResponse.VariantDetails.SubjectWeight
                            };

                            details.VariantBiases = new List <VariantBiases>();
                            details.VariantBiases.AddRange(getResponse.VariantBiases.Select(b => new VariantBiases()
                            {
                                BiasID   = b.BiasID,
                                ListName = b.ListName,
                                Weight   = b.Weight
                            }).ToList());


                            details.VariantModels = new List <ViewModels.Variant.VariantModel>();
                            details.VariantModels.AddRange(getResponse.VariantModels.Select(m => new ViewModels.Variant.VariantModel()
                            {
                                CatalogID   = m.CatalogID,
                                Description = m.Description,
                                ModelID     = m.ModelID,
                                Name        = m.Name,
                                Weight      = m.Weight
                            }).ToList());
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(details);
        }