public async Task <List <Product> > GetAll([FromHeader] string auth)
        {
            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);
            return(await ProductStore.GetAll());
        }
예제 #2
0
        public IActionResult Get(string name)
        {
            if (name == null)
            {
                return(Ok(_mProductStore.GetAll()));
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                return(NotFound(name));
            }

            var result = _mProductStore.GetByName(name);

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

            return(Ok(result));
        }
 public IEnumerable <Product> Get(string name)
 {
     Console.WriteLine(name);
     return(name == null?_store.GetAll() : _store.GetByName(name));
 }
예제 #4
0
        public async Task ProductsReturnAllProductsAsync()
        {
            var products = await productsController.Products();

            products.Should().BeEquivalentTo(productStore.GetAll());
        }
예제 #5
0
 public IEnumerable <Product> Get(string name)
 {
     return(name == null?_mProductStore.GetAll() : _mProductStore.GetByName(name));
 }