예제 #1
0
        public TaskListItemViewModel Create(TaskEditModel editModel)
        {
            TaskDefinition definition = _taskDefinitionDAO.Get(editModel.DefinitionId);

            TimeSpan allowedExposureTime = new TimeSpanFactory().CreateFromStrings(editModel.Hours, editModel.Minutes);

            Task task = new Task()
            {
                Title                  = editModel.Title,
                Role                   = _roleDAO.Get(editModel.RoleId),
                NoiseProtection        = _noiseProtectionDAO.Get(editModel.NoiseProtectionId),
                NoiseLevelGuideline    = Convert.ToDecimal(editModel.NoiseLevelGuideline.Trim(), new CultureInfo("en-US")),
                Frequency              = editModel.Frequency,
                AllowedExposureMinutes = Convert.ToInt32(allowedExposureTime.TotalMinutes),
                TaskDefinition         = definition,
                ButtonPressed          = editModel.ButtonPressed,
                CultureName            = editModel.SelectedCultureName,
            };

            definition.Tasks.Add(task);

            _taskDefinitionDAO.Store(definition);

            TaskListItemViewModel viewModel = CreateTaskListItemViewModel(task);

            return(viewModel);
        }
        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);
        }