예제 #1
0
        public TaskViewModel CreateGenericTaskForm(int definitionId)
        {
            IList <SelectOptionViewModel> languages = new LanguageListBuilder().CreateSelectedLanguageList("0");
            TaskViewModel viewModel = new TaskViewModel(languages)
            {
                DefinitionId = definitionId
            };

            viewModel.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)
                {
                    viewModel.Roles.Add(new SelectOptionViewModel(role.Title, role.Id.ToString(CultureInfo.InvariantCulture)));
                }
            }

            viewModel.NoiseProtections.Add(new SelectOptionViewModel(TaskResources.SelectOne, "0"));
            foreach (NoiseProtection noiseProtection in _noiseProtectionDAO.GetAllFilteredByCurrentCulture())
            {
                viewModel.NoiseProtections.Add(new SelectOptionViewModel(noiseProtection.Title, noiseProtection.Id.ToString(CultureInfo.InvariantCulture)));
            }

            return(viewModel);
        }
        public RotationTaskViewModel CreateRotationTaskForm(int definitionId)
        {
            IList <SelectOptionViewModel> languages = new LanguageListBuilder().CreateSelectedLanguageList("0");
            RotationTaskViewModel         viewModel = new RotationTaskViewModel(languages)
            {
                TaskDefinitionId = definitionId
            };

            AddTaskListsToViewModel(viewModel, null);

            return(viewModel);
        }
예제 #3
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);
        }
        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);
        }