45 lines
1021 B
C#
45 lines
1021 B
C#
using Bitget_Server.EFCore.Models;
|
|
using Bitget_Server.EFCore;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bitget_Server.Controller
|
|
{
|
|
|
|
[ApiController, Route("api")]
|
|
public class PushAlarmController : ControllerBase
|
|
{
|
|
private readonly BitgetContext context;
|
|
|
|
public PushAlarmController(BitgetContext _context)
|
|
{
|
|
context = _context;
|
|
}
|
|
|
|
[HttpGet, Route("getalarm")]
|
|
public List<PushAlarm> GetAlarm(int index)
|
|
{
|
|
return context.PushAlarms.Where(x => x.Id > index).ToList();
|
|
}
|
|
|
|
[HttpGet, Route("setalarm")]
|
|
public bool SetAlarm(string title,string contents)
|
|
{
|
|
|
|
try
|
|
{
|
|
context.PushAlarms.Add(new PushAlarm {Title = title,Contents = contents,AlarmTime = DateTime.Now});
|
|
context.SaveChanges();
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|