public static bool AddPostForFeed(Guid id, long feedId) { try { var dc = new RNManagementContext(); var p = dc.Posts.Where(x => x.PostId == id).FirstOrDefault(); if (p != null) { p.Feed = dc.RssFeeds.Where(x => x.RssId == feedId).FirstOrDefault(); } else { p = new Post(); p.PostId = id; p.Feed = dc.RssFeeds.Where(x => x.RssId == feedId).FirstOrDefault(); dc.Posts.Add(p); } int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool AddViewToPost(Guid id) { try { var dc = new RNManagementContext(); var p = dc.Posts.Where(x => x.PostId == id).FirstOrDefault(); if (p != null) { p.TotalViews += 1; p.CurrentMonthlyViews += 1; } else { p = new Post(); p.PostId = id; p.CurrentMonthlyViews = 1; p.TotalViews = 1; dc.Posts.Add(p); } int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }
public static bool SavePostToDb(Guid id, bool isAutoSharingDisabled, bool disablePaymentsForPost) { try { var dc = new RNManagementContext(); var p = dc.Posts.Where(x => x.PostId == id).FirstOrDefault(); if (p != null) { p.DisabledAutoPosting = isAutoSharingDisabled; p.DisablePaymentsForPost = disablePaymentsForPost; p.LastTimePostedToFacebook = DateTime.UtcNow; p.TotalFacebookPosts += 1; } else { p = new Post(); p.PostId = id; p.DisabledAutoPosting = isAutoSharingDisabled; p.DisablePaymentsForPost = disablePaymentsForPost; p.LastTimePostedToFacebook = DateTime.UtcNow; p.TotalFacebookPosts = 1; dc.Posts.Add(p); } int c = dc.SaveChanges(); return c > 0; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return false; }