public DiscussionDetailsViewModel(DiscussionDto gitLabDiscussion, GitLabService gitLabService) { this.Discussion = gitLabDiscussion; this.service = gitLabService; this.Notes.CollectionChanged += this.OnNotesCollectionChanged; this.NewNoteCommand = new DelegateCommand(this.ExecuteNewNote); this.CancelCommand = new DelegateCommand(this.ExecuteCancel); }
public async Task SilentChatNotification(DiscussionDto discussionDto, Project project) { //var singleIdentifier = new UserIdentifier(AppConstants.DefaultTenantId, discussionDto.Member.Id); //var userIdentifier = new[] { singleIdentifier }; var entityIdentifier = new EntityIdentifier(typeof(Project), project.Id); await _notificationPublisher.PublishAsync(TodoNotificationTypes.DiscussionMessage, new DiscussionMessage(discussionDto), entityIdentifier); }
public async Task CreateDiscussionAsync(Guid userId, string slug, Discussion discussion, CancellationToken cancellationToken) { if (Guid.Empty == userId) { throw new ArgumentOutOfRangeException(nameof(userId)); } if (string.IsNullOrEmpty(slug)) { throw new ArgumentOutOfRangeException(nameof(slug)); } var now = _systemClock.UtcNow.UtcDateTime; var groupId = await _groupCommand.GetGroupIdForSlugAsync(slug, cancellationToken); if (!groupId.HasValue) { _logger.LogError($"Error: CreateDiscussionAsync - Group not found for slug:{0}", slug); throw new KeyNotFoundException("Error: Group not found for slug"); } var userCanPerformAction = await _permissionsService.UserCanPerformActionAsync(userId, groupId.Value, AddDiscussionRole, cancellationToken); if (!userCanPerformAction) { _logger.LogError($"Error: CreateDiscussionAsync - User:{0} does not have access to group:{1}", userId, slug); throw new SecurityException($"Error: User does not have access"); } var entityId = Guid.NewGuid(); var discussionDto = new DiscussionDto { Id = entityId, Title = discussion.Title, Content = discussion.Content, CreatedAtUTC = now, CreatedBy = userId, IsSticky = discussion.IsSticky, IsLocked = false, GroupId = groupId.Value }; var validator = new DiscussionValidator(); var validationResult = await validator.ValidateAsync(discussionDto, cancellationToken); if (validationResult.Errors.Count > 0) { throw new ValidationException(validationResult); } await _discussionCommand.CreateDiscussionAsync(discussionDto, cancellationToken); }
public IHttpActionResult PostDiscussion(DiscussionDto dto) { var currentUser = User.Identity.GetUserFirstname(); var currentUserId = User.Identity.GetUserId(); var discussion = new Discussion { PostedByName = currentUser, PostedById = currentUserId, Body = dto.Body, TeamupId = dto.TeamupId }; _context.Discussions.Add(discussion); _context.SaveChanges(); return(Ok(discussion)); }
public DiscussionMessage(DiscussionDto message) { Message = message; }
public DiscussionViewModel(DiscussionDto gitLabDiscussion, GitLabService gitLabService) { this.Discussion = gitLabDiscussion; this.Details = new DiscussionDetailsViewModel(gitLabDiscussion, gitLabService); this.Items.Add(this.Details); }
public async Task CreateDiscussionAsync(DiscussionDto discussion, CancellationToken cancellationToken = default) { using var dbConnection = await _connectionFactory.GetReadWriteConnectionAsync(cancellationToken); await using var connection = new SqlConnection(dbConnection.ConnectionString); const string insertEntity = @" INSERT INTO [dbo].[Entity] ([Id]) VALUES (@EntityId) "; const string insertDiscussion = @" INSERT INTO [dbo].[Discussion] ([Entity_Id] ,[Title] ,[CreatedAtUtc] ,[CreatedBy] ,[IsSticky] ,[IsLocked] ,[Group_Id] ,[Poll_Id] ,[Category_Id] ,[Content]) VALUES (@Id ,@Title ,@CreatedAt ,@CreatedBy ,@IsSticky ,@IsLocked ,@Group ,NULL ,NULL ,@Content)"; await connection.OpenAsync(cancellationToken); var transaction = await connection.BeginTransactionAsync(cancellationToken); var insertEntityResult = await connection.ExecuteAsync(insertEntity, new { EntityId = discussion.Id, }, transaction : transaction); var insertDiscussionResult = await connection.ExecuteAsync(insertDiscussion, new { Id = discussion.Id, Title = discussion.Title, CreatedAt = discussion.CreatedAtUTC, CreatedBy = discussion.CreatedBy, IsSticky = discussion.IsSticky, IsLocked = discussion.IsLocked, Group = discussion.GroupId, Content = discussion.Content }, transaction : transaction); if (insertEntityResult != 1) { _logger.LogError("Error: User request to create was not successful.", insertEntity); throw new DataException("Error: User request to create was not successful."); } if (insertDiscussionResult != 1) { _logger.LogError("Error: User request to create was not successful.", insertDiscussion); throw new DataException("Error: User request to create was not successful."); } await transaction.CommitAsync(cancellationToken); }