Beispiel #1
0
        public void AddClassroom(Classroom Clasro)
        {
            pbDB = new ProgramBuilderEntities();
            Clasro.CreationTime = DateTime.Now;

            pbDB.Classrooms.Add(Clasro);
            pbDB.SaveChanges();
        }
Beispiel #2
0
        public Account FindAccount(string username, string password)
        {
            pbDB = new ProgramBuilderEntities();

            Account acc = pbDB.Accounts.Where(x => x.UserName == username && x.Password == password).FirstOrDefault();

            return(acc);
        }
        public string GetContentProgramPurposeBySubjectID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            Program prog = pbDB.Programs.Where(x => x.Faculty.Subjects.Any(y => y.ID == ID)).Single();

            return(prog.TrainingPurpose);
        }
        public void AddProgram(Program Prog)
        {
            pbDB = new ProgramBuilderEntities();

            Prog.CreationTime = DateTime.Now;
            pbDB.Programs.Add(Prog);

            pbDB.SaveChanges();
        }
        public void AddSyllabus(Syllabus Sylla)
        {
            pbDB = new ProgramBuilderEntities();

            Sylla.CreationTime = DateTime.Now;

            pbDB.Syllabuses.Add(Sylla);

            pbDB.SaveChanges();
        }
Beispiel #6
0
        public void AddFaculty(Faculty Facu)
        {
            pbDB = new ProgramBuilderEntities();

            Facu.CreationTime = DateTime.Now;

            pbDB.Faculties.Add(Facu);

            pbDB.SaveChanges();
        }
        public int GetLengthProgramPurposeBySubjectID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            Program prog = pbDB.Programs.Where(x => x.Faculty.Subjects.Any(y => y.ID == ID)).Single();

            int Length = Regex.Split(prog.TrainingPurpose, @"<li>").Length;

            return(Length);
        }
Beispiel #8
0
        public List <Subject> GetSubjectByAccountEditor(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            List <Subject> subs = (from s in pbDB.Subjects
                                   join sa in pbDB.SubjectsAccounts on s.ID equals sa.SubjectID
                                   where sa.AccountID == ID && sa.IsSyllabusEditor == true && sa.Subject.Faculty.Programs.Count > 0
                                   select s).ToList();

            return(subs);
        }
Beispiel #9
0
        public int GetCreditNumberByFacultyID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            var r = from su in pbDB.Subjects
                    where su.FacultyID.Value == ID
                    select su;
            int sum = r.Sum(x => x.CreditNumber);

            return(sum);
        }
Beispiel #10
0
        public List <Account> GetAccountsTeachSubjectByFacultyID(int FacultyID)
        {
            pbDB = new ProgramBuilderEntities();
            List <Account> accs = (from acc in pbDB.Accounts
                                   join sa in pbDB.SubjectsAccounts on acc.ID equals sa.AccountID
                                   join su in pbDB.Subjects on sa.SubjectID equals su.ID
                                   where su.FacultyID == FacultyID
                                   select acc).ToList();

            return(accs);
        }
Beispiel #11
0
        public void DeleteAccount(int ID)
        {
            pbDB = new ProgramBuilderEntities();
            Account AccReslut = pbDB.Accounts.Where(x => x.ID == ID).FirstOrDefault();

            pbDB.Accounts.Remove(AccReslut);

            pbDB.Roles.RemoveRange(AccReslut.Roles);

            pbDB.SaveChanges();
        }
Beispiel #12
0
        public void EditClassroom(Classroom Clasro)
        {
            pbDB = new ProgramBuilderEntities();

            Classroom clasroResult = pbDB.Classrooms.Where(x => x.ID == Clasro.ID).FirstOrDefault();

            clasroResult.Name             = Clasro.Name;
            clasroResult.IsOfficeFacility = Clasro.IsOfficeFacility;
            clasroResult.FacilityID       = Clasro.FacilityID;

            pbDB.SaveChanges();
        }
Beispiel #13
0
        public void EditFaculty(Faculty Facu)
        {
            pbDB = new ProgramBuilderEntities();

            Faculty facuResult = pbDB.Faculties.Where(x => x.ID == Facu.ID).FirstOrDefault();

            facuResult.VietNameseName = Facu.VietNameseName;
            facuResult.EnglishName    = Facu.EnglishName;
            facuResult.PhoneNumber    = Facu.PhoneNumber;
            facuResult.TrainingTime   = Facu.TrainingTime;
            facuResult.ClassroomID    = Facu.ClassroomID;

            pbDB.SaveChanges();
        }
Beispiel #14
0
        public List <GetProgramContentByFacultyID_Result> GetProgramContentByFacultyID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            List <GetProgramContentByFacultyID_Result> ProgramContent = pbDB.GetProgramContentByFacultyID(ID).ToList();

            return(ProgramContent);

            //var subject = from s in pbDB.Subjects
            //              join sof in pbDB.SubjectsOfFaculties.Where(x => x.FacultyID == ID) on s.ID equals sof.SubjectID
            //        select s;


            //var subjectTypes = (from st in pbDB.SubjectTypes
            //        join a in subject on st.ID equals a.SubjectTypeID into stGroup
            //        from stgr in stGroup.DefaultIfEmpty()
            //        select new
            //        {
            //            SubjectTypes = st
            //        }).Distinct().ToList();

            //List<SubjectType> SubTyps = new List<SubjectType>();

            //foreach (var SubjTyp in subjectTypes)
            //{
            //    SubjectType subty = new SubjectType();

            //    subty.Name = SubjTyp.SubjectTypes.Name;

            //    foreach (var sub in SubjTyp.SubjectTypes.Subjects)
            //    {
            //        Subject subj = new Subject();

            //        subj.PartialCode = sub.PartialCode;
            //        subj.Name = sub.Name;
            //        subj.CreditNumber = sub.CreditNumber;
            //        subj.SemesterNumber = sub.SemesterNumber;

            //        subty.Subjects.Add(subj);
            //    }

            //    subty.Name = SubjTyp.SubjectTypes.Name;

            //    SubTyps.Add(subty);

            //}
        }
Beispiel #15
0
        public void DeleteClassroom(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            Classroom clasro = pbDB.Classrooms.Where(x => x.ID == ID).FirstOrDefault();

            pbDB.Classrooms.Remove(clasro);

            Classroom DefaultClassro = pbDB.Classrooms.First();

            if (DefaultClassro != null)
            {
                DefaultClassro.IsOfficeFacility = false;

                EditClassroom(DefaultClassro);
            }

            pbDB.SaveChanges();
        }
Beispiel #16
0
        public void AddAccount(Account Acc, List <int> RoleIDs)
        {
            pbDB             = new ProgramBuilderEntities();
            Acc.CreationTime = DateTime.Now;

            pbDB.Accounts.Add(Acc);

            pbDB.SaveChanges();

            int CurrentAccID = Acc.ID;

            Account acc = pbDB.Accounts.FirstOrDefault(x => x.ID == CurrentAccID);

            foreach (int RoleID in RoleIDs)
            {
                Role role = pbDB.Roles.FirstOrDefault(x => x.ID == RoleID);
                acc.Roles.Add(role);
            }

            pbDB.SaveChanges();
        }
Beispiel #17
0
        public void EditAccount(Account Acc, List <int> RoleIDs)
        {
            pbDB = new ProgramBuilderEntities();
            Account AccReslut = pbDB.Accounts.FirstOrDefault(x => x.ID == Acc.ID);

            AccReslut.UserName    = Acc.UserName;
            AccReslut.Password    = Acc.Password;
            AccReslut.FullName    = Acc.FullName;
            AccReslut.Degree      = Acc.Degree;
            AccReslut.PhoneNumber = Acc.PhoneNumber;
            AccReslut.Email       = Acc.Email;
            AccReslut.FacultyID   = Acc.FacultyID;

            AccReslut.Roles.Clear();

            foreach (int RoleID in RoleIDs)
            {
                Role role = pbDB.Roles.FirstOrDefault(x => x.ID == RoleID);

                AccReslut.Roles.Add(role);
            }

            pbDB.SaveChanges();
        }
        public void EditSyllabus(Syllabus sylla)
        {
            pbDB = new ProgramBuilderEntities();

            Syllabus CurrentSylla = pbDB.Syllabuses.Single(x => x.ID == sylla.ID);

            CurrentSylla.VietnameseName            = sylla.VietnameseName;
            CurrentSylla.EnglishName               = sylla.EnglishName;
            CurrentSylla.KnowldgeType              = sylla.KnowldgeType;
            CurrentSylla.LearningTimeDetail        = sylla.LearningTimeDetail;
            CurrentSylla.Requirement               = sylla.Requirement;
            CurrentSylla.Planning                  = sylla.Planning;
            CurrentSylla.DocumentReference         = sylla.DocumentReference;
            CurrentSylla.LearningOutcomeEvaluate   = sylla.LearningOutcomeEvaluate;
            CurrentSylla.LecturerContact           = sylla.LecturerContact;
            CurrentSylla.ShortDescription          = sylla.ShortDescription;
            CurrentSylla.OutcomeContent            = sylla.OutcomeContent;
            CurrentSylla.OutcomeMaxtrixMapping     = sylla.OutcomeMaxtrixMapping;
            CurrentSylla.OutcomeMappingDescription = sylla.OutcomeMappingDescription;
            CurrentSylla.ClassroomID               = sylla.ClassroomID;
            CurrentSylla.CreationTime              = DateTime.Now;

            pbDB.SaveChanges();
        }
        public Program GetProgramByID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            return(pbDB.Programs.FirstOrDefault(x => x.ID == ID));
        }
Beispiel #20
0
        public Classroom GetClassroomByID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            return(pbDB.Classrooms.Single(x => x.ID == ID));
        }
Beispiel #21
0
        public void AddSubject(Subject subject, List <int> subjectConditionIDs, List <int> AccountIDs)
        {
            pbDB = new ProgramBuilderEntities();

            subject.CreationTime = DateTime.Now;

            pbDB.Subjects.Add(subject);

            pbDB.SaveChanges();

            int CurrentSubjectID = subject.ID;

            Subject CurrentSub = pbDB.Subjects.SingleOrDefault(x => x.ID == CurrentSubjectID);

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                if (AccountIDs[i] == AccountIDs[AccountIDs.Count - 1])
                {
                    AccountIDs.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                int tempAccID = AccountIDs[i];

                SubjectsAccount SubAcc = new SubjectsAccount();

                var acc = (from Acc2 in pbDB.Accounts
                           where Acc2.ID == tempAccID
                           select Acc2).SingleOrDefault();

                SubAcc.Subject          = CurrentSub;
                SubAcc.Account          = acc;
                SubAcc.IsSyllabusEditor = false;

                if (i == AccountIDs.Count - 1)
                {
                    SubAcc.IsSyllabusEditor = true;
                }

                pbDB.SubjectsAccounts.Add(SubAcc);
            }

            //if (AccountIDs != null)
            //{
            //    foreach (int item in AccountIDs)
            //    {
            //        if (item != AccountID)
            //        {
            //            NewAccountIDs.Add(item);
            //        }
            //    }
            //}

            //NewAccountIDs.Add(AccountID);


            //foreach(int item in NewAccountIDs)
            //{
            //    Account acc = (from Acc2 in pbDB.Accounts
            //                   where Acc2.ID == item
            //                   select Acc2).Single();

            //    SubjectsAccount SubAcc = new SubjectsAccount();
            //    SubAcc.Account = acc;
            //    SubAcc.Subject = CurrentSub;
            //    SubAcc.IsSyllabusEditor = false;

            //    if (item.Equals(AccountID))
            //    {
            //        SubAcc.IsSyllabusEditor = true;
            //    }

            //    pbDB.SubjectsAccounts.Add(SubAcc);
            //}

            if (subjectConditionIDs != null)
            {
                foreach (int subjectConditionID in subjectConditionIDs)
                {
                    Subject relateSub = pbDB.Subjects.SingleOrDefault(x => x.ID == subjectConditionID);

                    CurrentSub.Subjects1.Add(relateSub);
                }
            }

            pbDB.SaveChanges();
        }
Beispiel #22
0
        public void EditSubject(Subject subject, List <int> AccountIDs, List <int> subjectConditionIDs)
        {
            pbDB = new ProgramBuilderEntities();

            Subject CurrentSubj = pbDB.Subjects.SingleOrDefault(x => x.ID == subject.ID);

            CurrentSubj.Name           = subject.Name;
            CurrentSubj.PartialCode    = subject.PartialCode;
            CurrentSubj.CreditNumber   = subject.CreditNumber;
            CurrentSubj.TheoryNumber   = subject.TheoryNumber;
            CurrentSubj.PracticeNumber = subject.PracticeNumber;
            CurrentSubj.LearningLevel  = subject.LearningLevel;
            CurrentSubj.SemesterNumber = subject.SemesterNumber;
            CurrentSubj.Description    = subject.Description;
            CurrentSubj.Purpose        = subject.Purpose;
            CurrentSubj.SubjectTypeID  = subject.SubjectTypeID;
            CurrentSubj.FacultyID      = subject.FacultyID;
            CurrentSubj.Form           = subject.Form;


            //Remove

            CurrentSubj.SubjectsAccounts.Clear();

            CurrentSubj.Subjects1.Clear();

            // Add
            for (int i = 0; i < AccountIDs.Count; i++)
            {
                if (AccountIDs[i] == AccountIDs[AccountIDs.Count - 1])
                {
                    AccountIDs.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                int tempAccID = AccountIDs[i];

                SubjectsAccount SubAcc = new SubjectsAccount();

                var acc = (from Acc2 in pbDB.Accounts
                           where Acc2.ID == tempAccID
                           select Acc2).SingleOrDefault();

                SubAcc.Subject          = CurrentSubj;
                SubAcc.Account          = acc;
                SubAcc.IsSyllabusEditor = false;

                if (i == AccountIDs.Count - 1)
                {
                    SubAcc.IsSyllabusEditor = true;
                }

                pbDB.SubjectsAccounts.Add(SubAcc);
            }

            if (subjectConditionIDs != null)
            {
                foreach (int subjectConditionID in subjectConditionIDs)
                {
                    Subject relateSub = pbDB.Subjects.SingleOrDefault(x => x.ID == subjectConditionID);

                    CurrentSubj.Subjects1.Add(relateSub);
                }
            }


            pbDB.SaveChanges();
        }
 public List <Program> GetPrograms()
 {
     pbDB = new ProgramBuilderEntities();
     return(pbDB.Programs.ToList());
 }
        public List <Syllabus> SyllabusesList()
        {
            pbDB = new ProgramBuilderEntities();

            return(pbDB.Syllabuses.OrderBy(x => x.CreationTime).ToList());
        }
        public Syllabus GetSyllabusByID(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            return(pbDB.Syllabuses.Where(x => x.ID == ID).Single());
        }