public async Task <IActionResult> Save(AdminInputModel input) { LiveShowDetails liveShowDetails; if (!ModelState.IsValid) { // Model validation error, just return and let the error render liveShowDetails = await _liveShowDetails.LoadAsync(); var viewModel = new AdminViewModel(); UpdateAdminViewModel(viewModel, liveShowDetails); return(View(nameof(Index), viewModel)); } if (!string.IsNullOrEmpty(input.LiveShowEmbedUrl) && input.LiveShowEmbedUrl.StartsWith("http://")) { input.LiveShowEmbedUrl = "https://" + input.LiveShowEmbedUrl.Substring("http://".Length); } liveShowDetails = new LiveShowDetails(); liveShowDetails.LiveShowEmbedUrl = input.LiveShowEmbedUrl; liveShowDetails.LiveShowHtml = input.LiveShowHtml; liveShowDetails.NextShowDateUtc = input.NextShowDatePst?.ConvertFromPtcToUtc(); liveShowDetails.AdminMessage = input.AdminMessage; await _liveShowDetails.SaveAsync(liveShowDetails); TempData[nameof(AdminViewModel.SuccessMessage)] = "Live show details saved successfully!"; return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> CreateAdmin([FromBody] AdminInputModel model) { if (!ModelState.IsValid) { return(BadRequest()); } return(Ok(await _userService.CreateAdmin(model))); }
public async Task <IActionResult> RemoveRole(AdminInputModel input) { if ((await this.adminsServices.RemoveFromRoleAsync(input.UserName)) == false) { return(this.View(input)); } return(this.Redirect("/Administration/Admins/All")); }
private void TrackShowEvent(AdminInputModel input, LiveShowDetails liveShowDetails) { if (_telemetry.IsEnabled()) { var showStarted = string.IsNullOrEmpty(liveShowDetails.LiveShowEmbedUrl) && !string.IsNullOrEmpty(input.LiveShowEmbedUrl); var showEnded = !string.IsNullOrEmpty(liveShowDetails.LiveShowEmbedUrl) && string.IsNullOrEmpty(input.LiveShowEmbedUrl); if (showStarted || showEnded) { var showEvent = new EventTelemetry(showStarted ? "Show Started" : "Show Ended"); showEvent.Properties.Add("Show Embed URL", showStarted ? input.LiveShowEmbedUrl : liveShowDetails.LiveShowEmbedUrl); _telemetry.TrackEvent(showEvent); } } }
public async Task <ResponseViewModel> CreateAdmin(AdminInputModel model) { var department = _utilityRepository.DepartmentBy(model.DepartmentId); if (department == null) { return(Failed(ResponseMessageViewModel.INVALID_DEPARTMENT, ResponseErrorCodeStatus.INVALID_DEPARTMENT)); } model.IsAdmin = true; var result = await RegisterAsync(model); return(result); }
public async Task <IActionResult> Save(AdminInputModel input) { var liveShowDetails = await _liveShowDetails.LoadAsync() ?? new LiveShowDetails(); if (!ModelState.IsValid) { // Model validation error, just return and let the error render var viewModel = new AdminViewModel(); UpdateAdminViewModel(viewModel, liveShowDetails); return(View(nameof(Index), viewModel)); } if (!string.IsNullOrEmpty(input.LiveShowEmbedUrl)) { // Convert live show url to HTTPS if need be if (input.LiveShowEmbedUrl.StartsWith("http://")) { input.LiveShowEmbedUrl = "https://" + input.LiveShowEmbedUrl.Substring("http://".Length); } // Convert watch URL to embed URL if (input.LiveShowEmbedUrl.StartsWith("https://www.youtube.com/watch?v=", StringComparison.OrdinalIgnoreCase)) { var queryIndex = input.LiveShowEmbedUrl.LastIndexOf("?v=", StringComparison.OrdinalIgnoreCase); var showIdLength = input.LiveShowEmbedUrl.IndexOf('&', queryIndex) - 3 - queryIndex; var showId = showIdLength > 0 ? input.LiveShowEmbedUrl.Substring(queryIndex + 3, showIdLength) : input.LiveShowEmbedUrl.Substring(queryIndex + 3); input.LiveShowEmbedUrl = $"https://www.youtube.com/embed/{showId}"; } } TrackShowEvent(input, liveShowDetails); _mapper.Map(input, liveShowDetails); liveShowDetails.NextShowDateUtc = input.NextShowDatePst?.ConvertFromPtcToUtc(); await _liveShowDetails.SaveAsync(liveShowDetails); TempData[nameof(AdminViewModel.SuccessMessage)] = "Live show details saved successfully!"; return(RedirectToAction(nameof(Index))); }
public AdminViewModel Execute(AdminInputModel input) { return new AdminViewModel(); }