public PartialViewResult AddTaskRegular(RegularViewModel viewModel) { var task = _taskDAO.GetFilteredByCurrentCulture(viewModel.TaskId); var validationViewModel = ValidateInput(viewModel, task); if (validationViewModel.ValidationErrors.Count > 0) { Response.StatusCode = 500; return(PartialView("_ValidationErrorSummary", validationViewModel)); } var selectedTask = CreateSelectedTaskRegular(viewModel, task); _selectedTaskDAO.Store(selectedTask); return(PartialView("_SelectedTask", new SelectedTaskViewModel(selectedTask))); }
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)); }
public ActionResult AddTaskHelideck(HelideckViewModel viewModel) { var task = _taskDAO.Get(viewModel.TaskId); var validationViewModel = ValidateInput(viewModel); if (validationViewModel.ValidationErrors.Count > 0) { Response.StatusCode = 500; return(PartialView("_ValidationErrorSummary", validationViewModel)); } var noiseProtection = _noiseProtectionDAO.Get(viewModel.NoiseProtectionId); var helicopterTask = _helicopterTaskDAO.Get(viewModel.HelicopterId, task.Id); var selectedTask = new SelectedTask { NoiseLevel = task.NoiseLevelGuideline, ButtonPressed = task.ButtonPressed, NoiseProtectionId = viewModel.NoiseProtectionId, Title = string.Format("{0} - {1}", task.Title, helicopterTask.HelicopterType.Title), Role = task.Role.Title, NoiseProtection = noiseProtection.Title, Percentage = (int)CalculatePercentage(helicopterTask.NoiseLevel, task.ButtonPressed, 0, noiseProtection, new TimeSpan(0, 0, task.AllowedExposureMinutes, 0)), Minutes = task.AllowedExposureMinutes, Task = task, HelicopterTaskId = helicopterTask.Id, CreatedBy = string.IsNullOrEmpty(User.Identity.Name) ? Session.SessionID : User.Identity.Name, CreatedDate = DateTime.Now.Date, IsNoiseMeassured = false }; _selectedTaskDAO.Store(selectedTask); return(PartialView("_SelectedTask", new SelectedTaskViewModel(selectedTask))); }