Exemplo n.º 1
0
        public static bool ImageFunction(int postId, int groupId)
        {
            Bitmap[]            ImagePost;
            int                 b = 0;
            FindFileAndDownload findfileanddownload = new FindFileAndDownload();

            using (ContextGroupWallPhoto db = new ContextGroupWallPhoto())
            {
                try
                {
                    var tt = db.GroupWallPhotos
                             .Select(p => new { id = p.Id, photo = p.photo, PhotoName = p.PhotoName, postId = p.post_id, groupId = p.GroupId })
                             .Where(p => p.postId == postId && p.groupId == groupId);
                    if (tt.Count() != 0)
                    {
                        //Создаем масссив размером полученных изображений
                        int CountImg = tt.Count();
                        ImagePost = new Bitmap[CountImg];

                        foreach (var p in tt)
                        {
                            ImagePost[b] = (Bitmap)findfileanddownload.fileFind(p.photo);

                            b++;
                        }
                        StaticClass.ImagePost = ImagePost;
                        return(true);
                    }

                    return(false);
                }
                catch { return(false); }
            }
        }
Exemplo n.º 2
0
 private void PhotoDbAdd(string[] parametr)
 {
     string[] param = parametr;
     using (ContextGroupWallPhoto db = new ContextGroupWallPhoto())
     {
         GroupWallPhoto cgp = new GroupWallPhoto {
             photo = param[0], access_key = param[1], post_id = Convert.ToInt32(param[2]), GroupId = Convert.ToInt32(param[3])
         };
         db.GroupWallPhotos.Add(cgp);
         db.SaveChanges();
     }
 }