public async Task <ActionResult <IEnumerable <PictureViewModel> > > GetAll() { var pictures = await _service.GetAllAsync(); if (!pictures.Any()) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <PictureViewModel> >(pictures))); }
// GET: /<controller>/ public async Task <ActionResult> Index() { var images = await pictureService.GetAllAsync(); if (images == null) { return(RedirectToAction("获取服务失败!")); } var list = images.images.ToList(); var picture = list.Select(x => new PictureViewModel { url = x.url, startdate = x.startdate, copyright = x.copyright }); return(View(picture)); }
public async Task <IActionResult> RenderAllPicture() { var viewModel = await _pictureService.GetAllAsync(); return(PartialView("_SelectPicture", model: viewModel)); }