public Image GetById(int id) { using (var context = new ImagesDataContext(_connectionString)) { return(context.Images.FirstOrDefault(i => i.Id == id)); } }
public IEnumerable <Image> GetImages() { using (var context = new ImagesDataContext(_connectionString)) { return(context.Images.ToList().OrderByDescending(i => i.Id)); } }
public void AddImage(Image image) { using (var context = new ImagesDataContext(_connectionString)) { context.Images.InsertOnSubmit(image); context.SubmitChanges(); } }
public void IncrementLikeCount(int imageId) { using (var context = new ImagesDataContext(_connectionString)) { Image image = context.Images.FirstOrDefault(i => i.Id == imageId); image.LikeCount++; context.SubmitChanges(); } }