public async Task <IActionResult> CreateInfo(CreateCampaignInfoViewModel model) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(model.Image)) { model.Image = _fileHelper.MoveTempFile(model.Image, "campaign"); ViewBag.Image = model.Image; } var paymentModel = new CreateCampaignTargetViewModel() { InfoModel = JsonConvert.SerializeObject(model), Type = model.Type, KPIMin = model.Type.GetKpiMin(), InteractiveMin = model.Type.GetInteractiveMin(), AccountType = new List <AccountType>() { AccountType.Kols } }; await ViewbagData(); return(View("CreateTarget", paymentModel)); } return(View("Create", model)); //await ViewbagData(); //return View(model); }
public async Task <IActionResult> CreateTarget(CreateCampaignTargetViewModel model) { if (ModelState.IsValid) { var valid = true; if (valid) { var info = JsonConvert.DeserializeObject <CreateCampaignInfoViewModel>(model.InfoModel); var id = await _campaignService.CreateCampaign(CurrentUser.Id, info, model, CurrentUser.Username); if (id > 0) { if (model.AccountIds != null) { var accountids = model.AccountIds.Distinct().ToList(); for (var i = 0; i < accountids.Count; i++) { var amount = model.AmountMax; //model.AccountType.Contains(AccountType.Regular) ? model.AccountChargeAmount ?? 0 : model.AccountChargeAmounts[i]; //Anh Long sửa lại, không cần thiết phải BackgroundJob await _campaignService.CreateCampaignAccount(CurrentUser.Id, id, accountids[i], amount, CurrentUser.Username); //BackgroundJob.Enqueue<ICampaignService>(m => m.CreateCampaignAccount(CurrentUser.Id, id, accountids[i], amount, CurrentUser.Username)); } } //########### Longhk add create notification ########################################################## string _msg = string.Format("Chiến dịch \"{0}\" đã được tạo bởi \"{1}\".", info.Title, CurrentUser.Name); string _data = "Campaign"; await _notificationService.CreateNotification(id, EntityType.System, 0, NotificationType.CampaignCreated, _msg, _data); //##################################################################################################### TempData["MessageSuccess"] = "Tạo chiến dịch thành công, bạn vui lòng chờ hệ thống duyệt chiến dịch của bạn!"; return(RedirectToAction("Details", new { id = id })); } else { TempData["MessageError"] = "Lỗi khi tạo chiến dịch vui lòng thử lại"; } } } await ViewbagData(); return(View("CreateTarget", model)); //await ViewbagData(); //return View(model); }