public async new Task<ActionResult> Profile(string id) { var user = await UserManager.FindByIdAsync(id); if (user == null) return new HttpNotFoundResult(); var items = await _listingService.Query(x => x.UserID == id) .Include(x => x.ListingPictures) .Include(x => x.ListingType) .Include(x => x.AspNetUser) .Include(x => x.ListingReviews) .SelectAsync(); var itemsModel = new List<ListingItemModel>(); foreach (var item in items.OrderByDescending(x => x.Created)) { itemsModel.Add(new ListingItemModel() { ListingCurrent = item, UrlPicture = item.ListingPictures.Count == 0 ? ImageHelper.GetListingImagePath(0) : ImageHelper.GetListingImagePath(item.ListingPictures.OrderBy(x => x.Ordering).FirstOrDefault().PictureID) }); } // include reviews var reviews = await _listingReviewService .Query(x => x.UserTo == id) .Include(x => x.AspNetUserFrom) .SelectAsync(); var model = new ProfileModel() { Listings = itemsModel, User = user, ListingReviews = reviews.ToList() }; return View("~/Views/Listing/Profile.cshtml", model); }
public async new Task<ActionResult> Profile(string id) { var user = await UserManager.FindByIdAsync(id); if (user == null) return new HttpNotFoundResult(); var items = await _itemService.Query(x => x.UserID == id).Include(x => x.ItemPictures).SelectAsync(); var itemsModel = new List<ItemModel>(); foreach (var item in items.OrderByDescending(x => x.Created)) { itemsModel.Add(new ItemModel() { ItemCurrent = item, UrlPicture = item.ItemPictures.Count == 0 ? ImageHelper.GetItemImagePath(0) : ImageHelper.GetItemImagePath(item.ItemPictures.OrderBy(x => x.Ordering).FirstOrDefault().PictureID) }); } var model = new ProfileModel() { Items = itemsModel, User = user }; return View("~/Views/Listing/Profile.cshtml", model); }