...
This commit is contained in:
63
Presentation/HushianWebApp/Service/CompanyService.cs
Normal file
63
Presentation/HushianWebApp/Service/CompanyService.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Common.Dtos.Company;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace HushianWebApp.Service
|
||||
{
|
||||
public class CompanyService
|
||||
{
|
||||
private readonly BaseController _baseController;
|
||||
const string BaseRoute = "v1/Company/";
|
||||
public CompanyService(BaseController baseController)
|
||||
{
|
||||
_baseController = baseController;
|
||||
}
|
||||
|
||||
public async Task<int> RegisterCompany(RegisterCompanyDto request)
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}NewCompany", request);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<int>();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public async Task<ReadANDUpdate_CompanyDto?> GetCompany(int CompanyID)
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}GetCompany/{CompanyID}");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<ReadANDUpdate_CompanyDto>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public async Task<bool> UpdateCompany(ReadANDUpdate_CompanyDto dto)
|
||||
{
|
||||
var response = await _baseController.Put($"{BaseRoute}UpdateCompany",dto);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
//public async Task<bool> AddContentInfo(string str)
|
||||
//{
|
||||
// var response = await _baseController.Post($"{BaseRoute}AddContentInfo?ContentInfo={str}");
|
||||
// return response.IsSuccessStatusCode;
|
||||
//}
|
||||
//public async Task<bool> DeleteContentInfo(int ID)
|
||||
//{
|
||||
// var response = await _baseController.Delete($"{BaseRoute}DeleteContentInfo/{ID}");
|
||||
// return response.IsSuccessStatusCode;
|
||||
//}
|
||||
//public async Task<bool> UpdateContentInfo(int ID, string str)
|
||||
//{
|
||||
// var response = await _baseController.Put($"{BaseRoute}UpdateContentInfo/{ID}?ContentInfo={str}");
|
||||
// return response.IsSuccessStatusCode;
|
||||
//}
|
||||
//public async Task<List<ContentInfoDto>?> GetContentInfos()
|
||||
//{
|
||||
// var response = await _baseController.Get($"{BaseRoute}GetContentInfos");
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// return await response.Content.ReadFromJsonAsync<List<ContentInfoDto>?>();
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user