Ejemplo n.º 1
0
        public IActionResult Index()
        {
            var announcementVM = new AnnouncementViewModel();

            announcementVM.Announcement = _AnnouncementRepository.GetAnnouncementtByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            announcementVM.Classes = new List <SelectListItem>();
            var objClassSecSub = _LectureRepository.GetAllClassSectionByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            foreach (var lstclass in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstclass.Class_Name,
                    Value = lstclass.Class_Id.ToString(),
                };

                announcementVM.Classes.Add(selectListItem);
            }


            announcementVM.Sections = new List <SelectListItem>();
            foreach (var lstSection in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSection.Section_Name,
                    Value = lstSection.Section_Id.ToString(),
                };

                announcementVM.Sections.Add(selectListItem);
            }


            announcementVM.Subjects = new List <SelectListItem>();
            var objSubject = _LectureRepository.GetAllSubjectByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 0).ToList();

            foreach (var lstSubject in objSubject)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSubject.Subject_Name,
                    Value = lstSubject.Subject_Id.ToString(),
                };

                announcementVM.Subjects.Add(selectListItem);
            }



            if (TempData["Error"] != null)
            {
                ViewBag.Error = TempData["Error"].ToString();
            }

            if (TempData["Success"] != null)
            {
                ViewBag.Success = TempData["Success"].ToString();
            }

            return(View(announcementVM));
        }
Ejemplo n.º 2
0
        public IActionResult AddLecture()
        {
            List <SelectListItem> classList = new List <SelectListItem>();

            classList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            var objClassSecSub = _LectureRepository.GetAllClassSectionByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            foreach (var lstclass in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstclass.Class_Name,
                    Value = lstclass.Class_Id.ToString(),
                };

                classList.Add(selectListItem);
            }
            ViewBag.ClassList = classList;

            List <SelectListItem> sectionList = new List <SelectListItem>();

            sectionList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            foreach (var lstSection in objClassSecSub)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSection.Section_Name,
                    Value = lstSection.Section_Id.ToString(),
                };

                sectionList.Add(selectListItem);
            }
            ViewBag.SectionList = sectionList;


            List <SelectListItem> subjectList = new List <SelectListItem>();

            subjectList.Insert(0, new SelectListItem()
            {
                Value = "-1", Text = "--Select--"
            });
            var objSubject = _LectureRepository.GetAllSubjectByTeacherId(HttpContext.Session.GetInt32("UserId") ?? 1).ToList();

            foreach (var lstSubject in objSubject)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = lstSubject.Subject_Name,
                    Value = lstSubject.Subject_Id.ToString(),
                };

                subjectList.Add(selectListItem);
            }
            ViewBag.SubjectList = subjectList;

            return(View());
        }