public static ShareCount SaveShareCount(ShareCount shareCount) { using (EFDbContext db = new EFDbContext()) { var modal = db.ShareCount.Add(shareCount); int row = db.SaveChanges(); return(modal); } }
public static ShareCount Update(ShareCount shareCount) { using (EFDbContext db = new EFDbContext()) { var modal = db.ShareCount.Where(o => o.ID == shareCount.ID).FirstOrDefault(); modal.count = shareCount.count; modal.type = shareCount.type; int row = db.SaveChanges(); return(modal); } }
public static ShareCount SaveUserShareCount(string useropenid, string type) { var model = GetUserShareCount(useropenid, type); if (model != null) { model.count = model.count + 1; Update(model); } else { model = new ShareCount() { count = 1, type = type, openid = useropenid }; SaveShareCount(model); } return(model); }