Exemplo n.º 1
0
        public async void Edit([FromHeader] string auth, [FromForm] string uid, [FromForm] string name)
        {
            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 (await ShoppingListStore.ExistName(name, user))
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict;
                return;
            }

            await ShoppingListStore.EditName(user, uid, name);
        }
Exemplo n.º 2
0
        public async void Add([FromHeader] string auth, [FromForm] string name)
        {
            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 (await ShoppingListStore.ExistName(name, user))
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict;
            }
            else
            {
                await ShoppingListStore.Add(new Inventory <WantedProduct>(name), user);
            }
        }