public async Task <Inventory <OwnedProduct> > Info([FromHeader] string auth, [FromRoute] string uid) { 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); var u = await InventoryStore.Get(uid, user); if (u != null) { return(u); } HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; return(null); }
public async Task <List <MinimalRecipe> > Search([FromHeader] string auth, [FromForm] string keys, [FromForm] string inventory) { string user; if ((user = JwtBuilder.UserJwtToken(auth).Result) == null || !UserStore.Exists(user).Result) { HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized; return(null); } List <MinimalRecipe> list; HttpContext.Response.Headers.Add("auth", auth); if (inventory != null) { var inv = InventoryStore.Get(inventory, user).Result; if (inv == null) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; return(null); } var r = new List <Product>(inv._products); list = RecipeSearch.SearchMinimalRecipe(API_KEY, 10, r); } else { list = RecipeSearch.SearchMinimalRecipe(API_KEY, 10, keys); } foreach (var v in list) { await RecipeStore.Add(v); } return(list); }