Beispiel #1
0
        public void PublishSharedProducts(int Id, string topic)
        {
            var message = new SharedProducts
            {
                Id = Id
            };

            bus.Send(topic, message);
        }
        public IActionResult Post([FromBody] SharedProducts product)
        {
            if (product == null)
            {
                return(BadRequest());
            }

            var newProduct = repository.Add(product);

            return(CreatedAtRoute("GetProduct", new { id = newProduct.Id }, newProduct));
        }
        public IActionResult Put(int id, [FromBody] SharedProducts product)
        {
            if (product == null || product.Id != id)
            {
                return(BadRequest());
            }

            var modifiedProduct = repository.Get(id);

            if (modifiedProduct == null)
            {
                return(NotFound());
            }

            modifiedProduct.Name          = product.Name;
            modifiedProduct.Price         = product.Price;
            modifiedProduct.ItemsInStock  = product.ItemsInStock;
            modifiedProduct.ItemsReserved = product.ItemsReserved;

            repository.Edit(modifiedProduct);
            return(new NoContentResult());
        }