...
This commit is contained in:
62
Presentation/HushianWebApp/Service/ChatService.cs
Normal file
62
Presentation/HushianWebApp/Service/ChatService.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Common.Dtos.Conversation;
|
||||
using Common.Enums;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace HushianWebApp.Service
|
||||
{
|
||||
public class ChatService
|
||||
{
|
||||
private readonly BaseController _baseController;
|
||||
const string BaseRoute = "v1/Chat/";
|
||||
|
||||
//Inbox1
|
||||
public async Task<List<ChatItemDto>> ChatAwaitingOurResponse()
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}ChatsAwaitingOurResponse");
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<List<ChatItemDto>>();
|
||||
|
||||
return new();
|
||||
}
|
||||
//Inbox2
|
||||
public async Task<List<ChatItemDto>> MyChatsIsInProgress()
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}MyChats", ConversationStatus.InProgress);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<List<ChatItemDto>>();
|
||||
|
||||
return new();
|
||||
}
|
||||
//Inbox3
|
||||
public async Task<List<ChatItemDto>> MyChatsIsFinished()
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}MyChats", ConversationStatus.Finished);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<List<ChatItemDto>>();
|
||||
|
||||
return new();
|
||||
}
|
||||
public async Task<ChatItemDto> NewChatFromCurrentUser(ADD_ConversationDto conversation)
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}NewChatFromCurrentUser", conversation);
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<ChatItemDto>();
|
||||
|
||||
return null;
|
||||
}
|
||||
public async Task<ChatItemResponseDto?> ADDChatResponse(int ConversationID, string text, ConversationType type)
|
||||
{
|
||||
var response = await _baseController.Post($"{BaseRoute}ADDChatResponse", new ADD_ConversationResponseDto()
|
||||
{
|
||||
ConversationID = ConversationID,
|
||||
Text = text,
|
||||
Type = type
|
||||
});
|
||||
if (response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadFromJsonAsync<ChatItemResponseDto>();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -39,6 +39,15 @@ namespace HushianWebApp.Service
|
||||
var response = await _baseController.Delete ($"{BaseRoute}DeleteGroup/{GroupID}");
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
public async Task<List<Read_GroupDto>?> GetGroups()
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}GetGroups");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<List<Read_GroupDto>>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public async Task<List<Read_GroupDto>?> GetGroupsCompany()
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}GetGroupsCompany");
|
||||
|
@@ -92,6 +92,15 @@ namespace HushianWebApp.Service
|
||||
var response = await _baseController.Delete($"{BaseRoute}DeleteExperFromManager/{ExperID}");
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
public async Task<CurrentUserInfo> GetCurrentUserInfo()
|
||||
{
|
||||
var response = await _baseController.Get($"{BaseRoute}GetCurrentUserInfo");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadFromJsonAsync<CurrentUserInfo>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user