예제 #1
0
        public void AddLike(int id)
        {
            using var context = new ImagesDbContext(_connectionString);
            var image = context.Images.FirstOrDefault(i => i.Id == id);

            image.Likes++;
            context.SaveChanges();
        }
예제 #2
0
 public void AddImage(string title, string fileName)
 {
     using var context = new ImagesDbContext(_connectionString);
     context.Images.Add(new Image
     {
         Title    = title,
         Date     = DateTime.Now,
         Likes    = 0,
         FileName = fileName
     });
     context.SaveChanges();
 }