示例#1
0
        /// <summary>
        /// Remove project handler.
        /// </summary>
        /// <param name="command">Command.</param>
        /// <param name="uowFactory">Application unit of work factory.</param>
        public void HandleRemoveProject(RemoveProjectCommand command, IAppUnitOfWorkFactory uowFactory)
        {
            using (var uow = uowFactory.Create())
            {
                var project = uow.ProjectRepository.Get(command.ProjectId);

                if (project.User.Id != command.UpdatedByUserId)
                {
                    throw new ForbiddenException("Only user who created project can remove it.");
                }

                uow.TaskRepository.RemoveRange(uow.TaskRepository.Where(t => t.Project.Id == project.Id));
                uow.ProjectRepository.Remove(project);
                uow.SaveChanges();
            }
        }
示例#2
0
        public void Remove(Guid id)
        {
            var removeCommand = new RemoveProjectCommand(id);

            mediatorHandler.SendCommand(removeCommand);
        }