Files
BitGet_API/Bitget_Server/Controller/PushAlarmController.cs

45 lines
1021 B
C#
Raw Permalink Normal View History

2024-06-02 19:32:08 +09:00
using Bitget_Server.EFCore.Models;
using Bitget_Server.EFCore;
using Microsoft.AspNetCore.Mvc;
namespace Bitget_Server.Controller
{
2024-06-02 20:48:47 +09:00
[ApiController, Route("api")]
2024-06-02 19:32:08 +09:00
public class PushAlarmController : ControllerBase
{
private readonly BitgetContext context;
public PushAlarmController(BitgetContext _context)
{
context = _context;
}
2024-06-02 20:48:47 +09:00
[HttpGet, Route("getalarm")]
2024-06-02 19:32:08 +09:00
public List<PushAlarm> GetAlarm(int index)
{
return context.PushAlarms.Where(x => x.Id > index).ToList();
}
2024-06-02 20:48:47 +09:00
[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;
}
}
2024-06-02 19:32:08 +09:00
}
}