コード例 #1
0
 private void TryParseParametersForFilterAndTake(string takeCommand, string takeQuantity, string courseName, string filter)
 {
     if (takeCommand == "take")
     {
         if (takeQuantity == "all")
         {
             repository.FilterAndTake(courseName, filter, null);
         }
         else
         {
             int studentsToTake;
             var hasParsed = int.TryParse(takeQuantity, out studentsToTake);
             if (hasParsed)
             {
                 repository.FilterAndTake(courseName, filter, studentsToTake);
             }
             else
             {
                 OutputWriter.WriteMessageOnNewLine(ExceptionMessages.InvalidTakeQueryParamter);
             }
         }
     }
     else
     {
         OutputWriter.WriteMessageOnNewLine(ExceptionMessages.InvalidTakeQueryParamter);
     }
 }
コード例 #2
0
ファイル: CommandInterpreter.cs プロジェクト: nayots/SoftUni
 private static void TryParseParametersForFilterAndTake(string takeCommand, string takeQuantity, string courseName, string filter)
 {
     if (takeCommand == "take")
     {
         if (takeQuantity == "all")
         {
             StudentsRepository.FilterAndTake(courseName, filter);
         }
         else
         {
             int  studentsToTake;
             bool hasParsed = int.TryParse(takeQuantity, out studentsToTake);
             if (hasParsed)
             {
                 StudentsRepository.FilterAndTake(courseName, filter, studentsToTake);
             }
             else
             {
                 OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter);
             }
         }
     }
     else
     {
         OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter);
     }
 }
コード例 #3
0
 private static void TryParseParametersForOrderAndTake(string takeCommand, string takeQuantity, string courseName, string comparison)
 {
     if (takeCommand == "take")
     {
         if (takeQuantity == "all")
         {
             StudentsRepository.OrderAndTake(courseName, comparison);
         }
         else
         {
             if (int.TryParse(takeQuantity, out int studentsToTake))
             {
                 StudentsRepository.FilterAndTake(courseName, comparison, studentsToTake);
             }
             else
             {
                 OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter);
             }
         }
     }
     else
     {
         OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter);
     }
 }