public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee employee = db.Employees.Find(id);

            if (employee == null)
            {
                return(HttpNotFound());
            }
            List <EmployeeVM> completeCourses = new List <EmployeeVM>();

            foreach (var course in db.CourseCompletions.Where(cc => cc.UserID == id).Include(c => c.Course))
            {
                EmployeeVM evm = new EmployeeVM();
                evm.UserID        = id;
                evm.CourseName    = course.Course.CourseName;
                evm.Description   = course.Course.Description;
                evm.ValidFor      = course.Course.ValidFor;
                evm.LessonCount   = db.Lessons.Where(x => x.CourseID == course.CourseID).Count();
                evm.DateCompleted = course.DateCompleted;
                completeCourses.Add(evm);
            }

            List <IncompleteCourseVM> incompleteCourses = new List <IncompleteCourseVM>();

            foreach (var course in db.Courses.Where(c => c.IsActive))
            {
                if (db.CourseCompletions.Where(c => c.UserID == id && c.CourseID == course.CourseID).Count() == 0)
                {
                    IncompleteCourseVM icvm = new IncompleteCourseVM();
                    icvm.CourseID        = course.CourseID;
                    icvm.CourseName      = course.CourseName;
                    icvm.TotalLessons    = db.Lessons.Where(c => c.CourseID == course.CourseID && c.IsActive && c.Course.IsActive).Count();
                    icvm.LessonsComplete = db.LessonViews.Where(u => u.UserID == id && u.Lesson.CourseID == course.CourseID).Count();
                    incompleteCourses.Add(icvm);
                }
            }
            dynamic empCourses = new ExpandoObject();

            empCourses.Complete   = completeCourses;
            empCourses.Incomplete = incompleteCourses;
            ViewBag.Name          = employee.FirstName + " " + employee.LastName;
            var UserManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var user        = UserManager.FindById(employee.UserID);

            ViewBag.Email = user.Email;

            return(View(empCourses));
        }
        public ActionResult EmployeeProgress()
        {
            var id = User.Identity.GetUserId();
            List <EmployeeVM> completeCourses = new List <EmployeeVM>();

            foreach (var course in db.CourseCompletions.Where(cc => cc.UserID == id && cc.Course.IsActive).Include(c => c.Course))
            {
                EmployeeVM evm = new EmployeeVM();
                evm.UserID        = id;
                evm.CourseName    = course.Course.CourseName;
                evm.Description   = course.Course.Description;
                evm.ValidFor      = course.Course.ValidFor;
                evm.LessonCount   = db.Lessons.Where(x => x.CourseID == course.CourseID && x.IsActive).Count();
                evm.DateCompleted = course.DateCompleted;
                completeCourses.Add(evm);
            }

            List <IncompleteCourseVM> incompleteCourses = new List <IncompleteCourseVM>();

            foreach (var course in db.Courses.Where(c => c.IsActive))
            {
                if (db.CourseCompletions.Where(c => c.UserID == id && c.CourseID == course.CourseID).Count() == 0)
                {
                    IncompleteCourseVM icvm = new IncompleteCourseVM();
                    icvm.CourseID        = course.CourseID;
                    icvm.CourseName      = course.CourseName;
                    icvm.TotalLessons    = db.Lessons.Where(c => c.CourseID == course.CourseID && c.IsActive).Count();
                    icvm.LessonsComplete = db.LessonViews.Where(u => u.UserID == id && u.Lesson.CourseID == course.CourseID).Count();
                    incompleteCourses.Add(icvm);
                }
            }

            dynamic empCourses = new ExpandoObject();

            empCourses.Incomplete = incompleteCourses;
            empCourses.Complete   = completeCourses;

            return(View(empCourses));
        }