public async Task <IActionResult> CreateContent(CreateCampaignAccountContentViewModel model, List <IFormFile> file, List <string> content_image) { if (ModelState.IsValid) { var imgs = content_image; //if (strImages != null) //{ // string[] arrayImages = strImages.Split(new string[] { "|" }, StringSplitOptions.None); // foreach(string img in arrayImages) // { // imgs.Add(img); // } //} model.Image = imgs; var r = await _campaignAccountContentService.CreateCampaignAccountContent(model, CurrentUser.Username); SetMessageModal("Đã gửi nội dung thành công, Nội dung của bạn đang chờ được xét duyệt."); } return(RedirectToAction("Details", new { id = model.CampaignId, tab = 3 })); }
public async Task <int> CreateCampaignAccountContent(CreateCampaignAccountContentViewModel model, string username) { var campaign = await _campaignRepository.GetByIdAsync(model.CampaignId); if (campaign == null) { return(-1); } var entity = new CampaignAccountContent() { CampaignAccountId = model.CampaignAccountId, Content = model.Content, DateCreated = DateTime.Now, DateModified = DateTime.Now, Note = string.Empty, Status = CampaignAccountContentStatus.ChoDuyet, UserCreated = username, UserModified = username, Image = model.Image.ToListString() }; await _CampaignAccountContentRepository.AddAsync(entity); var notifType = NotificationType.AccountSubmitCampaignContent; 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); }