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
     {
     }
 }
Example #2
0
 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;
         }
     }
 }
Example #3
0
 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;
         }
     }
 }
Example #4
0
 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;
         }
     }
 }
Example #5
0
 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;
         }
     }
 }
Example #6
0
 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;
         }
     }
 }
Example #7
0
 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
     {
     }
 }
Example #9
0
 public ScienseDao()
 {
     db = new MTWDbContext();
 }
Example #10
0
 public StudentDao()
 {
     db = new MTWDbContext();
 }
 public CalendarWorkingDao()
 {
     db = new MTWDbContext();
 }
Example #12
0
 public GroupUserDao()
 {
     db = new MTWDbContext();
 }
Example #13
0
 public ReportMonthDao()
 {
     db = new MTWDbContext();
 }
Example #14
0
 public WorkDao()
 {
     db = new MTWDbContext();
 }
Example #15
0
 public ClassDao()
 {
     db = new MTWDbContext();
 }
Example #16
0
 public MenuDao()
 {
     db = new MTWDbContext();
 }
Example #17
0
 public TypeCalendarDao()
 {
     db = new MTWDbContext();
 }
Example #18
0
 public TeacherDao()
 {
     db = new MTWDbContext();
 }
Example #19
0
 public UserDao()
 {
     db = new MTWDbContext();
 }