|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace mvcForumapp.Controllers
{
public class QuestionController : Controller
{
[HttpGet]
public ActionResult PostQuestion()
{
int techID = Convert.ToInt16(Request.QueryString["TechID"].ToString());
return View();
}
[HttpPost]
public ActionResult PostQuestion(mvcForumapp.Models.Questions user)
{
int techID = 0;
if (ModelState.IsValid)
{
techID = Convert.ToInt16(Request.QueryString["TechID"].ToString());
using (var db = new newForumDBEntities())
{
var userdets = db.tblQuestions.CreateObject();
userdets.TechID = Convert.ToInt16(Request.QueryString["TechID"].ToString());
userdets.QuestionTitle = user.TopicTitle;
userdets.QuestionDesc = user.TopicContent;
userdets.DatePosted = DateTime.Now;
userdets.UserName = Session["UserName"].ToString();
userdets.viewCount = 0;
userdets.ReplyCount = 0;
db.tblQuestions.AddObject(userdets);
db.SaveChanges();
return RedirectToAction("DisplayQuestions", "Technology", new { TechID = techID });
}
}
return View(user);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am working as a Software engineer. Web development in Asp.Net with C#, WinForms and MS sql server are the experience tools that I have had for the past 3 years. Yet to work on WCF, WPF, Silverlight and other latest ones.