public void Handle(AddIssueCommentTranslationCommand command) { var issueComment = _issueCommentWithContentsQueryHandler.Handle(command.IssueCommentId); foreach (var item in command.Contents) { var content = issueComment.Contents.FirstOrDefault(c => c.Locale == item.Locale); if (content != null && content.IsUpdated) { continue; } if (content == null) { content = new IssueCommentContent(); content.IssueComment = issueComment; content.Locale = item.Locale; _issueCommentContentRepository.Add(content); } content.IsUpdated = true; content.Description = item.Description; } }
public void Handle(CreateIssueCommentCommand command) { var creator = _currentUserRetriever.Get(); var issueComment = new IssueComment(); issueComment.Creator = creator; issueComment.IssueId = command.IssueId.Value; issueComment.Id = Guid.NewGuid(); foreach (var item in command.Contents) { var content = new IssueCommentContent(); content.Description = item.Description; content.Locale = item.Locale; content.IssueComment = issueComment; content.IsUpdated = true; _issueCommentContentRepository.Add(content); } issueComment.LastModification = DateTime.Now; var currentProjectId = _currentProjectContextId.Get(); if (currentProjectId == null) { throw new Exception(Sentences.noProjectInContext); } issueComment.Active = true; issueComment.CreatedAt = DateTime.Now; _issueCommentRepository.Add(issueComment); }
public static IssueCommentContentViewModel FromModel(IssueCommentContent model) { return(new IssueCommentContentViewModel { Id = model.Id, Locale = model.Locale, Description = model.Description, IsUpdated = model.IsUpdated }); }
public void Handle(UpdateIssueCommentCommand command) { var issueComment = _issueCommentWithContentsQueryHandler.Handle(command.IssueCommentId); foreach (var content in issueComment.Contents) { if (command.Contents.Any(i => content.Locale == i.Locale)) { var item = command.Contents.FirstOrDefault(i => content.Locale == i.Locale); content.IsUpdated = true; content.Description = item.Description; } else { content.IsUpdated = false; } } foreach (var item in command.Contents) { if (issueComment.Contents.Any(p => p.Locale == item.Locale)) { continue; } var content = new IssueCommentContent(); content.Id = issueComment.Id; content.IsUpdated = true; content.Locale = item.Locale; content.Description = item.Description; content.IssueComment = issueComment; _issueCommentContentRepository.Add(content); } issueComment.LastModification = DateTime.Now; }