using Oqtane.Models; using System.Threading.Tasks; using System.Net.Http; using System.Linq; using System.Collections.Generic; using Oqtane.Shared; namespace Oqtane.Services { public class ProfileService : ServiceBase, IProfileService { private readonly SiteState _siteState; public ProfileService(HttpClient http, SiteState siteState) : base(http) { _siteState = siteState; } private string Apiurl => CreateApiUrl("Profile", _siteState.Alias); 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.SiteId}", profile); } public async Task DeleteProfileAsync(int profileId) { await DeleteAsync($"{Apiurl}/{profileId}"); } } }