Initial commit
This commit is contained in:
55
Client/Services/PremiumAreaService.cs
Normal file
55
Client/Services/PremiumAreaService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.PremiumArea.Services
|
||||
{
|
||||
public interface IPremiumAreaService
|
||||
{
|
||||
Task<List<Models.PremiumArea>> GetPremiumAreasAsync(int ModuleId);
|
||||
|
||||
Task<Models.PremiumArea> GetPremiumAreaAsync(int PremiumAreaId, int ModuleId);
|
||||
|
||||
Task<Models.PremiumArea> AddPremiumAreaAsync(Models.PremiumArea PremiumArea);
|
||||
|
||||
Task<Models.PremiumArea> UpdatePremiumAreaAsync(Models.PremiumArea PremiumArea);
|
||||
|
||||
Task DeletePremiumAreaAsync(int PremiumAreaId, int ModuleId);
|
||||
}
|
||||
|
||||
public class PremiumAreaService : ServiceBase, IPremiumAreaService
|
||||
{
|
||||
public PremiumAreaService(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
||||
|
||||
private string Apiurl => CreateApiUrl("PremiumArea");
|
||||
|
||||
public async Task<List<Models.PremiumArea>> GetPremiumAreasAsync(int ModuleId)
|
||||
{
|
||||
List<Models.PremiumArea> PremiumAreas = await GetJsonAsync<List<Models.PremiumArea>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.PremiumArea>().ToList());
|
||||
return PremiumAreas.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Models.PremiumArea> GetPremiumAreaAsync(int PremiumAreaId, int ModuleId)
|
||||
{
|
||||
return await GetJsonAsync<Models.PremiumArea>(CreateAuthorizationPolicyUrl($"{Apiurl}/{PremiumAreaId}/{ModuleId}", EntityNames.Module, ModuleId));
|
||||
}
|
||||
|
||||
public async Task<Models.PremiumArea> AddPremiumAreaAsync(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
return await PostJsonAsync<Models.PremiumArea>(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, PremiumArea.ModuleId), PremiumArea);
|
||||
}
|
||||
|
||||
public async Task<Models.PremiumArea> UpdatePremiumAreaAsync(Models.PremiumArea PremiumArea)
|
||||
{
|
||||
return await PutJsonAsync<Models.PremiumArea>(CreateAuthorizationPolicyUrl($"{Apiurl}/{PremiumArea.PremiumAreaId}", EntityNames.Module, PremiumArea.ModuleId), PremiumArea);
|
||||
}
|
||||
|
||||
public async Task DeletePremiumAreaAsync(int PremiumAreaId, int ModuleId)
|
||||
{
|
||||
await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{PremiumAreaId}/{ModuleId}", EntityNames.Module, ModuleId));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user