Exemplo n.º 1
0
        public async Task <ActionResult <ManageCommentResponse> > EditComment(ManageCommentRequest request)
        {
            var entityTypeId = _implementationsContainer.Metadata[request.EntityTypeName].EntityTypeId;

            using (var dbContext = _implementationsContainer.GetLobToolsRepository() as LobToolsDbContext)
            {
                var comment = await dbContext.Comments.FindAsync(request.Id);

                if (comment.EntityTypeId != entityTypeId || comment.Identifier != request.Identifier)
                {
                    ModelState.AddModelError("", "The comment is for another entity. You can't move comments between entities.");
                    return(BadRequest(ModelState));
                }

                comment.Description = request.Description;
                //Todo: Fill this after logging is implemented RequestLogId = null
                comment.Title = request.Title;
                await dbContext.SaveChangesAsync();

                return(new ManageCommentResponse
                {
                    Id = comment.Id
                });
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ManageCommentResponse> > DeleteComment(ManageCommentRequest request)
        {
            var entityTypeId = _implementationsContainer.Metadata[request.EntityTypeName].EntityTypeId;

            using (var dbContext = _implementationsContainer.GetLobToolsRepository() as LobToolsDbContext)
            {
                var comment = await dbContext.Comments.FindAsync(request.Id);

                dbContext.Remove(comment);
                await dbContext.SaveChangesAsync();

                return(new ManageCommentResponse
                {
                    Id = comment.Id
                });
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ManageCommentResponse> > AddComment(ManageCommentRequest request)
        {
            var entityTypeId = _implementationsContainer.Metadata[request.EntityTypeName].EntityTypeId;

            using (var dbContext = _implementationsContainer.GetLobToolsRepository() as LobToolsDbContext)
            {
                var comment = new Comment
                {
                    Description  = request.Description,
                    EntityTypeId = entityTypeId,
                    Identifier   = request.Identifier,
                    RequestLogId = null,                     //Todo: Fill this after logging is implemented
                    Title        = request.Title
                };
                await dbContext.AddAsync(comment);

                await dbContext.SaveChangesAsync();

                return(new ManageCommentResponse
                {
                    Id = comment.Id
                });
            }
        }