public RotationTaskListItemViewModel Create(RotationTaskEditModel editModel)
        {
            Rotation rotation = new Rotation()
            {
                OperatorTask  = _taskDAO.Get(editModel.OperatorTaskId),
                AssistantTask = _taskDAO.Get(editModel.AssistantTaskId)
            };

            Task task = new Task()
            {
                CultureName            = editModel.SelectedCultureName,
                Title                  = editModel.Title,
                AllowedExposureMinutes = 0,
                NoiseLevelGuideline    = 0,
                TaskDefinition         = _taskDefinitionDAO.Load(editModel.TaskDefinitionId),
                Role            = _roleDAO.Get("Rotation", Thread.CurrentThread.CurrentCulture.Name),
                NoiseProtection = rotation.OperatorTask.NoiseProtection
            };

            rotation.Task = task;

            _rotationDAO.Store(rotation);

            RotationTaskListItemViewModel viewModel = CreateTableRowViewModel(rotation);

            return(viewModel);
        }
Exemple #2
0
        public TaskViewModel EditGenericTaskForm(int id)
        {
            Task task = _taskDAO.Get(id);

            IList <SelectOptionViewModel> roles            = new List <SelectOptionViewModel>();
            IList <SelectOptionViewModel> noiseProtections = new List <SelectOptionViewModel>();

            roles.Add(new SelectOptionViewModel(TaskResources.SelectOne, "0"));
            foreach (Role role in _roleDAO.GetAllFilteredByCurrentCulture())
            {
                // We want separate handling for rotation tasks, as the view should be quite different
                if (role.RoleType != RoleTypeEnum.Rotation)
                {
                    roles.Add(new SelectOptionViewModel(role.Title, role.Id.ToString(CultureInfo.InvariantCulture))
                    {
                        IsSelected = (role.RoleDefinition.Id == task.Role.RoleDefinition.Id)
                    });
                }
            }

            noiseProtections.Add(new SelectOptionViewModel(TaskResources.SelectOne, "0"));
            foreach (NoiseProtection noiseProtection in _noiseProtectionDAO.GetAllFilteredByCurrentCulture())
            {
                var selectOption = new SelectOptionViewModel(noiseProtection.Title, noiseProtection.Id.ToString(CultureInfo.InvariantCulture))
                {
                    IsSelected = (noiseProtection.NoiseProtectionDefinition.Id == task.NoiseProtection.NoiseProtectionDefinition.Id)
                };
                noiseProtections.Add(selectOption);
            }

            TimeSpan allowedExposureTime = new TimeSpanFactory().CreateFromMinutes(task.AllowedExposureMinutes);

            IList <SelectOptionViewModel> languages = new LanguageListBuilder().CreateSelectedLanguageList(task.CultureName);
            TaskViewModel viewModel = new TaskViewModel(languages)
            {
                Id    = task.Id,
                Title = task.Title,
                NoiseLevelGuideline = task.NoiseLevelGuideline.ToString(CultureInfo.InvariantCulture),
                Frequency           = task.Frequency,
                Hours            = allowedExposureTime.Hours.ToString(CultureInfo.InvariantCulture),
                Minutes          = allowedExposureTime.Minutes.ToString(CultureInfo.InvariantCulture),
                DefinitionId     = task.TaskDefinition.Id,
                Roles            = roles,
                NoiseProtections = noiseProtections,
                ButtonPressed    = task.ButtonPressed
            };

            return(viewModel);
        }
Exemple #3
0
        public PartialViewResult AddTaskHelideck(int id)
        {
            var task = _taskDAO.Get(id);

            var viewModel = new HelideckViewModel
            {
                TaskId                      = task.Id,
                Title                       = task.Title,
                Role                        = task.Role.Title,
                RoleType                    = RoleTypeEnum.Helideck.ToString(),
                NoiseLevel                  = task.NoiseLevelGuideline,
                NoiseProtectionId           = task.NoiseProtection.Id,
                NoiseProtectionDefinitionId = task.NoiseProtection.NoiseProtectionDefinition.Id
            };

            AppendHelideckMasterData(viewModel);

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            return(PartialView("_CreateHelideckTask", viewModel));
        }
        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));
        }