Пример #1
0
        public IActionResult RegisterForCourse()
        {
            RegistrationManager manager = new RegistrationManager(_context);

            ViewBag.listOfCoursesForRegistration = manager.GetListOfCoursesForRegistration();
            return(View());
        }
Пример #2
0
        public IActionResult DropCourse(int courseID)
        {
            RegistrationManager manager = new RegistrationManager(_context);
            string userID = _userManager.GetUserId(User);

            manager.DropClass(courseID, userID);
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult Index(PaymentModel payment)
        {
            if (string.IsNullOrWhiteSpace(payment.FirstName) && string.IsNullOrWhiteSpace(payment.LastName) && string.IsNullOrWhiteSpace(payment.Address1) && string.IsNullOrWhiteSpace(payment.Address2) &&
                string.IsNullOrWhiteSpace(payment.Month) && string.IsNullOrWhiteSpace(payment.Year) && string.IsNullOrWhiteSpace(payment.PostCode) && string.IsNullOrWhiteSpace(payment.CardCode))
            {
                ModelState.AddModelError("CardNumber", "Cannot be empty and card number has to be 14 digits or greater");
            }
            if (!ModelState.IsValid)
            {
                View(payment);
            }

            TransactionResponse result = new PaymentProcesses().ChargeCredit(payment);

            if (result != null && result.ResultCode == AuthorizeNet.Api.Contracts.V1.messageTypeEnum.Ok)
            {
                PaymentManager paymentManager = new PaymentManager(_context);
                string         userID         = _userManager.GetUserId(User);
                paymentManager.SubtractBalanceFromStudent(userID, result.AmountPaid);

                RegistrationManager registrationManager = new RegistrationManager(_context);
                int studentID = registrationManager.GetStudentIDFromUserID(userID);
                paymentManager.CreatePaymentForDatabase(result, studentID);

                TransactionResponse viewmodel = new TransactionResponse()
                {
                    TransId      = result.TransId,
                    ResultCode   = result.ResultCode,
                    ResponseCode = result.ResponseCode,
                    MessageCode  = result.MessageCode,
                    AuthCode     = result.AuthCode,
                    Description  = result.Description,
                    AmountPaid   = result.AmountPaid,
                };

                List <TransactionResponse> viewmodelList = new List <TransactionResponse>
                {
                    viewmodel
                };
                return(RedirectToAction("TransactionResponse", new { viewmodelList = JsonConvert.SerializeObject(viewmodelList) }));
            }
            else
            {
                PaymentModel model = new PaymentModel();

                TransactionResponse transaction = new TransactionResponse();

                if (transaction.ErrorCode == "6" || transaction.ErrorCode == "78" || transaction.ErrorCode == "316" || transaction.ErrorCode == "112")
                {
                    model.CardNumber = transaction.ErrorText;
                    return(View("Index", model.CardNumber));
                }
                else
                {
                    return(View("Index", model.CardNumber));
                }
            }
        }
Пример #4
0
        public IActionResult DropCourse()
        {
            RegistrationManager manager = new RegistrationManager(_context);
            string userID    = _userManager.GetUserId(User);
            int    studentID = manager.GetStudentIDFromUserID(userID);
            List <CourseForRegistration> courses = manager.GetStudentEnrollments(studentID);

            ViewBag.studentEnrollments = courses;
            return(View());
        }
        public IActionResult TransactionResponse(string viewmodelList)
        {
            List <TransactionResponse> response = JsonConvert.DeserializeObject <List <TransactionResponse> >(viewmodelList);
            string userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int     studentID           = manager.GetStudentIDFromUserID(userID);
            Student student             = manager.GetStudentByStudentID(studentID);

            ViewData["StudentName"]    = String.Join(" ", student.FirstName, student.LastName);
            ViewData["StudentBalance"] = student.Balance;
            return(View("TransactionResponse", response));
        }
Пример #6
0
        async public Task <IActionResult> RegisterForCourse(int courseID)
        {
            var userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int    facultyID            = manager.GetFacultyIDFromUserID(userID);
            Course course = manager.GetCourseByCourseID(courseID);

            course.FacultyID = facultyID;

            _context.Update(course);
            await _context.SaveChangesAsync();

            return(View("Index"));
        }
Пример #7
0
        public IActionResult RegisterForCourse(string message)
        {
            RegistrationManager manager = new RegistrationManager(_context);

            ViewBag.listOfCoursesForRegistration = manager.GetListOfCoursesForRegistration();
            if (String.IsNullOrEmpty(message))
            {
                return(View());
            }
            else
            {
                ViewData["ErrorMessage"] = message;
            }

            return(View());
        }
        public ActionResult Index(string errorMessage)
        {
            var userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int     studentID           = manager.GetStudentIDFromUserID(userID);
            Student student             = manager.GetStudentByStudentID(studentID);

            ViewData["StudentBalance"] = student.Balance;


            if (String.IsNullOrEmpty(errorMessage))
            {
                return(View());
            }
            ViewData["ErrorMessage"] = errorMessage;
            return(View());
        }
Пример #9
0
        public IActionResult RegisterForCourse(int courseID)
        {
            var userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int studentID = manager.GetStudentIDFromUserID(userID);
            //int courseID = manager.GetCourseIDFromSectionNumber(sectionNumber);
            Enrollment enrollment = new Enrollment()
            {
                CourseID  = courseID,
                StudentID = studentID,
                Date      = DateTime.Now,
            };

            _context.Add(enrollment);
            _context.SaveChangesAsync();

            return(View("Index"));
        }
Пример #10
0
        async public Task <IActionResult> RegisterForCourse(int courseID)
        {
            var userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int    facultyID            = manager.GetFacultyIDFromUserID(userID);
            Course course = manager.GetCourseByCourseID(courseID);

            course.FacultyID = facultyID;
            _context.Update(course);

            Faculty faculty = manager.GetFacultyByFacultyID(facultyID);

            faculty.Balance += course.CreditHours * 2000;
            _context.Update(faculty);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #11
0
        async public Task <IActionResult> Index()
        {
            var             userID      = _userManager.GetUserId(User);
            ApplicationUser currentUser = await _userManager.FindByIdAsync(userID);

            if (currentUser.CompletedRegistration == false)
            {
                return(RedirectToAction("GetStudentInfo"));
            }
            RegistrationManager manager = new RegistrationManager(_context);
            int     studentID           = manager.GetStudentIDFromUserID(userID);
            Student student             = manager.GetStudentByStudentID(studentID);

            ViewData["StudentBalance"] = student.Balance;
            List <CourseForRegistration> courses = manager.GetStudentEnrollments(studentID);

            ViewBag.studentEnrollments = courses;
            return(View());
        }
Пример #12
0
        async public Task <IActionResult> Index()
        {
            var             userID      = _userManager.GetUserId(User);
            ApplicationUser currentUser = await _userManager.FindByIdAsync(userID);

            if (currentUser.CompletedRegistration == false)
            {
                return(RedirectToAction("GetFacultyInfo"));
            }
            RegistrationManager manager = new RegistrationManager(_context);
            int     facultyID           = manager.GetFacultyIDFromUserID(userID);
            Faculty faculty             = manager.GetFacultyByFacultyID(facultyID);

            ViewData["FacultyBalance"] = faculty.Balance;
            List <CourseForRegistration> courses = manager.GetFacultyCourses(facultyID);

            ViewBag.facultyCourses = courses;

            return(View());
        }
Пример #13
0
        async public Task <IActionResult> RegisterForCourse(int courseID)
        {
            var userID = _userManager.GetUserId(User);
            RegistrationManager manager = new RegistrationManager(_context);
            int studentID = manager.GetStudentIDFromUserID(userID);

            if (manager.IsStudentAlreadyEnrolled(studentID, courseID))
            {
                return(RedirectToAction("RegisterForCourse", new { message = "You're already enrolled in this class" }));
            }

            Course course = manager.GetCourseByCourseID(courseID);

            if (course.Capacity == course.Enrollment)
            {
                return(RedirectToAction("RegisterForCourse", new { message = "Sorry, that class is already full." }));
            }

            else
            {
                await manager.AddBalanceToStudent(courseID, userID);

                Enrollment enrollment = new Enrollment()
                {
                    CourseID  = courseID,
                    StudentID = studentID,
                    Date      = DateTime.Now,
                };


                course.Enrollment++;
                _context.Update(course);


                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }