modified all admin UIs to position action buttons on the left side of grids and implemented ActionDialog throughout rather than dedicated delete components
This commit is contained in:
72
Oqtane.Server/Controllers/ScheduleController.cs
Normal file
72
Oqtane.Server/Controllers/ScheduleController.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class ScheduleController : Controller
|
||||
{
|
||||
private readonly IScheduleRepository Schedules;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ScheduleController(IScheduleRepository Schedules, ILogManager logger)
|
||||
{
|
||||
this.Schedules = Schedules;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
public IEnumerable<Schedule> Get()
|
||||
{
|
||||
return Schedules.GetSchedules();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
public Schedule Get(int id)
|
||||
{
|
||||
return Schedules.GetSchedule(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Schedule Post([FromBody] Schedule Schedule)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Schedule = Schedules.AddSchedule(Schedule);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Schedule Added {Schedule}", Schedule);
|
||||
}
|
||||
return Schedule;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Schedule Put(int id, [FromBody] Schedule Schedule)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Schedule = Schedules.UpdateSchedule(Schedule);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Schedule Updated {Schedule}", Schedule);
|
||||
}
|
||||
return Schedule;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Schedules.DeleteSchedule(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Schedule Deleted {ScheduleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
74
Oqtane.Server/Controllers/ScheduleLogController.cs
Normal file
74
Oqtane.Server/Controllers/ScheduleLogController.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class ScheduleLogController : Controller
|
||||
{
|
||||
private readonly IScheduleLogRepository ScheduleLogs;
|
||||
private readonly ILogManager logger;
|
||||
|
||||
public ScheduleLogController(IScheduleLogRepository ScheduleLogs, ILogManager logger)
|
||||
{
|
||||
this.ScheduleLogs = ScheduleLogs;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public IEnumerable<ScheduleLog> Get()
|
||||
{
|
||||
return ScheduleLogs.GetScheduleLogs();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public ScheduleLog Get(int id)
|
||||
{
|
||||
return ScheduleLogs.GetScheduleLog(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public ScheduleLog Post([FromBody] ScheduleLog ScheduleLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ScheduleLog = ScheduleLogs.AddScheduleLog(ScheduleLog);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Schedule Log Added {ScheduleLog}", ScheduleLog);
|
||||
}
|
||||
return ScheduleLog;
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public ScheduleLog Put(int id, [FromBody] ScheduleLog ScheduleLog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ScheduleLog = ScheduleLogs.UpdateScheduleLog(ScheduleLog);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Schedule Log Updated {ScheduleLog}", ScheduleLog);
|
||||
}
|
||||
return ScheduleLog;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
ScheduleLogs.DeleteScheduleLog(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Schedule Log Deleted {ScheduleLogId}", id);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user