private ValidationErrorSummaryViewModel ValidateInput(RotationViewModel viewModel, Rotation rotation) { var errorSummaryViewModel = new ValidationErrorSummaryViewModel(); if (viewModel.OperatorNoiseLevelMeasured - rotation.OperatorTask.NoiseLevelGuideline > 6) { errorSummaryViewModel.ValidationErrors.Add( TaskResources.ValidationErrorNoiseLevelToHighAboveGuidlineOperator); } if (viewModel.AssistantNoiseLevelMeasured - rotation.AssistantTask.NoiseLevelGuideline > 6) { errorSummaryViewModel.ValidationErrors.Add( TaskResources.ValidationErrorNoiseLevelToHighAboveGuidlineAssistant); } if (string.IsNullOrEmpty(viewModel.Hours) && string.IsNullOrEmpty(viewModel.Minutes)) { errorSummaryViewModel.ValidationErrors.Add(TaskResources.ValidationErrorWorkTimeRequiredRotation); } var timeSpan = CreateTimeSpan(viewModel.Hours, viewModel.Minutes); if (timeSpan.TotalHours > 6) { errorSummaryViewModel.ValidationErrors.Add(TaskResources.ValidationErrorRotationMaximum6Hours); } return(errorSummaryViewModel); }
private void OK(IDialogWindow window) { if (StepType == null) { return; } StepViewModel stepViewModel; switch (StepType.Content) { case "Delay": stepViewModel = new DelayViewModel(); break; case "Tilt": stepViewModel = new TiltViewModel(); break; case "Rotation": stepViewModel = new RotationViewModel(); break; case "Extension": stepViewModel = new ExtensionViewModel(); break; case "Home": stepViewModel = new HomeViewModel(); break; case "End Effector": stepViewModel = new EndEffectorViewModel(); break; default: stepViewModel = null; break; } CloseDialogWithResult(window, stepViewModel); }
public PartialViewResult AddTaskRotation(int id) { var task = _taskDAO.Get(id); var rotation = _rotationDAO.GetByTaskId(id); var viewModel = new RotationViewModel() { RotationId = rotation.Id, Title = task.Title, OperatorNoiseLevelGuideline = rotation.OperatorTask.NoiseLevelGuideline.ToString(), OperatorTitle = rotation.OperatorTask.Title, AssistantNoiseLevelGuideline = rotation.AssistantTask.NoiseLevelGuideline.ToString(), AssistantTitle = rotation.AssistantTask.Title, RadioNoiseMeassuredNoCheckedAttr = InputChecked, RadioTimeCheckedAttr = InputChecked, RoleType = RoleTypeEnum.Rotation.ToString() }; Response.Cache.SetCacheability(HttpCacheability.NoCache); return(PartialView("_CreateTask", viewModel)); }
public PartialViewResult AddTaskRotation(RotationViewModel viewModel) { var rotation = _rotationDAO.Get(viewModel.RotationId); var validationViewModel = ValidateInput(viewModel, rotation); if (validationViewModel.ValidationErrors.Count > 0) { Response.StatusCode = 500; return(PartialView("_ValidationErrorSummary", validationViewModel)); } var selectedTaskOperator = CreateSelectedTask(viewModel.OperatorNoiseLevelMeasured, rotation.OperatorTask); var selectedTaskAssistant = CreateSelectedTask(viewModel.AssistantNoiseLevelMeasured, rotation.AssistantTask); var noiseProtectionAssistant = _noiseProtectionDAO.Get(selectedTaskAssistant.NoiseProtectionId); var noiseProtectionOperator = _noiseProtectionDAO.Get(selectedTaskOperator.NoiseProtectionId); var timeSpan = new TimeSpan(CreateTimeSpan(viewModel.Hours, viewModel.Minutes).Ticks / 2); var percentageOperator = (int)Math.Round(rotation.OperatorTask.CalculatePercentage(selectedTaskOperator.Task.TaskDefinition.RoleType.ToString(), selectedTaskOperator.NoiseLevel, selectedTaskOperator.ButtonPressed, selectedTaskOperator.BackgroundNoise, selectedTaskOperator.Task.Frequency, noiseProtectionOperator, timeSpan)); var percentageAssistant = (int)Math.Round(rotation.AssistantTask.CalculatePercentage(selectedTaskAssistant.Task.TaskDefinition.RoleType.ToString(), selectedTaskAssistant.NoiseLevel, selectedTaskAssistant.ButtonPressed, selectedTaskAssistant.BackgroundNoise, selectedTaskOperator.Task.Frequency, noiseProtectionAssistant, timeSpan)); selectedTaskOperator.AddWorkTime(timeSpan, percentageOperator); selectedTaskAssistant.AddWorkTime(timeSpan, percentageAssistant); _selectedTaskDAO.Store(selectedTaskOperator); _selectedTaskDAO.Store(selectedTaskAssistant); var selectedTaskRotationViewModel = new SelectedTasksRotationViewModel { OperatorSelectedTaskViewModel = new SelectedTaskViewModel(selectedTaskOperator), AssistantSelectedTaskViewModel = new SelectedTaskViewModel(selectedTaskAssistant) }; return(PartialView("_SelectedTasksRotation", selectedTaskRotationViewModel)); }