protected void Page_Load(object sender, EventArgs e)
        {
            int lecturerID = (int)Session["LecturerID"];

            if (lecturerID == 0)
                Response.Redirect("Login.aspx");

            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = new Lecturer();
            lecturer = lecturerHandler.GetLecturerDetails(lecturerID);

            if (!IsPostBack)
            {
                try
                {
                    txtEmail.Value = lecturer.Email;
                    txtFirstName.Value = lecturer.FirstName;
                    txtSurname.Value = lecturer.Surname;
                }
                catch (NullReferenceException)
                {
                    Response.Redirect("Default.aspx");
                }
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            /*string[] lines = { Request.UserHostName, Request.UserHostAddress, Request.UserAgent, Request.UrlReferrer.ToString() };
            File.WriteAllLines(@"C:\Users\micks\Documents\BitBucket\UAttendWeb\WebApp\temp\" + txtEmail.Value, lines);*/

            string loginResult = " ";
            string email = txtEmail.Value;
            string password = txtPassword.Value;
            int lecturerID = 0;
            string redirectURL = "Dashboard.aspx";

            if ((string)Session["LoginRedirect"] != null)
            {
                redirectURL = (string)Session["LoginRedirect"];
            }

            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = new Lecturer();

            lecturer = lecturerHandler.ValidateLogin(email, password);

            try
            {
                loginResult = lecturer.LecturerID.ToString();
                lecturerID = lecturer.LecturerID;
                Session["LecturerID"] = lecturerID;
                Session["FirstName"] = lecturer.FirstName;
                Session["Surname"] = lecturer.Surname;
                Response.Redirect(redirectURL);
            }
            catch (NullReferenceException)
            {
                litAlert.Text = "<div class='alert alert-danger'>The username or password you entered is incorrect</div>";
            }
        }
        protected void btnUpdateProfile_Click(object sender, EventArgs e)
        {
            int lecturerID = 0;
            try
            {
                lecturerID = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch (NullReferenceException)
            {

            }
            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = new Lecturer();
            lecturer = lecturerHandler.GetLecturerDetails(lecturerID);

            lecturer.LecturerID = lecturerID;
            lecturer.FirstName = txtFirstName.Value;
            lecturer.Surname = txtSurname.Value;

            lecturer.Email = txtEmail.Value;
            lecturer.Password = txtPassword.Value;

            if (txtPassword.Value == "")
                lecturerHandler.UpdateLecturer(lecturer);
            else if (txtPassword.Value != "")
                lecturerHandler.UpdateLecturerWithPassword(lecturer);

            Response.Redirect("Profile.aspx?id=" + lecturerID.ToString());
        }
        public async Task<ActionResult> Index()
        {
            #region Get Identity
            BusinessLogicHandler _gateWay = new BusinessLogicHandler();
            ApplicationDbContext dataSocket = new ApplicationDbContext();
            UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
            ApplicationUserManager UserManager = new ApplicationUserManager(myStore);
            var _user = await UserManager.FindByNameAsync(User.Identity.Name);
            Lecturer _staff = new Lecturer();
            _staff = _gateWay.GetLecturer(_user.Id.ToString());
            #endregion

            #region Get The Modules

            AttendanceViewModel _model = new AttendanceViewModel();
            List<Module> _modList = new List<Module>();
            List<SelectListItem> _selectList = new List<SelectListItem>();
            _modList = _gateWay.GetModulesForLecturer(_staff.StaffNumber);

            foreach (var _mod in _modList)
            {
                _selectList.Add(new SelectListItem { Text = _mod.ModuleName, Value = _mod.ModuleCode });
            }
            #endregion

            #region Get The Venues

            List<Venue> _venueList = new List<Venue>();
            List<SelectListItem> _vlist = new List<SelectListItem>();
            _venueList = _gateWay.GetAllVenues();

            foreach (Venue _venue in _venueList)
            {
                _vlist.Add(new SelectListItem { Text = _venue.VenueName, Value = _venue.VenueCode });
            }

            #endregion

            #region Getting the lectures
            List<Lecture> _lectureList = new List<Lecture>();
            List<SelectListItem> _yetAL = new List<SelectListItem>();
            _lectureList = _gateWay.GetLecturesForStaff(_staff.StaffNumber);
            _yetAL.Add(new SelectListItem { Text = "Select Lecture", Value = "0", Selected = true });
            foreach (var _item in _lectureList)
            {
                _yetAL.Add(new SelectListItem { Text = _item.ModuleCode + " " + _item.TimeSlot, Value = _item.LUI.ToString() });
            }
            #endregion

            ViewData["Lecture"] = _yetAL;
            //ViewData["Modules"] = _selectList;
            //ViewData["Venues"] = _vlist;
            //_model.Venues = _vlist;
            _model.Lectures = _yetAL;
            //_model.Modules = _selectList;
            return View(_model);
        }
Example #5
0
 public FullClassRecord(ClassTime classTime,  Group group, Subject subject, 
                        Lecturer lecturer, Classroom classroom)
 {
     Group     = group;
     ClassTime      = classTime;
     Subject   = subject;
     Lecturer  = lecturer;
     Classroom = classroom;
 }
 public bool NewLecturer(Lecturer _lecturer)
 {
     SqlParameter[] Params = new SqlParameter[]
     {
         new SqlParameter("@Name", _lecturer.Name),
         new SqlParameter("@StaffNumber", _lecturer.StaffNumber),
         new SqlParameter("@Surname",_lecturer.Surname),
         new SqlParameter("@User_Id", _lecturer.User_Id),
     };
     return DataAccess.ExecuteNonQuery("sp_InsertLecturer", CommandType.StoredProcedure,
         Params);
 }
Example #7
0
        public void Lesson_Add()
        {
            Lesson lesson1 = new Lesson();
            Lesson lesson2 = new Lesson();
            Lesson lesson3 = new Lesson();

            Lecturer l1 = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
            Lecturer l2 = new Lecturer("John Smith", 32, "JS1", Color.Blue);
            Lecturer l3 = new Lecturer("Fred Flintstone", 50, "FF", Color.Blue);

            Module m1 = new Module("Programming", "Level 3", "PL3", Color.Blue);
            Module m2 = new Module("Networking", "Degree", "NET", Color.Blue);
            Module m3 = new Module("Technical Support", "Level 1", "Tech1", Color.Blue);

            Room r1 = new Room("Room1", "L1", Color.Blue, 20);
            Room r2 = new Room("Room2", "L2", Color.Blue, 19);
            Room r3 = new Room("Room3", "L3", Color.Blue, 17);

            Group g1 = new Group("Class1", "C1", Color.Blue, 20);
            Group g2 = new Group("Class2", "C2", Color.Blue, 20);
            Group g3 = new Group("Class3", "C3", Color.Blue, 20);

            lesson1.Lecturer = l1;
            lesson1.Module = m1;
            lesson1.Group = g1;
            lesson1.Room = r1;

            lesson2.Lecturer = l2;
            lesson2.Module = m2;
            lesson2.Group = g2;
            lesson2.Room = r2;

            lesson3.Lecturer = l3;
            lesson3.Module = m3;
            lesson3.Group = g3;
            lesson3.Room = r3;

            DataCollection.Instance.Add(lesson1);
            Assert.AreEqual<Lesson>(lesson1, DataCollection.Instance.Lessons[0], "Lesson1 not found at 0");

            //  Add another instance and check if this instance is in the second index (1)
            DataCollection.Instance.Add(lesson2);
            Assert.AreEqual<Lesson>(lesson2, DataCollection.Instance.Lessons[1], "Lesson2 not found at 1");

            //  Insert an instance into the second index (1) and check if the instance is at that index and the instance
            //    before has moved to the next index (2)
            DataCollection.Instance.Insert(lesson3, 1);
            Assert.AreEqual<Lesson>(lesson3, DataCollection.Instance.Lessons[1], "Lesson3 not found at 1");
            Assert.AreEqual<Lesson>(lesson2, DataCollection.Instance.Lessons[2], "Lesson2 not found at 2");
        }
        private void okayButton_Click(object sender, EventArgs e)
        {
            string name = lecNameTextBox.Text ;
            string initials = lecInitialsTextBox.Text ;
            string email = lecEmailTextBox.Text ;
            int maxHours =Convert.ToInt32( lecMaxHoursTextBox.Text) ;
            int maxConsecHours  = Convert.ToInt32(lecMaxConsecHours.Text);
            int minSlotsPerday = Convert.ToInt32(lecMinimumSlotsTextBox.Text);
            string slotsOff = lecSlotsOffTextBox.Text;
            string department = lectDepartmentTextBox.Text ;

            Lecturer lecturer = new Lecturer(name, initials, email,  maxHours, maxConsecHours,
                minSlotsPerday , slotsOff, department );
            controller.addLecturer(lecturer);
        }
 public bool ValidateEmail(string email)
 {
     Lecturer lecturer = new Lecturer();
     lecturer = lecturerDB.ValidateEmail(email);
     bool exists = false;
     try
     {
         if (lecturer.Email != null)
             exists = true;
     }
     catch (NullReferenceException)
     {
         exists = false;
     }
     return exists;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["FirstName"] == null)
            {
                Response.Redirect("Default.aspx");
            }

            Lecturer lecturer = new Lecturer();
            LecturerHandler lecturerHandler = new LecturerHandler();

            lecturer = lecturerHandler.GetLecturerDetails(Convert.ToInt32(Session["LecturerID"]));

            if (lecturer.Role != 2)
            {
                Response.Redirect("Dashboard.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int lecturerID = (int)Session["LecturerID"];

            if (lecturerID == 0)
                Response.Redirect("Login.aspx");

            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = new Lecturer();
            lecturer = lecturerHandler.GetLecturerDetails(lecturerID);

            litLecturerName.Text = "Profile for " + lecturer.FirstName + " " + lecturer.Surname;

            txtEmail.Value = lecturer.Email;
            txtFirstName.Value = lecturer.FirstName;
            txtSurname.Value = lecturer.Surname;
        }
        //lecturer log in
        //get /api/mobile/a@a/123
        public int Get(string email, string password)
        {
            //log in here
            int lecturerId = 0;
            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = new Lecturer();

            lecturer = lecturerHandler.ValidateLogin(email, password);
            try
            {
                lecturerId = lecturer.LecturerID;
            }
            catch (Exception)
            {

            }
            return lecturerId;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["FirstName"] == null)
            {
                Response.Redirect("Default.aspx");
            }

            Lecturer lecturer = new Lecturer();
            LecturerHandler lecturerHandler = new LecturerHandler();

            lecturer = lecturerHandler.GetLecturerDetails(Convert.ToInt32(Session["LecturerID"]));

            if (lecturer.Role == 2)
            {
                litAdminMenu.Text = "<h3>Admin tools</h3><br /><a href='AddModuleAdmin.aspx' class='btn btn-success'>Add Module</a><br /><br />";
                //business button for litAdminMenu
                //<a href='BusinessSettings.aspx' class='btn btn-success'>Business Settings</a>
            }
        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            lblInvalidEmail.Text = "";
            lblConfirmPassword.Text = "";
            string option = "";
            double num = 0;

            Lecturer lecturer = new Lecturer();

            lecturer.Email = txtEmail.Value;
            lecturer.Password = txtPassword.Value;
            lecturer.FirstName = txtFirstName.Value;
            lecturer.Surname = txtSurname.Value;

            LecturerHandler lecturerHandler = new LecturerHandler();

            if (txtPassword.Value == txtConfirmPassword.Value)
            {
                if (lecturerHandler.ValidateEmail(txtEmail.Value) == false/* && double.TryParse(option, out num) == true*/)
                {
                    if (lecturerHandler.AddNewLecturer(lecturer) == false)
                        Response.Redirect("Login.aspx?registered=1");
                }

                else if (lecturerHandler.ValidateEmail(txtEmail.Value) == true)
                {
                    lblInvalidEmail.Text = "This E-Mail address is already in use";
                    txtPassword.Attributes.Add("value", txtPassword.Value);
                    txtConfirmPassword.Attributes.Add("value", txtConfirmPassword.Value);
                }

                else if (double.TryParse(option, out num) == false)
                {
                    lblInvalidEmail.Text = "";
                    txtPassword.Attributes.Add("value", txtPassword.Value);
                    txtConfirmPassword.Attributes.Add("value", txtConfirmPassword.Value);
                }
            }
            else
            {
                lblConfirmPassword.Text = "Passwords do not match";
            }
        }
        public Lecturer GetLecturer_StaffNumber(string StaffNumber)
        {
            Lecturer _lecturer = null;

            SqlParameter[] Params = { new SqlParameter("@StaffNumber", StaffNumber) };
            using (DataTable table = DataAccess.ExecuteParamatizedSelectCommand("sp_GetLecturer_StaffNumber",
                CommandType.StoredProcedure, Params))
            {
                if (table.Rows.Count == 1)
                {
                    DataRow row = table.Rows[0];
                    _lecturer = new Lecturer();
                    _lecturer.Name = row["Name"].ToString();
                    _lecturer.Surname = row["Surname"].ToString();
                    _lecturer.User_Id = row["User_Id"].ToString();
                    _lecturer.StaffNumber = row["StaffNumber"].ToString();
                }
            }
            return _lecturer;
        }
        public List<Lecturer> GetAllLecturers()
        {
            List<Lecturer> _staffList = null;

            using (DataTable table = DataAccess.ExecuteSelectCommand("sp_GetAllLecturers",
                CommandType.StoredProcedure))
            {
                if (table.Rows.Count > 0)
                {
                    _staffList = new List<Lecturer>();
                    foreach (DataRow row in table.Rows)
                    {
                        Lecturer _staff = new Lecturer();
                        _staff.Name = row["Name"].ToString();
                        _staff.StaffNumber = row["StaffNumber"].ToString();
                        _staff.Surname = row["Surname"].ToString();
                        _staff.User_Id = row["User_Id"].ToString();
                        _staffList.Add(_staff);
                    }
                }
            }
            return _staffList;
        }
Example #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.lecturer) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                // ======== Process ===========
                if (!Page.IsPostBack)
                {
                    divShow.Visible = false;
                    divFail.Visible = false;

                    // ระดับการศึกษา
                    degreeLevel = new Degree().getDegreeChar();

                    ddlDEGREE.Items.Insert(ddlDEGREE.Items.Count, new ListItem("ทุกระดับการศึกษา", "x"));
                    foreach (DegreeData data in degreeLevel)
                    {
                        ddlDEGREE.Items.Insert(ddlDEGREE.Items.Count, new ListItem(data.Degree_Thai, data.Degree_Char));
                    }

                    //อาจารย์
                    if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
                    {
                        // คณะ
                        facultyData = new Faculty().getFaculty();
                        ddlFACULTY.Items.Clear();
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }

                        departmentData = new Department().getDepartmentWithFaculty(ddlFACULTY.SelectedValue);
                        ddlDepartment.Items.Clear();
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }

                        LectuereInformationData lecturer_data = new Lecturer().getLecturer(login_data.Nation_ID);
                        ddlADVISOR.Items.Clear();
                        ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(lecturer_data.Lecturer_ShortName + " " + lecturer_data.First_ThaiName + " " + lecturer_data.Family_ThaiName, lecturer_data.Lecturer_ID));
                    }
                    //วิชาการคณะ
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                        // คณะ
                        facultyData = new Faculty().getFaculty(faculty_authorized);
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }

                        departmentData = new Department().getDepartmentWithFaculty(ddlFACULTY.SelectedValue);
                        ddlDepartment.Items.Clear();
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }

                        // อาจารย์
                        LecturerData = new Lecturer().getLecturerbyDepartment(ddlDepartment.SelectedValue);
                        ddlADVISOR.Items.Clear();
                        if (LecturerData.Count.Equals(0))
                        {
                            ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem("--- ไม่พบข้อมูลอาจารย์ ---", "00"));
                        }
                        else
                        {
                            foreach (LectuereInformationData data in LecturerData)
                            {
                                ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                            }
                        }
                    }
                    //วิชาการภาค
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        ddlFACULTY.Enabled   = false;
                        ddlFACULTY.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);

                        // ภาควิชา
                        departmentData = new Department().getDepartment(department_authorized);
                        foreach (DepartmentData data in departmentData)
                        {
                            ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        }

                        // คณะ
                        faculty_data = new Faculty().getFaculty(ddlDepartment.SelectedValue.Substring(0, 2));
                        ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(faculty_data.Faculty_Thai, faculty_data.Faculty_Code));

                        // อาจารย์
                        LecturerData = new Lecturer().getLecturerbyDepartment(ddlDepartment.SelectedValue);
                        ddlADVISOR.Items.Clear();
                        if (LecturerData.Count.Equals(0))
                        {
                            ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem("--- ไม่พบข้อมูลอาจารย์ ---", "00"));
                        }
                        else
                        {
                            foreach (LectuereInformationData data in LecturerData)
                            {
                                ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                            }
                        }
                    }



                    // หลักสูตร
                    string faculty_code   = ddlFACULTY.SelectedValue;
                    string Curr_LevelCode = "";
                    if (ddlDEGREE.SelectedValue == "U")
                    {
                        Curr_LevelCode = "01";
                    }
                    else if (ddlDEGREE.SelectedValue == "B")
                    {
                        Curr_LevelCode = "02";
                    }
                    else if (ddlDEGREE.SelectedValue == "P")
                    {
                        Curr_LevelCode = "05";
                    }
                    else if (ddlDEGREE.SelectedValue == "M")
                    {
                        Curr_LevelCode = "03";
                    }
                    else if (ddlDEGREE.SelectedValue == "D")
                    {
                        Curr_LevelCode = "04";
                    }
                    else if (ddlDEGREE.SelectedValue == "x")
                    {
                        Curr_LevelCode = "xx";
                    }

                    string curr_sql = "";
                    if (Curr_LevelCode != "xx")
                    {
                        curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE = '" + ddlDepartment.SelectedValue + "' AND LEVELCODE='" + Curr_LevelCode + "' AND CURRCODE!='999999999'";
                    }
                    else
                    {
                        curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE = '" + ddlDepartment.SelectedValue + "' AND CURRCODE!='999999999'";
                    }



                    currData = new Curriculum().getManualCurriculum(curr_sql);

                    ddlCURRICULUM.Items.Clear();
                    if (currData.Count.Equals(0))
                    {
                        ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- ไม่พบข้อมูลหลักสูตร ---", "0"));
                    }
                    else
                    {
                        ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- แสดงทุกหลักสูตร ---", "x"));
                        foreach (CurriculumGeneralData data in currData)
                        {
                            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem(data.Curr_Code + " " + data.Curr_ThaiName + " (" + data.Curr_Year + ")", data.Curr_Year + data.Curr_Code));
                        }
                    }
                }
                // ============================
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
 public bool UpdateLecturerWithPassword(Lecturer lecturer)
 {
     lecturer.Password = StringCipher.Encrypt(lecturer.Password, "12345uattend12345");
     return lecturerDB.UpdateLecturerWithPassword(lecturer);
 }
 public bool AddNewLecturer(Lecturer lecturer)
 {
     lecturer.Password = StringCipher.Encrypt(lecturer.Password, "12345uattend12345");
     return lecturerDB.AddNewLecturer(lecturer);
 }
        public async Task <ApiReturnValue <Lecturers> > UpdateLecturer(string lecturerId, Lecturer lecturer)
        {
            ApiReturnValue <Lecturers> apiReturnValue = new ApiReturnValue <Lecturers>();

            await Task.Delay(1000);

            return(apiReturnValue);
        }
Example #21
0
        private static void SetInitialData()
        {
            Reservations = new ConcurrentDictionary <int, Reservation>();
            Lecturers    = new ConcurrentDictionary <int, Lecturer>();
            LectureHalls = new ConcurrentDictionary <int, LectureHall>();
            Subjects     = new ConcurrentDictionary <int, Subject>();


            // Lecture Halls

            var lh101 = new LectureHall
            {
                Number   = 101,
                Capacity = 100
            };

            var lh102 = new LectureHall
            {
                Number   = 102,
                Capacity = 200
            };

            var lh105 = new LectureHall
            {
                Number   = 105,
                Capacity = 30
            };

            var lh108 = new LectureHall
            {
                Number   = 108,
                Capacity = 100
            };

            var lh201 = new LectureHall
            {
                Number   = 201,
                Capacity = 200
            };

            var lh202 = new LectureHall
            {
                Number   = 202,
                Capacity = 30
            };

            var lh210 = new LectureHall
            {
                Number   = 210,
                Capacity = 30
            };

            var lh212 = new LectureHall
            {
                Number   = 212,
                Capacity = 100
            };

            LectureHalls.Add(lh101.Number, lh101);
            LectureHalls.Add(lh102.Number, lh102);
            LectureHalls.Add(lh105.Number, lh105);
            LectureHalls.Add(lh108.Number, lh108);
            LectureHalls.Add(lh201.Number, lh201);
            LectureHalls.Add(lh202.Number, lh202);
            LectureHalls.Add(lh210.Number, lh210);
            LectureHalls.Add(lh212.Number, lh212);


            // Subjects

            var s1 = new Subject
            {
                Id        = 1,
                Name      = "Statistics",
                Size      = 4,
                Lecturers = new List <Lecturer>()
            };

            var s2 = new Subject
            {
                Id        = 2,
                Name      = "Algebra",
                Size      = 4,
                Lecturers = new List <Lecturer>()
            };

            var s3 = new Subject
            {
                Id        = 3,
                Name      = "Logic",
                Size      = 2,
                Lecturers = new List <Lecturer>()
            };

            var s4 = new Subject
            {
                Id        = 4,
                Name      = "Analysis",
                Size      = 5,
                Lecturers = new List <Lecturer>()
            };

            // Lecturers

            var l1 = new Lecturer()
            {
                Id               = 1,
                Name             = "John",
                Surname          = "Nash",
                Title            = "prof. ",
                ConductedLecture = s1
            };

            var l2 = new Lecturer()
            {
                Id               = 2,
                Name             = "Steve",
                Surname          = "Wozniak",
                Title            = "dr ",
                ConductedLecture = s1
            };

            var l3 = new Lecturer()
            {
                Id               = 3,
                Name             = "Jim",
                Surname          = "Morrisson",
                Title            = "prof. ",
                ConductedLecture = s2
            };

            var l4 = new Lecturer()
            {
                Id               = 4,
                Name             = "Ronnie",
                Surname          = "O'Sullivan",
                Title            = "prof. ",
                ConductedLecture = s2
            };

            var l5 = new Lecturer()
            {
                Id               = 5,
                Name             = "James",
                Surname          = "Milner",
                Title            = string.Empty,
                ConductedLecture = s3
            };

            var l6 = new Lecturer()
            {
                Id               = 6,
                Name             = "Roger",
                Surname          = "Schmidt",
                Title            = "prof. ",
                ConductedLecture = s4
            };

            var l7 = new Lecturer()
            {
                Id               = 7,
                Name             = "Julian",
                Surname          = "Archibald",
                Title            = "dr ",
                ConductedLecture = s4
            };

            var l8 = new Lecturer()
            {
                Id               = 8,
                Name             = "Christian",
                Surname          = "Vogelsang",
                Title            = string.Empty,
                ConductedLecture = s4
            };

            s1.Lecturers.Add(l1);
            s1.Lecturers.Add(l2);
            s2.Lecturers.Add(l3);
            s2.Lecturers.Add(l4);
            s3.Lecturers.Add(l5);
            s4.Lecturers.Add(l6);
            s4.Lecturers.Add(l7);
            s4.Lecturers.Add(l8);

            Subjects.Add(s1.Id, s1);
            Subjects.Add(s2.Id, s2);
            Subjects.Add(s3.Id, s3);
            Subjects.Add(s4.Id, s4);

            Lecturers.Add(l1.Id, l1);
            Lecturers.Add(l2.Id, l2);
            Lecturers.Add(l3.Id, l3);
            Lecturers.Add(l4.Id, l4);
            Lecturers.Add(l5.Id, l5);
            Lecturers.Add(l6.Id, l6);
            Lecturers.Add(l7.Id, l7);
            Lecturers.Add(l8.Id, l8);


            // Reservations

            var r1 = new Reservation
            {
                Id       = 1,
                From     = new DateTime(2015, 1, 2, 8, 0, 0),
                To       = new DateTime(2015, 1, 2, 8, 0, 0).AddHours(2),
                Hall     = lh202,
                Lecturer = l5
            };

            var r2 = new Reservation
            {
                Id       = 2,
                From     = new DateTime(2015, 1, 2, 11, 0, 0),
                To       = new DateTime(2015, 1, 2, 11, 0, 0).AddHours(1),
                Hall     = lh202,
                Lecturer = l2
            };

            var r3 = new Reservation
            {
                Id       = 3,
                From     = new DateTime(2015, 1, 2, 16, 0, 0),
                To       = new DateTime(2015, 1, 5, 16, 0, 0).AddHours(2),
                Hall     = lh202,
                Lecturer = l8
            };

            Reservations.Add(r1.Id, r1);
            Reservations.Add(r2.Id, r2);
            Reservations.Add(r3.Id, r3);
        }
Example #22
0
 public Lecturer Update(int id, Lecturer lecturer)
 {
     lecturer.Id = id;
     return(_lecturerRepository.Update(lecturer));
 }
Example #23
0
 public void DeleteLecturer(Lecturer lecturer)
 {
     _repoWrapper.Lecturer.Delete(lecturer);
 }
        public ActionResult ViewAttendees()
        {
            #region Declaring the variables

            BusinessLogicHandler _gateWay = new BusinessLogicHandler();
            List<Student> _studList = new List<Student>();
            Student _student = new Student();
            Lecturer _lecturer = new Lecturer();
            Lecture _lecture = new Lecture();
            CloserViewModel _closer = new CloserViewModel();

            #endregion

            Bridge _bridge = (Bridge)Session["Data"];
            //_lecture = _gateWay.GetLecture(_bridge.Lecture_Id);

            #region Getting The students

            foreach (var item in _bridge.User_Id)
            {
                string[] exString = item.Split('.');
                _student = _gateWay.GetStudent(exString[0]);
                _student.User_Id = item.ToString();
                _studList.Add(_student);
            }
            _closer.Students = _studList;

            #endregion

            #region Getting the lecture details

            _lecture = _gateWay.GetLecture(_bridge.Lecture_Id);
            _closer.Lecture = _lecture;

            #endregion

            #region Setting the date

            _closer.Date = "";
            for (int x = 0; x < 4; x++)
            {
                _closer.Date += _bridge.dateSlice[x] + " ";
            }

            #endregion

            #region Getting Lecturer details

            _lecturer = _gateWay.GetLecturer_StuffNumber(_lecture.StaffNumber);
            _closer.Lecturer = new Lecturer();
            _closer.Lecturer = _lecturer;
            #endregion

            #region Assigning images
            if (_bridge.filePath != null)
                _closer.files = _bridge.filePath;
            #endregion

            return View(_closer);
        }
Example #25
0
 private void ribbonButton1_Click(object sender, EventArgs e)
 {
     Lecturer document = new Lecturer();
     document.Show();
 }
 public bool Update_Info_Lec(Lecturer lec)
 {
     return true;
 }
 public void SaveLecturer(Lecturer lecturer)
 {
     if (lecturer.ID.ToString() == "00000000-0000-0000-0000-000000000000")
         _context.Lecturers.Add(lecturer);
     else
     {
         Lecturer dbEntry = _context.Lecturers.Find(lecturer.ID);
         if (dbEntry != null)
         {
             dbEntry.Email = lecturer.Email;
             dbEntry.Information = lecturer.Information;
             dbEntry.Interests = lecturer.Interests;
             dbEntry.IsAcademic = lecturer.IsAcademic;
             dbEntry.Name = lecturer.Name;
             dbEntry.Surname = lecturer.Surname;
         }
     }
     _context.SaveChanges();
 }
        public Lecturer SetLecturersInsertData()
        {
            Lecturer lecturers = new Lecturer()
            {
                Firstname = this.Firstname,
                Lastname = this.Lastname,
                Email = this.EMail + EMailHostAP,
                Access = 1,
                Password = Hash.Password_Encryption_md5(this.Password)
            };
            Entity.dataClassContext.Lecturers.InsertOnSubmit(lecturers);
            Entity.dataClassContext.SubmitChanges();

            return lecturers;
        }
Example #29
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Lecturer Insert(Lecturer model)
 {
     return(this._LecturerBiz.Insert(model));
 }
Example #30
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Delete(Lecturer model)
 {
     this._LecturerBiz.Delete(model);
 }
Example #31
0
 public void UpdateLecturer(int id, Lecturer lecturer)
 {
     _repoWrapper.Lecturer.Update(lecturer);
 }
Example #32
0
        public void Lesson_Clash_Test()
        {
            /*
             * Set instances: 2 Lessons with different data
             */
            Lesson lesson1 = new Lesson();
            Lesson lesson2 = new Lesson();

            Lecturer l1 = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
            Lecturer l2 = new Lecturer("John Smith", 32, "JS1", Color.Blue);

            Module m1 = new Module("Programming", "Level 3", "PL3", Color.Blue);
            Module m2 = new Module("Networking", "Degree", "NET", Color.Blue);

            Room r1 = new Room("Room1", "L1", Color.Blue, 20);
            Room r2 = new Room("Room2", "L2", Color.Blue, 19);

            Group g1 = new Group("Class1", "C1", Color.Blue, 20);
            Group g2 = new Group("Class2", "C2", Color.Blue, 20);

            /*
             * Set so that each Lesson has different data, except the same time and day
             */
            lesson1.Lecturer = l1;
            lesson1.Module = m1;
            lesson1.Group = g1;
            lesson1.Room = r1;

            lesson2.Lecturer = l2;
            lesson2.Module = m2;
            lesson2.Group = g2;
            lesson2.Room = r2;

            lesson1.Time = 1;
            lesson1.Day = 1;

            lesson2.Time = 1;
            lesson2.Day = 1;

            DataCollection.Instance.Add(lesson1);
            DataCollection.Instance.Add(lesson2);

            /*
             *  Test if there is NO clash.
             *  Each lesson is different.
             */
            Assert.IsFalse(DataCollection.Instance.DoesLessonClash(lesson1), "Detected a clash when values should not");

            /*
             *  Set lesson2 to have the same Room as lesson1.
             *  Test for clash: Same Room holding different Lessons.
             */
            lesson2.Room = r1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Room when it should");
            lesson2.Room = r2;

            /*
             *  Set lesson2 to have the same Lecturer as lesson1.
             *  Test for clash: Same Lecturer at different Lessons.
             */
            lesson2.Lecturer = l1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Lecturer when it should");
            lesson2.Lecturer = l2;

            /*
             *  Set lesson2 to have the same Group as lesson1.
             *  Test for clash: Same Group at different Lessons
             */
            lesson2.Group = g1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Group when it should");
            lesson2.Group = g2;

            /*
             *  Set lesson2 to have the same Module as lesson1.
             *  Test for NO clash: Same Module at different Lessons.
             */
            lesson2.Module = m1;
            Assert.IsFalse(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Module when it should");
            lesson2.Module = m2;
        }
Example #33
0
        public async Task <ActionResult> Profile()
        {
            try
            {
                int type = int.Parse(Request.Form["Type"]);

                var user = await _userManager.GetUserAsync(User);

                var profile = new Profile
                {
                    FullNames  = Request.Form["FullNames"],
                    NationalID = int.Parse(Request.Form["ID"])
                };
                if (Request.Form.Files.Count > 0)
                {
                    IFile file = new FormFile(Request.Form.Files[0]);
                    profile.PhotoUrl = await _uploader.Upload(file);
                }
                if (type == 1)
                {
                    //lec
                    Lecturer lecturer = new Lecturer(Guid.Parse(user.Id))
                    {
                        Profile = profile
                    };
                    _lepadContext.Lecturers.Add(lecturer);
                    _lepadContext.SaveChanges();

                    user.AccountId   = lecturer.Id;
                    user.AccountType = AccountType.Lecturer;
                }
                else if (type == 2)
                {
                    //student
                    Student student = new Student(Guid.Parse(user.Id))
                    {
                        YearOfStudy  = int.Parse(Request.Form["YrOfStudy"]),
                        AcademicYear = Request.Form["AcademicYr"],
                        RegNo        = Request.Form["RegNo"],
                        Profile      = profile,
                    };
                    _lepadContext.Students.Add(student);
                    _lepadContext.SaveChanges();

                    user.AccountId   = student.Id;
                    user.AccountType = AccountType.Student;
                }
                else if (type == 0)
                {
                    // admin
                    Admin admin = new Admin(Guid.Parse(user.Id))
                    {
                        Profile = profile
                    };

                    _lepadContext.Administrators.Add(admin);
                    _lepadContext.SaveChanges();

                    user.AccountId   = admin.Id;
                    user.AccountType = AccountType.Administrator;
                }

                // add claims we need in the app (userId, accountType)

                var claims = new List <Claim> {
                    new Claim("UserId", user.Id),
                    new Claim("ProfileId", profile.Id.ToString())
                };

                if (!string.IsNullOrWhiteSpace(profile.FullNames))
                {
                    claims.Add(new Claim("FullNames", profile.FullNames));
                }

                if (!string.IsNullOrWhiteSpace(profile.PhotoUrl))
                {
                    claims.Add(new Claim("PhotoUrl", profile.PhotoUrl));
                }

                await _userManager.AddClaimsAsync(user, claims);

                //update user identity account
                var result = await _userManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectPermanent("/"));
                }
                else
                {
                    return(Content(result.Errors.First().Description));
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
Example #34
0
 private void BindGridView_Lecturers()
 {
     gvLecturers.DataSource = Lecturer.GetAllLecturers();
     gvLecturers.DataBind();
 }
Example #35
0
 public static StatisticOfLecturer StaticticOfLecturer(Schedule schedule, Lecturer lecturer)
 {
     return new StatisticOfLecturer(schedule, lecturer);
 }
Example #36
0
        private Academy GetAcademyObjectModelFromXml(XDocument document)
        {
            Academy  academy     = new Academy();
            XElement academyNode = document.Elements().First();

            XElement      coursesNode = academyNode.Descendants("courses-list").FirstOrDefault();
            List <Course> courses     = GetCoursesFromNode(coursesNode);

            XElement        lecturersNode = academyNode.Descendants("lecturers-list").FirstOrDefault();
            List <Lecturer> lecturers     = GetLecturersFromNode(lecturersNode);

            XElement       studentsNode = academyNode.Descendants("students-list").FirstOrDefault();
            List <Student> students     = GetStudentsFromNode(studentsNode);

            XElement        hometasksNode = academyNode.Descendants("hometasks-list").FirstOrDefault();
            List <Hometask> hometasks     = GetHometasksFromNode(hometasksNode);

            XElement            hometasksMarksNode = academyNode.Descendants("hometasks-marks-list").FirstOrDefault();
            List <HometaskMark> hometasksMarks     = GetHometasksMarksFromNode(hometasksMarksNode);

            List <KeyValuePair <int, int> > bindingCoursesLecturersDictionary = GetBindingDictionaryById(coursesNode, "lecturers");
            List <KeyValuePair <int, int> > bindingCoursesStudentsDictionary  = GetBindingDictionaryById(coursesNode, "students");
            List <KeyValuePair <int, int> > bindingCoursesHometasksDictionary = GetBindingDictionaryById(coursesNode, "hometasks");

            List <KeyValuePair <int, int> > bindingStudentsMarksDictionary  = GetBindingDictionaryById(studentsNode, "hometask-marks");
            List <KeyValuePair <int, int> > bindingMarksHometasksDictionary = GetBindingDictionaryById(hometasksMarksNode, "hometask");
            List <KeyValuePair <int, int> > bindingMarksCoursesDictionary   = GetBindingDictionaryById(hometasksMarksNode, "course");

            // courses and lecturers binding
            foreach (var courseLecturer in bindingCoursesLecturersDictionary)
            {
                Course   course   = courses.Where(n => n.Id == courseLecturer.Key).First();
                Lecturer lecturer = lecturers.Where(n => n.Id == courseLecturer.Value).First();

                course.Lecturers.Add(lecturer);
                lecturer.Courses.Add(course);
            }

            // courses and students binding
            foreach (var courseStudent in bindingCoursesStudentsDictionary)
            {
                Course  course  = courses.Where(n => n.Id == courseStudent.Key).First();
                Student student = students.Where(n => n.Id == courseStudent.Value).First();

                course.Students.Add(student);
                student.Courses.Add(course);
            }

            // courses and hometasks binding
            foreach (var courseHometask in bindingCoursesHometasksDictionary)
            {
                Course   course   = courses.Where(n => n.Id == courseHometask.Key).First();
                Hometask hometask = hometasks.Where(n => n.Id == courseHometask.Value).First();

                course.Hometasks.Add(hometask);
                hometask.Course = course;;
            }

            // staudents and marks binding
            foreach (var studentMark in bindingStudentsMarksDictionary)
            {
                Student      student = students.Where(n => n.Id == studentMark.Key).First();
                HometaskMark mark    = hometasksMarks.Where(n => n.Id == studentMark.Value).First();

                student.Marks.Add(mark);
            }

            // marks and hometasks binding
            foreach (var markHometask in bindingMarksHometasksDictionary)
            {
                HometaskMark mark     = hometasksMarks.Where(n => n.Id == markHometask.Key).First();
                Hometask     hometask = hometasks.Where(n => n.Id == markHometask.Value).First();

                mark.Hometask = hometask;
                hometask.HomeworkMarks.Add(mark);
            }

            // marks and courses binding
            foreach (var markHometask in bindingMarksCoursesDictionary)
            {
                HometaskMark mark   = hometasksMarks.Where(n => n.Id == markHometask.Key).First();
                Course       course = courses.Where(n => n.Id == markHometask.Value).First();

                mark.Course = course;
            }

            academy.Courses        = courses;
            academy.Lecturers      = lecturers;
            academy.Students       = students;
            academy.Hometasks      = hometasks;
            academy.HometasksMarks = hometasksMarks;

            return(academy);
        }
        public Lecturer GetLecturer(Lecturer toGetLecturer)
        {
            int      lid = -1, hoursPerWeek = -1;
            string   id = null, firstName = null, lastName = null, address = null, email = null, tel = null, department = null, degree = null, login = null, password = null;
            DateTime birthDay = default(DateTime);
            bool     flag     = false;

            DataBase db = DataBase.Instance;

            SqlCommand cmd = new SqlCommand
                             (
                "SELECT * from Lecturer WHERE (id='" + toGetLecturer.ID + "')", db.Con // at this time get lecturer only by id, in the future by all keys
                             );

            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    //int example1 = reader.GetInt32(0); string example2 = reader.GetString(1); // another way to get values sergei note
                    lid       = (int)reader["lid"];
                    id        = reader["id"].ToString().Trim();
                    firstName = reader["first_name"].ToString().Trim();
                    lastName  = reader["last_name"].ToString().Trim();
                    address   = reader["address"].ToString().Trim();
                    email     = reader["email"].ToString().Trim();
                    tel       = reader["tel"].ToString().Trim();
                    DateTime.TryParse(reader["birth_day"].ToString().Trim(), out birthDay);
                    //birthDay = DateTime.Parse(reader["birth_day"].ToString().Trim());
                    department   = reader["department"].ToString().Trim();
                    degree       = reader["degree"].ToString().Trim();
                    hoursPerWeek = Convert.ToInt32(reader["hours_per_week"]);
                    flag         = true;
                }
            }

            if (toGetLecturer.Login != null)
            {
                cmd = new SqlCommand
                      (
                    "SELECT * from Login WHERE (Name='" + toGetLecturer.Login + "')", db.Con // get login only by login Name
                      );
            }
            else
            if (toGetLecturer.ID != null)
            {
                cmd = new SqlCommand
                      (
                    "SELECT * from Login WHERE (Id='" + toGetLecturer.ID + "')", db.Con // get login only by login Name
                      );
            }

            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    login    = reader["Name"].ToString().Trim();
                    password = reader["Password"].ToString().Trim();
                }
            }

            if (flag)
            {
                Lecturer lecturer = new Lecturer(id, firstName, lastName, address, email, tel, birthDay, login, password, department, degree, hoursPerWeek);
                return(lecturer);
            }

            return(null);
        }
Example #38
0
        private async void SearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                try
                {
                    if (string.IsNullOrEmpty(sender.Text))
                    {
                        return;
                    }
                    tokenSource?.Cancel();
                    tokenSource = new CancellationTokenSource();

                    switch (_type)
                    {
                    case UserType.Student:
                        break;

                    case UserType.Lecturer:
                    {
                        List <Lecturer> _suggestions = await Lecturer.FindAsync(sender.Text, tokenSource.Token);

                        if (_suggestions.Count > 0)
                        {
                            sender.ItemsSource = _suggestions;
                        }
                        else
                        {
                            sender.ItemsSource = new[] { "NoResult".Localize() }
                        };
                    }
                    break;

                    case UserType.Group:
                    {
                        List <Group> _suggestions = await Group.FindAsync(sender.Text, tokenSource.Token);

                        if (_suggestions.Count > 0)
                        {
                            sender.ItemsSource = _suggestions;
                        }
                        else
                        {
                            sender.ItemsSource = new[] { "NoResult".Localize() }
                        };
                    }
                    break;
                    }
                }
                catch (TaskCanceledException)
                {
                    // Игнорировать
                }
                catch (HttpRequestException ex)
                {
                    try
                    {
                        await new Dialogs.ErrorDialog(ex).ShowAsync();
                    }
                    catch (Exception)
                    {
                    }
                }
                catch (Exception) { }
            }
        }
 public Lecturer Create(Lecturer record)
 {
     record = _lectureRepository.Add(record);
     return(record);
 }
 public bool UpdateLecturer(Lecturer lecturer)
 {
     return lecturerDB.UpdateLecturer(lecturer);
 }
 public Lecturer Update(Lecturer record)
 {
     record = _lectureRepository.Update(record);
     return(record);
 }
Example #42
0
 public Section1_viewLecturer(Object obj)
 {
     InitializeComponent();
     this.L = (Lecturer)obj;
     drawData(this.L);
 }
 public IActionResult CreateLecturer([FromForm] Lecturer lecture)
 {
     _repository.CreateLecturer(lecture);
     return(RedirectToAction("AllLecturers"));
 }
Example #44
0
    protected void ddlDepartment_SelectedIndexChanged(object sender, EventArgs e)
    {
        string faculty_code = ddlFACULTY.SelectedValue;

        //วิชาการภาค
        if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
        {
            ddlFACULTY.Enabled   = false;
            ddlFACULTY.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
            List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);


            // คณะ
            faculty_data = new Faculty().getFaculty(ddlDepartment.SelectedValue.Substring(0, 2));
            ddlFACULTY.Items.Clear();
            ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(faculty_data.Faculty_Thai, faculty_data.Faculty_Code));
        }

        //อาจารย์
        if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
        {
            LectuereInformationData lecturer_data = new Lecturer().getLecturer(login_data.Nation_ID);

            ddlADVISOR.Items.Clear();
            ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(lecturer_data.Lecturer_ShortName + " " + lecturer_data.First_ThaiName + " " + lecturer_data.Family_ThaiName, lecturer_data.Lecturer_ID));
        }
        else
        {
            // อาจารย์
            LecturerData = new Lecturer().getLecturerbyDepartment(ddlDepartment.SelectedValue);
            ddlADVISOR.Items.Clear();
            if (LecturerData.Count.Equals(0))
            {
                ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem("--- ไม่พบข้อมูลอาจารย์ ---", "00"));
            }
            else
            {
                foreach (LectuereInformationData data in LecturerData)
                {
                    ddlADVISOR.Items.Insert(ddlADVISOR.Items.Count, new ListItem(data.Lecturer_ShortName + " " + data.First_ThaiName + " " + data.Family_ThaiName, data.Lecturer_ID));
                }
            }
        }



        // หลักสูตร
        string Curr_LevelCode = "";

        if (ddlDEGREE.SelectedValue == "U")
        {
            Curr_LevelCode = "01";
        }
        else if (ddlDEGREE.SelectedValue == "B")
        {
            Curr_LevelCode = "02";
        }
        else if (ddlDEGREE.SelectedValue == "P")
        {
            Curr_LevelCode = "05";
        }
        else if (ddlDEGREE.SelectedValue == "M")
        {
            Curr_LevelCode = "03";
        }
        else if (ddlDEGREE.SelectedValue == "D")
        {
            Curr_LevelCode = "04";
        }
        else if (ddlDEGREE.SelectedValue == "x")
        {
            Curr_LevelCode = "xx";
        }

        string curr_sql = "";

        if (Curr_LevelCode != "xx")
        {
            curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE = '" + ddlDepartment.SelectedValue + "' AND LEVELCODE='" + Curr_LevelCode + "' AND CURRCODE!='999999999'";
        }
        else
        {
            curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE = '" + ddlDepartment.SelectedValue + "' AND CURRCODE!='999999999'";
        }


        currData = new Curriculum().getManualCurriculum(curr_sql);

        ddlCURRICULUM.Items.Clear();
        if (currData.Count.Equals(0))
        {
            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- ไม่พบข้อมูลหลักสูตร ---", "0"));
        }
        else
        {
            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- แสดงทุกหลักสูตร ---", "x"));
            foreach (CurriculumGeneralData data in currData)
            {
                ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem(data.Curr_Code + " " + data.Curr_ThaiName + " (" + data.Curr_Year + ")", data.Curr_Year + data.Curr_Code));
            }
        }
    }
Example #45
0
        public void IsUserLecturer_True()
        {
            Lecturer lecturer = new Lecturer();

            Assert.IsTrue(UserServices.IsUserLecturer(lecturer));
        }
Example #46
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Update(Lecturer model)
 {
     this._LecturerBiz.Update(model);
 }
    protected void onclick_section_finish(object sender, EventArgs e)
    {
        try
        {
            bool check = (bool)Session["isOK"];

            if (check)
            {
                result.Text = new AvailableCourse().updateAvailableCourse(available_data, old_available_data, degree_char);

                string[] res = new AvailableStudent().updateAvailableStudent(available_student, old_available_student, degree_char);

                string[] res2 = new TeachingTable().updateTeachingTable(teachtable, old_teaching, degree_char);

                string[] res3 = new LecturerTable().updateLecturerTable(lecturertable, old_lecturer, degree_char);

                string[] res4 = new SubCredit().updateSubCredit(subcreditData, degree_char);

                divBody.Visible    = false;
                divSuccess.Visible = true;
            }
            else
            {
                float totalCredit = 0;

                CourseData course_data = new Course().getCourse(available_data.Course_Code);
                int        credit      = course_data.Credit;

                if (lecturertable[0].Course_Type == "1")
                {
                    if (course_data.Practice != 0)
                    {
                        credit = course_data.Theory;
                    }
                    else
                    {
                        credit = course_data.Credit;
                    }
                }
                else if (lecturertable[0].Course_Type == "2")
                {
                    if (course_data.Theory != 0)
                    {
                        credit = course_data.Practice / 2;
                    }
                    else
                    {
                        credit = course_data.Credit;
                    }
                }


                string credit_err = "";
                foreach (SubCreditData subcredit in subcreditData)
                {
                    totalCredit += subcredit.SubCredit;

                    float remain_credit = new WorkLoadCalculate().checkEditLecturerCredit2(subcredit.AcademicYear, subcredit.Semester, subcredit.Lecturer, subcredit.SubCredit, subcredit);

                    if (remain_credit != -1)
                    {
                        credit_err += subcredit.Lecturer + "," + remain_credit;
                        break;
                    }
                }

                if (credit_err.Length > 0)
                {
                    string[] arr = credit_err.Split(',');
                    lblSubDreditErr.Visible = true;
                    LectuereInformationData lec = new LectuereInformationData();
                    lec = new Lecturer().getLecturer(arr[0]);
                    lblSubDreditErr.Text = "อาจารย์ " + lec.First_ThaiName + " " + lec.Family_ThaiName + " ไม่สามารถสอนได้เกิน " + arr[1] + " เครดิต";
                    btnSubmit.Focus();
                }
                else if (totalCredit != credit)
                {
                    lblSubDreditErr.Visible = true;
                    lblSubDreditErr.Text    = "จำนวนหน่วยกิตรวมต้องเท่ากับ " + credit;
                    btnSubmit.Focus();
                }
                else
                {
                    result.Text = new AvailableCourse().updateAvailableCourse(available_data, old_available_data, degree_char);

                    string[] res = new AvailableStudent().updateAvailableStudent(available_student, old_available_student, degree_char);

                    string[] res2 = new TeachingTable().updateTeachingTable(teachtable, old_teaching, degree_char);

                    string[] res3 = new LecturerTable().updateLecturerTable(lecturertable, old_lecturer, degree_char);

                    string[] res4 = new SubCredit().updateSubCredit(subcreditData, degree_char);

                    divBody.Visible    = false;
                    divSuccess.Visible = true;
                }
            }
        }
        catch
        {
            divFail.Visible = true;
        }
    }
        public ActionResult Details(int?page, bool own = false, string tryb = "", string promotor = "", string AcademicYears = "")
        {
            List <string> years = (from w in db.AcademicYear orderby w.ID descending select w.Year).ToList();

            ViewBag.AcademicYears  = new SelectList(years);
            ViewBag.UserPermission = false;

            var userName = User.Identity.Name;

            if (AcademicYears == "")
            {
                AcademicYears = (from i in db.AcademicYear orderby i.ID descending select i.Year).FirstOrDefault();
            }
            AcademicYear academicYear = (from a in db.AcademicYear where a.Year == AcademicYears select a).FirstOrDefault();

            if (academicYear == null)
            {
                return(HttpNotFound());
            }

            var           academicYearId = (from a in db.AcademicYear where a.Year == AcademicYears select a.ID).FirstOrDefault();
            List <Thesis> thesis         = (from t in db.Thesis where t.AcademicYearID == academicYearId select t).ToList();

            foreach (var t in thesis)
            {
                Lecturer lecturer = (from l in db.Users where l.Id == t.LecturerID select l).FirstOrDefault();

                t.Lecturer = lecturer;
            }

            if (userName == null && String.IsNullOrEmpty(tryb))
            {
                thesis = (thesis.Where(a => a.Category == "Inżynierskie stacjonarne")).ToList();
            }

            if (tryb != "Wszystkie" && !String.IsNullOrEmpty(tryb))
            {
                thesis = (thesis.Where(a => a.Category == tryb)).ToList();
            }

            if (!String.IsNullOrEmpty(promotor))
            {
                string lecturer = (from l in db.Users where l.Lastname.Contains(promotor) select l.Id).FirstOrDefault();
                thesis = (thesis.Where(a => a.LecturerID == lecturer)).ToList();
            }
            else if (!String.IsNullOrEmpty(userName) && own)
            {
                string lecturer = (from l in db.Users where l.Email == userName select l.Id).FirstOrDefault();
                thesis = (thesis.Where(a => a.LecturerID == lecturer)).ToList();
            }

            if (!String.IsNullOrEmpty(userName))
            {
                Lecturer lecturer = (from user in db.Users where user.UserName == userName select user).FirstOrDefault();
                if (lecturer.AddThesisPermision != null)
                {
                    int current = DateTime.Compare(DateTime.Now, lecturer.AddThesisPermision);

                    if (current < 0)
                    {
                        ViewBag.UserPermission = true;
                    }
                }
            }

            List <Institute> institutes = (from f in db.Institutes select f).ToList();

            ViewBag.Institutes = new SelectList(institutes, "ID", "Name");

            int pageSize   = 5;
            int pageNumber = (page ?? 1);


            ThesisInYear thesisInYear = new ThesisInYear
            {
                AcademicYear = academicYear,
                Thesis       = new PagedList <Thesis>(thesis, pageNumber, pageSize)
            };

            return(View(thesisInYear));
        }
        protected void btnRecoverPassword_Click(object sender, EventArgs e)
        {
            LecturerHandler lecturerHandler = new LecturerHandler();
            Lecturer lecturer = null;
            BusinessHandler businessHandler = null;
            Business business = null;

            string destinationEmail = txtEmail.Value;

            //check email exists
            if (lecturerHandler.ValidateEmail(destinationEmail) == false)
            {
                //email doesn't exist in DB
                litAlert.Text = "<div class='alert alert-danger'>Invalid Email Address</div>";
            }

            else
            {
                //get business email and password
                string name, email, password, emailServer, newPassword;
                int port;

                businessHandler = new BusinessHandler();
                business = new Business();
                business = businessHandler.GetBusinessDetails();

                name = business.Name;
                email = business.Email;
                password = business.EmailPassword;
                emailServer = business.EmailServer;
                port = business.EmailPort;

                //generate new password
                newPassword = Membership.GeneratePassword(7, 0);

                //update database
                lecturer = new Lecturer();
                lecturer.Email = destinationEmail;
                lecturer.Password = newPassword;

                //send email
                try
                {
                    MailMessage mail = new MailMessage();
                    SmtpClient smtpClient = new SmtpClient(emailServer);
                    mail.From = new MailAddress(email);
                    mail.To.Add(destinationEmail);
                    mail.Subject = name + " Password Reset";
                    mail.Body = "Your password has been reset. Please use the following phrase as your new password when you log in: " + newPassword;

                    //code to include an attatchment
                    //System.Net.Mail.Attachment attachment;
                    //attachment = new System.Net.Mail.Attachment("attatchment.jpg");
                    //mail.Attachments.Add(attachment);

                    smtpClient.Port = port;
                    smtpClient.Credentials = new NetworkCredential(email, password);
                    smtpClient.EnableSsl = true;

                    smtpClient.Send(mail);
                    lecturerHandler.UpdateLecturerPassword(lecturer);

                    litAlert.Text = "<div class='alert alert-success'>An email was sent, check you email for your new password.</div>";

                    //delay redirect to alert user of page change
                    /*lblRedirect.Text = "Redirecting to log in, in 5 seconds.";
                    Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"Login.aspx\"; }, 5000);</script>");*/
                }
                catch (Exception)
                {
                    litAlert.Text = "<div class='alert alert-warning'>Failed to send an email</div>";
                }
            }
        }
 public IActionResult EditLecturer([FromForm] Lecturer lecturer)
 {
     _repository.UpdateLecturer(lecturer);
     return(RedirectToAction("AllLecturers"));
 }
Example #51
0
        public void Lesson_Constructor()
        {
            Lesson lesson = new Lesson();
            Assert.AreEqual(null, lesson.Lecturer, "Failed to match Lecturer after Construtor");
            Assert.AreEqual(null, lesson.Module, "Failed to match Module after Construtor");
            Assert.AreEqual(null, lesson.Room, "Failed to match Room after Construtor");
            Assert.AreEqual(null, lesson.Group, "Failed to match Group after Construtor");

            Lecturer lect = new Lecturer("Fred Flintstone", 12, "FF", Color.White);
            lesson.Lecturer = lect;
            Assert.AreEqual(lect, lesson.Lecturer, "Lecturer Property failed");

            Module mod = new Module("Software Engineering", "Degree", "SED", Color.White);
            lesson.Module = mod;
            Assert.AreEqual(mod, lesson.Module, "Module Property failed");

            Room room = new Room("Y007", "007", Color.Bisque, 30);
            lesson.Room = room;
            Assert.AreEqual(room, lesson.Room, "Room Property failed");

            Group grp = new Group("Group A", "GrA", Color.DarkSeaGreen, 24);
            lesson.Group = grp;
            Assert.AreEqual(grp, lesson.Group, "Group Property failed");
        }
 public Lecturer CreateLecturer(Lecturer lecturer)
 {
     throw new NotImplementedException();
 }
 public virtual void UpdateLecturer(Lecturer lecturer)
 {
     this.lecturerRepository.Update(lecturer);
 }
    private void txtChanged(object sender, EventArgs e)
    {
        float check_float;

        TextBox txtbox = new TextBox();

        txtbox = (TextBox)sender;

        lblSubDreditErr.Visible  = false;
        lblSubDreditPass.Visible = false;
        Session["isOK"]          = false;

        if (!float.TryParse(txtbox.Text, out check_float))
        {
            lblSubDreditErr.Visible = true;
            lblSubDreditErr.Text    = "โปรดตรวจสอบค่า หน่วยกิต";
        }
        else
        {
            lblSubDreditErr.Visible = false;
            float totalCredit = 0;

            CourseData course_data = new Course().getCourse(available_data.Course_Code);
            int        credit      = course_data.Credit;

            if (lecturertable[0].Course_Type == "1")
            {
                if (course_data.Practice != 0)
                {
                    credit = course_data.Theory;
                }
                else
                {
                    credit = course_data.Credit;
                }
            }
            else if (lecturertable[0].Course_Type == "2")
            {
                if (course_data.Theory != 0)
                {
                    credit = course_data.Practice / 2;
                }
                else
                {
                    credit = course_data.Credit;
                }
            }


            string credit_err = "";

            foreach (SubCreditData subcredit in subcreditData)
            {
                string txtid = subcredit.Lecturer + subcredit.Teaching_Day + subcredit.Teaching_Start_Time.Replace(":", "").Replace(".", "") + subcredit.Teaching_End_Time.Replace(":", "").Replace(".", "");


                if (txtid == txtbox.ID)
                {
                    subcredit.SubCredit = float.Parse(txtbox.Text);
                }

                totalCredit += subcredit.SubCredit;

                float remain_credit = new WorkLoadCalculate().checkEditLecturerCredit2(subcredit.AcademicYear, subcredit.Semester, subcredit.Lecturer, subcredit.SubCredit, subcredit);


                if (remain_credit != -1)
                {
                    credit_err += subcredit.Lecturer + "," + remain_credit;
                    break;
                }
            }

            if (credit_err.Length > 0)
            {
                string[] arr = credit_err.Split(',');
                lblSubDreditErr.Visible = true;
                LectuereInformationData lec = new LectuereInformationData();
                lec = new Lecturer().getLecturer(arr[0]);
                lblSubDreditErr.Text = "อาจารย์ " + lec.First_ThaiName + " " + lec.Family_ThaiName + " ไม่สามารถสอนได้เกิน " + arr[1] + " เครดิต";
            }
            else if (totalCredit != credit)
            {
                lblSubDreditErr.Visible = true;
                lblSubDreditErr.Text    = "จำนวนหน่วยกิตรวมต้องเท่ากับ " + credit;
            }
            else
            {
                Session["isOK"]          = true;
                lblSubDreditErr.Visible  = false;
                lblSubDreditPass.Visible = true;
                lblSubDreditPass.Text    = "สามารถดำเนินการได้";
            }
        }

        btnSubmit.Focus();
    }
 public virtual void CreateLecturer(Lecturer lecturer)
 {
     this.lecturerRepository.Create(lecturer);
 }
        private void buttonFindLecturer_Click(object sender, EventArgs e)
        {
            //buttonFindLecturer.Enabled = false;

            if (String.IsNullOrEmpty(textBoxID.Text))
            {
                label22.Text = "Empty field!";
            }
            else
            {
                int  n;
                bool isNumeric = int.TryParse(textBoxID.Text, out n);
                if (!isNumeric || textBoxID.Text.Length < 9 || textBoxID.Text.Length > 10)
                {
                    label22.Text = "Enter correct numeric ID with 9-10 digits";
                }
                else
                {
                    Handler  h = new Handler();
                    Lecturer toFindLecturer = new Lecturer(textBoxID.Text, null, null, null, null, null, default(DateTime), null, null, null, null, -1);
                    Lecturer findedLecturer = h.Get <Lecturer>(toFindLecturer);

                    if (findedLecturer != null)
                    {
                        textBoxID.Text           = findedLecturer.ID;
                        textBoxFirstName_.Text   = findedLecturer.FirstName;
                        textBoxLastName_.Text    = findedLecturer.LastName;
                        textBoxAddress.Text      = findedLecturer.Address;
                        textBoxEmail.Text        = findedLecturer.Email;
                        textBoxTel.Text          = findedLecturer.Tel;
                        dateTimePicker_.Value    = new DateTime(findedLecturer.BirthDay.Year, findedLecturer.BirthDay.Month, findedLecturer.BirthDay.Day, 0, 0, 0);
                        textBoxLogin.Text        = findedLecturer.Login;
                        textBoxPassword.Text     = findedLecturer.Password;
                        comboBoxDepartment.Text  = findedLecturer.Department;
                        comboBoxDegree_.Text     = findedLecturer.Degree;
                        textBoxHoursPerWeek.Text = findedLecturer.HoursPerWeek.ToString();
                        buttonFindLecturer.Hide();
                        pictureBox1.Hide();
                        label22.Text                       = "";
                        label26.Enabled                    = true;
                        label28.Enabled                    = true;
                        label29.Enabled                    = true;
                        label30.Enabled                    = true;
                        textBoxFirstName_.Enabled          = true;
                        textBoxLastName_.Enabled           = true;
                        comboBoxDegree_.Enabled            = true;
                        comboBoxDegree_.Enabled            = true;
                        dateTimePicker_.Enabled            = true;
                        groupBoxWorkingInformation.Enabled = true;
                        groupBoxContactInformation.Enabled = true;
                        groupBoxLoginInformation.Enabled   = true;
                        groupBoxPhoto.Enabled              = true;
                        labelInstruction1.Enabled          = true;
                        labelInstruction2.Enabled          = true;
                        buttonSubmit.Enabled               = true;
                        textBoxID.Enabled                  = false;
                        textBoxLogin.Enabled               = false;
                    }
                    else if (findedLecturer == null)
                    {
                        label22.Text = "ID " + textBoxID.Text + " not found!";;
                    }
                }
            }
        }
Example #57
0
            //public override void Up()
            //{
            //    Sql("INSERT INTO FACULTIES(ID, NAME, ISDELETED) VALUES ('CNTT',     N'CÔNG NGHỆ THÔNG TIN',     'FALSE')");
            //    Sql("INSERT INTO FACULTIES(ID, NAME, ISDELETED) VALUES ('KT',       N'KINH TẾ',                 'FALSE')");
            //    Sql("INSERT INTO FACULTIES(ID, NAME, ISDELETED) VALUES ('QTKD',     N'QUẢN TRỊ KINH DOANH',     'FALSE')");
            //    Sql("INSERT INTO FACULTIES(ID, NAME, ISDELETED) VALUES ('NN',       N'NGOẠI NGỮ',               'FALSE')");
            //}

            public void IninializeDatabase(StudentManagement_ASP.NET_MCV5.Models.ApplicationDbContext dbContext)
            {
                //HoanLK Insert sample data for Faculties table
                List <Faculty> faculties = new List <Faculty>
                {
                    new Faculty()
                    {
                        Id = "CNTT", Name = "CÔNG NGHỆ THÔNG TIN"
                    },
                    new Faculty()
                    {
                        Id = "KT", Name = "KINH TẾ"
                    },
                    new Faculty()
                    {
                        Id = "QTKD", Name = "QUẢN TRỊ KINH DOANH"
                    },
                    new Faculty()
                    {
                        Id = "NN", Name = "NGOẠI NGỮ"
                    }
                };

                foreach (Faculty item in faculties)
                {
                    if (dbContext.Faculties.Where(c => c.Id == item.Id).FirstOrDefault() == null)
                    {
                        dbContext.Faculties.Add(item);
                    }
                }


                //HoanLK Insert sample data for Subjects table
                List <Subject> subjects = new List <Subject>
                {
                    new Subject()
                    {
                        Id = "0001", Name = "Toán cao cấp 1", Description = "Series môn học Toán cao cấp 1,2,3"
                    },
                    new Subject()
                    {
                        Id = "0002", Name = "Toán cao cấp 2", Description = "Series môn học Toán cao cấp 1,2,3"
                    },
                    new Subject()
                    {
                        Id = "0003", Name = "Toán cao cấp 3", Description = "Series môn học Toán cao cấp 1,2,3"
                    },
                    new Subject()
                    {
                        Id = "0004", Name = "Tiếng Anh 1", Description = "Series môn học Tiếng Anh 1,2,3,4,5"
                    },
                    new Subject()
                    {
                        Id = "0005", Name = "Tiếng Anh 2", Description = "Series môn học Tiếng Anh 1,2,3,4,5"
                    },
                    new Subject()
                    {
                        Id = "0006", Name = "Tiếng Anh 3", Description = "Series môn học Tiếng Anh 1,2,3,4,5"
                    },
                    new Subject()
                    {
                        Id = "0007", Name = "Tiếng Anh 4", Description = "Series môn học Tiếng Anh 1,2,3,4,5"
                    },
                    new Subject()
                    {
                        Id = "0008", Name = "Tiếng Anh 5", Description = "Series môn học Tiếng Anh 1,2,3,4,5"
                    },
                    new Subject()
                    {
                        Id = "0009", Name = "Lập trình C", Description = "Lập trình C"
                    },
                    new Subject()
                    {
                        Id = "0010", Name = "Lập trình OOP", Description = "Lập trình hướng đối tượng"
                    },
                    new Subject()
                    {
                        Id = "0011", Name = "Lập trình Web", Description = "Lập trình Web"
                    }
                };

                foreach (Subject item in subjects)
                {
                    if (dbContext.Subjects.Where(c => c.Name == item.Name).FirstOrDefault() == null)
                    {
                        dbContext.Subjects.Add(item);
                    }
                }



                //HoanLK init default data for table Roles in DB
                foreach (string role in Enum.GetNames(typeof(ApplicationRole)))
                {
                    IdentityRole identityRole = new IdentityRole(role.ToString());
                    IdentityRole dbRoles      = dbContext.Roles.Where(c => c.Name == identityRole.Name).FirstOrDefault();
                    if (dbRoles is null)
                    {
                        dbContext.Roles.AddOrUpdate(identityRole);
                    }
                }

                //Up();

                //HoanLK Add default admin account
                if (!dbContext.Users.Any(u => u.UserName == "*****@*****.**"))
                {
                    UserStore <ApplicationUser>   store   = new UserStore <ApplicationUser>(dbContext);
                    UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(store);
                    ApplicationUser user = new ApplicationUser
                    {
                        Id        = "*****@*****.**",
                        Address   = "Ho Chi Minh City",
                        BirthDay  = DateTime.Now,
                        Email     = "*****@*****.**",
                        FirstName = "Admin",
                        LastName  = "1",
                        UserName  = "******"
                    };

                    manager.Create(user, "123Aa.");
                    manager.AddToRole(user.Id, ApplicationRole.Administrator.ToString());
                }

                //HoanLK Add default user(lecturer) account
                Lecturer createdLecturer = null;

                if (!dbContext.Users.Any(u => u.UserName == "*****@*****.**"))
                {
                    UserStore <Lecturer>   store   = new UserStore <Lecturer>(dbContext);
                    UserManager <Lecturer> manager = new UserManager <Lecturer>(store);
                    Lecturer user = new Lecturer
                    {
                        Id           = "*****@*****.**",
                        Address      = "Ho Chi Minh City",
                        BirthDay     = DateTime.Now,
                        Email        = "*****@*****.**",
                        FirstName    = "lecturer",
                        LastName     = "1",
                        UserName     = "******",
                        HireDate     = DateTime.Now,
                        LecturerCode = "0000000001"
                    };

                    manager.Create(user, "123Aa.");
                    manager.AddToRole(user.Id, ApplicationRole.Administrator.ToString());
                    createdLecturer = user;
                }

                //HoanLK Insert sample data for Classes table
                List <Class> Classes = new List <Class>
                {
                    new Class()
                    {
                        Name = "16HTH01", DegreeLevel = DegreeLevels.AssociateDegree, FacultyId = "CNTT", LecturerId = "*****@*****.**", SchoolYear = "2016", TypeOfEducation = TypeOfEducations.InServices, Faculty = faculties[0], Lecturer = createdLecturer
                    },
                    new Class()
                    {
                        Name = "16HTH02", DegreeLevel = DegreeLevels.BachelorDegree, FacultyId = "CNTT", LecturerId = "*****@*****.**", SchoolYear = "2016", TypeOfEducation = TypeOfEducations.FullTime, Faculty = faculties[0], Lecturer = createdLecturer
                    },
                    new Class()
                    {
                        Name = "16HTH03", DegreeLevel = DegreeLevels.MasterDegree, FacultyId = "CNTT", LecturerId = "*****@*****.**", SchoolYear = "2016", TypeOfEducation = TypeOfEducations.FullTime, Faculty = faculties[0], Lecturer = createdLecturer
                    }
                };

                foreach (Class item in Classes)
                {
                    if (dbContext.Classes.Where(c => c.Id == item.Id).FirstOrDefault() == null)
                    {
                        dbContext.Classes.Add(item);
                    }
                }
                dbContext.SaveChanges();

                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Launch();
                }

                //HoanLK Add default user(student) account
                if (!dbContext.Users.Any(u => u.UserName == "*****@*****.**"))
                {
                    UserStore <Student>   store   = new UserStore <Student>(dbContext);
                    UserManager <Student> manager = new UserManager <Student>(store);
                    Student user = new Student
                    {
                        Id             = "*****@*****.**",
                        Address        = "Ho Chi Minh City",
                        BirthDay       = DateTime.Now,
                        Email          = "*****@*****.**",
                        FirstName      = "student",
                        LastName       = "1",
                        UserName       = "******",
                        EnrollmentDate = DateTime.Now,
                        StudentCode    = "0000000002"
                    };

                    manager.Create(user, "123Aa.");
                    manager.AddToRole(user.Id, ApplicationRole.Administrator.ToString());
                    dbContext.SaveChanges();

                    int tmpClassId = dbContext.Classes.FirstOrDefault().Id;
                    Console.WriteLine(tmpClassId);
                    Console.WriteLine(user.Id);
                    dbContext.StudentClasses.Add(new StudentClass()
                    {
                        StudentId = user.Id,
                        ClassId   = tmpClassId
                    });
                }

                dbContext.SaveChanges();
            }
 public void UpdateLecturer(Lecturer lecturer)
 {
     throw new NotImplementedException();
 }
 public bool InsertLecturer(Lecturer _lecturer)
 {
     LecturerHandler myHandler = new LecturerHandler(); return myHandler.NewLecturer(_lecturer);
 }