async Task <IActionResult> UpsertSpeaker(SpeakerViewModel model, Speaker speaker, string moniker, string userName)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (speaker == null)
                    {
                        speaker          = Mapper.Map <Speaker>(model);
                        speaker.UserName = userName;
                        speaker.Event    = _repo.GetEventInfo(moniker);

                        // Send confirmation email on new speaker
                        var user = await _userMgr.FindByNameAsync(userName);

                        var speakerUrl = this.Url.Link("MySpeakerPage", new { moniker = moniker });
                        await _mailService.SendTemplateMailAsync(
                            "SpeakerSignUp",
                            new SpeakerModel()
                        {
                            Name       = user.Name,
                            Email      = user.Email,
                            Subject    = $"Speaking at the {speaker.Event.Name}",
                            Speaker    = speaker,
                            SpeakerUrl = speakerUrl,
                            Event      = speaker.Event
                        });
                    }
                    else
                    {
                        Mapper.Map <SpeakerViewModel, Speaker>(model, speaker);
                    }

                    _repo.AddOrUpdate(speaker);
                    await _repo.SaveChangesAsync();

                    return(Ok(Mapper.Map <SpeakerViewModel>(speaker)));
                }
                catch (Exception ex)
                {
                    _logger.LogError("Failed to get update speaker: {0}", ex);
                    ModelState.AddModelError("", $"Failed to Save: {ex.Message}");
                }
            }
            _logger.LogError("Failed to get update speaker because of bad Model State: {0}", ModelState);
            return(BadRequest($"Failed to save Speaker: ModelState has Errors: #{ModelState.ErrorCount}"));
        }
        async Task <IActionResult> UpsertSpeaker(SpeakerViewModel model, Speaker speaker, string moniker, string userName)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (speaker == null)
                    {
                        speaker          = Mapper.Map <Speaker>(model);
                        speaker.UserName = userName;
                        speaker.Event    = _repo.GetEventInfo(moniker);

                        // Send confirmation email on new speaker
                        var user = await _userMgr.FindByNameAsync(userName);

                        var speakerUrl = this.Url.Link("MySpeakerPage", new { moniker = moniker });
                        await _mailService.SendTemplateMailAsync(user.Name,
                                                                 user.Email,
                                                                 $"Speaking at the {speaker.Event.Name}",
                                                                 "SpeakerSignUp",
                                                                 speaker.Event.Name,
                                                                 speaker.Event.CallForSpeakersClosed.ToShortDateString(),
                                                                 speakerUrl);
                    }
                    else
                    {
                        Mapper.Map <SpeakerViewModel, Speaker>(model, speaker);
                    }

                    _repo.AddOrUpdate(speaker);
                    await _repo.SaveChangesAsync();

                    return(Ok(Mapper.Map <SpeakerViewModel>(speaker)));
                }
                catch (Exception ex)
                {
                    _logger.LogError("Failed to get update speaker: {0}", ex);
                    ModelState.AddModelError("", $"Failed to Save: {ex.Message}");
                }
            }
            return(BadRequest("Failed to save Speaker"));
        }
        public async Task <IActionResult> Create(string moniker, [FromBody] Room model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var eventInfo = _repo.GetEventInfo(moniker);
                    if (eventInfo != null)
                    {
                        model.Event = eventInfo;
                        _repo.AddOrUpdate(model);
                        await _repo.SaveChangesAsync();

                        return(Created($"{moniker}/api/rooms/{model.Id}", model));
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError("Failed to save new Room: {0}", ex);
                }
            }

            return(BadRequest("Failed to save Room"));
        }