Example #1
0
        public PartialViewResult EditTaskHelideck(int id)
        {
            var selectedTask = _selectedTaskDAO.Get(id);

            var helicopterTask = _helicopterTaskDAO.Get(selectedTask.HelicopterTaskId);

            var viewModel = new HelideckViewModel
            {
                NoiseProtectionId = selectedTask.NoiseProtectionId,
                TaskId            = selectedTask.Task.Id,
                SelectedTaskId    = selectedTask.Id,
                Title             = selectedTask.Task.Title,
                Role         = selectedTask.Task.Role.Title,
                RoleType     = RoleTypeEnum.Helideck.ToString(),
                HelicopterId = helicopterTask.HelicopterType.Id,
                NoiseLevel   = helicopterTask.NoiseLevel
            };

            viewModel.Helicopters.Add(new SelectListItem {
                Text = TaskResources.SelectOne, Value = "0"
            });
            foreach (var type in _helicopterTypeDAO.GetAll())
            {
                var selectListItem = new SelectListItem {
                    Text = type.Title, Value = type.Id.ToString()
                };
                if (viewModel.HelicopterId == type.Id)
                {
                    selectListItem.Selected = true;
                }

                viewModel.Helicopters.Add(selectListItem);
            }

            viewModel.NoiseProtection.Add(new SelectListItem {
                Text = TaskResources.SelectOne, Value = "0"
            });
            foreach (var noiseProtection in _noiseProtectionDAO.GetAllFilteredByCurrentCulture())
            {
                var selectListItem = new SelectListItem {
                    Text = noiseProtection.Title, Value = noiseProtection.Id.ToString()
                };
                if (viewModel.NoiseProtectionId == noiseProtection.Id)
                {
                    selectListItem.Selected = true;
                }

                viewModel.NoiseProtection.Add(selectListItem);
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            return(PartialView("_EditHelideckTask", viewModel));
        }
        public ActionResult GetRemoveTaskConfirmationDialog(int id)
        {
            var selectedTask = _selectedTaskDAO.Get(id);

            var viewModel = new RemoveConfirmationViewModel
            {
                Title          = selectedTask.Title,
                Role           = selectedTask.Role,
                SelectedTaskId = selectedTask.Id
            };

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            return(PartialView("_RemoveTaskConfirmation", viewModel));
        }
        public PartialViewResult EditTaskRegular(int id)
        {
            var selectedTask = _selectedTaskDAO.Get(id);

            var noiseLevelGuideLine = selectedTask.Task.NoiseLevelGuideline.ToString(CultureInfo.InvariantCulture);

            if (noiseLevelGuideLine.IndexOf(".", StringComparison.Ordinal) > 0)
            {
                noiseLevelGuideLine = noiseLevelGuideLine.Substring(0, noiseLevelGuideLine.IndexOf(".", StringComparison.Ordinal));
            }


            var viewModel = new RegularViewModel
            {
                TaskId              = selectedTask.Task.Id,
                SelectedTaskId      = selectedTask.Id,
                Title               = selectedTask.Task.Title,
                Role                = selectedTask.Task.Role.Title,
                RoleType            = selectedTask.Task.Role.RoleType.ToString(),
                NoiseLevelGuideline = noiseLevelGuideLine,
                NoiseLevelMeassured = selectedTask.NoiseLevel,
                NoiseProtectionId   = selectedTask.NoiseProtectionId,
                RadioNoiseMeassuredNoCheckedAttr  = selectedTask.IsNoiseMeassured ? InputNotChecked : InputChecked,
                RadioNoiseMeassuredYesCheckedAttr = selectedTask.IsNoiseMeassured ? InputChecked : InputNotChecked,
                RadioTimeCheckedAttr       = selectedTask.UsePercentage ? InputNotChecked : InputChecked,
                RadioPercentageCheckedAttr = selectedTask.UsePercentage ? InputChecked : InputNotChecked,
                ButtonPressed   = selectedTask.ButtonPressed,
                BackgroundNoise = selectedTask.BackgroundNoise == 0 ? "<80" : selectedTask.BackgroundNoise.ToString(CultureInfo.InvariantCulture),
                Hours           = selectedTask.UsePercentage ? "" : selectedTask.Hours.ToString(CultureInfo.InvariantCulture),
                Minutes         = selectedTask.UsePercentage ? "" : selectedTask.Minutes.ToString(CultureInfo.InvariantCulture),
                Percentage      = selectedTask.UsePercentage ? selectedTask.Percentage.ToString(CultureInfo.InvariantCulture) : ""
            };

            viewModel.NoiseProtection.Add(new SelectListItem {
                Text = TaskResources.SelectOne, Value = "0"
            });
            foreach (var noiseProtection in _noiseProtectionDAO.GetAllFilteredByCurrentCulture())
            {
                var selectListItem = new SelectListItem {
                    Text = noiseProtection.Title, Value = noiseProtection.Id.ToString(CultureInfo.InvariantCulture)
                };
                if (viewModel.NoiseProtectionId == noiseProtection.Id)
                {
                    selectListItem.Selected = true;
                }
                if (selectedTask.Task.Role.RoleType.ToString() == "AreaNoise")
                {
                    if (!selectListItem.Selected)
                    {
                        if (selectedTask.Task.Title.Contains("80") || selectedTask.Task.Title.Contains("85") ||
                            selectedTask.Task.Title.Contains("90"))
                        {
                            if (noiseProtection.NoiseProtectionDefinition.Id != 3 &&
                                selectedTask.Task.NoiseProtection.Id != noiseProtection.Id) // Quietpro
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (noiseProtection.NoiseProtectionDefinition.Id != 3 &&
                                noiseProtection.NoiseProtectionDefinition.Id != 2 &&
                                selectedTask.Task.NoiseProtection.Id != noiseProtection.Id)
                            {
                                // Quietpro and double hearing
                                continue;
                            }
                        }
                    }
                }
                viewModel.NoiseProtection.Add(selectListItem);
            }

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            return(PartialView("_EditRegularTask", viewModel));
        }