public bool CreateTheme(string subforum, CreationTheme theme) { using (var cmd = _conn.CreateCommand()) { cmd.CommandText = @"INSERT INTO Themes(Title, Kind, Author, Content, CreatedOn, Subforum) VALUES (@title, @kind, @author, @content, @createdon, @subforum);"; cmd.Parameters.AddWithValue("@title", theme.Title); cmd.Parameters.AddWithValue("@kind", (int)theme.Kind); cmd.Parameters.AddWithValue("@author", theme.AuthorName); cmd.Parameters.AddWithValue("@content", theme.Content); cmd.Parameters.AddWithValue("@createdOn", theme.CreatedOn.ToString("yyyy-MM-dd")); cmd.Parameters.AddWithValue("@subforum", subforum); return(Execute(cmd)); } }
public ActionResult CreateTheme(string subforum) { if (LoggedUserName == null) { return(View("NotLoggedIn")); } var subforumNames = Dao.GetSubforumNames(); if (!subforumNames.Contains(subforum)) { return(HttpNotFound()); } ViewBag.Subforum = subforum; if (Request.HttpMethod == "GET") { return(View()); } var theme = new CreationTheme() { Title = Request.Params["title"], AuthorName = LoggedUserName, Content = Request.Params["content"], CreatedOn = DateTime.Now, Kind = (Kind)int.Parse(Request.Params["kind"]), }; if (Dao.CreateTheme(subforum, theme)) { ViewBag.Title = "Creation Successful"; ViewBag.Theme = theme.Title; } else { ViewBag.Title = "Creation Failed"; } return(View("CreateThemeResult")); }