public async Task <IActionResult> EditTarget(EditCampaignTargetViewModel model) { if (ModelState.IsValid) { var r = await _campaignService.EditCampaignTarget(model, CurrentUser.Username); this.AddAlert(r); if (r) { await _campaignService.RemoveCampaignAccount(model.Id); if (model.EnabledAccount && 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, model.Id, accountids[i], amount, CurrentUser.Username); //BackgroundJob.Enqueue<ICampaignService>(m => m.CreateCampaignAccount(CurrentUser.Id, model.Id, accountids[i], amount, CurrentUser.Username)); } } } return(RedirectToAction("Details", new { id = model.Id })); } await ViewbagData(); return(View(model)); }