public async Task <int> SubmitCampaignAccountRefContent(int accountid, SubmitCampaignAccountRefContentViewModel model, string username) { // thiều phần verify .... 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.RefContent = model.RefContent; campaignAccount.Status = CampaignAccountStatus.SubmittedContent; campaignAccount.DateModified = DateTime.Now; campaignAccount.UserModified = username; await _campaignAccountRepository.UpdateAsync(campaignAccount); //notification await _notificationRepository.CreateNotification(NotificationType.AccountSubmitCampaignRefContent, EntityType.Agency, campaign.AgencyId, campaign.Id, NotificationType.AccountSubmitCampaignRefContent.GetMessageText(username, campaign.Id.ToString()), campaignAccount.Id.ToString()); return(1); }
public async Task <int> UpdateCampaignAccountRefImages(int accountid, UpdateCampaignAccountRefImagesViewModel 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.RefImage = model.RefImage.ToListString(); campaignAccount.DateModified = DateTime.Now; campaignAccount.UserModified = username; await _campaignAccountRepository.UpdateAsync(campaignAccount); return(1); }
public async Task <CampaignCounterViewModel> GetCampaignCounterByAccount(int accountid) { var filter = new CampaignAccountByAccountSpecification(accountid, new List <CampaignAccountStatus>() { CampaignAccountStatus.Confirmed, CampaignAccountStatus.SubmittedContent, CampaignAccountStatus.DeclinedContent, CampaignAccountStatus.ApprovedContent, CampaignAccountStatus.UpdatedContent, CampaignAccountStatus.Finished, }); var filter2 = new CampaignAccountByAccountSpecification(accountid, new List <CampaignAccountStatus>() { CampaignAccountStatus.SubmittedContent, CampaignAccountStatus.DeclinedContent, CampaignAccountStatus.ApprovedContent, CampaignAccountStatus.UpdatedContent, }); var filter3 = new CampaignAccountByAccountSpecification(accountid, new List <CampaignAccountStatus>() { CampaignAccountStatus.Finished, }); return(new CampaignCounterViewModel() { Total = await _campaignAccountRepository.CountAsync(filter), TotalProcess = await _campaignAccountRepository.CountAsync(filter2), TotalFinished = await _campaignAccountRepository.CountAsync(filter3), }); }
public async Task <CampaignAccountByAccountViewModel> GetCampaignAccountByAccount(int accountid, int campaignid) { var campaign = await _campaignRepository.GetByIdAsync(campaignid); if (campaign != null) { var filter = new CampaignAccountByAccountSpecification(accountid, campaignid); var campaignAccount = await _campaignAccountRepository.GetSingleBySpecAsync(filter); if (campaignAccount != null) { return(new CampaignAccountByAccountViewModel(campaignAccount, campaign)); } } return(null); }
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 <int> FeedbackCampaignAccountRefContent(int agencyid, int campaignid, int accountid, string username, int type, string newContent) { var campaign = await _campaignRepository.GetByIdAsync(campaignid); if (campaign == null || campaign.AgencyId != agencyid) { return(-1); } var filter = new CampaignAccountByAccountSpecification(accountid, campaign.Id); var campaignAccount = await _campaignAccountRepository.GetSingleBySpecAsync(filter); if (campaignAccount == null) { return(-1); } var status = type == 1 ? CampaignAccountStatus.ApprovedContent : type == 2 ? CampaignAccountStatus.UpdatedContent : CampaignAccountStatus.DeclinedContent; campaignAccount.Status = status; if (status == CampaignAccountStatus.UpdatedContent) { campaignAccount.RefContent = newContent; } campaignAccount.DateModified = DateTime.Now; campaignAccount.UserModified = username; await _campaignAccountRepository.UpdateAsync(campaignAccount); //notification var notiftype = type == 1 ? NotificationType.AgencyApproveCampaignRefContent : NotificationType.AgencyDeclineCampaignRefContent; await _notificationRepository.CreateNotification(notiftype, EntityType.Account, campaignAccount.AccountId, campaign.Id, notiftype.GetMessageText(username, campaign.Id.ToString()), campaignAccount.Id.ToString()); return(1); }
public async Task <int> CancelCampaignAccount(int campaignid, int accountid, string note, string username) { var filter = new CampaignAccountByAccountSpecification(accountid, campaignid); var campaignAccount = await _campaignAccountRepository.GetSingleBySpecAsync(filter); if (campaignAccount == null) { return(-1); } campaignAccount.Status = CampaignAccountStatus.Canceled; campaignAccount.DateModified = DateTime.Now; campaignAccount.UserModified = username; await _campaignAccountRepository.UpdateAsync(campaignAccount); //notification await _notificationRepository.CreateNotification(NotificationType.AgencyCancelAccountJoinCampaign, EntityType.Account, campaignAccount.AccountId, campaignid, NotificationType.AgencyCancelAccountJoinCampaign.GetMessageText(username, campaignid.ToString()), campaignAccount.Id.ToString()); return(1); }