コード例 #1
0
        public IActionResult UpdateLocation([FromBody] UpdateInventoryModel updateInventoryModel, string token)
        {
            var usertoken = Configuration["usertoken"];

            if (token == usertoken)
            {
                bool result = _inventoryService.UpdateLocation(updateInventoryModel.QRCode, updateInventoryModel.BinLocationId, updateInventoryModel.Quantity, updateInventoryModel.MovementType);
                if (result)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(Ok("wrong token passed"));
            }
        }
コード例 #2
0
        public static async Task <ErrorModel> UpdateInventory(long inventoryId, long shelfId, int newAmount = -1)
        {
            var url     = Links.baseLink + Links.inventories;
            var payload = new UpdateInventoryModel
            {
                InventoryId = inventoryId,
                ShelfId     = shelfId
            };

            if (newAmount != -1)
            {
                payload.Amount = newAmount;
            }

            var token = await GetToken();

            var responseBody = await RestVerbs.Put(url, payload, token);

            if (string.IsNullOrEmpty(responseBody) && newAmount == 0)
            {
                return(new ErrorModel {
                    ErrorCode = true, Message = null, Object = new InventoryResponse {
                        InventoryId = 0, ShelfId = 0, Amount = 0
                    }
                });
            }
            try
            {
                var responseBodyJson = JsonConvert.DeserializeObject <InventoryResponse>(responseBody);
                return(new ErrorModel {
                    ErrorCode = true, Message = null, Object = responseBodyJson
                });
            }
            catch (Exception error)
            {
                return(new ErrorModel {
                    ErrorCode = false, Message = error.Message, Object = null
                });
            }
        }