Exemple #1
0
        public IResponse CreateCampaign(IContactPostCampaignRequest requestBody, IContactRequest requestFrm)
        {
            IResponse response = new IContactPostCampaignsResponse();

            try
            {
                config.mailingProvider = requestFrm;
                IContactPostCampaignRequest[] requestArrayBody = new IContactPostCampaignRequest[] { requestBody };
                config.data = new JavaScriptSerializer().Serialize(requestArrayBody);
                HttpWebRequest request = GetRequest(KindAds.Common.Utils.IContactRequest.AddCampaign, config, requestFrm);
                response = GetResponse(request);
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }
            return(response);
        }
Exemple #2
0
        public async Task <ActionResult> CreateProduct(Models.Publisher.CreateProductModel _createProduct, HttpPostedFileBase fileup)
        {
            if (ModelState.IsValid)
            {
                var productType = new Guid(Session["ProductTypeSelecc"].ToString());
                var partner     = new Guid(Session["PartnerSelecc"].ToString());

                if (partner.Equals(new Guid(Utils.Constants.PROVIDER_DEFAULT_ADSMONETIZATION)))
                {
                    var productTypeString = Session["ProductTypeSelecc"].ToString();
                    var site       = new Guid(Session["SiteSelecc"].ToString());
                    var userId     = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity);
                    var userDetail = _accessService.GetUserDetailByIdUser(new Guid(userId).ToString());

                    //llenamos el modelo
                    MoneyAdsViewModel viewModel = _createProduct.adsManager.viewModel;
                    viewModel.defaultAd.IdSite       = site.ToString();
                    viewModel.defaultAd.name         = _createProduct.Name;
                    viewModel.defaultAd.typeSelected = "1";

                    CreateAds(viewModel);

                    return(RedirectToAction("Settings", "MoneyAds"));
                }
                else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_STICKY_ADSMONETIZATION)))
                {
                    var productTypeString = Session["ProductTypeSelecc"].ToString();
                    var site       = new Guid(Session["SiteSelecc"].ToString());
                    var userId     = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity);
                    var userDetail = _accessService.GetUserDetailByIdUser(new Guid(userId).ToString());

                    //llenamos el modelo
                    MoneyAdsViewModel viewModel = _createProduct.adsManager.viewModel;
                    viewModel.defaultAd.IdSite       = site.ToString();
                    viewModel.defaultAd.name         = _createProduct.Name;
                    viewModel.defaultAd.typeSelected = "2";

                    CreateAds(viewModel);

                    return(RedirectToAction("Settings", "MoneyAds"));
                }
                else
                {
                    var apiToken   = Session["ApiToken"].ToString();
                    var price      = Session["ProceSelecc"] == null ? _createProduct.PriceSelecc : Convert.ToDouble(Session["PriceSelecc"].ToString());
                    var site       = new Guid(Session["SiteSelecc"].ToString());
                    var userId     = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity);
                    var userDetail = _accessService.GetUserDetailByIdUser(new Guid(userId).ToString());

                    if (partner.Equals(new Guid(Utils.Constants.PROVIDER_MAIL_CHIMP)))
                    {
                        var listMailChimp     = (string)TempData["ListMCSelecc"];
                        var templateMailChimp = Convert.ToInt32(TempData["TemplateMCSelecc"]);

                        _createProduct.ListMCSelecc     = listMailChimp;
                        _createProduct.TemplateMCSelecc = templateMailChimp;
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_CAMPAIGN_MONITOR)))
                    {
                        var listCampaignMonitor = (string)TempData["ListCMSelecc"];
                        var client  = (string)TempData["ClientCMSelecc"];
                        var segment = (string)TempData["SegmentCMSelecc"];

                        _createProduct.ListCMSelecc    = listCampaignMonitor;
                        _createProduct.ClientCMSelecc  = client;
                        _createProduct.SegmentCMSelecc = segment;
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_AWEBER)))
                    {
                        var listAWeber = (string)TempData["ListAWSelecc"];
                        _createProduct.providerAWeberApiResult = (ProviderAWeberApiResult)Session["ProviderAWeberApiResult"];
                        _createProduct.ListAWSelecc            = listAWeber;
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_GETRESPONSE)))
                    {
                        _createProduct.ListGRSelecc      = (string)TempData["ListsGRSelecc"];
                        _createProduct.FromFieldGRSelecc = (string)TempData["FromFieldSelecc"];
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_SEND_GRID)))
                    {
                        _createProduct.ListSGSelecc             = (string)TempData["ListsSGSelecc"];
                        _createProduct.SenderSGSelecc           = (string)TempData["SenderSGSelecc"];
                        _createProduct.UnsubscribeGroupSGSelecc = (string)TempData["UnsubscribeGroupSGSelecc"];
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_ACTIVE_CAMPAIGN)))
                    {
                        _createProduct.ListACSelecc = (string)TempData["ListsACSelecc"];
                        _createProduct.URLACSelecc  = (string)Session["WildCard"];
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_ICONTACT)))
                    {
                        _createProduct.ListICSelecc    = (string)TempData["ListsICSelecc"];
                        _createProduct.IContact.ListId = _createProduct.ListICSelecc;

                        //Generar campaña
                        IContactService <ICampaign, IContactPostCampaignsResponse> iContactProvider = new IContactService <ICampaign, IContactPostCampaignsResponse>();
                        IContactRequest               requestFrm       = (IContactRequest)Session["IContactRequest"];
                        IContactPostCampaignRequest   requestBody      = new IContactPostCampaignRequest();
                        IContactPostCampaignsResponse responseCampaign = new IContactPostCampaignsResponse();

                        // Fill object
                        requestBody.fromEmail = requestFrm.ApiUserName;
                        requestBody.name      = _createProduct.Name;
                        requestBody.fromName  = requestFrm.ApiUserName;
                        responseCampaign      = (IContactPostCampaignsResponse)iContactProvider.CreateCampaign(requestBody, requestFrm);
                        _createProduct.IContact.IdCampaign = responseCampaign.campaigns[0].campaignId;
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_SENDINBLUE)))
                    {
                        _createProduct.ListSBSelecc       = (string)TempData["ListsSBSelecc"];
                        _createProduct.SendinBlue.ListIds = new List <int> {
                            Convert.ToInt32(_createProduct.ListSBSelecc)
                        };
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_ONE_SIGNAL)))
                    {
                        _createProduct.ListAppOSSelecc = (string)TempData["ListsAppOSSelecc"];
                        _createProduct.AuthAppOSSelecc = (string)TempData["AuthAppOSSelecc"];
                    }
                    else if (partner.Equals(new Guid(Utils.Constants.PROVIDER_MAILJET)))
                    {
                        _createProduct.ListMJSelecc    = (string)TempData["ListsMJSelecc"];
                        _createProduct.SegmentMJSelecc = (string)TempData["SegmentMJSelecc"];
                    }

                    _createProduct.PriceSelecc       = price;
                    _createProduct.Token             = apiToken;
                    _createProduct.ProductTypeSelect = productType;
                    _createProduct.ParterTypeSelect  = partner;
                    _createProduct.SiteTypeSelecc    = site;
                    //_createProduct.IsPremium = userDetail != null ? userDetail.IsPremium : false;

                    if (_productService.SaveProduct(_createProduct, userId, GetFileUpload(fileup)))
                    {
                        ViewBag.Message = "Congratulations!!!";
                    }
                    else
                    {
                        ViewBag.Message = "Error";
                    }
                }
            }

            await FillProductTypeAsync();
            await FillCategory();

            FillPrice();
            await FillSites();

            FillProductPremium(_createProduct);
            return(View(_createProduct));
        }