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 }); } }
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 }); } }
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 }); } }