public void SaveQualification(TestWeb.Models.EmployeeQualification model)
        {
            TestWeb.Models.EmployeeQualification e = new TestWeb.Models.EmployeeQualification();
            e.QualificationId = model.QualificationId;
            e.EmployeeId      = model.EmployeeId;
            e.Note            = model.Note;
            e.Institution     = model.Institution;
            e.ValidFrom       = model.ValidFrom;
            e.ValidTo         = model.ValidTo;
            e.City            = model.City;

            context.EmployeeQualifications.Add(e);
            context.SaveChanges();
            // Hiển thj ra Name của tất cả Qualification trong hệ thống
            SelectList cateList = new SelectList(context.Qualifications, "Id", "Name", model.QualificationId);

            ViewBag.qualificationId = cateList;
        }
        public ActionResult Edit(Employee model, TestWeb.Models.EmployeeQualification modelQualification, int id, string firstName, string middleName, string lastName, DateTime birthDate, string email, string note, int?page, string submit)
        {
            ViewBag.firstName  = firstName;
            ViewBag.middleName = middleName;
            ViewBag.lastName   = lastName;
            ViewBag.fullName   = firstName + " " + middleName + " " + lastName; // tạo full Name cho employee
            ViewBag.birthDate  = birthDate.ToString("yyyy-MM-dd");
            ViewBag.page       = page;
            ViewBag.id         = id;
            ViewBag.email      = email;
            ViewBag.note       = note;
            ViewBag.submit     = submit;

            if (submit != null)
            {
                // Lưu thông tin mới của employee
                Employee e = context.Employees.Find(id);
                e.FirstName  = model.FirstName;
                e.MiddleName = model.MiddleName;
                e.LastName   = model.LastName;
                e.Gender     = model.Gender;
                e.BirthDate  = model.BirthDate;
                e.Email      = model.Email;
                e.Note       = model.Note;
                context.SaveChanges();
                ViewBag.isValid = true;
                return(RedirectToAction("Index"));
            }
            else
            {
                //return RedirectToAction("Index");
            }
            var employeeQualifications = context.EmployeeQualifications.Where(m => m.Id != null);
            var qualifications         = context.Qualifications.Where(m => m.Id != null);
            //Hiển thị list Qualifications của Employee có mã == id
            var model2 = (from eq in employeeQualifications
                          join q in qualifications on eq.QualificationId equals q.Id
                          where eq.EmployeeId == id
                          select new ListQualification()
            {
                EmployeeId = eq.EmployeeId,
                Name = q.Name,
                City = eq.City,
                Institution = eq.Institution,
                ValidFrom = eq.ValidFrom,
                ValidTo = eq.ValidTo
            }).OrderBy(x => x.EmployeeId).ToList();

            int pageSize  = 5;
            int pageIndex = 1;

            pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;
            IPagedList <ListQualification> employeeQualification = null;

            employeeQualification = model2.ToPagedList(pageIndex, pageSize);
            // Hiển thj ra Name của tất cả Qualification trong hệ thống
            SelectList cateList = new SelectList(context.Qualifications, "Id", "Name", modelQualification.QualificationId);

            ViewBag.qualificationId = cateList;
            return(View(employeeQualification));
        }