public ActionResult AddProduct([FromBody] ProductViewModel product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _logger.LogInformation("Adding product"); var newProduct = ProductMapping.SerializeProductModel(product); var newProductResponse = _productService.CreateProduct(newProduct); return(Ok(newProductResponse)); }
public ActionResult GetCurrentInventory() { _logger.LogInformation("Getting all inventory..."); var inventory = _inventoryService.GetCurrentInventory() .Select(pi => new InventoryViewModel { Id = pi.Id, Product = ProductMapping.SerializeProductModel(pi.Product), SupposedQuantity = pi.SupposedQuantity, AvailableQuantity = pi.AvailableQuantity }) .OrderBy(inv => inv.Product.Name) .ToList(); return(Ok(inventory)); }