Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PictureHelper.PictureViewCounter(PictureHelper.GetSinglePicture(userID,pic), (List<int>)Session["ViewedPictures"], pic);
- public static Picture GetSinglePicture(int userID, int picture)
- {
- DBContext db = new DBContext();
- return (from p in db.Pictures
- where userID == p.UserID && picture == p.Url
- select p).First();
- }
- public static void PictureViewCounter(Picture picture, List<int> pictureArray, int pictureUrl)
- {
- PetscoveryDBContext db = new PetscoveryDBContext();
- if (pictureArray == null)
- {
- //Automatically +1 picture views
- picture.Views++;
- db.SaveChanges(); //does not save
- }
- else
- {
- int result = pictureArray.Find(pic => pic == pictureUrl);
- //if result == 0 increase picture views by 1
- picture.Views++;
- db.SaveChanges(); //does not save
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement