public async Task <SpendingOperation> PostSpending(SpendingOperation _newSpendingOperation)
        {
            var model = new SpendingOperation {
                SpendingId = _newSpendingOperation.SpendingId, Time = DateTime.Now, Value = _newSpendingOperation.Value
            };
            var sendJson = JsonSerializer.Serialize <SpendingOperation>(model, null);

            using (var client = new HttpClient())
            {
                HttpResponseMessage result = await client.PostAsync(_serverURL + "/api/SpendingOperation", new StringContent(sendJson, Encoding.UTF8, "application/json"));

                if (result.IsSuccessStatusCode)
                {
                    var temp = await result.Content.ReadAsStringAsync();

                    var response = JsonSerializer.Deserialize <SpendingOperation>(await result.Content.ReadAsStringAsync(),
                                                                                  new JsonSerializerOptions
                    {
                        PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    });
                    return(response);
                }
                return(null);
            }
        }
        public async Task <IActionResult> Post(SpendingOperation _spendingOperation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            _context.Add(_spendingOperation);
            await _context.SaveChangesAsync();

            return(Ok(_spendingOperation));
        }
        public async Task <IActionResult> Put(int id, SpendingOperation _spendingOperation)
        {
            if (_spendingOperation == null || !ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            var existingSpendingOperation = _context.SpendingOperations.FirstOrDefault(x => x.SpendingOperationId == id);

            if (existingSpendingOperation != null)
            {
                existingSpendingOperation.SpendingId = _spendingOperation.SpendingId;
                existingSpendingOperation.Time       = _spendingOperation.Time;
                existingSpendingOperation.Value      = _spendingOperation.Value;

                await _context.SaveChangesAsync();
            }
            else
            {
                return(NotFound());
            }

            return(Ok(_spendingOperation));
        }