public async Task <ActionResult> Create( string clubInitials, BoatClass model) { try { var clubId = await _clubService.GetClubId(clubInitials); if (!await _authService.CanUserEdit(User, clubId)) { return(Forbid()); } model.ClubId = clubId; if (!ModelState.IsValid) { return(View(model)); } await _classService.SaveNew(model); return(RedirectToAction("Index", "Admin")); } catch { ModelState.AddModelError(String.Empty, "An error occurred saving these changes."); return(View(model)); } }
private SsObjects.BoatClass MakeNewBoatClass(SsObjects.Club club) { // Get Name and initials: Console.Write("Enter the new class name > "); var className = Console.ReadLine().Trim(); SsObjects.BoatClass boatClass = new SsObjects.BoatClass { Id = Guid.NewGuid(), Name = className, ClubId = club.Id }; try { var createTask = _coreClassService.SaveNew(boatClass); createTask.Wait(); //createTask.GetAwaiter().GetResult(); } catch (Exception ex) { Console.WriteLine($"Oh Noes! There was an exception: {ex}"); } return(boatClass); }