//bool CanGenerate(object parameter) //{ // return Generator.IsValid; //} void Generate(object parameter) { if (!Generator.IsValid) { //foreach (var det in Generator.ValidationDetails) // ValidationDetails.Add(det); Generator.ShowValidationDetailsMessage(); return; } for (var i = 0; i < Generator.ProcessesCount; i++) { var process = new ProcessViewModel { Name = ChangeName(), Prioritet = RandomHelper.Randomizer.Next(Generator.PriorityFrom, Generator.PriorityTo + 1), }; var stagesCount = RandomHelper.Randomizer.Next(Generator.StagesCountFrom, Generator.StagesCountTo + 1); var coercedStagesCount = stagesCount % 2 == 1 ? stagesCount : stagesCount - 1; for (var j = 0; j < coercedStagesCount; j++) { var stage = new StageViewModel { Time = RandomHelper.Randomizer.Next(Generator.StageTimeFrom, Generator.StageTimeTo + 1), }; process.Stages.Add(stage); } Processes.Add(process); } }
public static ProcessStage ToModel(this StageViewModel vm) { var res = new ProcessStage(vm.Time); return(res); }