public ActionResult Generate(GenerateRectangleInput model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                var grid = gridService.InitialiseWithRectanglesOfRandomSize(model.NumberOfRectangles);
                return(File(Encoding.UTF8.GetBytes(grid.ToStringUsingDimensionsOfRectangles()), "text/plain", "rectangle-dimensions.txt"));
            }
            catch (LogicException ex)
            {
                ModelState.AddLogicErrors(ex);
                return(View(model));
            }
        }
        public ActionResult Upload(UploadInput input)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            try
            {
                using (var streamReader = new StreamReader(input.RectanglesFile.InputStream))
                {
                    var rectanglesString = streamReader.ReadToEnd();
                    var grid             = gridService.InitialiseGridFromString(rectanglesString);

                    var model = new SolutionRectanglesDisplay(grid, grid.GetMinimumVerticallyStackedRectangles());
                    return(View("Solution", model));
                }
            }
            catch (LogicException ex)
            {
                ModelState.AddLogicErrors(ex);
                return(View(input));
            }
        }