Example #1
0
        public static Teacher GetUserByEmail(string email)
        {
            var db = new DnevnikEntities();
            var t  = db.Teachers.Where(a => a.Email == email).FirstOrDefault();

            db.Dispose();
            return(t);
        }
Example #2
0
        public static List <Subject> GetSubjects()
        {
            var db       = new DnevnikEntities();
            var subjects = db.Subjects.ToList();

            db.Dispose();
            return(subjects);
        }
Example #3
0
        public static Teacher GetCurrentUser(int id)
        {
            var dbContext = new DnevnikEntities();
            var teacher   = dbContext.Teachers.Where(t => t.Id == id).FirstOrDefault();

            dbContext.Dispose();
            return(teacher);
        }
Example #4
0
        public static List <SingleClass> GetClasses()
        {
            var db      = new DnevnikEntities();
            var classes = db.Classes.Where(c => c.Id > 1).OrderBy(c => c.Number).ThenBy(c => c.Letter);

            List <SingleClass> classesList = new List <SingleClass>();

            foreach (var item in classes)
            {
                SingleClass c = new SingleClass()
                {
                    Id     = item.Id,
                    Number = item.Number,
                    Letter = ConvertClassLetter(item.Letter)
                };
                classesList.Add(c);
            }

            db.Dispose();
            return(classesList);
        }
Example #5
0
        public static List <SubjectVM> GetClassSubjects(int class_id)
        {
            var db       = new DnevnikEntities();
            var subjects = db.Schedules
                           .Where(s => s.Class_id == class_id)
                           .GroupBy(s => new
            {
                Id       = s.Subject.Id,
                Title    = s.Subject.Title,
                IsZip    = s.Subject.IsZip,
                Semester = s.Semester
            })
                           .Select(o => new SubjectVM
            {
                Id       = o.Key.Id,
                Title    = o.Key.Title,
                IsZip    = o.Key.IsZip,
                Semester = o.Key.Semester
            })
                           .ToList();

            db.Dispose();
            return(subjects);
        }