public int GetLikes(int id) { using var context = new ImageDbContext(_connectionString); return(context.Images.FirstOrDefault(i => i.Id == id).Likes); }
public List <Image> GetAllImages() { using var context = new ImageDbContext(_connectionString); return(context.Images.OrderByDescending(i => i.DateUploaded).ToList()); }
public Image GetImage(int id) { using var context = new ImageDbContext(_connectionString); return(context.Images.FirstOrDefault(i => i.Id == id)); }
public void AddImage(Image image) { using var context = new ImageDbContext(_connectionString); context.Images.Add(image); context.SaveChanges(); }