public async Task <IActionResult> CreateCaptainAsync(RosterCaptainViewModel viewModel) { try { if (!ModelState.IsValid) { StatusMessage = "ModelState is invalid"; return(RedirectToAction("CreateCaptainAsync")); } var result = await _adminService.AssignTeamCaptain(viewModel.Captain); if (result) { StatusMessage = "You have assigned the new captain"; return(RedirectToAction("CreateCaptainAsync")); } } catch (Exception e) { _logger.LogError(e, "error on assigning captain, da f**k Ryan"); } StatusMessage = "Error assigning captain"; return(RedirectToAction("Index")); }
public async Task <IActionResult> CreateCaptainAsync() { var rosters = await _adminService.GetAllRosters(); var model = new RosterCaptainViewModel { Rosters = rosters, StatusMessage = StatusMessage }; return(View(model)); }