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 Edit(TalkDto incomingModel) { if (incomingModel.Id > 0) { if (ModelState.IsValid) { Talk model = new Talk(); model = mapper.Map <Talk>(incomingModel); service.Update(model); service.Save(); return(RedirectToAction("List", "Talk")); } } return(View(incomingModel)); }
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 ActionResult Delete(int id, TalksViewModel model) { Talks talkToDelete = new Talks(); talkToDelete = talkService.GetTalkById(id); model.InjectFrom(talkToDelete); talkService.Delete(talkToDelete); talkService.Save(); return(RedirectToAction(nameof(Index))); }