public static void AddReport(ReportedPost newReport) { using (var db = new MyCirclesEntityModel()) { db.ReportedPosts.Add(newReport); db.SaveChanges(); } }
public ReportedPost ReportPost(int postID) { ReportedPost reportedPost = new ReportedPost() { PostID = postID, Date = DateTime.UtcNow }; _reportedPostRepository.Add(reportedPost); _unitOfWork.Commit(); return(reportedPost); }
public UserReportedPost(ReportedPost reportedPost, User reporterUser) { this.id = reportedPost.Id; if (reportedPost.postId.HasValue) { this.postId = reportedPost.postId.Value; } else { this.postId = -1; } this.reporterUserId = reportedPost.reporterUserId; this.reporterUsername = reporterUser.Username; this.reason = reportedPost.reason; this.dateCreated = reportedPost.dateCreated; }
protected void Page_Load(object sender, EventArgs e) { List <ReportedPost> reportedPosts = new List <ReportedPost>(); foreach (ReportedPost post in ReportedPost.GetAllReportedPosts()) { if (post.postId > -1) { reportedPosts.Add(post); } } numOfReportedPosts = reportedPosts.Count; numOfEvents = Event.GetAllEvent().Count; numOfUsers = BLL.User.GetAllUsers().Count; numOfCircles = DAL.CircleDAO.GetAllCircles().Count; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session[keySessionRowIdx] = -1; } refreshGridView(); IDictionary <string, int> dateToReportsDict = new Dictionary <string, int>(); foreach (ReportedPostCount count in ReportedPost.GetReportedPostCountByDate()) { dateToReportsDict.Add(count.dateCreated.ToString("dd/MMM/yyyy"), count.reportsCount); } jsonStringDict = JsonConvert.SerializeObject(dateToReportsDict); System.Diagnostics.Debug.WriteLine(jsonStringDict); }
private List <UserReportedPost> GetReports(bool WantValid) // means want to get reports that has postId if true { List <UserReportedPost> data = new List <UserReportedPost>(); foreach (UserReportedPost post in ReportedPost.GetAllUserReportedPosts()) { System.Diagnostics.Debug.WriteLine(post.reason + "," + post.postId); if (WantValid) { if (post.postId > -1) { data.Add(post); } } else { data.Add(post); } } return(data); }
public void deleteOp(int index) { // TODO deleting from modal, index is out of range System.Diagnostics.Debug.WriteLine("deleteOp, index:" + index); UserReportedPost userReportedPost = GetReports(true)[index]; Post post = Post.GetPostById(userReportedPost.postId); System.Diagnostics.Debug.WriteLine("deleteOp, postId:" + post.Id); // Set reportedpost data's postId to null, to indicate post got deleted ReportedPost rp = ReportedPost.GetReportedPostById(userReportedPost.id); System.Diagnostics.Debug.WriteLine("deleteOp, reportedPost:" + rp.reason); ReportedPost.DeleteReportedPostByPostId(userReportedPost.postId); // delete post data Post.DeletePost(post.Id); // TODO - Investigate why cannot use remove, but removeRange can work for inside the DAO refreshGridView(); }