Beispiel #1
0
        // GET: api/Images
        public List <ImageBindModel> Get()
        {
            var     accountId            = User.Identity.GetUserId();
            Profile p                    = _dataContext.Profile.Where(c => c.AccountId == accountId).FirstOrDefault();
            var     dataGallery          = _dataContext.Gallery.Where(g => g.ProfileId == p.Id).ToList();
            List <ImageBindModel> images = new List <ImageBindModel>();

            foreach (var g in dataGallery)
            {
                foreach (var f in g.Images)
                {
                    if (f.GalleryId == g.GalleryId)
                    {
                        ImageBindModel i = new ImageBindModel()
                        {
                            ImageId   = f.ImageId,
                            Title     = f.Title,
                            Subtitle  = f.Subtitle,
                            Url       = f.Url,
                            GalleryId = f.GalleryId
                        };

                        images.Add(i);
                    }
                }
            }

            return(images);
        }
Beispiel #2
0
        // GET: api/Gallery/5
        public List <ImageBindModel> Get(int id)
        {
            Gallery               gallery    = _dataContext.Gallery.Where(g => g.GalleryId == id).FirstOrDefault();
            List <Image>          images     = _dataContext.Image.Where(i => i.GalleryId == id).ToList();
            List <ImageBindModel> bindImages = new List <ImageBindModel>();

            foreach (var i in images)
            {
                ImageBindModel image = new ImageBindModel()
                {
                    Title     = i.Title,
                    Subtitle  = i.Subtitle,
                    Url       = i.Url,
                    GalleryId = i.GalleryId,
                    ImageId   = i.ImageId
                };
                bindImages.Add(image);
            }

            return(bindImages);
        }