Beispiel #1
0
        public async Task <int> SubmmitCampaignAccountChangeAvatar(int accountid, SubmmitCampaignAccountChangeAvatarViewModel 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);
            }

            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> SubmmitCampaignAccountChangeAvatar(SubmmitCampaignAccountChangeAvatarViewModel model)
        {
            if (ModelState.IsValid)
            {
                var r = await _campaignService.SubmmitCampaignAccountChangeAvatar(CurrentUser.Id, model, CurrentUser.Username);

                if (r > 0)
                {
                    ViewBag.Success = "Cảm ơn bạn đã thực hiện 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"));
        }