コード例 #1
0
ファイル: Picture.cs プロジェクト: richinoz/Art1stLeeds
 public PictureItem(PictureItemNoBufferData pictureItemNoBufferData)
 {
     ID = pictureItemNoBufferData.ID;
     DisplayOrder = pictureItemNoBufferData.DisplayOrder;
     Artist = pictureItemNoBufferData.Artist;
     Price = pictureItemNoBufferData.Price;
     Media = pictureItemNoBufferData.Media;
     Theme = pictureItemNoBufferData.Theme;
     Size = pictureItemNoBufferData.Size;
     Created = pictureItemNoBufferData.Created;
     UserId = pictureItemNoBufferData.UserId;
 }
コード例 #2
0
        //PictureItemNoBufferData
        public static List<LandingPageItemViewModel> GetImagesForLandingPage()
        {
            using (var db = (ArtGalleryDBContext)DependencyResolver.Current.GetService<DbContext>())
            {
                var pictureDal = new PictureDal(db);

                var landingPageDal = new LandingPageDal(db);
                var fullList = landingPageDal.Enitities.ToList();
                var list = fullList.Select(x => x.PictureId).ToList();

                var selected =
                    from p in pictureDal.Enitities
                    from l in list
                    where p.ID == l
                    select new PictureItemNoBufferData()

                               {
                                   Artist = p.Artist,
                                   Created = p.Created,
                                   ID = p.ID,
                                   Media = p.Media,
                                   Price = p.Price,
                                   Size = p.Size,
                                   Theme = p.Theme,
                                   Title = p.Title,
                                   UserId = p.UserId,
                                   DisplayOrder = p.DisplayOrder
                               };

                var ret = selected.ToList();

                List<LandingPageItemViewModel> list2 = new List<LandingPageItemViewModel>();
                foreach (var landingPageItem in fullList)
                {
                    var pictureItemNoBufferData = ret.FirstOrDefault(x => x.ID == landingPageItem.PictureId);
                    if (pictureItemNoBufferData == null)
                    {
                        //LogOnModel logOnModel = Permissions.GetCurrentUser();
                        //if(logOnModel!=null)
                        {
                            pictureItemNoBufferData = new PictureItemNoBufferData() { UserId = 1 };
                        }

                    }
                    if (pictureItemNoBufferData != null)
                    {
                        var landingPageItemViewModel = new LandingPageItemViewModel()
                                                           {
                                                               LandingPageItemId = landingPageItem.Id,
                                                               Picture = pictureItemNoBufferData
                                                           };

                        list2.Add(landingPageItemViewModel);
                    }

                }

                return list2;

            }
        }