Esempio n. 1
0
        public async Task <ActionResult <string> > PostMutation([FromBody] string value)
        {
            UserData user = await GetUserData(Request.Headers["token"]);

            if (user == null)
            {
                return(Unauthorized("No valid session found for this token"));
            }
            if (user.storeId == null)
            {
                return(Unauthorized("No store found for this user"));
            }
            StockMutation mutation;

            try
            {
                mutation = Json.Deserialize <StockMutation>(value);
            } catch (Exception e)
            {
                return(BadRequest("Could not process inputted mutation\n" + e.Message + "\n " + e.StackTrace.ToString()));
            }
            await StockService.AddMutation((int)user.storeId, mutation);

            return(Ok("Mutation has been posted"));
        }