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 <IActionResult> Create([FromBody] SpeakerBindingModel model) { var entity = _mapper.Map <Speaker>(model); entity.CreatedBy = UserId; await _repository.AddAsync(entity); return(Ok()); }
public async Task <IActionResult> AddSpeaker() { var subjects = await _subjectService.GetAllSubjectsAsync(); var subjectTitles = subjects .Select(x => new SelectListItem { Text = x.Title, Value = x.Id.ToString() }).ToList(); var speakerBindingModel = new SpeakerBindingModel { SubjectTitles = subjectTitles }; return(View(speakerBindingModel)); }
public async Task <IActionResult> Update([FromBody] SpeakerBindingModel model) { var entity = await _repository.FindAsync(model.Id); if (entity == null) { return(BadRequest(new BadRequestResponseModel(ErrorTypes.BadRequest, ErrorMessages.ItemNotFound))); } entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Title = model.Title; entity.CompanyName = model.CompanyName; entity.UpdatedBy = UserId; entity.UpdatedAt = DateTime.Now; await _repository.UpdateAsync(entity); return(Ok()); }