Ejemplo n.º 1
0
 public Picture FindRandomPicture()
 {
     using (HotOrNotContext hotOrNotContext = new HotOrNotContext())
     {
         return(hotOrNotContext.Pictures.OrderBy(o => System.Guid.NewGuid()).First());
     }
 }
Ejemplo n.º 2
0
        public void Create(string MyFileName, string Mytitle, string Mydescription)
        {
            Picture picture = new Picture();

            using (HotOrNotContext hotOrNotContext = new HotOrNotContext())
            {
                var MaxPictureID = hotOrNotContext.Pictures.OrderByDescending(u => u.PictureId).FirstOrDefault();
                int NextID       = MaxPictureID.PictureId;
                hotOrNotContext.Pictures.Add(new Picture {
                    PictureId = NextID + 1, FilePath = MyFileName, Title = Mytitle, Description = Mydescription, LikeCnt = 0, DisLikeCnt = 0, CreateDate = System.DateTime.Now
                });
                hotOrNotContext.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 public void AddLikeOrDislike(int pictureId, bool flag)
 {
     using (HotOrNotContext hotOrNotContext = new HotOrNotContext())
     {
         if (flag == true)
         {
             var MyPicture = hotOrNotContext.Pictures.Find(pictureId);
             MyPicture.LikeCnt++;
             hotOrNotContext.SaveChanges();
         }
         else
         {
             var MyPicture = hotOrNotContext.Pictures.Find(pictureId);
             MyPicture.DisLikeCnt++;
             hotOrNotContext.SaveChanges();
         }
     }
 }