public async Task <IActionResult> OnGet() { var theSteps = await StepDataAccess.GetAllSteps(); Steps = theSteps.OrderBy(i => i.StepId).ToList(); return(Page()); }
//As of now, this will only get hit if a spec id is passed into the page. public async Task SetUpProperties(int?aSpecId) { if (aSpecId != null && aSpecId != 0) { int theSpecId = aSpecId ?? default(int); //The spec id passed into SpecDataAccess.GetHydratedCurrentRevOfSpec needs to be of type int, not int? var theCurrentSpec = await SpecDataAccess.GetHydratedCurrentRevOfSpec(theSpecId); var theCurrentSpecRev = theCurrentSpec.SpecRevModels.FirstOrDefault(); SpecCode = theCurrentSpec.Code; SpecDescription = theCurrentSpecRev.Description; ExternalRev = theCurrentSpecRev.ExternalRev; SamplePlanId = theCurrentSpecRev.SamplePlanId; theCurrentSpecRev.SubLevels.OrderBy(i => i.LevelSeq); foreach (var sublevel in theCurrentSpecRev.SubLevels) { BuildPageFromModels(sublevel); } } var tempAllSpecModels = await SpecDataAccess.GetAllHydratedSpecs(); AllSpecModels = tempAllSpecModels.ToList(); var tempAllSamplePlanModels = await SamplePlanDataAccess.GetAllHydratedSamplePlans(); AllSamplePlans = tempAllSamplePlanModels.ToList(); var tempAllStepModels = await StepDataAccess.GetAllSteps(); AllSteps = tempAllStepModels.ToList(); var tempAllStepCategoryModels = await StepDataAccess.GetAllStepCategoryies(); AllStepCategories = tempAllStepCategoryModels.ToList(); }
public async Task SetUpProperties(int aProcessId) { var theProcesses = await ProcessDataAccess.GetHydratedProcessesWithCurrentAnyRev(); AllProcesses = theProcesses.ToList(); foreach (var process in AllProcesses) { process.Revisions.OrderByDescending(i => i.ProcessRevId); } var theSteps = await StepDataAccess.GetAllSteps(); AllSteps = theSteps.OrderBy(i => i.StepName).ToList(); var theOperations = await OperationDataAccess.GetAllOperations(); AllOperations = theOperations.OrderBy(i => i.Name).ToList(); CurrentProcess = new ProcessModel(); //This needs to be created even if there isn't a process being passed in so the front-end doesn't throw a null reference exception when looking for a name. CurrentRev = new ProcessRevisionModel(); //This also needs to be created right away so the front-end doesn't throw a null reference exception when loading the current step list. CurrentRev.StepSeqs = new List <StepSeqModel>(); CurrentStepIds = null; CurrentOperationIds = null; if (aProcessId > 0) { CurrentProcess = AllProcesses.FirstOrDefault(i => i.ProcessId == aProcessId); CurrentProcessId = aProcessId; if (CurrentProcess.Revisions.Any()) { ModelState.Remove("CurrentRevId"); //The input field wasn't updating when deleting an unlocked revision. This clears the model state for just this property CurrentRev = CurrentProcess.Revisions.OrderByDescending(i => i.ProcessRevId).FirstOrDefault(); CurrentRevId = CurrentRev.ProcessRevId; Comment = CurrentRev.Comments; EmpCreatedCurrentRev = await EmployeeDataAccess.GetEmployeeById(CurrentRev.CreatedByEmp); CurrentOperations = new List <OperationModel>(); //Finds each unique operation within the revision's steps and loads it into CurrentOperations. foreach (var stepSeq in CurrentRev.StepSeqs) { var shouldThisStepBeAdded = true; foreach (var operation in CurrentOperations) { if (operation.Id == stepSeq.Operation.Id) { shouldThisStepBeAdded = false; } } if (shouldThisStepBeAdded) { CurrentOperations.Add(stepSeq.Operation); } } } else { ModelState.Remove("CurrentRevId"); //The input field wasn't updating when deleting an unlocked revision. This clears the model state for just this property CurrentRevId = 0; } } }