public async Task <IDataResult <IList <BomComponentDetailsDto> > > GetBomComponentDetailsDtoByOrderIdAsync(int orderId) { List <BomComponentDetailsDto> bomCompDetailsDtos = new List <BomComponentDetailsDto>(); var bom = await _bomDao.GetAsync(b => b.Id == orderId); var bomComps = await _bomComponentDao.GetListAsync(comp => comp.BomId == bom.Id); var products = await _productDao.GetListAsync() as List <Product>; foreach (BillOfMaterialsComponent bomComp in bomComps) { var product = products.Find(p => p.Id == bomComp.ProductId); var bomCompDetailsDto = new BomComponentDetailsDto { BomId = bom.Id, BomReference = bom.Reference, BomComponentId = bomComp.Id, ProductId = product.Id, ProductName = product.Name, Quantity = bomComp.Quantity }; bomCompDetailsDtos.Add(bomCompDetailsDto); } return(new SuccessDataResult <IList <BomComponentDetailsDto> >(bomCompDetailsDtos)); }
public IDataResult <BomComponentDetailsDto> GetBomComponentDetailsDtoById(int bomComponentId) { var bomComp = _bomComponentDao.Get(comp => comp.Id == bomComponentId); var productInComp = _productDao.Get(p => p.Id == bomComp.ProductId); var bom = _bomDao.Get(comp => comp.Id == bomComp.BomId); var bomComponentDetailsDto = new BomComponentDetailsDto { BomComponentId = bomComp.Id, BomId = bomComp.BomId, BomReference = bom.Reference, ProductId = bomComp.ProductId, ProductName = productInComp.Name, }; return(new SuccessDataResult <BomComponentDetailsDto>(bomComponentDetailsDto)); }
public async Task <IDataResult <BomComponentDetailsDto> > GetBomComponentDetailsDtoByIdAsync(int bomComponentId) { var bomComp = await _bomComponentDao.GetAsync(comp => comp.Id == bomComponentId); var productInComp = await _productDao.GetAsync(p => p.Id == bomComp.ProductId); var bom = await _bomDao.GetAsync(comp => comp.Id == bomComp.BomId); var bomComponentDetailsDto = new BomComponentDetailsDto { BomComponentId = bomComp.Id, BomId = bomComp.BomId, BomReference = bom.Reference, ProductId = bomComp.ProductId, ProductName = productInComp.Name, }; return(new SuccessDataResult <BomComponentDetailsDto>(bomComponentDetailsDto)); }