Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("StudentID,FirstName,LastName,InstructorID")] StudentM student)
        {
            //TODO: Need ref. to Instructor TD from Login Instructor//

            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(student));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("StudentID,FirstName,LastName,InstructorID")] StudentM student)
        {
            //TODO: Need ref. to Instructor TD from Login Instructor//

            if (ModelState.IsValid)
            {
                if (HttpContext.Session.GetInt32(SessionLoggedID) != null)
                {
                    var PassID = HttpContext.Session.GetInt32(SessionLoggedID);
                    student.InstructorID = (int)PassID;
                    _context.Add(student);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.Error("An Error Occured, Please Re-Log into your account");
            return(RedirectToAction("Logout", "Instructors"));
        }
        public async Task <IActionResult> InstructorRegister([Bind("ID,LastName,FirstName,UserName,Password,Email")] InstructorM instructor)
        {
            bool find = _context.Instructors.ToList().Any(m => m.UserName == instructor.UserName);

            if (find)
            {
                ViewBag.Error       = "User Name already exists, Please choose a different User Name";
                instructor.UserName = "";
                return(View());
            }
            else if (ModelState.IsValid)
            {
                ViewBag.success = instructor.FirstName + " Your Account Has Been Succesfully Created!";
                _context.Add(instructor);
                await _context.SaveChangesAsync();

                ModelState.Clear();
                return(View("InstructorLogin"));
            }
            return(View(instructor));
        }