public ActionResult <ProductDto> CreateProductForCategory(Guid categoryId, ProductForUpdateAndCreateDto product) { var category = _categoryRepository.GetCategory(categoryId); if (category == null) { return(NotFound()); } var ProductEntity = _mapper.Map <Product>(product); _productRepository.CreateProduct(categoryId, ProductEntity); _productRepository.Save(); var ProductToReturn = _mapper.Map <ProductDto>(ProductEntity); return(CreatedAtRoute("GetProductForCategory", new { categoryId = categoryId, ProductToReturn.ProductId }, ProductToReturn)); }
public ActionResult UpdateProductForCategory(Guid productId, Guid categoryId, ProductForUpdateAndCreateDto product) { var Category = _categoryRepository.GetCategory(categoryId); if (Category == null) { return(NotFound()); } var ProductForCategoryFromRepo = _productRepository.GetProduct(categoryId, productId); if (ProductForCategoryFromRepo == null) { return(NotFound()); } _mapper.Map(product, ProductForCategoryFromRepo); // AutoMapper Here Is Used For update , This Function Has No Implementation //_productRepository.UpdateProducts(product); _productRepository.Save(); return(NoContent()); }