Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblSurvey tblSurvey = db.tblSurveys.Find(id);

            tblSurvey.SurveyActive = false;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public void SaveSurvey(tblSurvey Survey)
 {
     if (Survey.SurveyId == 0)
     {
         db.tblSurveys.Add(Survey);
     }
     else
     {
         db.Entry(Survey).State = EntityState.Modified;
     }
     db.SaveChanges();
 }
Esempio n. 3
0
        public void SaveSurvey(string agebox, string retireAgeBox, string savedBox, string savePerMonth, string riskBox, string yearsBox, string amountBox)
        {
            using (System.Data.IDbConnection connection = new SqlConnection(HelperforSQLDB.ConVal("PersonalFinance")))
            {
                tblSurvey newsurvey = new tblSurvey {
                    Age = agebox, RetirementAge = retireAgeBox, CurrentSavings = savedBox, SavingsPerMonth = savePerMonth, Risk = riskBox, YearsUntilRetirement = yearsBox, AmountSaved = amountBox
                };

                string SurveyResponse = @"INSERT INTO dbo.tblSurvey(Age,RetirementAge,CurrentSavings,SavingsPerMonth,Risk,YearsUntilRetirement,AmountSaved) Values('" + agebox + "','" + retireAgeBox + "', '" + savedBox + "', '" + savePerMonth + "','" + riskBox + "','" + yearsBox + "','" + amountBox + "')";

                var addsurvey = connection.Execute(SurveyResponse, "PersonalFinance");
            }
        }
Esempio n. 4
0
        // GET: Surveys/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            tblSurvey tblSurvey = db.tblSurveys.Find(id);

            if (tblSurvey == null)
            {
                return(HttpNotFound());
            }

            return(View(tblSurvey));
        }
Esempio n. 5
0
        // GET: Surveys/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ViewBag.UserTypeID = new SelectList(db.tblUserTypes, "UserTypeID", "UserTypeName");
            tblSurvey tblSurvey = db.tblSurveys.Find(id);

            if (tblSurvey == null)
            {
                return(HttpNotFound());
            }

            return(View(tblSurvey));
        }
Esempio n. 6
0
        public ActionResult Edit([Bind(Include = "SurveyID,SurveyTitle,SurveyDescription," +
                                                 "UserTypeID,SurveyConducts,SurveyReportingDateTime")]
                                 tblSurvey tblSurvey, string surveyDueDate)
        {
            if (ModelState.IsValid)
            {
                tblSurvey.SurveyActive  = true;
                tblSurvey.SurveyDueDate = surveyDueDate;

                db.Entry(tblSurvey).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.UserTypeID = new SelectList(db.tblUserTypes, "UserTypeID", "UserTypeName");
            return(View(tblSurvey));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "SurveyID,SurveyTitle,SurveyDescription,UserTypeID,SurveyConducts,SurveyActive")] tblSurvey tblSurvey, string surveyDueDate)
        {
            if (ModelState.IsValid)
            {
                // Setting all values which do not require user input to their default values
                #region
                tblSurvey.SurveyConducts          = 0;
                tblSurvey.SurveyActive            = true;
                tblSurvey.SurveyReportingDateTime = DateTime.Today.ToShortDateString();

                #endregion

                tblSurvey.SurveyDueDate = surveyDueDate;

                db.tblSurveys.Add(tblSurvey);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblSurvey));
        }