protected void Page_Load(object sender, EventArgs e)
 {
     var db = new PhotoArt.Data.PhotoArtDbContext();
     var albums = db.Albums
            .Where(x => x.Images.Count > 0)
            .ToList()
            .Select(x => new
            {
                Id = x.Id,
                Name = x.Name,
                Description = x.Description,
                CreatedOn = x.CreatedOn,
                IsApproved = x.IsApproved,
                Url = x.Images.FirstOrDefault().Url,
                CoverImage1 = "data:image/jpeg;base64," + x.Images.FirstOrDefault().Content,
                CoverImage = "data:image/jpeg;base64," + Convert.ToBase64String(x.Images.FirstOrDefault().Content)
            })
            .ToList();
     // this.Image1.ImageUrl = pendingAlbums.FirstOrDefault().CoverImage;
     if (!Page.IsPostBack)
     {
         this.albums.DataSource = albums;
         this.albums.DataBind();
     }
 }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session[CAROUSEL_OFFSET] == null)
            {
                Session[CAROUSEL_OFFSET] = 0;
            }

            if (Request.Params["Id"] == null)
            {
                Response.Redirect(PENDING_ALBUMS_URL);
            }
             var db = new PhotoArt.Data.PhotoArtDbContext();
             var id = int.Parse(Request.Params["Id"]);
            // var album = db.Albums
            //     .Where(x => x.Id == id)
            //     .Select(x => new
            //     {
            //         x.Id,
            //         x.Name,
            //         x.Description,
            //         Images = x.Images
            //         .Select(i => new
            //         {
            //             Id = i.Id,
            //             Url = i.Url
            //         })
            //     })
            //     .FirstOrDefault();
            // if (album == null)
            // {
            //     Response.Redirect(PENDING_ALBUMS_URL);
            // }

            // // TODO: check for null
            var cover = db.Albums
                .Where(x => x.Id == id)
                .Select(x => x.Images
                .FirstOrDefault())
                .FirstOrDefault();

            if (cover != null)
            {
                this.CoverImage.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(cover.Content);
            }

            //// this.Carousel.DataSource = album.Images.Skip(0).Take(5);
            // this.DataBind();

        }
Beispiel #3
0
 public IQueryable<UserViewModel> UsersGrid_GetData(object sender, EventArgs e)
 {
     var db = new PhotoArt.Data.PhotoArtDbContext();
     return db.Users
         .Select(x => new UserViewModel
         {
             Id = x.Id,
             Name = x.FirstName + " " + x.LastName,
             Country = x.Country,
             Email = x.Email,
             Albums = x.Portfolio.Albums.Count,
             CoverUrlPath = x.Portfolio.Albums.FirstOrDefault() != null ?
             x.Portfolio.Albums.FirstOrDefault().Images.FirstOrDefault() != null ?
                     x.Portfolio.Albums.FirstOrDefault().Images.FirstOrDefault().Url : null
             : null
         });
 }
Beispiel #4
0
        //protected void Carousel_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    var item = e.Item.DataItem as Models.Image;
        //    if (item != null)
        //    {
        //        e.Item.ID = item.Id.ToString();
        //    }
        //}

        public IQueryable<ImageViewModel> GetImages()
        {
            if (Request.Params["Id"] == null)
            {
                Response.Redirect(PENDING_ALBUMS_URL);
            }

            var id = int.Parse(Request.Params["Id"]);
            var skip = (int)Session[CAROUSEL_OFFSET];
            var db = new PhotoArt.Data.PhotoArtDbContext();
            return db.Images
                .Where(x => x.AlbumId == id)
                .Select(x => new ImageViewModel
                {
                    Id = x.Id,
                    Url = x.Url
                })
                .OrderBy(x => x.Id)
                .Skip(skip)
                .Take(5);

        }