public async Task <IActionResult> UpdateCampaignAccountRef(UpdateCampaignAccountRefViewModel model)
        {
            var r = await _campaignService.UpdateCampaignAccountRef(CurrentUser.Id, model.CampaignId, model.RefUrl);

            if (r > 0)
            {
                //check thực hiện công việc
                BackgroundJob.Enqueue <IFacebookJob>(m => m.UpdateFbPost(CurrentUser.Id, CurrentUser.Username, 2));
                //await _IFacebookJob.UpdateFbPost(CurrentUser.Id, CurrentUser.Username, 2);
                try
                {
                    if (model.CampaignType != CampaignType.ShareContentWithCaption)
                    {
                        ViewBag.Success = "Cảm ơn bạn đã thực hiện công việc";
                    }
                    else
                    {
                        ViewBag.Success = "Bạn đã thực hiện thành công công việc";
                    }
                }
                catch
                {
                    ViewBag.Success = "Bạn đã thực hiện thành công công việc";
                }
            }
            else
            {
                ViewBag.Error = "Thông tin chiến dịch không đúng";
            }

            return(PartialView("UpdateCampaignAccountMessage"));
        }
Esempio n. 2
0
        public async Task <int> UpdateCampaignAccountRef(int accountid, UpdateCampaignAccountRefViewModel model, string username)
        {
            var campaign = await _campaignRepository.GetByIdAsync(model.CampaignId);

            if (campaign == null)
            {
                return(-1);
            }

            var filter          = new CampaignAccountByAccountSpecification(accountid, campaign.Id);
            var campaignAccount = await _campaignAccountRepository.GetSingleBySpecAsync(filter);

            if (campaignAccount == null)
            {
                return(-1);
            }

            if (!string.IsNullOrEmpty(model.RefId))
            {
                campaignAccount.RefId = model.RefId;
            }
            if (!string.IsNullOrEmpty(model.RefUrl))
            {
                campaignAccount.RefUrl = model.RefUrl;
            }
            campaignAccount.RefImage     = model.RefImage.ToListString();
            campaignAccount.Status       = CampaignAccountStatus.Finished;
            campaignAccount.DateModified = DateTime.Now;
            campaignAccount.UserModified = username;
            await _campaignAccountRepository.UpdateAsync(campaignAccount);

            //notification

            await _notificationRepository.CreateNotification(NotificationType.AccountFinishCampaignRefContent,
                                                             EntityType.Agency, campaign.AgencyId, campaign.Id,
                                                             NotificationType.AccountFinishCampaignRefContent.GetMessageText(username, campaign.Id.ToString()),
                                                             campaignAccount.Id.ToString());

            return(1);
        }
        public async Task <IActionResult> UpdateCampaignAccountRef(UpdateCampaignAccountRefViewModel model)
        {
            if (ModelState.IsValid)
            {
                var r = await _campaignService.UpdateCampaignAccountRef(CurrentUser.Id, model, CurrentUser.Username);

                if (r > 0)
                {
                    ViewBag.Success = "Bạn đã thực hiện thành công công việc";
                }
                else
                {
                    ViewBag.Error = "Thông tin chiến dịch không đúng";
                }
            }
            else
            {
                ViewBag.Error = "Hãy nhập đầy đủ thông tin";
            }

            return(PartialView("UpdateCampaignAccountMessage"));
        }