Exemple #1
0
        /// <inheritdoc/>
        /// <param name="group">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override Task ExecuteAsync(GroupDto group)
        {
            if (!CanExecute(group))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <GroupValidator>();

            validator.ValidateAndThrow(group, nameof(GroupDto.Id));

            var repository = _repositoryFactory.GetRepository <Core.Group>();

            using (var transaction = repository.GetTransaction())
            {
                var groupEntity = _mapper.Map <Core.Group>(group);

                repository.Delete(groupEntity);

                return(transaction.CommitAsync());
            }
        }
Exemple #2
0
        /// <inheritdoc/>
        /// <param name="task">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override AsyncOperation ExecuteAsync(TaskDto task)
        {
            if (!CanExecute(task))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <TaskValidator>();

            validator.ValidateAndThrow(task);

            var repository = _repositoryFactory.GetRepository <Core.Task>();

            using (var transaction = repository.GetTransaction())
            {
                var taskEntity = _mapper.Map <Core.Task>(task);

                repository.Add(taskEntity);

                return(transaction.CommitAsync());
            }
        }
Exemple #3
0
        /// <inheritdoc/>
        /// <param name="template">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override Task ExecuteAsync(TaskExportTemplateDto template)
        {
            if (!CanExecute(template))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <TemplateValidator>();

            validator.ValidateAndThrow(template, nameof(TaskExportTemplateDto.Id));

            var repository = _repositoryFactory.GetRepository <Description>();

            using (var transaction = repository.GetTransaction())
            {
                var templateEntity = _mapper.Map <Description>(template);

                repository.Delete(templateEntity);

                return(transaction.CommitAsync());
            }
        }
Exemple #4
0
        /// <inheritdoc/>
        /// <param name="taskSchedule">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override Task ExecuteAsync(TasksScheduleDto taskSchedule)
        {
            if (!CanExecute(taskSchedule))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <TasksScheduleValidator>();

            validator.ValidateAndThrow(taskSchedule, nameof(TasksScheduleDto.Id));

            var repository = _repositoryFactory.GetRepository <Core.TasksSchedule>();

            using (var transaction = repository.GetTransaction())
            {
                var taskEntity = _mapper.Map <Core.TasksSchedule>(taskSchedule);

                repository.Delete(taskEntity);

                return(transaction.CommitAsync());
            }
        }
Exemple #5
0
        /// <inheritdoc/>
        /// <param name="schedule">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override Task ExecuteAsync(ScheduleDto schedule)
        {
            if (!CanExecute(schedule))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <ScheduleValidator>();

            validator.ValidateAndThrow(schedule);

            var repository = _repositoryFactory.GetRepository <Core.Schedule>();

            using (var transaction = repository.GetTransaction())
            {
                var scheduleEntity = _mapper.Map <Core.Schedule>(schedule);

                repository.Update(scheduleEntity);

                return(transaction.CommitAsync());
            }
        }
Exemple #6
0
        /// <inheritdoc/>
        /// <param name="taskSchedule">Nullable parameter.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ValidationException"/>
        public override Task ExecuteAsync(TasksScheduleDto taskSchedule)
        {
            if (!CanExecute(taskSchedule))
            {
                return(Task.CompletedTask);
            }

            var validator = _validatorFactory.GetInstance <TasksScheduleValidator>();

            validator.ValidateAndThrow(taskSchedule, $"default,{nameof(TasksScheduleDto.Id)}");

            var repository = _repositoryFactory.GetRepository <Core.TasksSchedule>();

            using (var transaction = repository.GetTransaction())
            {
                var taskEntity = _mapper.Map <Core.TasksSchedule>(taskSchedule);

                taskEntity.TimeEnd = TimeSpan.FromSeconds(5); //TODO: implement logic.

                repository.Update(taskEntity);

                return(transaction.CommitAsync());
            }
        }