public int Save(CommentVM comment) { using (var db = new TeamEntitiesConn()) { var commentEntity = new Comment(); commentEntity.IssueID = comment.IssueId; commentEntity.CommentText = comment.CommentBody; commentEntity.CreatedDate = DateTime.Now; commentEntity.CreatedByID = comment.Author.Id; ; db.Comments.Add(commentEntity); db.SaveChanges(); return commentEntity.ID; } }
public async Task Delete(int id) { using (var db = new TeamEntitiesConn()) { var c = new Comment {ID = id}; db.Comments.Attach(c); db.Comments.Remove(c); await db.SaveChangesAsync(); //var c = db.Comments.FirstOrDefault(s => s.ID == id); //if (c != null) //{ // db.Comments.Remove(c); // await db.SaveChangesAsync(); //} } }
public Activity SaveActivity(Comment comment,int teamId) { var issue = repo.GetIssue(comment.IssueID); Activity activity = new Activity(); activity.CreatedByID = comment.CreatedByID; activity.OldState = issue.Title; activity.NewState = comment.CommentText; activity.ObjectID = comment.ID; activity.ObjectType = "IssueComment"; activity.ActivityDesc = "Commented"; activity.TeamID = teamId; var result = repo.SaveActivity(activity); if (result.Status) { return repo.GetActivity(activity.ID); } return null; }
public CommentVM GetIssueCommentVM(int currentUserId, Comment item) { var commentVM = new CommentVM { ID = item.ID, CommentBody = item.CommentText, AuthorName = item.Author.FirstName, CreativeDate = item.CreatedDate }; commentVM.CommentBody = commentVM.CommentBody.ConvertUrlsToLinks(); commentVM.AvatarHash = UserService.GetAvatarUrl(item.Author.Avatar, 42); commentVM.CreatedDateRelative = item.CreatedDate.ToJSONFriendlyDateTime();//.ToRelativeDateTime(); commentVM.IsOwner = item.CreatedByID == currentUserId; return commentVM; }
public OperationStatus SaveComment(Comment comment) { try { comment.CreatedDate = DateTime.UtcNow; db.Comments.Add(comment); db.SaveChanges(); } catch(Exception ex) { return OperationStatus.CreateFromException("Error in comment", ex); } return new OperationStatus { Status = true, OperationID = comment.ID }; }