public OperationResultVo Comment(CommentViewModel vm) { try { BrainstormIdea idea = brainstormDomainService.GetIdea(vm.UserContentId); BrainstormComment model = new BrainstormComment { UserId = vm.UserId, IdeaId = vm.UserContentId, SessionId = idea.SessionId, Text = vm.Text, AuthorName = vm.AuthorName, AuthorPicture = vm.AuthorPicture }; brainstormDomainService.AddComment(model); unitOfWork.Commit(); return(new OperationResultVo <Guid>(model.Id)); } catch (Exception ex) { return(new OperationResultVo <Guid>(ex.Message)); } }
public async Task <bool> AddComment(BrainstormComment model) { FilterDefinition <BrainstormIdea> filter = Builders <BrainstormIdea> .Filter.Where(x => x.Id == model.IdeaId); UpdateDefinition <BrainstormIdea> add = Builders <BrainstormIdea> .Update.AddToSet(c => c.Comments, model); UpdateResult result = await GetCollection <BrainstormIdea>().UpdateOneAsync(filter, add); return(result.IsAcknowledged && result.MatchedCount > 0); }
public void AddComment(BrainstormComment model) { repository.AddComment(model); }