/
n1kolas
/
VendingUserClient
Обзор
Документация
Войти
/
n1kolas
/
VendingUserClient
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Services/MoneyService.cs
39 строк
1 KB
Kharchenko Nickolai
All DONE!
27 июн 2025, 23:31
27 июн 2025, 23:31
526b129
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using AdminClient.Models; using Newtonsoft.Json; namespace AdminClient.Services { internal class MoneyService { public static async Task<Money[]?> GetMoneyAsync() { try { string url = APILinking.BaseUrl + $"Money"; var response = await APIHttpClient.Instance.GetAsync(url); if (response.IsSuccessStatusCode) { var jsonResponse = await response.Content.ReadAsStringAsync(); var money = JsonConvert.DeserializeObject<Money[]>(jsonResponse); return money; } else { return null; } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); return null; } } } }