示例#1
0
        public ViewResult SubmitForm([Bind] SchoolProject.Models.Form.Professor form)
        {
            Professor prof = new Professor();

            prof.professor_id   = form.professor_id;
            prof.professor_no   = form.professor_no;
            prof.professor_name = form.professor_name;
            prof.gender         = form.gender;
            prof.status         = form.status;
            prof.birthdate      = form.birthdate;
            prof.username       = form.username;
            prof.password       = form.password;

            _context.professor.Add(prof);
            int rec = _context.SaveChanges();

            if (rec == 1)
            {
                IQueryable <Admin_User> admin = from s in _context.admin_user
                                                select s;
                IQueryable <Professor> profe = from s in _context.professor
                                               select s;
                IQueryable <Programs> prog = from s in _context.program
                                             select s;
                IQueryable <Student> stud = from s in _context.student
                                            select s;
                IQueryable <Subject> subj = from s in _context.subject
                                            select s;
                IQueryable <Parent_User> par = from s in _context.parent_user
                                               select s;
                ViewBag.parent_user = par;
                ViewBag.subject     = subj;
                ViewBag.student     = stud;
                ViewBag.admin_user  = admin;
                ViewBag.professor   = profe;
                ViewBag.programs    = prog;
                return(View());
            }
            return(View("Error"));
        }
示例#2
0
        public ViewResult SubmitForm([Bind] SchoolProject.Models.Form.Professor form)
        {
            var user = _context.professor
                       .Where(u => u.username == form.username && u.password == form.password)
                       .FirstOrDefault();

            if (user == null)
            {
                ViewBag.error = "Login error!";
                return(View("InitForm"));
            }
            else
            {
                var profid = _context.professor
                             .Where(u => u.username == form.username)
                             .Select(u => u.professor_id)
                             .FirstOrDefault();
                httpContext.Session.SetString("username", form.username);
                httpContext.Session.SetInt32("uid", profid);
                return(View());
            }
        }