Пример #1
0
        public async Task <ActionResult <string> > PostBulkMutation([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[] mutations;
            try
            {
                mutations = Json.Deserialize <StockMutation[]>(value);
            }
            catch (Exception e)
            {
                return(BadRequest("Could not process inputted mutations"));
            }
            await StockService.AddMutationBulk((int)user.storeId, mutations);

            return(Ok("Mutations have been posted"));
        }