Ejemplo n.º 1
0
        public ActionResult MissionFAQ(FormCollection form, int missionKey)
        {
            String formType = form["formType"].ToString();

            if (formType == "Question")
            {
                String           question    = form["NewQuestion"].ToString();
                MissionQuestions newQuestion = new MissionQuestions();
                newQuestion.missionQuestion = question;
                newQuestion.userID          = User.Identity.GetUserName();
                newQuestion.missionID       = missionKey;
                if (ModelState.IsValid)
                {
                    MissionContext.MissionQuestions.Add(newQuestion);
                    MissionContext.SaveChanges();
                    return(RedirectToAction("MissionFAQ", "Mission", new { missionKey = newQuestion.missionID, questionID = newQuestion.missionQuestionID }));
                }
            }
            else
            {
                int            missionQuestionID = Convert.ToInt32(form["missionQuestionID"]);
                MissionAnswers newAnswer         = new MissionAnswers();
                newAnswer.answer            = form["NewComment"].ToString();
                newAnswer.missionQuestionID = missionQuestionID;
                IEnumerable <string> handler = MissionContext.Database.SqlQuery <String>("SELECT Handler FROM AspNetUsers WHERE UserName = @p0", User.Identity.GetUserName());
                newAnswer.handler = "@" + handler.ToList()[0]; //there will only be one
                if (ModelState.IsValid)
                {
                    MissionContext.MissionAnswers.Add(newAnswer);
                    MissionContext.SaveChanges();
                    return(RedirectToAction("MissionFAQ", "Mission", new { missionKey = missionKey, questionID = missionQuestionID }));
                }
            }
            return(RedirectToAction("MissionFAQ", "Mission", new { missionKey = missionKey }));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "MissionQ_ID,Question,Answer,MissionID,UserID")] MissionQuestions missionQuestions)
        {
            if (ModelState.IsValid)
            {
                missionQuestions.MissionID = M_ID;
                var id   = Session["UserID"];
                int U_ID = Convert.ToInt32(id);
                if (string.IsNullOrEmpty(U_ID.ToString()) || U_ID == 0)
                {
                    missionQuestions.UserID = 1;
                }
                else
                {
                    missionQuestions.UserID = U_ID;
                }

                db.MissionQuestions.Add(missionQuestions);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MissionID = new SelectList(db.Missions, "MissionID", "MissionName", missionQuestions.MissionID);
            ViewBag.UserID    = new SelectList(db.Users, "UserID", "UserFName", missionQuestions.UserID);
            return(View(missionQuestions));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "MissionID,Designation,Description")] Mission mission)
        {
            if (ModelState.IsValid)
            {
                db.Missions.Add(mission);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mission));
        }
        public ActionResult Create([Bind(Include = "QUESTION_ID,MISSION_ID,USER_ID,QUESTION,ANSWER")] MissionQuestions missionQuestions)
        {
            if (ModelState.IsValid)
            {
                db.missionQuestions.Add(missionQuestions);
                db.SaveChanges();
                return(RedirectToAction("Index", new { missionID = globalMission.MISSION_ID, id = UserID }));
            }

            return(View(missionQuestions));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "MissionID,missionName,missionPresidentsName,missionAddress,language,climate,dominantReligion,flagSymbol")] Mission mission)
        {
            if (ModelState.IsValid)
            {
                db.Missions.Add(mission);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mission));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "userID,userEmail,password,firstName,lastName")] Users users)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(users));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "AstronautID,Name,Birthday,Nationality")] Astronaut astronaut)
        {
            if (ModelState.IsValid)
            {
                db.Astronauts.Add(astronaut);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Nationality = new SelectList(db.Countries, "CountryID", "CountryName", astronaut.Nationality);
            return(View(astronaut));
        }
Ejemplo n.º 8
0
        public ActionResult MissionPage(FormCollection answer, int?question_ID, int?mission_ID)
        {
            MissionQuestions myQuestion = db.MissionQuestion.Find(question_ID);

            myQuestion.answer = answer["answer" + question_ID];
            string fullname = TempData["firstname"].ToString() + " " + TempData["lastname"].ToString();

            myQuestion.user_ID = fullname;
            db.SaveChanges();

            return(RedirectToAction("MissionPage", new { mission_ID = myQuestion.mission_ID }));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "missionQuestionID,MissionID,UserID,question,answer")] MissionQuestions missionQuestions)
        {
            if (ModelState.IsValid)
            {
                db.MissionQuestions.Add(missionQuestions);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MissionID = new SelectList(db.Missions, "MissionID", "missionName", missionQuestions.MissionID);
            return(View(missionQuestions));
        }
        public ActionResult Create([Bind(Include = "CrewID,Astronaut,Mission,Position")] Crew crew)
        {
            if (ModelState.IsValid)
            {
                db.Crews.Add(crew);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Astronaut = new SelectList(db.Astronauts, "AstronautID", "Name", crew.Astronaut);
            ViewBag.Mission   = new SelectList(db.Missions, "MissionID", "Designation", crew.Mission);
            return(View(crew));
        }
Ejemplo n.º 11
0
 public ActionResult Create([Bind(Include = "question")] MissionQuestions newQuestion)
 {
     newQuestion.userID    = usID;
     newQuestion.missionID = missID;
     newQuestion.answer    = "";
     if (ModelState.IsValid)
     {
         db.MissionQuestions.Add(newQuestion);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newQuestion));
 }
Ejemplo n.º 12
0
      public ActionResult Create([Bind(Include = "MissionQuestionID,MissionID,UserID,Question,Answer")] MissionQuestions missionQuestions, int?id)
      {
          if (ModelState.IsValid)
          {
              missionQuestions.MissionID = id;
              db.MissionQuestion.Add(missionQuestions);
              db.SaveChanges();
              return(RedirectToAction("FAQ", "Missions", id));
          }

          ViewBag.MissionID = new SelectList(db.Mission, "MissionID", "MissionName", missionQuestions.MissionID);
          ViewBag.UserID    = new SelectList(db.User, "UserID", "UserEmail", missionQuestions.UserID);
          return(View(missionQuestions));
      }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "USER_ID,USER_EMAIL,PASSWORD,FIRST_NAME,LAST_NAME")] Users users, int missionID)
        {
            if (ModelState.IsValid)
            {
                db.users.Add(users);
                db.SaveChanges();

                FormsAuthentication.SetAuthCookie(users.USER_EMAIL, false);

                return(RedirectToAction("Index", "MissionQuestions", new { missionID = missionID, id = users.USER_ID }));
            }

            return(View(users));
        }
Ejemplo n.º 14
0
        public ActionResult CreateAccount([Bind(Include = "userID,userEmail,password,firstName,lastName")] Users user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();

                var currentUser =
                    db.Database.SqlQuery <Users>(
                        "Select * " +
                        "FROM Users " +
                        "WHERE userEmail = '" + user.userEmail + "' AND " +
                        "password = '******'");

                if (currentUser.Count() > 0)
                {
                    FormsAuthentication.SetAuthCookie(user.userEmail, false);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(View());
                }
            }

            return(View(user));
        }
        public ActionResult NewQuestion(FormCollection form, int id)
        {
            if (form["question"] != null && form["question"] != String.Empty)
            {
                //new question object
                MissionQuestions question = new MissionQuestions();
                question.MissionID = id;
                question.Question  = form["question"];
                question.UserID    = User.Identity.Name;

                //add question to database
                db.MissionQuestions.Add(question);
                db.SaveChanges();
            }

            //knows what mission to display
            return(RedirectToAction("Faqs", routeValues: new { id = id }));
        }
Ejemplo n.º 16
0
        public ActionResult CreateQuestion([Bind(Include = "Mission_Question_ID, Mission_ID, User_ID, Question, Answer")] Mission_Questions mqID)
        {
            mqID.Mission_ID = missionID;
            mqID.User_ID    = userID;
            mqID.Answer     = "";


            if (ModelState.IsValid)
            {
                //add entry
                db.Mission_Questions.Add(mqID);
                //edit entries
                //db.Entry(wo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mqID));
        }
Ejemplo n.º 17
0
        public ActionResult SignUp([Bind(Include = "UserID,UserEmail,Password,FirstName,LastName")] Users users, bool rememberMe = false)
        {
            if (ModelState.IsValid)
            {
                db.User.Add(users);
                db.SaveChanges();
                FormsAuthentication.SetAuthCookie(users.UserEmail, rememberMe);
                return(RedirectToAction("Index", "Home", new { userlogin = users.UserEmail }));
            }

            return(View(users));
        }
Ejemplo n.º 18
0
        public ActionResult Create([Bind(Include = "missionQuestionID,missionQuestion,userID,missionID")] MissionQuestions missionQuestions)
        {
            if (ModelState.IsValid)
            {
                db.MissionQuestions.Add(missionQuestions);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home", null));
            }

            ViewBag.userID    = User.Identity.GetUserName();
            ViewBag.missionID = new SelectList(db.Missions, "missionID", "missionName", missionQuestions.missionID);
            return(View(missionQuestions));
        }
Ejemplo n.º 19
0
        public ActionResult CreateUser([Bind(Include = "User_ID, User_Email, User_Password, First_Name, Last_Name")] Users user)
        {
            if (ModelState.IsValid)
            {
                //add entry
                db.Users.Add(user);
                //edit entries
                //db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Ejemplo n.º 20
0
        public ActionResult Create([Bind(Include = "missionID,missionName,presidentName,missionAddress,missionLanguage,missionClimate,missionDominateReligion")] Mission mission)
        {
            if (ModelState.IsValid)
            {
                db.Mission.Add(mission);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mission));
        }
 public ActionResult SignUp(Users newUser)
 {
     db.Users.Add(newUser);
     db.SaveChanges();
     return(RedirectToAction("Index", "Missions"));
 }