public void AddLike(int id) { using var context = new ImagesDbContext(_connectionString); var image = context.Images.FirstOrDefault(i => i.Id == id); image.Likes++; context.SaveChanges(); }
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(); }