public async Task <List <DTO.GoodsDTO> > GetAllGoods() { using (IDAL.IGoodsService goodService = new GoodsService()) { var goodsDtos = await goodService.GetAllAsync().Select(m => new GoodsDTO() { id = m.Id, name = m.Name, imgUrl = m.ImgUrl, price = m.Price, price_old = m.Price_old }).ToListAsync(); using (IGoodDetailService goodDetailService = new GoodDetailService()) { foreach (var goodsDto in goodsDtos) { goodsDto.imgsUrl = new List <string>(); var goodDetails = goodDetailService.GetAllAsync().Where(m => m.GoodsId == goodsDto.id).ToList(); foreach (var goodDetail in goodDetails) { goodsDto.imgsUrl.Add(goodDetail.ImgUrl); } ; } } return(goodsDtos); } }
public async Task <DTO.GoodsDTO> GetOneById(Guid id) { using (IDAL.IGoodsService goodsService = new GoodsService()) { var data = await goodsService.GetAllAsync() .Where(m => m.Id == id) .Select(m => new DTO.GoodsDTO() { id = m.Id, name = m.Name, price = m.Price, price_old = m.Price_old, imgUrl = m.ImgUrl }).FirstAsync(); return(data); } }
private async void PrivateRefreshList() { var result = await _goodsService.GetAllAsync("Price ASC"); GoodsItems = result == null ? null : new ObservableCollection <GoodsDto>(result); }