public IActionResult AddCampaign([Bind(nameof(CreateCampaignModel.Name), nameof(CreateCampaignModel.Subject), nameof(CreateCampaignModel.Body), nameof(CreateCampaignModel.Datetime), nameof(CreateCampaignModel.GroupId), nameof(CreateCampaignModel.Status))] CreateCampaignModel model) { if (ModelState.IsValid) { try { model.Create(); model.Response = new ResponseModel("Insert Successfull", ResponseType.Success); return(RedirectToAction("index")); } catch (DuplicationException message) { model.Response = new ResponseModel(message.Message, ResponseType.Failure); } catch (Exception ex) { model.Response = new ResponseModel("Insert Failed.", ResponseType.Failure); // error logger code } } return(View(model)); }
public IActionResult Create() { var model = new CreateCampaignModel { Sources = _mapper.Map <List <SourceDTO>, List <SourceModel> >(SendQuery <GetSourcesQuery, IEnumerable <SourceDTO> >(new GetSourcesQuery()).ToList()), CharacterGenOptionModels = _mapper.Map <List <CharacterGenerationMethodDTO>, List <CharacterGenerationMethodModel> >(SendQuery <GetCharacterGenerationOptionsQuery, IEnumerable <CharacterGenerationMethodDTO> >(new GetCharacterGenerationOptionsQuery()).ToList()) }; return(View(model)); }
public async Task <ActionResult <CampaignCreatedModel> > CreateAndEdit([FromBody] CreateCampaignModel model) { var operationResult = await _campaignModule.CreateAndEdit(model); if (operationResult.Result != OperationResult.Ok) { return(BadRequest(operationResult)); } return(Ok(operationResult)); }
public IActionResult Create(CreateCampaignModel model) { var result = SendCommand(new CreateCampaignCommand { Name = model.Name, Description = model.Description, CharacterGenerationMethodId = model.SelectedCharacterGenOptionId, NewCharacterStartingLevel = model.NewCharacterStartingLevel, Sources = model.Sources.Where(n => n.IsSelected).Select(n => n.Id).ToList() }); var campaignId = Encrypt(result.NewRecordId.ToString()); return(RedirectToAction(nameof(Details), new { campaignId })); }
public async Task<ResultModel<CampaignCreatedModel>> CreateAndEdit(CreateCampaignModel campaignModel) { var action = "edit"; try { using (HttpClient client = new HttpClient()) { var parameters = new List<KeyValuePair<string, string>>(); if (campaignModel.CampaignID.HasValue) { parameters.Add(new KeyValuePair<string, string>("CampaignID", campaignModel.CampaignID.Value.ToString())); } if (!string.IsNullOrEmpty(campaignModel.CampaignName)) { parameters.Add(new KeyValuePair<string, string>("CampaignName", campaignModel.CampaignName)); } if (!string.IsNullOrEmpty(campaignModel.CampaignSubject)) { parameters.Add(new KeyValuePair<string, string>("CampaignSubject", campaignModel.CampaignSubject)); } foreach (var mailList in campaignModel.MailListsIds) { parameters.Add(new KeyValuePair<string, string>("MailListsIds[]", mailList.ToString())); } if (campaignModel.FromId.HasValue) { parameters.Add(new KeyValuePair<string, string>("FromID", campaignModel.FromId.Value.ToString())); } if (campaignModel.ReplyToId.HasValue) { parameters.Add(new KeyValuePair<string, string>("ReplyToID", campaignModel.ReplyToId.Value.ToString())); } parameters.Add(new KeyValuePair<string, string>("TrackLinkClicks", Convert.ToInt32(campaignModel.TrackLinkClicks).ToString())); parameters.Add(new KeyValuePair<string, string>("TrackReads", Convert.ToInt32(campaignModel.TrackReads).ToString())); parameters.Add(new KeyValuePair<string, string>("TrackAnalitics", Convert.ToInt32(campaignModel.TrackAnalitics).ToString())); parameters.Add(new KeyValuePair<string, string>("SendStateReport", Convert.ToInt32(campaignModel.SendStateReport).ToString())); parameters.Add(new KeyValuePair<string, string>("ScheduleCampaign", Convert.ToInt32(campaignModel.ScheduleCampaign).ToString())); if (campaignModel.SendDate.HasValue) { parameters.Add(new KeyValuePair<string, string>("SendDate", campaignModel.SendDate.Value.ToString("yyyy-MM-dd HH:mm:ss"))); } if (!campaignModel.DontSendNow) { parameters.Add(new KeyValuePair<string, string>("SendNow", "1")); } var formContent = new FormUrlEncodedContent(parameters); var url = String.Format("{0}/{1}/{2}?{3}&{4}", _baseUri.GetURI(), _modulo, action, _baseUri.GetAPIKEY(), _baseUri.GetFormat()); HttpResponseMessage response = await client.PostAsync(url, formContent); response.EnsureSuccessStatusCode(); string json = await response.Content.ReadAsStringAsync(); JObject rss = JObject.Parse(json); try { JToken item = rss["root"]["ajaxResponse"]["campaign"]; CampaignCreatedModel campaingCreatedModel = new CampaignCreatedModel(); campaingCreatedModel = item.ToObject<CampaignCreatedModel>(); return new SuccessResultModel<CampaignCreatedModel>(campaingCreatedModel); } catch { JToken item = rss["root"]["ajaxResponse"]["errors"]; return new ErrorResultModel<CampaignCreatedModel>(item.ToString()); } } } catch (Exception e) { return new ErrorResultModel<CampaignCreatedModel>(e.Message); } }
public IActionResult AddCampaign() { var model = new CreateCampaignModel(); return(View(model)); }
public ActionResult Create(CreateCampaignModel model) { return(AsView(Handler.Get <CreateCampaignHandler>().Handle(model), RedirectToAction("Index", "Campaign"), CreateModel(model))); }
/// <summary> /// /// Pomocné volání kvůli validacím /// </summary> /// <param name="id">Id</param> /// <returns>View</returns> protected ActionResult CreateModel(CreateCampaignModel model) { return(AsView(Handler.Get <CreateCampaignBuilder>().Build(model))); }
public CampaingWithContentRequestModel() { Campaign = new CreateCampaignModel(); Content = new ContentModel(); }