Ejemplo n.º 1
0
        public ActionResult AssignTeacher()
        {
            var model = new AssignTeacherViewModel();

            model.DepartmentSelectListItems2 = courseTeacherDAL.TeacherGetAll().Select(c => new SelectListItem()
            {
                Value = c.DepartmentId.ToString(), Text = c.Department.DepartmentName
            });
            model.CoursetSelectListItems  = GetDefaultSelectListItem();
            model.TeachertSelectListItems = GetDefaultSelectListItem();
            model.TeachertInfoListItems   = GetTDefaultSelectListItem();
            return(View(model));
        }
Ejemplo n.º 2
0
        public JsonResult GetTeacherInfoByTeacherId(int teacherTd)
        {
            //var dataList = courseTeacherDAL.TeacherGetAll().Where(c => c.TeacherId == teacherTd).ToList();
            CoueseTeacherDAL courseTeacherDAL = new CoueseTeacherDAL();
            var teacherGetAll            = courseTeacherDAL.TeacherGetAll();
            var AssignCourseCreditresult = courseTeacherDAL.AssingTeacherGetAll();
            var gropbySum = AssignCourseCreditresult
                            .GroupBy(s => new { s.TeacherId })
                            .Select(g => new
            {
                TeacherId          = g.Key.TeacherId,
                AssignCourseCredit = g.Sum(x => x.AssignCourseCredit)
            });
            var result = from e in teacherGetAll
                         join d in gropbySum
                         on e.TeacherId equals d.TeacherId into eGroup
                         from d in eGroup.DefaultIfEmpty()
                         select new
            {
                TeacherId         = e.TeacherId,
                TeacherName       = e.TeacherName,
                CreditTeken       = e.CreditTaken,
                AssignCreditTeken = d == null ? 0 : d.AssignCourseCredit,
            };
            var newResult = result.Select(n => new
            {
                TeacherId       = n.TeacherId,
                TeacherName     = n.TeacherName,
                CreditTeken     = n.CreditTeken,
                AssignCredit    = n.AssignCreditTeken,
                RemainingCredit = n.CreditTeken - n.AssignCreditTeken,
            });
            var finalResult = newResult.Where(c => c.TeacherId == teacherTd).ToList();
            var jsonData    = finalResult.Select(c => new { c.CreditTeken, c.RemainingCredit });

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }