Example #1
0
        internal Campaign GetEntity(Campaign campaign)
        {
            var executionTime = DateRangeHelper.GetDateRange(ExecutionTime);
            var regTime       = DateRangeHelper.GetDateRange(RegisterTime);
            var feedbackTime  = DateRangeHelper.GetDateRange(FeedbackBefore);


            campaign.Quantity       = Quantity;
            campaign.DateStart      = regTime != null ? (DateTime?)regTime.Value.Start : null;
            campaign.DateEnd        = regTime != null ? (DateTime?)regTime.Value.End : null;
            campaign.CustomKolNames = CustomKolNames.ToListString();
            campaign.KPIMin         = KPIMin;

            campaign.InteractiveMin = InteractiveMin;

            //campaign.InteractiveMin = KPIMin + InteractiveMin;

            campaign.ExecutionStart = executionTime != null ? (DateTime?)executionTime.Value.Start : null;
            campaign.ExecutionEnd   = executionTime != null ? (DateTime?)executionTime.Value.End : null;
            campaign.FeedbackStart  = feedbackTime != null ? (DateTime?)feedbackTime.Value.Start : null;
            campaign.FeedbackEnd    = feedbackTime != null ? (DateTime?)feedbackTime.Value.End : null;
            campaign.AmountMax      = AmountMax;
            campaign.AmountMin      = AmountMin;

            return(campaign);
        }
Example #2
0
        public Campaign GetEntity(Campaign campaign)
        {
            campaign.Title       = Title;
            campaign.Description = Description;
            campaign.Data        = Data;
            var image = string.Empty;

            if (!string.IsNullOrEmpty(Image))
            {
                image = Image;
            }
            else
            {
                image = AddonImages.ToListString();
            }

            //if (Type == CampaignType.ChangeAvatar)
            //{
            //    image = Image;
            //}
            //else if (Type == CampaignType.ShareContentWithCaption)
            //{
            //    image = AddonImages.ToListString();
            //}

            campaign.Image       = image;
            campaign.Requirement = Requirement;

            campaign.AccountChargeTime = AccountChargeTime ?? 1;
            campaign.Type          = Type;
            campaign.IsSendProduct = SendProduct;
            campaign.Code          = campaign.Code;
            campaign.Hashtag       = HashTag.ToListString();

            if (!string.IsNullOrEmpty(SampleContent.ToListString()))
            {
                campaign.SampleContent = SampleContent.ToListString();
            }


            campaign.SampleContentText = SampleContentText;
            campaign.Method            = Method;

            var reviewTime = DateRangeHelper.GetDateRange(ReviewDate);


            campaign.ReviewStart = reviewTime != null ? (DateTime?)reviewTime.Value.Start : null;
            campaign.ReviewEnd   = reviewTime != null ? (DateTime?)reviewTime.Value.End : null;

            if (ReviewType == CampaignReviewType.GuiSanPham)
            {
                campaign.ReviewAddress = ReviewAddress;
            }
            else
            {
                campaign.ReviewAddress = ReviewAddress;
            }


            if (ReviewPayback.HasValue == true)
            {
                if (ReviewPayback.Value == 1)
                {
                    campaign.ReviewPayback = true;
                }
                else
                {
                    campaign.ReviewPayback = false;
                }
            }
            else
            {
                campaign.ReviewPayback = false;
            }

            campaign.ReviewType = ReviewType;



            return(campaign);
        }
Example #3
0
        public static Campaign GetEntity(int agencyid, CreateCampaignInfoViewModel info, CreateCampaignTargetViewModel target,
                                         CampaignTypeCharge campaignTypeCharge, Core.Models.SettingModel setting, string code, string username)
        {
            var executionTime = DateRangeHelper.GetDateRange(target.ExecutionTime);
            var regTime       = DateRangeHelper.GetDateRange(target.RegisterTime);
            var feedbackTime  = DateRangeHelper.GetDateRange(target.FeedbackBefore);

            var reviewTime = DateRangeHelper.GetDateRange(info.ReviewDate);


            var image = string.Empty;

            if (!string.IsNullOrEmpty(info.Image))
            {
                image = info.Image;
            }
            else
            {
                image = info.AddonImages.ToListString();
            }



            //if (info.Type == CampaignType.ChangeAvatar)
            //{

            //}
            //else if (info.Type == CampaignType.ShareContentWithCaption)
            //{
            //    image = info.AddonImages.ToListString();
            //}

            var reviewaddress = "";
            var reviewpayback = false;

            if (info.Type == CampaignType.ReviewProduct && info.ReviewType.HasValue)
            {
                if (info.ReviewType == CampaignReviewType.GuiSanPham)
                {
                    if (1 == info.ReviewPayback)
                    {
                        reviewaddress = info.ReviewAddress;
                        reviewpayback = true;
                    }
                }
                else
                {
                    reviewaddress = info.ReviewAddress2;
                }
            }

            var campaign = new Campaign()
            {
                DateCreated  = DateTime.Now,
                AgencyId     = agencyid,
                Data         = info.Data,
                DateModified = DateTime.Now,
                Deleted      = false,
                Description  = info.Description,
                Image        = image,
                Published    = true,
                Status       = CampaignStatus.Created, // cap nhat status da duyet luon de facebook check,
                //Status = CampaignStatus.Confirmed,
                Title                     = info.Title,
                UserCreated               = username,
                UserModified              = username,
                ExtraOptionChargePercent  = setting.CampaignExtraOptionChargePercent,
                ServiceChargePercent      = setting.CampaignServiceChargePercent,
                ServiceVATPercent         = setting.CampaignVATChargePercent,
                ServiceChargeAmount       = 0,
                AccountChargeExtraPercent = 0,
                AccountChargeAmount       = 0,
                EnabledAccountChargeExtra = false,
                AccountChargeTime         = info.AccountChargeTime ?? 1, //change avatar campaign
                Requirement               = info.Requirement,
                Type      = info.Type,
                Code      = code,
                Quantity  = target.Quantity,
                DateStart = regTime != null ? (DateTime?)regTime.Value.Start : null,
                DateEnd   = regTime != null ? (DateTime?)regTime.Value.End.AddSeconds(59) : null,
                //AccountFeedbackBefore = target.FeedbackBefore.ToViDateTime(),
                CustomKolNames    = target.CustomKolNames.ToListString(),
                Method            = CampaignMethod.OpenJoined,
                SampleContent     = info.SampleContent.ToListString(),
                Hashtag           = info.HashTag.ToListString(),
                SampleContentText = info.SampleContentText,
                KPIMin            = target.KPIMin,
                //InteractiveMin = target.InteractiveMin,
                InteractiveMin = target.KPIMin + target.InteractiveMin,

                ExecutionStart = executionTime != null ? (DateTime?)executionTime.Value.Start : null,
                ExecutionEnd   = executionTime != null ? (DateTime?)executionTime.Value.End : null,

                FeedbackStart = feedbackTime != null ? (DateTime?)feedbackTime.Value.Start : null,
                FeedbackEnd   = feedbackTime != null ? (DateTime?)feedbackTime.Value.End : null,
                AmountMax     = target.AmountMax,
                AmountMin     = target.AmountMin,
                IsSendProduct = info.SendProduct,
                ReviewStart   = reviewTime != null ? (DateTime?)reviewTime.Value.Start : null,
                ReviewEnd     = reviewTime != null ? (DateTime?)reviewTime.Value.End : null,

                ReviewAddress = reviewaddress,
                ReviewType    = info.ReviewType,
                ReviewPayback = reviewpayback
            };


            try {
                AccountType _accountType = target.AccountType[0];
                campaign.FilterAccountType = (int)_accountType;


                if (_accountType == AccountType.HotMom)
                {
                    if (target.ChildType.HasValue)
                    {
                        campaign.FilterAccountChildrenGender = target.ChildType.Value;
                    }

                    if (target.ChildAgeMin.HasValue)
                    {
                        campaign.FilterAccountAgeChildrenFrom = target.ChildAgeMin.Value;
                    }

                    if (target.ChildAgeMax.HasValue)
                    {
                        campaign.FilterAccountAgeChildrenTo = target.ChildAgeMax.Value;
                    }
                }
            }
            catch { }

            try
            {
                if (target.EnabledCity && target.CityId != null && target.CityId.Count > 0)
                {
                    string _arrCity = string.Empty;
                    foreach (var cityId in target.CityId)
                    {
                        _arrCity += _arrCity == string.Empty ? $" {cityId.ToString()} " : $"| {cityId} ";
                    }
                    campaign.FilterAccountRegion = _arrCity;
                }
            }
            catch { }

            try {
                if (target.EnabledGender && target.Gender.HasValue)
                {
                    campaign.FilterAccountGender = (int)target.Gender.Value;
                }
            }
            catch { }

            try {
                if (target.EnabledAgeRange && target.AgeEnd.HasValue && target.AgeStart.HasValue)
                {
                    campaign.FilterAccountAgeFrom = target.AgeStart.Value;
                    campaign.FilterAccountAgeTo   = target.AgeEnd.Value;
                }
            }
            catch { }

            try
            {
                if (target.EnabledCategory && target.CategoryId != null && target.CategoryId.Count > 0)
                {
                    string _arrCategories = string.Empty;
                    foreach (var categoryid in target.CategoryId)
                    {
                        _arrCategories += _arrCategories == string.Empty ? $" {categoryid.ToString()} " : $"| {categoryid} ";
                    }
                    campaign.FilterAccountCategories = _arrCategories;
                }
            }
            catch { }


            return(campaign);
        }