public static bool InsertAttribute(WebServiceResponse attribute)
 {
     bool success = false;
     if (attribute != null && attribute.Data != null)
     {
         AttributeObject attributeToInsert = JsonConvert.DeserializeObject<AttributeObject>(attribute.Data);
         AttributeSettingObject attributeSettingToInsert = JsonConvert.DeserializeObject<AttributeSettingObject>(attribute.Data);
         attributeToInsert.AttributeSetting = new AttributeSettingObject();
         attributeToInsert.AttributeSetting.Publish = (attributeSettingToInsert.Publish != null) ? attributeSettingToInsert.Publish : true;
         AutomationManager.attributes.Add(attributeToInsert);
         AutomationManager.IAttributeRepository.Setup(i => i.SelectByID(attributeToInsert.Id)).Returns(new AttributeObject() { Id = attributeToInsert.Id });
         success = true;
     }
     return success;
 }
 public IHttpActionResult InsertAttribute(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     if (AutomationManager.InsertAttribute(query))
     {
         _responseEnvelope.Data.Info = "Attribute successfully added.";
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", "Error adding attribute."));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public IHttpActionResult InsertRespondentAttribute(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     string status = "Error adding respondent attribute.";
     if (AutomationManager.InsertRespondentAttribute(query))
     {
         _responseEnvelope.Data.Info = "Respondent attribute successfully added.";
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", status + "The Offer Id for this respondent attribute does not exist."));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public IHttpActionResult InsertOffer(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     string status = "Error adding offer.";
     if (AutomationManager.InsertOffer(query))
     {
         _responseEnvelope.Data.Info = "Offer successfully added";
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", status + "Invalid Offer Id"));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public static bool InsertOffer(WebServiceResponse offer)
 {
     bool success = false;
     if (offer != null && offer.Data != null)
     {
         OfferObject convertedOffer = JsonConvert.DeserializeObject<OfferObject>(offer.Data);
         if (convertedOffer.Id != new Guid())
         {
             OfferObject offerToAdd = new OfferObject();
             offerToAdd.Id = convertedOffer.Id;
             offerToAdd.Description = (convertedOffer.Description != null) ? convertedOffer.Description : "Default Description";
             offerToAdd.Status = convertedOffer.Status;
             offerToAdd.IR = (convertedOffer.IR != null) ? convertedOffer.IR : 0;
             offerToAdd.LOI = (convertedOffer.LOI != null) ? convertedOffer.LOI : 0;
             offerToAdd.OfferLink = (convertedOffer.OfferLink != null) ? convertedOffer.OfferLink : "https://devhub.globaltestmarket.com/hub/tplm/welcome";
             offerToAdd.QuotaRemaining = (convertedOffer.QuotaRemaining != null) ? convertedOffer.QuotaRemaining : 0;
             offerToAdd.RespondentAttributes = new List<RespondentAttributeObject>();
             offerToAdd.SampleId = (convertedOffer.SampleId != null) ? convertedOffer.SampleId : 0;
             offerToAdd.StudyId = (convertedOffer.StudyId != null) ? convertedOffer.StudyId : 0;
             offerToAdd.StudyStartDate = (convertedOffer.StudyStartDate != null) ? convertedOffer.StudyStartDate : null;
             offerToAdd.StudyEndDate = (convertedOffer.StudyEndDate != null) ? convertedOffer.StudyEndDate : null;
             offerToAdd.Terms = new List<TermObject>();
             offerToAdd.TestOffer = (convertedOffer.TestOffer != null) ? convertedOffer.TestOffer : false;
             offerToAdd.Title = (convertedOffer.Title != null) ? convertedOffer.Title : "Default Title";
             offerToAdd.Topic = (convertedOffer.Topic != null) ? convertedOffer.Topic : "Default Topic";
             offerToAdd.RetryCount = (convertedOffer.RetryCount != null) ? convertedOffer.RetryCount : 0;
             offers.Add(offerToAdd);
             success = true;
         }
     }
     return success;
 }
        public static bool ThirdpartyRespondentProfileResponse(WebServiceResponse ThirdPartyRespondentResponse)
        {
            bool success = false;
            try
            {
                respondentCatalogueAttributes = new RespondentCatalog().ProcessRespondentCatalogAttributesResponse(ThirdPartyRespondentResponse.Data);
                IRespondentCatalog.Setup(i => i.GetRespondentCatalogueAttributes(AutomationManager.internalpid)).Returns(respondentCatalogueAttributes);
                success = true;
            }
            catch
            {

            }
            return success;
        }
 public static bool QuotaExpressions(WebServiceResponse QuotaExpressionResponse)
 {
     bool success = false;
     Guid oid = new Guid();
     int SampleId = 0;
     if (Int32.TryParse(QuotaExpressionResponse.OptionalParam, out SampleId))
     {
         if (offers.Exists(i => i.SampleId == SampleId))
         {
             var offer = offers.Find(i => i.SampleId == Convert.ToInt32(QuotaExpressionResponse.OptionalParam));
             IQuotaExpressionRepository.Setup(i => i.SelectByID(SampleId)).Returns(new SteamStudyObject() { ExpressionsXML = QuotaExpressionResponse.Data, QuotaExpressionsXML = QuotaExpressionResponse.Data, OfferId = offer.Id, SampleId = SampleId });
             success = true;
         }
     }
     else if (Guid.TryParse(QuotaExpressionResponse.OptionalParam, out oid))
     {
         if (offers.Exists(i => i.Id == oid))
         {
             var offer = offers.Find(i => i.Id == oid);
             if (offer.SampleId != null)
             {
                 IQuotaExpressionRepository.Setup(i => i.SelectByID(offer.SampleId)).Returns(new SteamStudyObject() { ExpressionsXML = QuotaExpressionResponse.Data, QuotaExpressionsXML = QuotaExpressionResponse.Data, OfferId = offer.Id, SampleId = (int)offer.SampleId });
                 success = true;
             }
         }
     }
     return success;
 }
        public static bool LiveMatchInternalPIDResponse(WebServiceResponse InternalPIDResponse)
        {
            bool success = false;
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(InternalPIDResponse.Data);
                internalpid = new LiveMatch().ProcessLiveMatchIntenalPIDResponse(xmlDoc);
                ILiveMatch.Setup(i => i.GetInternalPid(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(AutomationManager.internalpid);
                success = true;
            }
            catch
            {

            }
            return success;
        }
        public static bool LiveMatchFetchNonPanelistStudiesResponse(WebServiceResponse FetchNonPaneListResponse)
        {
            bool success = false;
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(FetchNonPaneListResponse.Data);
                studiesList = new LiveMatch().ProcessLiveMatchStudiesActivityResponse(FetchNonPaneListResponse.Data);
                AutomationManager.ILiveMatch.Setup(i => i.ProcessLiveMatchStudiesActivityResponse(It.IsAny<string>())).Returns(studiesList);
                AutomationManager.ILiveMatch.Setup(i => i.CallLiveMatchService("fetchNonPanelistActivity", It.IsAny<Hashtable>())).Returns(xmlDoc);
                success = true;
            }
            catch
            {

            }
            return success;
        }
        public static bool InsertTerm(WebServiceResponse term)
        {
            bool success = false;
            if (term != null && term.Data != null)
            {
                TermObject termToInsert = JsonConvert.DeserializeObject<TermObject>(term.Data);
                if (termToInsert.OfferId != null)
                {
                    if (offers.Exists(i => i.Id == termToInsert.OfferId))
                    {
                        OfferObject offer = offers.Find(i => i.Id == termToInsert.OfferId);
                        offers.Remove(offer);
                        if (offer.Terms == null)
                            offer.Terms = new List<TermObject>();
                        offer.Terms.Add(termToInsert);
                        offers.Add(offer);
                        success = true;
                    }
                }

            }
            return success;
        }
 public static bool InsertRespondentAttribute(WebServiceResponse respondentAttribute)
 {
     bool success = false;
     if (respondentAttribute != null && respondentAttribute.Data != null)
     {
         RespondentAttributeObject respondentAttributeToInsert = JsonConvert.DeserializeObject<RespondentAttributeObject>(respondentAttribute.Data);
         if (respondentAttributeToInsert.OfferId != null)
         {
             if (AutomationManager.offers.Exists(i => i.Id == respondentAttributeToInsert.OfferId))
             {
                 OfferObject offer = offers.Find(i => i.Id == respondentAttributeToInsert.OfferId);
                 offers.Remove(offer);
                 if (offer.RespondentAttributes == null)
                     offer.RespondentAttributes = new List<RespondentAttributeObject>();
                 offer.RespondentAttributes.Add(respondentAttributeToInsert);
                 offers.Add(offer);
                 success = true;
             }
         }
     }
     return success;
 }
 public IHttpActionResult SetThirdpartyRespondentProfileResponse(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     if (AutomationManager.ThirdpartyRespondentProfileResponse(query))
     {
         _responseEnvelope.Data.Info = AutomationManager.respondentCatalogueAttributes.ToString();
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", "Error reading respondent catalog attributes from XML"));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public IHttpActionResult SetQuotaExpressions(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     string status = "Error saving Quota Expressions.";
     if (AutomationManager.QuotaExpressions(query))
     {
         _responseEnvelope.Data.Info = "Quota Expressions saved for sample id.";
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", status + " Either SampleId specified does not exists or invalid OfferId"));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public IHttpActionResult SetLiveMatchInternalPIDResponse(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     string status = "Error reading Internal PID from XML";
     if (AutomationManager.LiveMatchInternalPIDResponse(query))
     {
         _responseEnvelope.Data.Info = "Internal PID successfully parsed and set. Internal PID=" + AutomationManager.internalpid;
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", status));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }
 public IHttpActionResult SetLiveMatchFetchNonPanelistStudiesResponse(WebServiceResponse query)
 {
     AutomationResponse _responseEnvelope = new AutomationResponse(true);
     if (AutomationManager.LiveMatchFetchNonPanelistStudiesResponse(query))
     {
         _responseEnvelope.Data.Info = AutomationManager.studiesList.ToString();
         _responseEnvelope.Data.Errors = null;
     }
     else
     {
         _responseEnvelope.Data.Errors.Add(new ErrorObject("-1", "ErrorAutomation", "-1", "Error reading studies list from XML"));
         _responseEnvelope.Status = false;
     }
     return Ok(_responseEnvelope);
 }