示例#1
0
        public ForageGenerationRequest GetForageGenerationRequest()
        {
            DisplayHeader(MainMenuOption.Generate.ToLabel());
            DateTime start = io.ReadDate("Select a start date [MM/dd/yyyy]: ");

            if (start > DateTime.Now)
            {
                DisplayStatus(false, "Start date must be in the past.");
                return(null);
            }

            DateTime end = io.ReadDate("Select an end date [MM/dd/yyyy]: ");

            if (end > DateTime.Now || end < start)
            {
                DisplayStatus(false, "End date must be in the past and after the start date.");
                return(null);
            }

            ForageGenerationRequest request = new ForageGenerationRequest();

            request.Start = start;
            request.End   = end;
            request.Count = io.ReadInt("Generate how many random forages [1-500]?: ", 1, 500);
            return(request);
        }
        private void Generate()
        {
            ForageGenerationRequest request = view.GetForageGenerationRequest();

            if (request != null)
            {
                int count = forageService.Generate(request.Start, request.End, request.Count);
                view.DisplayStatus(true, $"{count} forages generated.");
            }
        }