Esempio n. 1
0
        public ActionResult Edit(Guid ID)
        {
            var ob = new CoursesStudentDetailtBCL().GetByScsId(ID);

            ob.CoursesJournalJoin             = new CoursesJournalBCL().GetByCJId((Guid)ob.CJId);
            ob.CoursesJournalJoin.CoursesJoin = new CoursesBCL().GetByCoId((Guid)ob.CoursesJournalJoin.CoId);

            var dropStuden = new List <SelectListItem>();
            var old        = new CoursesStudentDetailtBCL().GetAll().Where(q => q.CJId == ob.CJId).ToList();
            var all        = new StudentDetailtBCL().GetJoin().Where(q => q.CoId == ob.CoursesJournalJoin.CoId && (!old.Any(x => x.StudetId == q.StudetId) || q.StudetId == ob.StudetId)).ToList();

            foreach (var item in all)
            {
                dropStuden.Add(new SelectListItem()
                {
                    Text     = item.StudentJoin.FullName,
                    Value    = item.StudetId.ToString(),
                    Selected = item.StudetId == ob.StudetId
                });
            }

            ViewBag.CJ         = ob;
            ViewBag.dropStuden = dropStuden;
            return(View(ob));
        }
Esempio n. 2
0
        public ActionResult Create(Guid?ID)
        {
            if (!ID.HasValue)
            {
                ModelState.AddModelError("", "Chọn một Nhật kí để thêm");
                return(RedirectToAction("Index"));
            }
            Guid id = (Guid)ID;
            var  ob = new CoursesJournalBCL().GetByCJId(id);

            ob.CoursesJoin = new CoursesBCL().GetByCoId((Guid)ob.CoId);
            var dropStuden = new List <SelectListItem>();
            var old        = new CoursesStudentDetailtBCL().GetAll().Where(q => q.CJId == ob.CJId).ToList();
            var all        = new StudentDetailtBCL().GetJoin().Where(q => q.CoId == ob.CoId && !old.Any(x => x.StudetId == q.StudetId)).ToList();

            foreach (var item in all)
            {
                dropStuden.Add(new SelectListItem()
                {
                    Text  = item.StudentJoin.FullName,
                    Value = item.StudetId.ToString()
                });
            }

            ViewBag.CJ         = ob;
            ViewBag.dropStuden = dropStuden;
            if (dropStuden.Count <= 0)
            {
                ModelState.AddModelError("StudetId", "Không có học viên nào trong lớp học để thêm!");
            }

            return(View(new CoursesStudentDetailtObject()
            {
                CJId = ob.CJId
            }));
        }