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));
        }
Пример #2
0
 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());
 }
Пример #3
0
 public IActionResult Create([FromBody] Speaker speaker)
 {
     speakerService.Add(speaker);
     speakerService.Save();
     return(Ok(speaker));
 }