public IDataResult <ScrapDetailsDto> GetScrapDetailsDtoById(int scrapId) { var scrap = _scrapDao.Get(s => s.Id == scrapId); var locSource = _locationDao.Get(l => l.Id == scrap.SourceLocationId); var locScrap = _locationDao.Get(l => l.Id == scrap.ScrapLocationId); var productToScrap = _productDao.Get(p => p.Id == scrap.ProductId); var scrapDetailsDto = new ScrapDetailsDto { ScrapId = scrap.Id, ProductId = productToScrap.Id, ProductName = productToScrap.Name, OrderReference = scrap.Reference, OrderDescription = scrap.Description, ScheduledDate = scrap.ScheduledDate, CompletedDate = scrap.CompletedDate, Quantity = scrap.Quantity, ScrapLocationId = locScrap.Id, ScrapLocationName = locScrap.Name, SourceLocationId = locSource.Id, SourceLocationName = locSource.Name, ScrapStatus = scrap.Status, }; return(new SuccessDataResult <ScrapDetailsDto>(scrapDetailsDto)); }
public bool UpdateProduct(ProductViewModel model) { var product = _productDao.Get(model.Id); if (product == null) { throw new BusinessLogicException("该产品不存在"); } product.Category = model.Category; product.CategoryB = model.CategoryB; product.Description = model.Description; product.Name = model.Name; product.Price = model.Price; return(_productDao.Modify(product)); }
public IDataResult <ReplenishmentDetailsDto> GetReplenishmentDetailsDtoById(int replenishmentId) { var replenishment = _replenishmentDao.Get(r => r.Id == replenishmentId); var prodToReplenish = _productDao.Get(p => p.Id == replenishment.ProductToReplenishId); var replenishmentLocation = _locationDao.Get(l => l.Id == replenishment.LocationId); var replenishmentDetailsDto = new ReplenishmentDetailsDto { Id = replenishment.Id, Reference = replenishment.Reference, ProductToReplenishId = prodToReplenish.Id, ProductToReplenishName = prodToReplenish.Name, LocationId = replenishmentLocation.Id, LocationName = replenishmentLocation.Name, OnHandQuantity = replenishment.OnHandQuantity, OrderQuantity = replenishment.OrderQuantity, Status = replenishment.Status }; return(new SuccessDataResult <ReplenishmentDetailsDto>(replenishmentDetailsDto)); }
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 IDataResult <BomDetailsDto> GetBomDetailsDtoById(int bomId) { var bom = _bomDao.Get(b => b.Id == bomId); var productOfBom = _productDao.Get(p => p.Id == bom.ProductId); var bomDetailsDto = new BomDetailsDto { BomId = bom.Id, ProductId = bom.ProductId, ProductName = productOfBom.Name, BomReference = bom.Reference, BomType = bom.BoMType, Quantity = bom.Quantity }; return(new SuccessDataResult <BomDetailsDto>(bomDetailsDto)); }
public bool InsertOrder(OrderViewModel model) { var productIds = model.OrderItems.Select(item => item.ProductId).ToList(); var products = _productDao.Get(p => productIds.Contains(p.Id)); var itemsModels = (from item in model.OrderItems let product = products.FirstOrDefault(p => p.Id == item.ProductId) select new OrderItem() { ProductId = item.ProductId, Price = product.Price }).ToList(); var order = new Order { Title = model.Title, CreateTime = DateTime.Now, TotalAmount = itemsModels.Count, TotalPrice = itemsModels.Sum(item => item.Price), OrderItems = itemsModels }; return(_orderDao.Add(order)); }
public IHttpActionResult Get(int id) { return(Ok(productService.Get(id))); }
public ProductDto Get(int id) { return(DtoConverter.Convert(_productDao.Get(id))); }
/// <summary> /// Returns a product with the given id. /// </summary> /// <param name="productId">Product's ID.</param> /// <returns>A product</returns> public IDataResult <Product> GetById(int productId) { return(new SuccessDataResult <Product>(_productDao.Get(p => p.Id == productId))); }
public async Task <IEnumerable <Product> > Get(ProductGetOptions options) => await _dao.Get(options);
public Product Get(int idProduct) { IdCheck(idProduct); return(productDao.Get(idProduct)); }
public Product GetById(int id) { return(_productDao.Get(p => p.ProductId == id)); }