Esempio n. 1
0
        public IActionResult Put([FromBody] Product value)
        {
            var result = _mProductStore.GetByName(value.Name);

            if (result == null)
            {
                return(NotFound(value));
            }

            _mProductStore.Remove(result.Name);
            _mProductStore.Add(value);

            return(Ok(value));
        }
        public async Task <Product> Add([FromHeader] string auth, [FromForm] string name, [FromForm] string category,
                                        [FromForm] long quantity, [FromForm] string units, [FromForm] double price)
        {
            string user;

            if ((user = JwtBuilder.UserJwtToken(auth).Result) == null || !UserStore.Exists(user).Result)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return(null);
            }

            HttpContext.Response.Headers.Add("auth", auth);
            //TODO Check products with same name
            var p = new Product(name, category, quantity, units, price);
            await ProductStore.Add(p);

            return(p);
        }
 public IActionResult Post([FromBody] Product product)
 {
     _store.Add(product);
     return(Ok());
 }
 public void Post([FromBody] Product value)
 {
     _mProductStore.Add(value);
 }