public object SaveNotification(ParamNotification objnote) { SchoolMainContext db = new ConcreateContext().GetContext(objnote.userid, objnote.password); TBLNOTIFICATION objmaster = new TBLNOTIFICATION(); TBLNOTIFICATIONDETAIL objdetail = new TBLNOTIFICATIONDETAIL(); objmaster.TITLE = objnote.Title; objmaster.NOTIFICATIONDATE = objnote.NotificationDate; objmaster.NOTIFICATIONTIME = objnote.Time; objmaster.ACADEMICYEAR = "2018-2019"; objmaster.NOTIFICATIONTYPE = objnote.NotificationType; db.TBLNOTIFICATIONs.Add(objmaster); db.SaveChanges(); objdetail.NOTIFICATIONID = objmaster.NOTIFICATIONID; string studentid = objnote.student; string[] student = studentid.Split(','); if (student.Length > 0) { for (int j = 0; j < student.Length; j++) { var studid = student[j]; objdetail.STUDENTID = int.Parse(studid); objdetail.STATUS = 0; db.TBLNOTIFICATIONDETAILs.Add(objdetail); db.SaveChanges(); } } return("Notification Saved successfully"); }
public string clearNotification(ParamNotification paramNotification) { string result = null; using (IDbConnection connection = Extension.GetConnection(1)) { try { string paramTitle = ""; if (!string.IsNullOrEmpty(paramNotification.title) && paramNotification.title != "string") { paramTitle = " AND TITLE='" + paramNotification.title + "'"; } string paramKdAgen = ""; if (!string.IsNullOrEmpty(paramNotification.kd_agen) && paramNotification.kd_agen != "string") { paramKdAgen = " WHERE KD_AGEN ='" + paramNotification.kd_agen + "'"; } string sql = @"DELETE FROM T_MAGIC_NOTIFICATION" + paramKdAgen + paramTitle; var update = connection.Execute(sql); result = "Success"; } catch (Exception) { result = null; } } return(result); }
public IActionResult clearNotification(ParamNotification data) { NotificationDL dal = new NotificationDL(); var hasil = dal.clearNotification(data); return(Ok(hasil)); }
public object SaveNotification(ParamNotification objnote) { try { SchoolMainContext db = new ConcreateContext().GetContext(objnote.userid, objnote.password); if (db == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } TBLNOTIFICATION objmaster = new TBLNOTIFICATION(); TBLNOTIFICATIONDETAIL objdetail = new TBLNOTIFICATIONDETAIL(); objmaster.TITLE = objnote.Title; objmaster.NOTIFICATIONDATE = objnote.NotificationDate; objmaster.NOTIFICATIONTIME = objnote.Time; objmaster.ACADEMICYEAR = "2018-2019"; objmaster.NOTIFICATIONTYPE = objnote.NotificationType; db.TBLNOTIFICATIONs.Add(objmaster); db.SaveChanges(); objdetail.NOTIFICATIONID = objmaster.NOTIFICATIONID; string studentid = objnote.student; string[] student = studentid.Split(','); if (student.Length > 0) { for (int j = 0; j < student.Length; j++) { var studid = student[j]; objdetail.STUDENTID = int.Parse(studid); objdetail.STATUS = 0; db.TBLNOTIFICATIONDETAILs.Add(objdetail); db.SaveChanges(); } } return(new DivisionListResult() { IsSuccess = true, Notification = new InvalidUser() { IsSuccess = true, Result = "Notification Saved successfully" } }); } catch (Exception E) { return(new Results { IsSuccess = false, Message = E.Message }); } }
public IEnumerable <NotificationData> getNotificationData(ParamNotification paramNotification) { IEnumerable <NotificationData> result = null; using (IDbConnection connection = Extension.GetConnection(1)) { try { string paramTitle = ""; if (!string.IsNullOrEmpty(paramNotification.title) && paramNotification.title != "string") { paramTitle = " AND TITLE='" + paramNotification.title + "'"; } string paramId = ""; if (!string.IsNullOrEmpty(paramNotification.id) && paramNotification.id != "string") { paramId = " AND ID='" + paramNotification.id + "'"; } string paramIsRead = ""; if (!string.IsNullOrEmpty(paramNotification.is_read) && paramNotification.is_read != "string") { paramIsRead = " AND IS_READ='" + paramNotification.is_read + "'"; } string paramKdAgen = ""; if (!string.IsNullOrEmpty(paramNotification.kd_agen) && paramNotification.kd_agen != "string") { paramKdAgen = " WHERE KD_AGEN ='" + paramNotification.kd_agen + "'"; } string sql = @"SELECT * FROM T_MAGIC_NOTIFICATION" + paramKdAgen + paramId + paramIsRead + paramTitle + " ORDER BY CREATED_DATE DESC"; result = connection.Query <NotificationData>(sql); } catch (Exception) { result = null; } } return(result); }
public string readNotification(ParamNotification paramNotification) { string result = null; using (IDbConnection connection = Extension.GetConnection(1)) { try { string paramTitle = ""; if (!string.IsNullOrEmpty(paramNotification.title) && paramNotification.title != "string") { paramTitle = " AND TITLE='" + paramNotification.title + "'"; } string paramId = ""; if (!string.IsNullOrEmpty(paramNotification.id) && paramNotification.id != "string") { paramId = " AND ID='" + paramNotification.id + "'"; } string paramKdAgen = ""; if (!string.IsNullOrEmpty(paramNotification.kd_agen) && paramNotification.kd_agen != "string") { paramKdAgen = " WHERE KD_AGEN ='" + paramNotification.kd_agen + "'"; } string sql = @"UPDATE T_MAGIC_NOTIFICATION SET IS_READ='1'" + paramKdAgen + paramId + paramTitle; var update = connection.Execute(sql); if (update == 1) { result = "Success"; } } catch (Exception) { result = null; } } return(result); }
public IActionResult getNotificationList(ParamNotification data) { NotificationDL dal = new NotificationDL(); NotificationAvailable hasil = new NotificationAvailable(); /** * This params is for pagination function */ if (!string.IsNullOrEmpty(data.limit) && data.limit != "string" && !string.IsNullOrEmpty(data.page) && data.page != "string") { data.page = data.page; data.limit = data.limit; } else if (!string.IsNullOrEmpty(data.page) && data.page != "string" && string.IsNullOrEmpty(data.limit) && data.limit != "string") { data.page = data.page; data.limit = "10"; } else if (!string.IsNullOrEmpty(data.limit) && data.limit != "string" && string.IsNullOrEmpty(data.page) && data.page != "string") { data.page = "1"; data.limit = data.limit; } else { data.page = "1"; data.limit = "10"; } IEnumerable <NotificationData> result = dal.getNotificationData(data); hasil.message = "Success"; hasil.status = "S"; hasil.count = result.Cast <Object>().Count(); hasil.data = new PagedList <NotificationData>(result.ToList(), Convert.ToInt32(data.page), Convert.ToInt32(data.limit)); return(Ok(hasil)); }
public object SaveNotification([FromBody] ParamNotification obj) { NotificationBusiness objnote = new NotificationBusiness(); return(objnote.SaveNotification(obj)); }