public async Task <OutProductDTO> CreateProductAsync(InProductDTO inProductDto) { var manufacturingPlan = await _manufacturingPlanRepository.GetById(inProductDto.manufacturingPlan); var product = await _productRepository.Create(ProductMapping.InDtoToProduct(inProductDto, manufacturingPlan)); return(ProductMapping.ProductToOutDto(product)); }
public async Task <OutProductDTO> UpdateProductAsync(int id, InProductDTO inProductDto) { var manufacturingPlan = await _manufacturingPlanRepository.GetById(inProductDto.manufacturingPlan); var product = ProductMapping.InDtoToProduct(inProductDto, manufacturingPlan); product.Id = id; var updatedProduct = await _productRepository.Update(product); return(ProductMapping.ProductToOutDto(updatedProduct)); }
public async Task <IEnumerable <OutProductDTO> > GetProductsAsync(int skip, int take) { var products = await _productRepository.GetAll(skip, take); List <OutProductDTO> outProductDTOs = new List <OutProductDTO>(); foreach (Product product in products) { outProductDTOs.Add(ProductMapping.ProductToOutDto(product)); } return(outProductDTOs); }
public async Task <OutProductDTO> GetProductByIdAsync(int id) { var product = await _productRepository.GetById(id); return(ProductMapping.ProductToOutDto(product)); }