protected void GetNotifications() { Session[Common.CommonConstants.NOTIFICATION_COUNT] = 0; Session[Common.CommonConstants.NOTIFICATION] = new List <Notification>(); try { var session = (UserLogin)Session[Common.CommonConstants.USER_SESSION]; if (session.GroupID == "MEMBER") { var notifications = new List <Notification>(); MTWDbContext mTWDbContext = new MTWDbContext(); var notification = mTWDbContext.Notification.Where(x => x.UserID == session.ID && !x.IsRead); if (notification != null) { Session[Common.CommonConstants.NOTIFICATION_COUNT] = notification.Count(); } if (notification.Count() > 3) { notifications = notification.Take(3).ToList(); } else { notifications = notification.ToList(); } Session[Common.CommonConstants.NOTIFICATION] = notifications; } } catch { } }
public void GetClass() { if (ClassID > 0) { using (MTWDbContext db = new MTWDbContext()) { this.ClassName = db.Class.Find(this.ClassID) != null? db.Class.Find(this.ClassID).Name : string.Empty; } } }
public void GetScience() { if (ScienceID > 0) { using (MTWDbContext db = new MTWDbContext()) { this.ScienceName = db.Science.Find(this.ScienceID) != null? db.Science.Find(this.ScienceID).Name : string.Empty; } } }
public void GetTeacher() { if (TeacherID > 0) { using (MTWDbContext db = new MTWDbContext()) { this.TeacherName = db.Teacher.Find(this.TeacherID) != null? db.Teacher.Find(this.TeacherID).Name_Teacher : string.Empty; } } }
public void GetTypeCalendar() { if (TypeCalendarID > 0) { using (MTWDbContext db = new MTWDbContext()) { this.TypeCalendar_Name = db.TypeCalendar.Find(this.TypeCalendarID) != null? db.TypeCalendar.Find(this.TypeCalendarID).TypeName : string.Empty; } } }
public void GetWork() { if (WorkID > 0) { using (MTWDbContext db = new MTWDbContext()) { this.Work_Name = db.Work.Find(this.WorkID) != null? db.Work.Find(this.WorkID).Name_Work : string.Empty; } } }
public void GetTeacher() { this.Teachers_Name = new List <string>(); if (CalendarWorkingTeachers.Count() > 0) { using (MTWDbContext db = new MTWDbContext()) { foreach (var item in CalendarWorkingTeachers) { this.Teachers_Name.Add(db.Teacher.Find(item.TeacherID) != null ? db.Teacher.Find(item.TeacherID).Name_Teacher : string.Empty); } } } }
protected void SetNotification() { try { var _userLogin = (UserLogin)Session[Common.CommonConstants.USER_SESSION]; if (_userLogin != null) { if (_userLogin.GroupID == "MEMBER") { MTWDbContext db = new MTWDbContext(); var dateNow = DateTime.Now; var teacher = db.Teacher.Find(_userLogin.TeacherID); var calendarWorkingTeachers = db.CalendarWorkingTeacher.Where(x => x.TeacherID == teacher.ID).Select(x => x.CalendarWorkingID).ToArray(); var calendarWorking = db.CalendarWorking.OrderBy(x => x.DateStart).ToList().FirstOrDefault(x => calendarWorkingTeachers.Contains(x.ID) && x.DateStart.Date > dateNow.Date ); var check = db.Notification.SingleOrDefault(x => x.ContentID == calendarWorking.ID); if (check == null) { db.Notification.Add(new Notification { Type = 0, ContentID = calendarWorking.ID, UserID = _userLogin.ID, IsRead = false, CreatedDate = dateNow, Contents = string.Format("Sắp đến công tác '{0}' vào thời gian '{1}' tại địa điểm '{2}'", calendarWorking.Name_CalendarWorking, calendarWorking.DateStart, calendarWorking.Address) }); db.SaveChanges(); } } } } catch { } }
public ScienseDao() { db = new MTWDbContext(); }
public StudentDao() { db = new MTWDbContext(); }
public CalendarWorkingDao() { db = new MTWDbContext(); }
public GroupUserDao() { db = new MTWDbContext(); }
public ReportMonthDao() { db = new MTWDbContext(); }
public WorkDao() { db = new MTWDbContext(); }
public ClassDao() { db = new MTWDbContext(); }
public MenuDao() { db = new MTWDbContext(); }
public TypeCalendarDao() { db = new MTWDbContext(); }
public TeacherDao() { db = new MTWDbContext(); }
public UserDao() { db = new MTWDbContext(); }