private void TryParseParametersForOrderAndTake(string takeCommand, string takeQuantity, string courseName, string comparison) { if (takeCommand == "take") { if (takeQuantity == "all") { repository.OrderAndTake(courseName, comparison, null); } else { int studentsToTake; var hasParsed = int.TryParse(takeQuantity, out studentsToTake); if (hasParsed) { repository.OrderAndTake(courseName, comparison, studentsToTake); } else { OutputWriter.WriteMessageOnNewLine(ExceptionMessages.InvalidTakeQueryParamter); } } } else { OutputWriter.WriteMessageOnNewLine(ExceptionMessages.InvalidTakeQueryParamter); } }
private static void TryParseParametersForOrderAndTake(string takeCommand, string takeQuantity, string courseName, string filter) { if (takeCommand == "take") { if (takeQuantity == "all") { StudentsRepository.OrderAndTake(courseName, filter); } else { int studentsToTake; bool hasParsed = int.TryParse(takeQuantity, out studentsToTake); if (hasParsed) { StudentsRepository.OrderAndTake(courseName, filter, studentsToTake); } else { OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter); } } } else { OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter); } }
private static void TryParseParametersForOrderAndTake(string orderCommand, string orderQuantity, string courseName, string orderType) { if (orderCommand.Equals("take")) { if (orderQuantity.Equals("all")) { StudentsRepository.OrderAndTake(courseName, orderType); } else { bool hasParsed = int.TryParse(orderQuantity, out int studentsToTake); if (hasParsed) { StudentsRepository.OrderAndTake(courseName, orderType, studentsToTake); } else { OutputWriter.DisplayException(ExceptionMessages.InvalidTakeQuantityParameter); } } } else { OutputWriter.DisplayException(ExceptionMessages.InvalidTakeCommand); } }
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); } }