public async Task <IActionResult> AddSpeaker(SpeakerBindingModel speakerBindingModel) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var subjectModel = await _subjectService.GetSubjectByIdAsync(speakerBindingModel.SubjectId); if (subjectModel == null) { return(BadRequest("Could not find the subject.")); } var speakerModel = new SpeakerModel { SubjectModel = subjectModel, FirstName = speakerBindingModel.FirstName, LastName = speakerBindingModel.LastName, Email = speakerBindingModel.Email, Title = speakerBindingModel.Title }; var successful = await _speakerService.AddSpeakerAsync(speakerModel); if (!successful) { return(BadRequest("Could not add the room")); } return(RedirectToAction("Index")); }
public async Task <SpeakerVm> AddSpeakerAsync(SpeakerVm speaker) { var result = await _speakerService.AddSpeakerAsync(speaker).ConfigureAwait(false); _cache.Remove(nameof(GetAllSpeakersAsync)); return(result); }
public Task <SpeakerVm> AddSpeaker([FromBody] SpeakerVm speaker) => _speakerService.AddSpeakerAsync(speaker);