-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from SaintAngeLs/frontend_organizations
Frontend organizations and reactions
- Loading branch information
Showing
36 changed files
with
660 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
MiniSpace.Web/src/MiniSpace.Web/Areas/Reactions/IReactionsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using MiniSpace.Web.DTO; | ||
using MiniSpace.Web.DTO.Enums; | ||
using MiniSpace.Web.HttpClients; | ||
|
||
namespace MiniSpace.Web.Areas.Reactions | ||
{ | ||
public interface IReactionsService | ||
{ | ||
Task<IEnumerable<ReactionDto>> GetReactions(Guid contentId, ReactionContentType contentType); | ||
Task<ReactionsSummaryDto> GetReactionsSummary(Guid contentId, ReactionContentType contentType); | ||
Task<HttpResponse<object>> CreateReaction(Guid reactionId, Guid studentId, string reactionType, | ||
Guid contentId, string contentType); | ||
Task DeleteReaction(Guid reactionId); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
MiniSpace.Web/src/MiniSpace.Web/Areas/Reactions/ReactionsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using MiniSpace.Web.Areas.Identity; | ||
using MiniSpace.Web.DTO; | ||
using MiniSpace.Web.DTO.Enums; | ||
using MiniSpace.Web.HttpClients; | ||
|
||
namespace MiniSpace.Web.Areas.Reactions | ||
{ | ||
public class ReactionsService : IReactionsService | ||
{ | ||
private readonly IHttpClient _httpClient; | ||
private readonly IIdentityService _identityService; | ||
|
||
public ReactionsService(IHttpClient httpClient, IIdentityService identityService) | ||
{ | ||
_httpClient = httpClient; | ||
_identityService = identityService; | ||
} | ||
|
||
public Task<IEnumerable<ReactionDto>> GetReactions(Guid contentId, ReactionContentType contentType) | ||
{ | ||
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); | ||
return _httpClient.GetAsync<IEnumerable<ReactionDto>>($"reactions?contentId={contentId}&contentType={contentType}"); | ||
} | ||
|
||
public Task<ReactionsSummaryDto> GetReactionsSummary(Guid contentId, ReactionContentType contentType) | ||
{ | ||
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); | ||
return _httpClient.GetAsync<ReactionsSummaryDto>($"reactions/summary?contentId={contentId}&contentType={contentType}"); | ||
} | ||
|
||
public Task<HttpResponse<object>> CreateReaction(Guid reactionId, Guid studentId, string reactionType, | ||
Guid contentId, string contentType) | ||
{ | ||
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); | ||
return _httpClient.PostAsync<object, object>("reactions", | ||
new { reactionId, studentId, reactionType, contentId, contentType }); | ||
} | ||
|
||
public Task DeleteReaction(Guid reactionId) | ||
{ | ||
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken); | ||
return _httpClient.DeleteAsync($"reactions/{reactionId}"); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
MiniSpace.Web/src/MiniSpace.Web/DTO/Enums/ReactionContentType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace MiniSpace.Web.DTO.Enums | ||
{ | ||
public enum ReactionContentType | ||
{ | ||
Event, | ||
Post | ||
} | ||
} |
Oops, something went wrong.