Exemplo n.º 1
0
        public IActionResult Register(string fname, string mname, string lname, string suffix, string age, string gender, string civilstat, string addr, string bdate, string bplace, string mobile, string email, string uname, string pwd, string confirm, string isgrad)
        {
            if (confirm == pwd)
            {
                Student x = new Student()
                {
                    Fname       = fname,
                    Mname       = mname,
                    Lname       = lname,
                    Suffix      = suffix,
                    Age         = long.Parse(age),
                    Gender      = gender,
                    CivilStatus = civilstat,
                    Address     = addr,

                    Mobileno = mobile,
                    Email    = email,

                    Birthdate  = DateTime.Parse(bdate).ToString("MM/dd/yyyy"),
                    Birthplace = bplace,
                    Isgraduate = isgrad,

                    Uname = uname,
                    Pwd   = pwd,
                };

                _ctx.Students.Add(x);

                _ctx.SaveChanges();

                ViewData["yesmsg"]  = "You have been successfully registered to the site. You can now login as student.";
                ViewData["yesmsg2"] = "Complete your academic information in your Profile page.";

                return(View());
            }
            else
            {
                ViewData["fname"]     = fname;
                ViewData["mname"]     = mname;
                ViewData["lname"]     = lname;
                ViewData["suffix"]    = suffix;
                ViewData["age"]       = age;
                ViewData["gender"]    = gender;
                ViewData["civilstat"] = civilstat;
                ViewData["bdate"]     = bdate;
                ViewData["bplace"]    = bplace;
                ViewData["addr"]      = addr;
                ViewData["mobileno"]  = mobile;
                ViewData["email"]     = email;

                ViewData["uname"]  = uname;
                ViewData["isgrad"] = isgrad;


                ViewData["errmsg"] = "Confirm password doesn't match. Please try again.";

                return(View());
            }
        }
        public IActionResult AddUser(string Uname, string Fname, string Lname, string Gender, string Pwd, string Confirm)
        {
            if (Confirm == Pwd)
            {
                User x = new User()
                {
                    Uname  = Uname,
                    Fname  = Fname,
                    Lname  = Lname,
                    Gender = Gender,
                    Pwd    = Pwd
                };

                _ctx.Users.Add(x);

                _ctx.SaveChanges();

                return(RedirectToAction("Users"));
            }
            else
            {
                ViewData["err"] = "Incorrect confirmation password.";

                return(View());
            }
        }
Exemplo n.º 3
0
        public IActionResult UpdateProfile(string mobile, string email, string isgrad, string gradyr, string course, string major, string elemname, string elemaddr, string elemyr, string secname, string secaddr, string secyr, string tername, string teraddr, string teryr)  // not implemented
        {
            string u = HttpContext.User.FindFirst("username").Value;

            Student x = _ctx.Students.Find(u);

            x.Mobileno   = mobile;
            x.Email      = email;
            x.Isgraduate = isgrad;

            if (isgrad == "Yes")
            {
                if (gradyr != "N/A" || gradyr != "NA" || gradyr != "")
                {
                    x.Graduateyr = int.Parse(gradyr);
                }
            }

            x.Course = course;
            x.Major  = major;

            x.Elemname = elemname;
            x.Elemaddr = elemaddr;
            x.Elemyr   = int.Parse(elemyr);

            x.Secname = secname;
            x.Secaddr = secaddr;
            x.Secyr   = int.Parse(secyr);

            x.Tername = tername;
            x.Teraddr = teraddr;

            int yr = 0;

            if (teryr != "N/A" || teryr != "NA" || teryr != "")
            {
                // x.Teryr = int.Parse(teryr);
                int.TryParse(teryr, out yr);
            }

            x.Teryr = yr;

            _ctx.Students.Update(x);

            _ctx.SaveChanges();

            ViewData["yesmsg"] = "Your profile has been successfully updated.";

            return(View());
        }