Example #1
0
 public ActionResult Details(int id)
 {
     using (EnrollmentsManager)
     {
         using (StudManager)
         {
             using (PeopleManager)
             {
                 using (CoursesManager)
                 {
                     using (SemestersManager)
                     {
                         var disp = Mapper.Map <vmEnrollment>(EnrollmentsManager.GetEnrollmentbyID(id));
                         if (disp != null)
                         {
                             disp.Student        = Mapper.Map <vmStudent>(StudManager.GetStudentbyID(disp.StudentID));
                             disp.Student.Person = Mapper.Map <vmPerson>(PeopleManager.GetPersonbyID(disp.Student.PersonID));
                             disp.Course         = Mapper.Map <vmCourse>(CoursesManager.GetCoursebyID(disp.CourseID));
                             disp.Semester       = Mapper.Map <vmSemester>(SemestersManager.GetSemesterbyID(disp.SemesterID));
                         }
                         else
                         {
                             disp = new vmEnrollment();
                             ModelState.AddModelError("", "Failed to load details for requested object");
                         }
                         return(View(disp));
                     }
                 }
             }
         }
     }
 }
Example #2
0
 public JournalController()
 {
     usersManager    = new UsersManager();
     journalsManager = new JournalsManager();
     coursesManager  = new CoursesManager();
     logManager      = new LogManager();
 }
Example #3
0
        public ActionResult Create()
        {
            using (EnrollmentsManager)
            {
                using (CoursesManager)
                {
                    using (StudManager)
                    {
                        using (PeopleManager)
                        {
                            using (SemestersManager)
                            {
                                var disp = new vmEnrollment();
                                disp.Courses   = CoursesManager.GetAllCourses().ToList();
                                disp.Semesters = SemestersManager.GetAllSemesters().ToList();
                                var students = StudManager.GetAllStudents();
                                var people   = PeopleManager.GetAllPeople();

                                var studs = from student in students
                                            join person in people on student.PersonID equals person.ID
                                            select new KeyValuePair <int, string>(student.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                                disp.Students = studs.ToDictionary(t => t.Key, t => t.Value);
                                return(View(disp));
                            }
                        }
                    }
                }
            }
        }
Example #4
0
 public ManageJournalsController()
 {
     journalsManager = new JournalsManager();
     usersManager    = new UsersManager();
     coursesManager  = new CoursesManager();
     logManager      = new LogManager();
 }
Example #5
0
 public ActionResult Index()
 {
     using (EnrollmentsManager)
     {
         using (CoursesManager)
         {
             using (StudManager)
             {
                 using (PeopleManager)
                 {
                     using (SemestersManager)
                     {
                         var disp = Mapper.Map <IEnumerable <vmEnrollment> >(EnrollmentsManager.GetAllEnrollments());
                         foreach (var d in disp)
                         {
                             d.Course         = Mapper.Map <vmCourse>(CoursesManager.GetCoursebyID(d.CourseID));
                             d.Student        = Mapper.Map <vmStudent>(StudManager.GetStudentbyID(d.StudentID));
                             d.Student.Person = Mapper.Map <vmPerson>(PeopleManager.GetPersonbyID(d.Student.PersonID));
                             d.Semester       = Mapper.Map <vmSemester>(SemestersManager.GetSemesterbyID(d.SemesterID));
                         }
                         return(View(disp));
                     }
                 }
             }
         }
     }
 }
 //
 // GET: /Course/Delete/5
 public ActionResult Delete(int id)
 {
     using (CoursesManager)
     {
         var disp = Mapper.Map <vmCourse>(CoursesManager.GetAllCourseDetails().Where(d => d.ID == id).FirstOrDefault());
         return(View(disp));
     }
 }
Example #7
0
 public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager)
 {
     UserManager     = userManager;
     SignInManager   = signInManager;
     usersManager    = new UsersManager();
     journalsManager = new JournalsManager();
     coursesManager  = new CoursesManager();
     logManager      = new LogManager();
 }
Example #8
0
 public ValuesController(CoursesManager courseManager, IMapper mapper,
                         UserManager <ApplicationUser> userManager,
                         SignInManager <ApplicationUser> signInManager)
 {
     _courseManager = courseManager;
     _mapper        = mapper;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
Example #9
0
        private void BindgzCourses()
        {
            DataTable dt = CoursesManager.SelectgzTop3();

            if (dt != null && dt.Rows.Count != 0)
            {
                DLgzcourses.DataSource = dt;
                DLgzcourses.DataBind();
            }
        }
 //
 // GET: /Course/Details/5
 public ActionResult Details(int id)
 {
     using (CoursesManager)
     {
         var disp = Mapper.Map <vmCourse>(CoursesManager.GetAllCourseDetails().Where(d => d.ID == id).FirstOrDefault());
         if (disp == null)
         {
             disp = new vmCourse();
             ModelState.AddModelError("", "Failed to load details for requested object");
         }
         return(View(disp));
     }
 }
        public ActionResult Edit(vmCourse course)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (CoursesManager)
                    {
                        var item = CoursesManager.GetCoursebyID(course.ID);
                        item.Credits      = course.Credits;
                        item.DepartmentID = course.DepartmentID;
                        item.Description  = course.Description;
                        item.InstructorID = course.InstructorID;
                        item.TextBookID   = course.TextBookID;
                        item.Title        = course.Title;
                        var success = CoursesManager.UpdateCourse(item);
                        if (success)
                        {
                            return(RedirectToAction("Details", new { id = item.ID }));
                        }
                        throw new DataException("Failed to save " + course.Title + ". Please try again");
                    }
                }
            }
            catch (DataException ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            using (DeptManager)
            {
                using (InstManager)
                {
                    using (PeopleManager)
                    {
                        using (TBManager)
                        {
                            course.Departments = DeptManager.GetAllDepartments().ToList();
                            var inst   = InstManager.GetAllInstructors();
                            var people = PeopleManager.GetAllPeople();

                            var instr = from instructor in inst
                                        join person in people on instructor.PersonID equals person.ID
                                        select new KeyValuePair <int, string>(instructor.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                            course.Instructors = instr.ToDictionary(t => t.Key, t => t.Value);
                            course.Textbooks   = TBManager.GetAllTextbooks().ToList();
                        }
                    }
                }
            }
            return(View(course));
        }
Example #12
0
        public ActionResult Create(vmEnrollment enroll)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (EnrollmentsManager)
                    {
                        var item    = Mapper.Map <Enrollment>(enroll);
                        var success = EnrollmentsManager.AddEnrollment(item);
                        if (success)
                        {
                            return(RedirectToAction("Index"));
                        }
                        throw new DataException("Failed to save  enrollment #" + enroll.ID + ". Please try again");
                    }
                }
            }
            catch (DataException ex)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("", ex.Message);
            }
            using (EnrollmentsManager)
            {
                using (CoursesManager)
                {
                    using (StudManager)
                    {
                        using (PeopleManager)
                        {
                            using (SemestersManager)
                            {
                                enroll.Courses   = CoursesManager.GetAllCourses().ToList();
                                enroll.Semesters = SemestersManager.GetAllSemesters().ToList();
                                var students = StudManager.GetAllStudents();
                                var people   = PeopleManager.GetAllPeople();

                                var studs = from student in students
                                            join person in people on student.PersonID equals person.ID
                                            select new KeyValuePair <int, string>(student.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                                enroll.Students = studs.ToDictionary(t => t.Key, t => t.Value);
                                return(View(enroll));
                            }
                        }
                    }
                }
            }
        }
Example #13
0
        private void Startup()
        {
            EnviromentManager.DirectorySetup();
            CoursesManager.ImportCourses();

            for (int i = 0; i < 13; i++)
            {
                GameManager.UserScoreValues.Add(new Hole()
                {
                    HoleNumber = i
                });
            }

            //Mainwin_LoadSetup();
        }
Example #14
0
        private RateMyPClient()
        {
            var httpClient = new HttpClient();

            //httpClient.BaseAddress = new Uri("https://localhost:44382");
            httpClient.BaseAddress = new Uri("https://ratemypserver79.azurewebsites.net");
            httpClient.DefaultRequestHeaders.Accept.Clear();
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            Teachers = new TeachersManager(httpClient);
            Students = new StudentsManager(httpClient);
            Ratings  = new RatingsManager(httpClient);
            Courses  = new CoursesManager(httpClient);
            Tags     = new TagsManager(httpClient);
        }
        public HttpResponseMessage DeleteCourse([FromBody] CourseEntity Course)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError);

            try
            {
                CoursesManager courseManager = new CoursesManager();
                courseManager.DeleteCourse(Course);
                response = Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                response.Content = new StringContent($"{GENERIC_ERROR}  [{ex.Message}]");
                DbLog.LogError("Error in CoursesController", ex);
            }
            return(response);
        }
        public HttpResponseMessage GetCourseById(int id)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError);

            try
            {
                CoursesManager courseManager = new CoursesManager();
                CourseEntity   course        = courseManager.GetCourse(id);
                response = Request.CreateResponse(HttpStatusCode.OK, course);
            }
            catch (Exception ex)
            {
                response.Content = new StringContent($"{GENERIC_ERROR}  [{ex.Message}]");
                DbLog.LogError("Error in CoursesController", ex);
            }
            return(response);
        }
 public ActionResult Delete(vmCourse course)
 {
     try
     {
         using (CoursesManager)
         {
             var item    = CoursesManager.GetCoursebyID(course.ID);
             var success = CoursesManager.RemoveCourse(item);
             if (success)
             {
                 return(RedirectToAction("Index"));
             }
             throw new DataException();
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
         return(View(course));
     }
 }
        public IEnumerable <SelectListItem> GetCoursesForDropDown()
        {
            List <SelectListItem> selectListItems = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "---Select---", Value = ""
                },
            };
            List <Course> courses = new CoursesManager().GetAllCourses();

            foreach (Course course in courses)
            {
                SelectListItem selectListItem = new SelectListItem();
                selectListItem.Text  = course.CourseName;
                selectListItem.Value = course.Id.ToString();
                selectListItems.Add(selectListItem);
            }

            return(selectListItems);
        }
Example #19
0
 public ActionResult Index(Course course)
 {
     if (ModelState.IsValid)
     {
         CoursesManager coursesManager = new CoursesManager();
         course.CourseCode = course.CourseCode.ToUpper();
         course            = CheckInput(course);
         string result = coursesManager.InsertNewCourse(course);
         ViewBag.Departments = GetDepartmentForDropDown();
         ViewBag.Semesters   = GetSemesterForDropDown();
         ViewData["Message"] = result;
         ModelState.Clear();
         return(View());
     }
     else
     {
         ViewData["Message"] = "";
         ViewBag.Departments = GetDepartmentForDropDown();
         ViewBag.Semesters   = GetSemesterForDropDown();
         return(View());
     }
 }
Example #20
0
        private void bt_load_game_Click(object sender, EventArgs e)
        {
            if (lv_courses.SelectedItem == null)
            {
                DisplayAlert("Select a Course", "Please select a Course to Play!", "Ok");
            }
            else
            {
                CoursesManager.LaunchGame();
                GameManager.CurrentGame.IsEnabled    = true;
                GameManager.CurrentGame.UserHandicap = GameManager.UserHandicap;

                foreach (var hole in GameManager.CurrentGame.CourseHoles)
                {
                    hole.HoleScore = 0;
                }

                lv_courses.SelectedItem   = null;
                GameManager.UserHandicap  = 0;
                Shell.Current.CurrentItem = Shell.Current.CurrentItem.Items[3];
            }
        }
        public ActionResult Edit(int id)
        {
            using (DeptManager)
            {
                using (InstManager)
                {
                    using (PeopleManager)
                    {
                        using (TBManager)
                        {
                            using (CoursesManager)
                            {
                                var disp = Mapper.Map <vmCourse>(CoursesManager.GetCoursebyID(id));
                                if (disp != null)
                                {
                                    disp.Departments = DeptManager.GetAllDepartments().ToList();
                                    var inst   = InstManager.GetAllInstructors();
                                    var people = PeopleManager.GetAllPeople();

                                    var instr = from instructor in inst
                                                join person in people on instructor.PersonID equals person.ID
                                                select new KeyValuePair <int, string>(instructor.ID, string.Format("{0}, {1}", person.LastName, person.FirstMidName));
                                    disp.Instructors = instr.ToDictionary(t => t.Key, t => t.Value);

                                    disp.Textbooks = TBManager.GetAllTextbooks().ToList();
                                }
                                else
                                {
                                    disp = new vmCourse();
                                    ModelState.AddModelError("", "Failed to load details for requested object");
                                }
                                return(View(disp));
                            }
                        }
                    }
                }
            }
        }
        public ActionResult Index(vmCourseSearch vm)
        {
            List <CourseDetail>        toreturn = new List <CourseDetail>();
            IEnumerable <CourseDetail> courses  = null;

            using (CoursesManager)
            {
                courses = CoursesManager.GetAllCourseDetails();
                if (vm.SelectedDept > 0)
                {
                    courses = courses.Where(c => c.DepartmentID == vm.SelectedDept);
                }
                if (vm.SelectedInst > 0)
                {
                    courses = courses.Where(c => c.InstructorID == vm.SelectedInst);
                }
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    courses = courses.Where(c => c.Title.Contains(vm.SearchText));
                }
                JsonResult result = Json(courses.ToList());
                return(result);
            }
        }
Example #23
0
        public JsonResult GetAllCoursesByDeptId(int departmentId)
        {
            var courses = new CoursesManager().GetAllCoursesByDeptId(departmentId);

            return(Json(courses));
        }
Example #24
0
        public JsonResult GetCourseByStudentId(string studentId)
        {
            var courses = new CoursesManager().GetCourseByStudentId(studentId);

            return(Json(courses));
        }
 public ManageCoursesController()
 {
     usersManager   = new UsersManager();
     coursesManager = new CoursesManager();
     logManager     = new LogManager();
 }
Example #26
0
 public LectorController()
 {
     usersManager   = new UsersManager();
     coursesManager = new CoursesManager();
     logManager     = new LogManager();
 }
 public CourseManagerTests()
 {
     _coursesManager = new CoursesManager(_config.Object, _service, _converter, _authRepository);
 }
Example #28
0
        public static List <JournalViewModel> GetJournalsList(ICollection <Journal> journals, UsersManager usersManager, CoursesManager coursesManager)
        {
            LogManager logManager = new LogManager();

            logManager.AddEventLog("JournalViewModel => GetJournalsList 2nd method called", "Method");

            List <JournalViewModel> result = new List <JournalViewModel>();

            foreach (var item in journals)
            {
                var course     = coursesManager.GetSpecificCourse(item.CourseId);
                var lectorData = usersManager.GetSpecificUser(course.LectorId);
                var lector     = "None";
                if (lectorData != null)
                {
                    lector = string.Concat(lectorData.FirstName, " ", lectorData.LastName);
                }
                result.Add(new JournalViewModel(
                               item.Id,
                               item.Users.First().FirstName,
                               item.Users.First().LastName,
                               item.Mark,
                               course.CourseName,
                               course.Theme,
                               course.Id,
                               lector,
                               course.CourseStatus.ToString()
                               ));
            }
            return(result);
        }
Example #29
0
        public JsonResult GetCourseInformationByCourseId(int courseId)
        {
            var course = new CoursesManager().GetCourseInformationByCourseId(courseId);

            return(Json(course));
        }
 public CourseManagerTests()
 {
     _coursesManager = new CoursesManager(_config.Object, _service, _converter, _authRepository);
 }