|
@@ -0,0 +1,56 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace HyperCube.Models
|
|
|
+{
|
|
|
+ public enum NotificationType {System = 0, User }
|
|
|
+
|
|
|
+ public class Notification
|
|
|
+ {
|
|
|
+ public int ID { get; set; }
|
|
|
+ public NotificationType Type { get; set; }
|
|
|
+ public string Header { get; set; }
|
|
|
+ public string Body { get; set; }
|
|
|
+ public bool IsRead
|
|
|
+ {
|
|
|
+ get { return IsRead; }
|
|
|
+ set { DateRead = IsRead ? DateTime.Now : null; }
|
|
|
+ }
|
|
|
+ public DateTime? DateRead { get; private set; }
|
|
|
+ public bool IsApproved
|
|
|
+ {
|
|
|
+ get { return IsApproved; }
|
|
|
+ set { DateApprove = IsApproved ? DateTime.Now : null; }
|
|
|
+ }
|
|
|
+ public DateTime? DateApprove { get; private set; }
|
|
|
+ public bool IsRejected
|
|
|
+ {
|
|
|
+ get { return IsRejected; }
|
|
|
+ set { DateReject = IsRejected ? DateTime.Now : null; }
|
|
|
+ }
|
|
|
+ public DateTime? DateReject { get; private set; }
|
|
|
+
|
|
|
+ //public Notification(NotificationType type, string header, string body)
|
|
|
+ //{
|
|
|
+ //}
|
|
|
+
|
|
|
+ public async Task<int> Send()
|
|
|
+ {
|
|
|
+ string sql = $"INSERT INTO notifications (type, header, body) " +
|
|
|
+ $"VALUES ('{(int)Type}','{Header}','{Body}')";
|
|
|
+ long id = await MySQLConnector.Instance().SQLInsert(sql);
|
|
|
+ ID = (int)id;
|
|
|
+ return ID;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task Update()
|
|
|
+ {
|
|
|
+ string sql = $"UPDATE notifications" +
|
|
|
+ $" SET isread='{IsRead}', dateread='{DateRead}', isapproved='{IsApproved}', dateapprove='{DateApprove}', isrejected='{IsRejected}', datereject='{DateReject}' " +
|
|
|
+ $" WHERE id ='{ID}'";
|
|
|
+ await MySQLConnector.Instance().SQLInsert(sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|