Ejemplo n.º 1
0
        public static int GetStudentNumber(int groupID)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = dc.Students_Groups.Where(x => x.GroupID == groupID).Where(y => y.Active == true).Select(s => s).Count();

            return(res);
        }
Ejemplo n.º 2
0
        public static Sections GetSectionData(int topicID)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = dc.Sections.Where(x => x.TopicID == topicID).Select(s => s).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 3
0
        public static String GetSalt(Users searchCrit)
        {
            BDIIDataContext dc   = new BDIIDataContext();
            String          salt = dc.Users.Where(x => x.Login == searchCrit.Login).Select(x => x.Salt).SingleOrDefault();

            return(salt != null ? salt : null);
        }
Ejemplo n.º 4
0
        public static IQueryable <dynamic> GetStudents(Users searchCrit, int number)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = from el in dc.Users
                                  join ol in dc.Students on el.ID equals ol.UserID
                                  where
                                  (String.IsNullOrEmpty(searchCrit.Surname) || el.Surname.StartsWith(searchCrit.Surname))
                                  &&
                                  (String.IsNullOrEmpty(searchCrit.Name) || el.Name.StartsWith(searchCrit.Name))
                                  &&
                                  (number == 0) || (number == Convert.ToInt32(ol.AlbumNr))
                                  select new
            {
                el.ID,
                el.Login,
                el.Name,
                el.Surname,
                el.Hash,
                el.TypeOfUser,
                ol.UserID,
                ol.AlbumNr
            };

            return(res);
        }
Ejemplo n.º 5
0
        public static Topics GetTopicData(Topics searchCrit)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = dc.Topics.Where(x => x.ID == searchCrit.ID).Select(s => s).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 6
0
        public static Users LogIn(Users searchCrit)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            Users           usr = dc.Users.Where(x => Equals(x.Hash, searchCrit.Hash)).Where(x => Equals(x.Login, searchCrit.Login)).Select(x => x).SingleOrDefault();

            return(usr);
        }
Ejemplo n.º 7
0
        public static Topics[] GetArrayTopics(int teacherID)
        {
            BDIIDataContext dc = new BDIIDataContext();

            Topics[] res = (from el in dc.Topics
                            where el.TeacherID == teacherID
                            select el).ToArray();

            return(res);
        }
Ejemplo n.º 8
0
        public static Sections GetSection(Sections searchCrit)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = (from el in dc.Sections
                                   where
                                   ((el.ID == searchCrit.ID) || (searchCrit.ID == 0))
                                   select el).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 9
0
        public static Files GetFile(int id)
        {
            BDIIDataContext dc = new BDIIDataContext();

            var res = (from el in dc.Files
                       where (el.ID == id)
                       select el).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 10
0
        public static Sections GetMySection(int albumnr)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = (from el in dc.Sections
                                   join ol in dc.Students_Groups on el.ID equals ol.GroupID
                                   where
                                   (Convert.ToInt32(ol.StudentAlbumNr) == albumnr && ol.Active != false)
                                   select el).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 11
0
        public static string GetName(int id)
        {
            BDIIDataContext dc = new BDIIDataContext();

            Users res = (from el in dc.Users
                         join ol in dc.Teachers on el.ID equals ol.UserID
                         where
                         (id == Convert.ToInt32(ol.ID))
                         select el).SingleOrDefault();

            return(res.Name + " " + res.Surname);
        }
Ejemplo n.º 12
0
        public static Users[] GetSectionSquad(int id)
        {
            BDIIDataContext dc = new BDIIDataContext();

            Users[] res = (from el in dc.Users
                           join ol in dc.Students on el.ID equals ol.UserID
                           join il in dc.Students_Groups on ol.AlbumNr equals il.StudentAlbumNr
                           where
                           (id == Convert.ToInt32(il.GroupID) && il.Active == true)
                           select el).ToArray();
            return(res);
        }
Ejemplo n.º 13
0
        public static Teachers GetTeacherFromUser(Users usr)
        {
            BDIIDataContext dc = new BDIIDataContext();

            var res = (from el in dc.Users
                       join ol in dc.Teachers on el.ID equals ol.UserID
                       where
                       (usr.ID == Convert.ToInt32(el.ID))
                       select ol).SingleOrDefault();

            return(res);
        }
Ejemplo n.º 14
0
 public static int GetMaxSecID()
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         if (dc.Sections.Select(x => x.ID).Count() == 0)
         {
             return(0);
         }
         else
         {
             return(dc.Sections.Select(x => x.ID).Max());
         }
     }
 }
Ejemplo n.º 15
0
        public static void InsertTeacher(Users user, string degree)
        {
            var teacher = InsertUser(user);

            using (BDIIDataContext dc = new BDIIDataContext())
            {
                Teachers tch = new Teachers();
                tch.AcademicDegree = degree;
                tch.UserID         = teacher.ID;
                tch.ID             = -1;
                dc.Teachers.InsertOnSubmit(tch);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 16
0
        public static IQueryable <Users> GetUsers(Users searchCrit, string type)
        {
            BDIIDataContext dc  = new BDIIDataContext();
            var             res = from el in dc.Users
                                  where
                                  (String.IsNullOrEmpty(searchCrit.Surname) || el.Surname.StartsWith(searchCrit.Surname))
                                  &&
                                  (String.IsNullOrEmpty(searchCrit.Name) || el.Name.StartsWith(searchCrit.Name))
                                  &&
                                  (String.IsNullOrEmpty(type) || el.TypeOfUser.Equals(type))
                                  select el;

            return(res);
        }
Ejemplo n.º 17
0
 public static void UpdateGroupStudent(int number, int secID, bool state)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         if (state == false)
         {
             Students_Groups res = (from el in dc.Students_Groups
                                    where (el.StudentAlbumNr == number.ToString() && el.GroupID == secID)
                                    select el).SingleOrDefault();
             if (res != null)
             {
                 res.Active = state;
                 dc.SubmitChanges();
             }
         }
     }
 }