using Oqtane.Models; using System.Threading.Tasks; using System.Net.Http; using System.Collections.Generic; using Oqtane.Documentation; using Oqtane.Shared; using System.Linq; namespace Oqtane.Services { /// /// Service to manage s on a /// public interface ISiteGroupDefinitionService { /// /// Get all s /// /// Task> GetSiteGroupDefinitionsAsync(); /// /// Get one specific /// /// ID-reference of a /// Task GetSiteGroupDefinitionAsync(int siteGroupDefinitionId); /// /// Add / save a new to the database. /// /// /// Task AddSiteGroupDefinitionAsync(SiteGroupDefinition siteGroupDefinition); /// /// Update a in the database. /// /// /// Task UpdateSiteGroupDefinitionAsync(SiteGroupDefinition siteGroupDefinition); /// /// Delete a in the database. /// /// ID-reference of a /// Task DeleteSiteGroupDefinitionAsync(int siteGroupDefinitionId); } [PrivateApi("Don't show in the documentation, as everything should use the Interface")] public class SiteGroupDefinitionService : ServiceBase, ISiteGroupDefinitionService { public SiteGroupDefinitionService(HttpClient http, SiteState siteState) : base(http, siteState) { } private string Apiurl => CreateApiUrl("SiteGroupDefinition"); public async Task> GetSiteGroupDefinitionsAsync() { return await GetJsonAsync>($"{Apiurl}", Enumerable.Empty().ToList()); } public async Task GetSiteGroupDefinitionAsync(int siteGroupDefinitionId) { return await GetJsonAsync($"{Apiurl}/{siteGroupDefinitionId}"); } public async Task AddSiteGroupDefinitionAsync(SiteGroupDefinition siteGroupDefinition) { return await PostJsonAsync(Apiurl, siteGroupDefinition); } public async Task UpdateSiteGroupDefinitionAsync(SiteGroupDefinition siteGroupDefinition) { return await PutJsonAsync($"{Apiurl}/{siteGroupDefinition.SiteGroupDefinitionId}", siteGroupDefinition); } public async Task DeleteSiteGroupDefinitionAsync(int siteGroupDefinitionId) { await DeleteAsync($"{Apiurl}/{siteGroupDefinitionId}"); } } }