Esempio n. 1
0
        private void delete_onclick(object sender, EventArgs e)
        {
            LecturerModel objLecModel = new LecturerModel();

            objLecModel.Name       = titleTxt.Text + " " + nameTxt.Text;
            objLecModel.EmpId      = empIdTxt.Text;
            objLecModel.Faculty    = facultyTxt.Text;
            objLecModel.Department = deptmntTxt.Text;
            objLecModel.Center     = centerTxt.Text;
            objLecModel.Building   = buildingtxt.Text;
            objLecModel.Level      = lvlTxt.Text;
            objLecModel.Rank       = rankTxt.Text;

            objLecturer.deleteLecturer(objLecModel);
            loadData();

            nameTxt.Text     = "";
            empIdTxt.Text    = "";
            facultyTxt.Text  = "";
            deptmntTxt.Text  = "";
            centerTxt.Text   = "";
            buildingtxt.Text = "";
            lvlTxt.Text      = "";
            rankTxt.Text     = "";
        }
Esempio n. 2
0
        public void Update(int id, LecturerModel model)
        {
            var lecturer = _repo.Get <Lecturer>(model.LecturerId);
            var entity   = model.Edit(lecturer, model);

            _repo.Update(model.LecturerId, entity);
        }
Esempio n. 3
0
        public ActionResult SelectAllUsers()
        {
            if (Session["USER"] != null)
            {
                if (lecturer.IsAdmin == 1)
                {
                    if (lecturer.Priority >= 7)
                    {
                        LecturerModel        lecturer     = new LecturerModel();
                        AccountModel         account      = new AccountModel();
                        List <AccountModel>  accounts     = account.GetAccount(null, null);
                        List <LecturerModel> lecturerList = lecturer.GetLecturer(null, null);

                        foreach (LecturerModel item in lecturerList)
                        {
                            foreach (AccountModel item2 in accounts)
                            {
                                if (item.AccId == item2.AccId)
                                {
                                    item.Username = item2.Username;
                                    item.Password = item2.Password;
                                    item.Priority = item2.Priority;
                                    item.IsAdmin  = item2.IsAdmin;
                                }
                            }
                        }

                        return(View(lecturerList));
                    }
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 4
0
 private bool isValidModel(LecturerModel model)
 {
     return(!model.Name.Equals(string.Empty) &&
            !model.Pulpit.Equals(string.Empty) &&
            !model.LectureHall.Equals(string.Empty) &&
            !model.PhoneNumber.Equals(string.Empty));
 }
        public ActionResult Login(FormCollection form)
        {
            LecturerModel       lecturer = new LecturerModel(form["Username"].ToString(), form["Password"].ToString());
            List <AccountModel> accounts = lecturer.GetAccount(null, new List <string> {
                "username = '******'", "AccPassword = '******'"
            });

            if (accounts.Count > 0)
            {
                List <LecturerModel> lecList = lecturer.GetLecturer(null, new List <string> {
                    "AccountID = " + accounts[0].AccId
                });
                lecturer         = new LecturerModel(accounts[0].Username, accounts[0].Password, accounts[0].Priority, accounts[0].IsAdmin);
                lecturer.AccId   = accounts[0].AccId;
                lecturer.Name    = lecList[0].Name;
                lecturer.Surname = lecList[0].Surname;
                lecturer.Cell    = lecList[0].Cell;
                lecturer.Email   = lecList[0].Email;
                lecturer.Level   = lecList[0].Level;
                lecturer.LectID  = lecList[0].LectID;
                System.Web.HttpContext.Current.Session["USER"] = lecturer;
                return(View("~/Views/Home/Index.cshtml"));
            }
            else
            {
                lecturer = null; //Invalid Credentials, Reset Lecturer Object
                return(View("~/Views/Account/Login.cshtml", lecturer));
            }
        }
Esempio n. 6
0
        public async Task <ResponseModel> Insert(LecturerModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                Lecturer md = new Lecturer();

                md.Name             = model.Name;
                md.Avatar           = model.Avatar;
                md.Gender           = model.Gender;
                md.DateOfBirth      = model.DateOfBirth;
                md.Phone            = model.Phone;
                md.Mobile           = model.Mobile;
                md.Fax              = model.Fax;
                md.Email            = model.Email;
                md.Rating           = model.Rating;
                md.IsWorkInCenter   = model.IsWorkInCenter;
                md.TrainingCenterId = model.TrainingCenterId;
                md.IsActive         = model.IsActive;
                md.CreateBy         = base.UserId;
                md.CreateDate       = DateTime.Now;

                await _context.LecturerRepository.AddAsync(md).ConfigureAwait(true);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Esempio n. 7
0
        public async Task <ResponseModel> Delete(LecturerModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                Lecturer md = await _context.LecturerRepository.FirstOrDefaultAsync(m => m.Id == model.Id);

                if (!md.RowVersion.SequenceEqual(model.RowVersion))
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.OutOfDateData;
                    return(response);
                }

                md.Deleted    = true;
                md.UpdateBy   = base.UserId;
                md.UpdateDate = DateTime.Now;

                _context.LecturerRepository.Update(md);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
        public void insertLecturer(LecturerModel objLec)
        {
            try
            {
                string Query = "Insert into lecturers(lecturer_name,emp_id,faculty,department,center,building,level_s,rank_s) " + "values('"
                               + objLec.Name + "','"
                               + objLec.EmpId + "','"
                               + objLec.Faculty + "','"
                               + objLec.Department + "','"
                               + objLec.Center + "','"
                               + objLec.Building + "','"
                               + objLec.Level + "','"
                               + objLec.Rank + "')";



                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                }
                DBConnection.CloseConnection();
            }
            catch (Exception ex)
            {
            }
        }
        public List <LecturerModel> getLecturers()
        {
            List <LecturerModel> listLecturer = new List <LecturerModel>();

            try
            {
                string Query = "Select lecturer_name,emp_id,faculty,department,center,building,level_s,rank_s from lecturers";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                    LecturerModel objLecturer = new LecturerModel();
                    objLecturer.Name       = myReader["lecturer_name"].ToString();
                    objLecturer.EmpId      = myReader["emp_id"].ToString();
                    objLecturer.Faculty    = myReader["faculty"].ToString();
                    objLecturer.Department = myReader["department"].ToString();
                    objLecturer.Center     = myReader["center"].ToString();
                    objLecturer.Building   = myReader["building"].ToString();
                    objLecturer.Level      = myReader["level_s"].ToString();
                    objLecturer.Rank       = myReader["rank_s"].ToString();

                    listLecturer.Add(objLecturer);
                }
            }
            catch (Exception ex)
            {
            }

            return(listLecturer);
        }
Esempio n. 10
0
        private void EditCurrentLecturer(object obj)
        {
            var view = CollectionViewSource.GetDefaultView(Lecturers);

            LecturerModel selectedLecturer = view.CurrentItem as LecturerModel;

            foreach (var subject in SpecialtiesCollection.Instance.SpecWithStudents)
            {
                if (selectedLecturer.Subjects.Contains(subject.Key))
                {
                    LecturerStudents.AddRange(subject.Value);
                }
            }

            this.CurrentLecturer.FirstName       = selectedLecturer.FirstName;
            this.CurrentLecturer.LastName        = selectedLecturer.LastName;
            this.CurrentLecturer.PersonalNumber  = selectedLecturer.PersonalNumber;
            this.CurrentLecturer.Gender          = selectedLecturer.Gender;
            this.CurrentLecturer.Title           = selectedLecturer.Title;
            this.CurrentLecturer.Faculty         = selectedLecturer.Faculty;
            this.CurrentLecturer.CurrentSubjects = string.Join(", ", selectedLecturer.Subjects);
            this.CurrentLecturer.Region          = selectedLecturer.Region;
            this.CurrentLecturer.BirthDate       = selectedLecturer.BirthDate;
            this.CurrentLecturer.Students        = string.Join(", ", LecturerStudents);
        }
Esempio n. 11
0
        private IEnumerable <LecturerModel> GetSampleLecturers(LecturerModel student = null)
        {
            List <LecturerModel> common = new List <LecturerModel>()
            {
                new LecturerModel()
                {
                    Id = 1, Email = "*****@*****.**", Phone = "8 911 929-22-22", Le_First_Name = "Bob", Le_Last_Name = "Marley"
                },
                new LecturerModel()
                {
                    Id = 2, Email = "*****@*****.**", Phone = "8 811 919-22-22", Le_First_Name = "Bob1", Le_Last_Name = "Marley1"
                },
                new LecturerModel()
                {
                    Id = 3, Email = "*****@*****.**", Phone = "8 911 939-22-22", Le_First_Name = "Bob2", Le_Last_Name = "Marley2"
                },
            };

            if (student != null)
            {
                common[student.Id] = student;
            }
            //var result = from commonModel in common group commonModel by commonModel.St_Last_Name;

            return(common);
        }
Esempio n. 12
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            var           selectedRows = Lecturers.SelectedRows;
            LecturerModel model        = GetLecturerModelFromRow(selectedRows[0]);

            DataContainer.LecturerModel = model;
            this.Close();
        }
Esempio n. 13
0
        private void DeleteCurrentLecturer(object obj)
        {
            var view = CollectionViewSource.GetDefaultView(Lecturers);

            LecturerModel selectedLecturer = view.CurrentItem as LecturerModel;

            Lecturers.Remove(selectedLecturer);
        }
Esempio n. 14
0
        public async Task <LecturerModel> AddLecturer(LecturerModel model)
        {
            var addLecturer = new Lecturer().Assign(model);

            _context.Lecturers.Add(addLecturer);
            await _context.SaveChangesAsync();

            return(new LecturerModel().Assign(addLecturer));
        }
Esempio n. 15
0
        private void AddLecturerToTable(LecturerModel model)
        {
            int rowNum = Lecturers.Rows.Add();

            Lecturers.Rows[rowNum].Cells[0].Value = model.Name;
            Lecturers.Rows[rowNum].Cells[1].Value = model.Pulpit;
            Lecturers.Rows[rowNum].Cells[2].Value = model.LectureHall;
            Lecturers.Rows[rowNum].Cells[3].Value = model.DateOfBirth;
            Lecturers.Rows[rowNum].Cells[4].Value = model.PhoneNumber;
        }
Esempio n. 16
0
        public async Task Edit(LecturerModel item)
        {
            await Task.Run(() =>
            {
                var element = lecturers.Where(x => x.Id == item.Id).FirstOrDefault();
                lecturers.Remove(element);

                lecturers.Add(item);
            });
        }
Esempio n. 17
0
 public async Task Add(LecturerModel item)
 {
     if (lecturers.Where(x => x.FirstName.ToLower() == item.FirstName.ToLower() && x.LastName.ToLower() == item.LastName.ToLower()).Count() == 0)
     {
         await Task.Run(() => {
             item.Id = lecturers.Count;
             item.Id++;
             lecturers.Add(item);
         });
     }
 }
Esempio n. 18
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            LecturerModel model = GetLecturerModelFromInputs();

            if (isValidModel(model))
            {
                DataContainer.Lecturers.Add(model);
                DataContainer.SerializeLecturers();
                AddLecturerToTable(model);
            }
        }
Esempio n. 19
0
        public void AddMail_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "ddad",
                Le_First_Name = "sasd",
                Phone         = "8 999 222-11-11",
                Email         = "23233.ru"
            };

            Assert.Throws <InvalidMailExeption>(() => service.AddLecturer(expected));
        }
Esempio n. 20
0
        public void AddName_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "242df34",
                Le_First_Name = "s41s",
                Phone         = "8 999 222-11-11",
                Email         = "*****@*****.**"
            };

            Assert.Throws <InvalidNameException>(() => service.AddLecturer(expected));
        }
Esempio n. 21
0
        public void AddPhone_Exception()
        {
            LecturersService service = new LecturersService();

            LecturerModel expected = new LecturerModel()
            {
                Id            = 4,
                Le_Last_Name  = "ddds",
                Le_First_Name = "ssad",
                Phone         = "42s4d323",
                Email         = "*****@*****.**",
            };

            Assert.Throws <InvalidPhoneException>(() => service.AddLecturer(expected));
        }
Esempio n. 22
0
        public ActionResult Create(LecturerModel model)
        {
            ViewBag.programmes = new SelectList(_attmgr.GetProgrammes(), "ProgrammeId", "ProgrammeName");
            ViewBag.colleges   = new SelectList(_attmgr.GetColleges(), "CollegeId", "CollegeName");

            if (!ModelState.IsValid)
            {
                TempData["Message"] = "Lecturer is not valid";
                return(View("Create", model));
            }

            _attmgr.Add(model);
            TempData["Message"] = "Lecturer has been successfully added";
            return(RedirectToAction("Index"));
        }
Esempio n. 23
0
        public async Task <LecturerModel> AssignCourseToLecturer(LecturerModel model)
        {
            var getlecturer = await _context.Lecturers.FirstOrDefaultAsync(l => l.Id == model.Id);

            getlecturer.Courses = model.Courses.Select(x => new Courses()
            {
                CourseCode        = x.CourseCode,
                CourseDescription = x.CourseDescription,
                Id         = x.Id,
                CourseUnit = x.CourseUnit
            }).ToList();

            await _context.SaveChangesAsync();

            return(new LecturerModel().Assign(getlecturer));
        }
Esempio n. 24
0
        private void SaveCurrentLecturer(object obj)
        {
            var view = CollectionViewSource.GetDefaultView(Lecturers);

            LecturerModel selectedLecturer = view.CurrentItem as LecturerModel;

            selectedLecturer.FirstName      = this.CurrentLecturer.FirstName;
            selectedLecturer.LastName       = this.CurrentLecturer.LastName;
            selectedLecturer.PersonalNumber = this.CurrentLecturer.PersonalNumber;
            selectedLecturer.Gender         = this.CurrentLecturer.Gender;
            selectedLecturer.Title          = this.CurrentLecturer.Title;
            selectedLecturer.Faculty        = this.CurrentLecturer.Faculty;
            selectedLecturer.Subjects       = this.CurrentLecturer.CurrentSubjects.Split(", ".ToArray()).ToList();
            selectedLecturer.Region         = this.CurrentLecturer.Region;
            selectedLecturer.BirthDate      = this.CurrentLecturer.BirthDate;
        }
Esempio n. 25
0
        public void FindLecturersById_ValidCall()
        {
            Mock <ILecturerRepository> mockGradeRepository = MockLecturerRepository;

            mockGradeRepository.Setup(mr => mr.FindByID(It.IsAny <int>()))
            .Returns((int s) => GetSampleLecturers().Where(x => x.Id == s).FirstOrDefault());
            _mockLecturerRepository = mockGradeRepository.Object;


            int           checkingId = 1;
            LecturerModel expected   = _mockLecturerRepository.FindByID(checkingId);
            var           t          = GetSampleLecturers().Where(x => x.Id == checkingId);

            Assert.True(expected != null); // Test if null
            Assert.That(expected.Le_Last_Name, Is.EqualTo(GetSampleLecturers().FirstOrDefault(x => x.Id == checkingId).Le_Last_Name));
        }
Esempio n. 26
0
        public ActionResult Edit(LecturerModel model)
        {
            ViewBag.colleges   = new SelectList(_attmgr.GetColleges(), "CollegeId", "CollegeName");
            ViewBag.programmes = new SelectList(_attmgr.GetProgrammeByCollegeId(model.CollegeId ?? 0), "ProgrammeId", "ProgrammeName");

            if (ModelState.IsValid)
            {
                if (model == null)
                {
                    TempData["Message"] = "Lecturer is not found";
                    return(View("Index"));
                }
                _attmgr.Update(model.LecturerId, model);
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public ActionResult ForgotPassword(int accid, FormCollection form)
        {
            LecturerModel       lecturer = new LecturerModel();
            List <AccountModel> accounts = lecturer.GetAccount(null, new List <string> {
                "id = " + accid + ""
            });
            HttpCookie gdsjhgfjhsdgjhf = new HttpCookie("gdsjhgfjhsdgjhf", accid.ToString());

            Response.Cookies.Add(gdsjhgfjhsdgjhf);

            if (form["password"].ToString() != null)
            {
                lecturer.Password = form["password"].ToString();
                lecturer.ChangeAccount(new List <string> {
                    "id = " + accid + ""
                });
            }

            return(View());
        }
Esempio n. 28
0
        private static void ValidateLecturerName(LecturerModel lec)
        {
            if (lec == null)
            {
                throw new ArgumentNullException(nameof(lec));
            }

            _regex = new Regex(RegexName);

            if (!_regex.IsMatch(lec.Le_First_Name))
            {
                Log.MakeLog(LoggerOperations.Error, "InvalidNameException");
                throw new InvalidNameException(lec.Le_First_Name);
            }

            if (!_regex.IsMatch(lec.Le_Last_Name))
            {
                Log.MakeLog(LoggerOperations.Error, "InvalidNameException");
                throw new InvalidNameException(lec.Le_Last_Name);
            }
        }
        public void deleteLecturer(LecturerModel objlecture)
        {
            try
            {
                string          Query = "Delete from college_db.lecturers where emp_id = '" + objlecture.EmpId + "'";
                MySqlConnection con   = new MySqlConnection(DBConnection.ConnectionString);

                MySqlCommand    cmd = new MySqlCommand(Query, con);
                MySqlDataReader myReader;
                con.Open();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                }
                con.Close();
            }
            catch (Exception ex)
            {
            }
        }
        public void deleteLecturer(LecturerModel objlecture)
        {
            try
            {
                string Query = "Delete from lecturers where emp_id = '" + objlecture.EmpId + "'";


                SqlCommand    cmd = new SqlCommand(Query, DBConnection.DatabaseConnection);
                SqlDataReader myReader;
                DBConnection.OpenConnection();
                myReader = cmd.ExecuteReader();

                while (myReader.Read())
                {
                }
                DBConnection.CloseConnection();
            }
            catch (Exception ex)
            {
            }
        }