public ActionResult DeleteConfirmed(int id) { tblSurvey tblSurvey = db.tblSurveys.Find(id); tblSurvey.SurveyActive = false; db.SaveChanges(); return(RedirectToAction("Index")); }
public void SaveSurvey(tblSurvey Survey) { if (Survey.SurveyId == 0) { db.tblSurveys.Add(Survey); } else { db.Entry(Survey).State = EntityState.Modified; } db.SaveChanges(); }
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"); } }
// 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)); }
// 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)); }
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)); }
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)); }