Esempio n. 1
0
        public IList <PhotographerDto> GetAll()
        {
            var photographers = photographerRepository.GetAll(q => q.OrderBy(p => p.Id)).ToList();
            var photo         = photoRepository.GetAll(q => q.OrderBy(p => p.Id)).ToList();

            return(photographers.Select(p => new PhotographerDto
            {
                Id = p.Id,
                Name = p.Name,
                BirthDate = p.BirthDate,
                PictureCount = photo.Count(q => q.PhotographerId == p.Id)
            }).ToList());
        }
Esempio n. 2
0
        public async Task <IActionResult> AddPhotos(int?albumId = null, int?photographerId = null)
        {
            List <Album> albums = await _albumRepository.GetAll();

            List <Photographer> photographers = await _photographerRepository.GetAll();

            Album selectedAlbum = null;

            if (albumId != null)
            {
                selectedAlbum = albums.FirstOrDefault(x => x.Id == albumId);
            }
            Photographer selectedpPhotographer = null;

            if (photographerId != null)
            {
                selectedpPhotographer = photographers.FirstOrDefault(x => x.Id == photographerId);
            }
            //添加照片的时候选择摄影师
            ViewBag.Photographers = new SelectList(photographers, "Id", "Name", selectedpPhotographer);
            //添加照片的时候选择相册
            ViewBag.Albums = new SelectList(albums, "Id", "Title", selectedAlbum);
            return(View());
        }
 public List <PhotographerViewModel> GetAll()
 {
     return(MapList <PhotographerViewModel>(_repository.GetAll()));
 }
        public async Task <IActionResult> Index()
        {
            List <Photographer> photographers = await _photographerRepository.GetAll();

            return(View(photographers));
        }