public ActionResult <SpeakerDto> CreateSpeaker(SpeakerDto speakerDto) { var model = mapper.Map <Speaker>(speakerDto); service.Add(model); service.Save(); var speakerRead = mapper.Map <SpeakerDto>(model); return(CreatedAtRoute(nameof(GetById), new { Id = speakerDto.ID }, speakerRead)); }
public IActionResult Create(SpeakerDto model) { if (ModelState.IsValid) { Speaker newSpeaker = new Speaker(); newSpeaker = mapper.Map <Speaker>(model); service.Add(newSpeaker); service.Save(); return(RedirectToAction("List", "Speakers")); } return(View()); }
public IActionResult Create([FromBody] Speaker speaker) { speakerService.Add(speaker); speakerService.Save(); return(Ok(speaker)); }