public IActionResult ScheduleInput(List <OperationViewModel> operations, [FromQuery] string myMethod = null)
        {
            for (int i = 0; i < operations.Count; i++)
            {
                if (operations[i].Deadline <= 0 || operations[i].Penalty <= 0 || operations[i].Deadline.GetType() != typeof(int) || operations[i].Penalty.GetType() != typeof(int))
                {
                    return(View("Error", "Deadlines or Penalties cannot be 0 or negative or not integer"));
                }

                operations[i].Id = i + 1;
            }
            ManualInputViewModel manual = new ManualInputViewModel
            {
                NumberOfElements = operations.Count,
                Schedule         = new List <ScheduleViewModel>()
            };

            manual.Schedule.Add(new ScheduleViewModel()
            {
                operations = operations
            });


            return(View("ManualInput", manual));
        }
Example #2
0
        public IActionResult ManualInput(ManualInputViewModel manual)
        {
            List <OperationViewModel> operations = new List <OperationViewModel>();

            for (int i = 0; i < manual.NumberOfElements; i++)
            {
                operations.Add(new OperationViewModel());
            }

            List <ScheduleViewModel> schedules = new List <ScheduleViewModel>();

            schedules.Add(new ScheduleViewModel()
            {
                operations = operations
            });

            ManualInputViewModel manualInput = new ManualInputViewModel()
            {
                Schedule = schedules
            };

            for (int i = 0; i < manual.NumberOfElements * (manual.NumberOfPenalties + 1); i++)
            {
                manualInput.manualList.Add(0);
            }

            manualInput.manualList.Add(manual.NumberOfElements);
            manualInput.manualList.Add(manual.NumberOfPenalties);

            return(View("ManualInput", manualInput));
        }
        public IActionResult NumInput(int numOfElements)
        {
            if (numOfElements <= 0 || numOfElements.GetType() != typeof(int) || numOfElements > 10000)
            {
                return(View("Error", "The number of elements cannot be 0 or negative or not integer or greater than 10000"));
            }
            ManualInputViewModel manual = new ManualInputViewModel
            {
                NumberOfElements = numOfElements,
                Schedule         = new List <ScheduleViewModel>()
            };

            manual.Schedule.Add(new ScheduleViewModel());

            return(RedirectToAction("ManualInput", manual));
        }
Example #4
0
        public IActionResult NumInput(int numOfElements, int numOfPenalties)
        {
            if (numOfPenalties <= 0 || numOfElements <= 0 || numOfPenalties.GetType() != typeof(int) || numOfElements.GetType() != typeof(int) ||
                numOfElements > 10000 || numOfPenalties > 100)
            {
                return(View("Error", "The number of schedules and elements cannot be 0 or negative or not integer and the max bound of elements count is 10000 and the max bound of schedules is 100"));
            }
            ManualInputViewModel manual = new ManualInputViewModel
            {
                NumberOfElements  = numOfElements,
                NumberOfPenalties = numOfPenalties,
                Schedule          = new List <ScheduleViewModel>()
            };

            return(RedirectToAction("ManualInput", manual));
        }
Example #5
0
        public IActionResult ScheduleInput(List <int> list, [FromQuery] string myMethod = null)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] <= 0 || list[i].GetType() != typeof(int))
                {
                    return(View("Error", "Cells cannot be 0 or negative or integer"));
                }
            }

            int numOfElements  = list[list.Count - 2];
            int numOfPenalties = list[list.Count - 1];

            ManualInputViewModel manualInput = new ManualInputViewModel
            {
                NumberOfElements  = numOfElements,
                NumberOfPenalties = numOfPenalties,
                Schedule          = new List <ScheduleViewModel>(),
                manualList        = list
            };

            //  manual.Schedule.Add(new ScheduleViewModel() { operations = operations });

            for (int j = 0; j < numOfPenalties; j++)
            {
                manualInput.Schedule.Add(new ScheduleViewModel());
                int id = 1;
                for (int i = 0; i < list.Count - 2; i += numOfPenalties + 1)
                {
                    manualInput.Schedule[j].operations.Add(new OperationViewModel()
                    {
                        Id = id++, Deadline = list[i], Penalty = list[i + (j + 1)]
                    });
                }
            }

            return(View("ManualInput", manualInput));
        }
        public IActionResult ManualInput(ManualInputViewModel manual)
        {
            List <OperationViewModel> operations = new List <OperationViewModel>();

            for (int i = 0; i < manual.NumberOfElements; i++)
            {
                operations.Add(new OperationViewModel());
            }

            List <ScheduleViewModel> schedules = new List <ScheduleViewModel>();

            schedules.Add(new ScheduleViewModel()
            {
                operations = operations
            });

            ManualInputViewModel manualInput = new ManualInputViewModel()
            {
                NumberOfElements = operations.Count(),
                Schedule         = schedules
            };

            return(View("ManualInput", manualInput));
        }