public RotationTaskViewModel EditRotationTaskForm(int id) { Rotation rotation = _rotationDAO.Get(id); IList <SelectOptionViewModel> languages = new LanguageListBuilder().CreateSelectedLanguageList(rotation.Task.CultureName); RotationTaskViewModel viewModel = new RotationTaskViewModel(languages) { Id = rotation.Id, TaskDefinitionId = rotation.Task.TaskDefinition.Id, Title = rotation.Task.Title }; AddTaskListsToViewModel(viewModel, rotation); return(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)); }