public ActionResult <SpeakerDto> Create(TalkDto talkDto) { var model = mapper.Map <Talk>(talkDto); service.Add(model); service.Save(); var talkRead = mapper.Map <TalkDto>(model); return(CreatedAtRoute(nameof(GetById), new { Id = talkDto.ID }, talkRead)); }
public IActionResult Create(TalkDto model) { if (ModelState.IsValid) { Talk newTalk = new Talk(); newTalk = mapper.Map <Talk>(model); service.Add(newTalk); service.Save(); return(RedirectToAction("List", "Talk")); } return(View(model)); }
public ActionResult Create(TalkDto model) { if (ModelState.IsValid) { //create a new Speaker Talk newTalk = new Talk(); newTalk = mapper.Map <Talk>(model); service.Add(newTalk); ////save speaker service.Save(); //redirect to List return(RedirectToAction("List", "Talks")); } return(View(model)); }
public IActionResult AddTalk([FromBody] Talk talk) { return(Ok(talkServices.Add(talk))); }