示例#1
0
        public async void Share([FromHeader] string auth, [FromForm] string uid, [FromForm] string friend)
        {
            string user;

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

            HttpContext.Response.Headers.Add("auth", auth);
            if (!ShoppingListStore.Exists(uid, user).Result || !UserStore.Exists(friend).Result)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            await ShoppingListStore.Share(uid, user, friend);
        }
示例#2
0
        public async void EditProduct([FromHeader] string auth, [FromForm] string product,
                                      [FromForm] string uid, [FromForm] long quantity)
        {
            string user;

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

            HttpContext.Response.Headers.Add("auth", auth);
            if (!ProductStore.Exists(product).Result || !ShoppingListStore.Exists(uid, user).Result)
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            await ShoppingListStore.Restock(uid, product, quantity, user);
        }