/// <summary> /// Adds a record to the data source with information provided by the user /// </summary> /// <param name="skiRunRepository"></param> private static void AddSkiRun() { SkiRunBusiness skiRunBusiness = new SkiRunBusiness(skiRunRepository); //Variable Declarations. SkiRun aSkiRun = new SkiRun(); ConsoleView.DisplayReset(); //Get the ID, Name, and Vertical feet from the user. aSkiRun.ID = ConsoleView.GetIntegerFromUser("Enter the ID for the Ski Run: "); aSkiRun.Name = ConsoleView.GetUserResponse("Enter the name for the Ski Run: "); aSkiRun.Vertical = ConsoleView.GetIntegerFromUser("Enter the vertical (in feet) for the Ski Run: "); using (skiRunBusiness) { //Insert the new ski run. try { //Insert the new record. skiRunRepository.Insert(aSkiRun); //Display a message to the user that the record was inserted. ConsoleView.DisplayReset(); ConsoleView.DisplayMessage($"The information for the {aSkiRun.Name} ski run has been saved."); ConsoleView.DisplayContinuePrompt(); } catch (Exception ex) { //Display the error message for the error that occurred. CatchIOExceptions(ex); } } }
public void Insert(SkiRun skiRun) { _skiRunRepository.Insert(skiRun); }