using Oqtane.Models; using System.Threading.Tasks; using System.Net.Http; using System.Linq; using System.Collections.Generic; using Oqtane.Documentation; using Oqtane.Shared; namespace Oqtane.Services { [PrivateApi("Don't show in the documentation, as everything should use the Interface")] public class ProfileService : ServiceBase, IProfileService { public ProfileService(HttpClient http, SiteState siteState) : base(http, siteState) { } private string Apiurl => CreateApiUrl("Profile"); public async Task> GetProfilesAsync(int siteId) { List profiles = await GetJsonAsync>($"{Apiurl}?siteid={siteId}"); return profiles.OrderBy(item => item.ViewOrder).ToList(); } public async Task GetProfileAsync(int profileId) { return await GetJsonAsync($"{Apiurl}/{profileId}"); } public async Task AddProfileAsync(Profile profile) { return await PostJsonAsync(Apiurl, profile); } public async Task UpdateProfileAsync(Profile profile) { return await PutJsonAsync($"{Apiurl}/{profile.ProfileId}", profile); } public async Task DeleteProfileAsync(int profileId) { await DeleteAsync($"{Apiurl}/{profileId}"); } } }