public async Task <ActionResult> CreateCampaign([Bind(Include = "idCampaign,name,idStateCampaign,urlImage,description,idProduct,startDate,endDate")] Campaign campaignz, string listStateCampaign) { long idStateCampaign = 0; Int64.TryParse(listStateCampaign, out idStateCampaign); campaignz.idStateCampaign = idStateCampaign; campaignz.idUser = 2; campaignz.modificationDate = DateTime.Now; Response message = new UtilitiesProject.Response(); CampaignService campaignService = new CampaignService(); if (ModelState.IsValid) { try { message = await campaignService.CreateCampaign(campaignz, Session["token"].ToString()); } catch (Exception exp) { log.Error("CampaignController/EditCampaign", exp); } } //return new JsonResult() //{ // JsonRequestBehavior = JsonRequestBehavior.AllowGet, // Data = new { success = true} //}; return(RedirectToAction("Index", "Campaign")); }
public async Task <IActionResult> CreateCampaign([FromBody] CreateCampaignRequest request) { var campaign = await CampaignService.CreateCampaign(request); await EventService.Publish(new CampaignCreatedEvent(campaign.ToCampaignQueueItem(request.SelectedUserCodes))); return(CreatedAtAction(nameof(GetCampaignById), new { campaignId = campaign.Id }, campaign)); }
public void When_Name_IsNull() { CreateCampaignInput createCampaignInput = new CreateCampaignInput(); Assert.Throws <ValidationException>(() => campaignService.CreateCampaign(createCampaignInput)); }
public async Task Create([FromBody] CampaignViewModel model) { await campaignService.CreateCampaign(model); }