Exemple #1
0
        // Возвращает только что добавленную запись
        public PostImage AddPostImage(int post_id, int image_id)
        {
            PostImage postImage = new PostImage();
            if (post_id != null && image_id != null)
            {
                PostImageContext postImageContext = new PostImageContext();
                postImage.post_id = post_id;
                postImage.image_id = image_id;

                postImageContext.post_image.Add(postImage);
                postImageContext.SaveChanges();
                var imId = postImageContext.post_image.Select(id => id.id).Max();
                postImage.id = imId;
                return postImage;
            }
            else return null;
        }
Exemple #2
0
 public Image getImageByPostId(int post_id)
 {
     Image image = new Image();
     foreach (var pi in post_image)
     {
         if (pi.post_id == post_id)
         {
             image = imagesContext.getImageById(pi.image_id);
             return image;
         }
     }
     return null;
 }