Добавил глобальный поиск
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Create and publish a Docker image / build-and-push-image (push) Successful in 29s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Create and publish a Docker image / build-and-push-image (push) Successful in 29s
				
			This commit is contained in:
		
							
								
								
									
										43
									
								
								PaydayFrontend/Services/IBankService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								PaydayFrontend/Services/IBankService.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
using System.Text.Json;
 | 
			
		||||
using PaydayFrontend.Models;
 | 
			
		||||
 | 
			
		||||
namespace PaydayFrontend.Services;
 | 
			
		||||
 | 
			
		||||
public interface IBankService
 | 
			
		||||
{
 | 
			
		||||
    public Task<List<Bank>> GetAllBanks();
 | 
			
		||||
    public Task<IEnumerable<Offer>> GetOffers(long directionId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class BankService : IBankService
 | 
			
		||||
{
 | 
			
		||||
    private readonly HttpClient _httpClient;
 | 
			
		||||
 | 
			
		||||
    public BankService(HttpClient httpClient)
 | 
			
		||||
    {
 | 
			
		||||
        _httpClient = httpClient;
 | 
			
		||||
        _httpClient.BaseAddress = new Uri("https://payday.zetcraft.ru");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task<List<Bank>> GetAllBanks()
 | 
			
		||||
    {
 | 
			
		||||
        var response = await _httpClient.GetAsync("v1/admin/banks");
 | 
			
		||||
        var result = await response.Content.ReadAsStringAsync();
 | 
			
		||||
        var banks = JsonSerializer.Deserialize<List<Bank>>(result, new JsonSerializerOptions
 | 
			
		||||
        {
 | 
			
		||||
            PropertyNameCaseInsensitive = true
 | 
			
		||||
        });
 | 
			
		||||
        return banks;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public async Task<IEnumerable<Offer>> GetOffers(long directionId)
 | 
			
		||||
    {
 | 
			
		||||
        var response = await _httpClient.GetAsync("v1/public/credit/direction/" + directionId);
 | 
			
		||||
        var result = await response.Content.ReadAsStringAsync();
 | 
			
		||||
        var offers = JsonSerializer.Deserialize<IEnumerable<Offer>>(result, new JsonSerializerOptions
 | 
			
		||||
        {
 | 
			
		||||
            PropertyNameCaseInsensitive = true
 | 
			
		||||
        });
 | 
			
		||||
        return offers;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -8,7 +8,6 @@ public interface IUniversityService
 | 
			
		||||
    public Task<List<University>> GetAllUniversity(); 
 | 
			
		||||
    public Task<List<Direction>> GetDirectionsByUniversityId(long universityId);
 | 
			
		||||
    public Task<University> GetUniversityById(long id);
 | 
			
		||||
    public Task<IEnumerable<Offer>> GetOffers(long directionId);
 | 
			
		||||
    public Task<Direction> GetDirectionsById(long directionId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -66,14 +65,4 @@ public class UniversityService : IUniversityService
 | 
			
		||||
        return university;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public async Task<IEnumerable<Offer>> GetOffers(long directionId)
 | 
			
		||||
    {
 | 
			
		||||
        var response = await _httpClient.GetAsync("v1/public/credit/direction/" + directionId);
 | 
			
		||||
        var result = await response.Content.ReadAsStringAsync();
 | 
			
		||||
        var offers = JsonSerializer.Deserialize<IEnumerable<Offer>>(result, new JsonSerializerOptions
 | 
			
		||||
        {
 | 
			
		||||
            PropertyNameCaseInsensitive = true
 | 
			
		||||
        });
 | 
			
		||||
        return offers;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user