improve performance of alias handling and allow aliases to be an unlimited number of subfolders in depth
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Shared;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -11,29 +10,24 @@ namespace Oqtane.Services
|
||||
public class NotificationService : ServiceBase, INotificationService
|
||||
{
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public NotificationService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
|
||||
public NotificationService(HttpClient http, SiteState siteState) : base(http)
|
||||
{
|
||||
_siteState = siteState;
|
||||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Notification"); }
|
||||
}
|
||||
private string Apiurl => CreateApiUrl(_siteState.Alias, "Notification");
|
||||
|
||||
public async Task<List<Notification>> GetNotificationsAsync(int siteId, string direction, int userId)
|
||||
{
|
||||
var notifications = await GetJsonAsync<List<Notification>>($"{Apiurl}?siteid={siteId.ToString()}&direction={direction.ToLower()}&userid={userId.ToString()}");
|
||||
var notifications = await GetJsonAsync<List<Notification>>($"{Apiurl}?siteid={siteId}&direction={direction.ToLower()}&userid={userId}");
|
||||
|
||||
return notifications.OrderByDescending(item => item.CreatedOn).ToList();
|
||||
}
|
||||
|
||||
public async Task<Notification> GetNotificationAsync(int notificationId)
|
||||
{
|
||||
return await GetJsonAsync<Notification>($"{Apiurl}/{notificationId.ToString()}");
|
||||
return await GetJsonAsync<Notification>($"{Apiurl}/{notificationId}");
|
||||
}
|
||||
|
||||
public async Task<Notification> AddNotificationAsync(Notification notification)
|
||||
@ -43,12 +37,12 @@ namespace Oqtane.Services
|
||||
|
||||
public async Task<Notification> UpdateNotificationAsync(Notification notification)
|
||||
{
|
||||
return await PutJsonAsync<Notification>($"{Apiurl}/{notification.NotificationId.ToString()}", notification);
|
||||
return await PutJsonAsync<Notification>($"{Apiurl}/{notification.NotificationId}", notification);
|
||||
}
|
||||
|
||||
public async Task DeleteNotificationAsync(int notificationId)
|
||||
{
|
||||
await DeleteAsync($"{Apiurl}/{notificationId.ToString()}");
|
||||
await DeleteAsync($"{Apiurl}/{notificationId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user