public async Task <IActionResult> CreateCaption(CreateCampaignAccountCaptionViewModel model) { if (ModelState.IsValid) { var r = await _campaignAccountCaptionService.CreateCampaignAccountCaption(model, CurrentUser.Username); SetMessageModal("Đã gửi caption thành công, caption của bạn đang chờ được xét duyệt."); } return(RedirectToAction("Details", new { id = model.CampaignId, tab = 2 })); }
public async Task <int> CreateCampaignAccountCaption(CreateCampaignAccountCaptionViewModel model, string username) { var campaign = await _campaignRepository.GetByIdAsync(model.CampaignId); if (campaign == null) { return(-1); } var entity = new CampaignAccountCaption() { CampaignAccountId = model.CampaignAccountId, Content = model.Content, DateCreated = DateTime.Now, DateModified = DateTime.Now, Note = string.Empty, Status = CampaignAccountCaptionStatus.ChoDuyet, UserCreated = username, UserModified = username, }; await _CampaignAccountCaptionRepository.AddAsync(entity); var notifType = NotificationType.AccountSubmitCampaignCaption; await _notificationRepository.AddAsync(new Notification() { Type = notifType, DataId = campaign.Id, Data = string.Empty, DateCreated = DateTime.Now, EntityType = EntityType.Agency, EntityId = campaign.AgencyId, Message = notifType.GetMessageText(username, campaign.Title.ToString()), Status = NotificationStatus.Created }); return(entity.Id); }