コード例 #1
0
        public ActionResult Register(UserVM usr)
        {
            if (ModelState.IsValid)
            {
                string username  = Request["UserName"];
                string pass      = Request["Password"];
                string Email     = Request["Email"];
                string Phone     = Request["Phone"];
                string FirstName = Request["FirstName"];
                string LastName  = Request["LastName"];
                User   obj       = new User();
                obj.UserName  = username;
                obj.Password  = pass;
                obj.Phone     = Phone;
                obj.Email     = Email;
                obj.FirstName = FirstName;
                obj.LastName  = LastName;

                if (obj.UserName == null || obj.Password == null || obj.Phone == null || obj.Email == null || obj.FirstName == null || obj.LastName == null)
                {
                    Response.Write("<script>alert('Please enter all field in correct form');</script>");
                    return(View("Login"));
                }
                else
                {
                    db.Users.Add(obj);
                    db.SaveChanges();
                    return(RedirectPermanent("/Questions/Index"));
                }
            }
            Response.Write("<script>alert('Please enter all field in correct form');</script>");
            return(View("Register"));
        }
コード例 #2
0
        public ActionResult AddQuestions(Question quest)
        {
            string   Question = Request["Questions"];
            Question obj      = new Question();

            obj.QuestionTitle = Question;

            db.Questions.Add(obj);
            db.SaveChanges();

            return(Json(obj.QuestionID));
        }
コード例 #3
0
        public ActionResult AddAnswers(Answer answer)
        {
            string QuestionID = Request["Question_ID"];
            string answers    = Request["Answer"];
            Answer obj        = new Answer();

            obj.QuestionID    = int.Parse(QuestionID);
            obj.AnswerDetails = answers;

            db.Answers.Add(obj);
            db.SaveChanges();

            return(Json("OK!"));
        }