Exemplo n.º 1
0
        public static List <SelectListItem> PopulateLecturerSelectListItem()
        {
            try
            {
                StaffLogic   staffLogic = new StaffLogic();
                List <STAFF> users      = staffLogic.GetEntitiesBy(p => p.Is_Lecturer);
                if (users == null || users.Count <= 0)
                {
                    return(new List <SelectListItem>());
                }

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

                SelectListItem list = new SelectListItem();
                list.Value = "";
                list.Text  = Select;
                userList.Add(list);

                foreach (STAFF user in users)
                {
                    SelectListItem selectList = new SelectListItem();
                    selectList.Value = user.Person_Id.ToString();
                    selectList.Text  = user.PERSON.Last_Name + " " + user.PERSON.First_Name + " " + user.PERSON.Other_Name;

                    userList.Add(selectList);
                }

                return(userList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public JsonResult GetCourses(int progId, int deptId, int levelId)
        {
            List <COURSE>         courses          = new List <COURSE>();
            List <SelectListItem> courseSelectList = new List <SelectListItem>();

            try
            {
                if (progId > 0 && deptId > 0 && levelId > 0)
                {
                    CourseLogic courseLogic = new CourseLogic();

                    courses = courseLogic.GetEntitiesBy(c => c.Department_Id == deptId && c.Level_Id == levelId && c.Programme_Id == progId && c.Active);
                    if (User.IsInRole("Lecturer"))
                    {
                        UserLogic        userLogic        = new UserLogic();
                        USER             user             = userLogic.GetEntityBy(u => u.Username == User.Identity.Name);
                        StaffLogic       staffLogic       = new StaffLogic();
                        StaffCourseLogic staffCourseLogic = new StaffCourseLogic();
                        STAFF            staff            = staffLogic.GetEntitiesBy(s => s.Person_Id == user.Person_Id).LastOrDefault();
                        if (staff != null)
                        {
                            List <STAFF_COURSE> staffCourses = staffCourseLogic.GetEntitiesBy(s => s.Staff_Id == staff.Person_Id);
                            if (staffCourses != null)
                            {
                                courses = staffCourses.Select(s => s.COURSE).ToList();
                            }
                            else
                            {
                                courses = new List <COURSE>();
                            }
                        }
                    }

                    SelectListItem list = new SelectListItem();
                    list.Value = "";
                    list.Text  = "-- Select Course --";
                    courseSelectList.Add(list);

                    courses.ForEach(c =>
                    {
                        SelectListItem myList = new SelectListItem();
                        myList.Value          = c.Id.ToString();
                        myList.Text           = c.Code + " - " + c.Name;
                        courseSelectList.Add(myList);
                    });
                }
            }
            catch (Exception ex)
            {
            }

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