Esempio n. 1
0
        public static bool UpdateVariantModifiers(string variantId, int pool, int profile, List <VariantBiases> biases, List <ViewModels.Variant.VariantModel> variants)
        {
            var isSuccesful = false;

            using (_certonaService = new CertonaServiceClient())
            {
                try
                {
                    var biasDTO    = new List <VariantBiasDTO>();
                    var variantDTO = new List <VariantModelDTO>();

                    var details = new VariantDetailsDTO();
                    details.VariantId     = variantId;
                    details.PoolFactor    = pool;
                    details.SubjectWeight = profile;

                    if (biases != null)
                    {
                        biasDTO = biases.Select(m => new VariantBiasDTO()
                        {
                            BiasID = m.BiasID,
                            Weight = Convert.ToDouble("." + m.Weight)
                        }).ToList();
                    }

                    if (variants != null)
                    {
                        variantDTO = variants.Select(m => new VariantModelDTO()
                        {
                            ModelID = m.ModelID,
                            Weight  = m.Weight
                        }).ToList();
                    }

                    UserDTO user    = FormsAuthenticationWrapper.User;
                    var     request = new UpdateVariantModifiersRequest
                    {
                        User           = user,
                        VariantDetails = details,
                        VariantBiases  = biasDTO,
                        VariantModels  = variantDTO
                    };
                    var response = _certonaService.UpdateVariantModifiers(request);

                    if (response.Success)
                    {
                        isSuccesful = true;
                    }
                }
                catch (TimeoutException exception)
                {
                    _certonaService.Abort();
                    throw;
                }
                catch (CommunicationException exception)
                {
                    _certonaService.Abort();
                    throw;
                }
            }

            return(isSuccesful);
        }