Esempio n. 1
0
        private DomainModel.Project CreateProject(CreateProjectCommand project)
        {
            int     vkGroupId     = this.groupInfoProvider.GetVkGroupId(project.Url);
            VkGroup group         = this.vkGroupRepository.GetGroupById(vkGroupId);
            bool    isGroupExists = group != null;

            DomainModel.Project projectToCreate = new DomainModel.Project
            {
                Title        = project.Title,
                CreationDate = this.dateTimeHelper.GetDateTimeNow(),
                AccountId    = project.AccountId,
                VkGroup      = group ?? new VkGroup
                {
                    Id   = vkGroupId,
                    Name = this.groupInfoProvider.GetVkGroupName(project.Url),
                    Url  = project.Url,
                    Type = VkGroupType.Group
                }
            };

            using (ITransactionScope transaction = this.unitOfWorkProvider.CreateTransaction().Begin())
            {
                this.projectRepository.Save(projectToCreate);

                if (!isGroupExists)
                {
                    this.AddGroupRelatedData(projectToCreate);
                }

                transaction.Commit();
            }

            return(projectToCreate);
        }
Esempio n. 2
0
        private void AddGroupRelatedData(DomainModel.Project projectToCreate)
        {
            IList <long> adminIds = this.groupInfoProvider.GetVkGroupAdministratorIds(projectToCreate.VkGroup.Url, projectToCreate.VkGroup.Type);

            foreach (var adminId in adminIds)
            {
                var admin = new Administrator {
                    UserId = adminId, VkGroupId = projectToCreate.VkGroup.Id
                };
                this.vkGroupRepository.SaveAdministator(admin);
            }

            var groupAdministrator = new Administrator {
                UserId = -projectToCreate.VkGroup.Id, VkGroupId = projectToCreate.VkGroup.Id
            };

            this.vkGroupRepository.SaveAdministator(groupAdministrator);

            this.feedRepository.AddVkGroupFeedFetchingToQueue(projectToCreate.VkGroup.Id);
        }
Esempio n. 3
0
        private void SendCreateProjectFinished(CreateProjectCommand createProjectCommand, DomainModel.Project project, bool isSuccess)
        {
            Contract.Requires(project != null);

            using (ICommandSender commandSender = Factory.GetInstance <ICommandSender>().Open(CONST_CreateProjectResultQueueName))
            {
                CreateProjectResultCommand command = new CreateProjectResultCommand
                {
                    VkGroupId = project.VkGroup.Id,
                    AccountId = createProjectCommand.AccountId,
                    TicketId  = createProjectCommand.TicketId,
                    IsSuccess = isSuccess,
                    ProjectId = project.Id
                };

                commandSender.SendCommand(command);
            }
        }