public List <ProductBillDto> GetAllBillDetailByBill(int billId) { List <ProductBillDto> dtos = new List <ProductBillDto>(); try { List <BillDetail> billDetails = billDetailRepository.GetByBill(billId).ToList(); foreach (BillDetail db in billDetails) { ProductBillDto dto = new ProductBillDto(); dto.Id = db.BillDetailId.ToString(); dto.Quantity = db.Quantity.ToString(); dto.SellRate = "0"; int productDetailId = db.ProductDetailId; ProductDetail productDetail = this.productDetailRepository.GetById(productDetailId); dto.Barcode = productDetail.GeneratedCode; dto.Price = productDetail.Price.ToString("#,#", CultureInfo.InvariantCulture); Product product = this.productRepository.GetById(productDetail.ProductId); dto.ProductName = product.Name; dto.Unit = product.Unit; dtos.Add(dto); } } catch { return(dtos); } return(dtos); }