Beispiel #1
0
        public static Teacher LoginUser(string username, string password)
        {
            var db   = new DnevnikEntities();
            var user = db.Teachers.Include("Class").Where(t => t.Email == username && t.Password == password).FirstOrDefault();

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

            db.Dispose();
            return(subjects);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 public static void DeleteAllGrades()
 {
     using (var db = new DnevnikEntities())
     {
         db.Grades.RemoveRange(db.Grades.Where(x => 1 == 1));
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public static int GetClassId(int number, int letter)
 {
     using (var db = new DnevnikEntities())
     {
         int id = db.Classes.Where(c => c.Number == number && c.Letter == letter).Select(c => c.Id).FirstOrDefault();
         return(id);
     }
 }
Beispiel #7
0
 public static void UpdateTeacherSettings(Teacher t)
 {
     using (var db = new DnevnikEntities())
     {
         db.Teachers.Add(t);
         var entry = db.Entry(t);
         entry.State = EntityState.Modified;
         entry.Property(e => e.IsAdmin).IsModified  = false;
         entry.Property(e => e.Class_id).IsModified = false;
         db.SaveChanges();
     }
 }
Beispiel #8
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);
        }
Beispiel #9
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);
        }