using Oqtane.Models; using System.Threading.Tasks; using System.Net.Http; using System.Linq; using Microsoft.AspNetCore.Components; using System.Collections.Generic; using Oqtane.Shared; namespace Oqtane.Services { public class ScheduleLogService : ServiceBase, IScheduleLogService { private readonly HttpClient http; private readonly SiteState sitestate; private readonly NavigationManager NavigationManager; public ScheduleLogService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager) { this.http = http; this.sitestate = sitestate; this.NavigationManager = NavigationManager; } private string apiurl { get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "ScheduleLog"); } } public async Task> GetScheduleLogsAsync() { List schedulelogs = await http.GetJsonAsync>(apiurl); return schedulelogs.OrderBy(item => item.StartDate).ToList(); } public async Task GetScheduleLogAsync(int ScheduleLogId) { return await http.GetJsonAsync(apiurl + "/" + ScheduleLogId.ToString()); } public async Task AddScheduleLogAsync(ScheduleLog schedulelog) { return await http.PostJsonAsync(apiurl, schedulelog); } public async Task UpdateScheduleLogAsync(ScheduleLog schedulelog) { return await http.PutJsonAsync(apiurl + "/" + schedulelog.ScheduleLogId.ToString(), schedulelog); } public async Task DeleteScheduleLogAsync(int ScheduleLogId) { await http.DeleteAsync(apiurl + "/" + ScheduleLogId.ToString()); } } }