public ActionResult UpdateEntry(string hdnBP_UID, string txtTitle, string taBody) { try { // TODO: Add insert logic here T_BlogPost bp = new T_BlogPost(); //bp.BP_UID = (Guid) System.Convert.ChangeType(Request.Params["hdnBP_UID"], typeof(Guid)); bp.BP_UID = new System.Guid(hdnBP_UID); bp.BP_Title = txtTitle; // Request.Params["txtTitle"]; bp.BP_Content = taBody; // Request.Params["taBody"]; using (System.Data.Common.DbConnection con = this.m_fac.Connection) { con.Insert <T_BlogPost>(bp); } // End Using con return(RedirectToAction("Success")); } catch { // return View(); int num1 = 1; int num2 = 2; int result = 3; return(Content($"Result of {num1} + {num2} is {result}", "text/plain")); } } // End Action AddEntry
} // End Action ShowEntry // // GET: /Blog/Delete/5 public ActionResult EditEntry(string id) { T_BlogPost bp = null; using (System.Data.IDbCommand cmd = Settings.DAL.CreateLimitedCommand("SELECT {0} BP_UID FROM T_BlogPost ORDER BY BP_EntryDate DESC;", 1)) { id = Settings.DAL.ExecuteScalar <string>(cmd); } // End Using cmd using (System.Data.IDbCommand cmd = Settings.DAL.CreateCommand("SELECT * FROM T_BlogPost WHERE BP_UID = @__bp_uid")) { Settings.DAL.AddParameter(cmd, "__bp_uid", new System.Guid(id)); bp = Settings.DAL.GetClass <T_BlogPost>(cmd); } // End Using cmd return(View(bp)); } // End Action EditEntry
public ActionResult AddEntry(FormCollection collection) { try { // TODO: Add insert logic here T_BlogPost bp = new T_BlogPost(); bp.BP_Title = Request.Params["txtTitle"]; bp.BP_Content = Request.Params["taBody"]; Settings.DAL.Insert <T_BlogPost>(bp); return(RedirectToAction("Success")); } catch { return(View()); } } // End Action AddEntry
public static async System.Threading.Tasks.Task Test() { SqlFactory fac = new SqlClientFactory(); // DbConnection.ProviderFactory => DbProviderFactory; using (System.Data.Common.DbConnection con = fac.Connection) { string sql = "SELECT * FROM T_BlogPost"; string sql_paged = sql += fac.PagingTemplate(3, 2); string sql_limited = sql += fac.PagingTemplate(1); IEnumerable <T_BlogPost> a = con.Query <T_BlogPost>(sql); IEnumerable <T_BlogPost> aa = await con.QueryAsync <T_BlogPost>(sql_paged); T_BlogPost b = con.QuerySingle <T_BlogPost>(sql_limited); T_BlogPost ba = await con.QuerySingleAsync <T_BlogPost>(sql_limited); } // End Using con } // End Sub Test
} // End Action ShowEntry // // GET: /Blog/Delete/5 public ActionResult EditEntry(System.Guid?id) { T_BlogPost bp = null; // string sql = "SELECT {0} BP_UID string sql = "SELECT BP_UID FROM T_BlogPost ORDER BY BP_EntryDate DESC" + this.m_fac.PagingTemplate(1); using (System.Data.Common.DbConnection con = this.m_fac.Connection) { id = con.QuerySingle <System.Guid>(sql); } sql = "SELECT * FROM T_BlogPost WHERE BP_UID = @__bp_uid"; using (System.Data.Common.DbConnection con = this.m_fac.Connection) { bp = con.QuerySingle <T_BlogPost>(sql, new { __bp_uid = id }); } return(View(bp)); } // End Action EditEntry
public ActionResult UpdateEntry(FormCollection collection) { try { // TODO: Add insert logic here T_BlogPost bp = new T_BlogPost(); //bp.BP_UID = (Guid) System.Convert.ChangeType(Request.Params["hdnBP_UID"], typeof(Guid)); bp.BP_UID = new Guid(Request.Params["hdnBP_UID"]); bp.BP_Title = Request.Params["txtTitle"]; bp.BP_Content = Request.Params["taBody"]; Settings.DAL.Insert <T_BlogPost>(bp); return(RedirectToAction("Success")); } catch { return(View()); } } // End Action AddEntry
public ActionResult AddEntry(string txtTitle, string taBody) { try { // TODO: Add insert logic here T_BlogPost bp = new T_BlogPost(); bp.BP_Title = txtTitle; // Request.Params["txtTitle"]; bp.BP_Content = taBody; // Request.Params["taBody"]; using (System.Data.Common.DbConnection con = this.m_fac.Connection) { con.Insert <T_BlogPost>(bp); } // End Using con return(RedirectToAction("Success")); } catch (System.Exception ex) { // return View(); return(Json(new { success = false, responseText = ex.Message, stackTrace = ex.StackTrace })); } } // End Action AddEntry
} // End Function GetMachineId // // GET: /Blog/Delete/5 public ActionResult ShowEntry(string id) { T_BlogPost bp = null; string lol = "http://localhost/image.aspx?&postimage_text=%0A%5Burl%3Dhttp%3A%2F%2Fpostimg.org%2Fimage%2Fu0zc6aznf%2F%5D%5Bimg%5Dhttp%3A%2F%2Fs1.postimg.org%2Fu0zc6aznf%2Fhtc_hero_wallpaper_03.jpg%5B%2Fimg%5D%5B%2Furl%5D%0A"; //"http://localhost/image.aspx?&postimage_text=[url=http://postimg.org/image/u0zc6aznf/][img]http://s1.postimg.org/u0zc6aznf/htc_hero_wallpaper_03.jpg[/img][/url] lol = System.Web.HttpUtility.UrlDecode(lol); Console.WriteLine(lol); using (System.Data.IDbCommand cmd = Settings.DAL.CreateLimitedCommand("SELECT {0} BP_UID FROM T_BlogPost ORDER BY BP_EntryDate DESC;", 1)) { id = Settings.DAL.ExecuteScalar <string>(cmd); } // End Using cmd using (System.Data.IDbCommand cmd = Settings.DAL.CreateCommand("SELECT * FROM T_BlogPost WHERE BP_UID = @__bp_uid")) { Settings.DAL.AddParameter(cmd, "__bp_uid", new System.Guid(id)); bp = Settings.DAL.GetClass <T_BlogPost>(cmd); } // End Using cmd bp.BP_Content = ReplaceURLs(bp.BP_Content); // http://stackoverflow.com/questions/16389234/create-dropdown-with-predefined-values-in-asp-net-mvc-3-using-razor-view/16389278#16389278 ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new { value = x, text = x }), "value", "text", "15"); List <SelectListItem> ls = new List <SelectListItem>(); ls.Add(new SelectListItem() { Text = "Yes", Value = "true", Selected = true }); ls.Add(new SelectListItem() { Text = "No", Value = "false", Selected = false }); ls.Add(new SelectListItem() { Text = "Not Applicable", Value = "NULL", Selected = false }); ViewData["myList"] = ls; ViewData["myList"] = new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Selected = x == "25", Text = x, Value = x }); ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Value = x, Text = x }), "Value", "Text", "15"); ViewData["myList"] = from c in new[] { "10", "15", "25", "50", "100", "1000" } select new SelectListItem { Selected = (c == "25"), Text = c, Value = c }; return(View(bp)); } // End Action ShowEntry
// // GET: /Blog/Delete/5 public ActionResult ShowEntry_old(System.Guid?id) { string host = (string)this.RouteData.Values["Host"]; System.Console.WriteLine(host); T_BlogPost bp = null; // string lol = "http://localhost/image.aspx?&postimage_text=%0A%5Burl%3Dhttp%3A%2F%2Fpostimg.org%2Fimage%2Fu0zc6aznf%2F%5D%5Bimg%5Dhttp%3A%2F%2Fs1.postimg.org%2Fu0zc6aznf%2Fhtc_hero_wallpaper_03.jpg%5B%2Fimg%5D%5B%2Furl%5D%0A"; // //"http://localhost/image.aspx?&postimage_text=[url=http://postimg.org/image/u0zc6aznf/][img]http://s1.postimg.org/u0zc6aznf/htc_hero_wallpaper_03.jpg[/img][/url] // lol = System.Web.HttpUtility.UrlDecode(lol); // System.Console.WriteLine(lol); if (!id.HasValue) { string fetchLatestId = "SELECT BP_UID FROM T_BlogPost ORDER BY BP_EntryDate DESC" + this.m_fac.PagingTemplate(1); using (System.Data.Common.DbConnection con = this.m_fac.Connection) { id = con.QuerySingle <System.Guid>(fetchLatestId); } } string sql = "SELECT * FROM T_BlogPost WHERE BP_UID = @__bp_uid"; using (System.Data.Common.DbConnection con = this.m_fac.Connection) { bp = con.QuerySingle <T_BlogPost>(sql, new { __bp_uid = id }); } bp.BP_Content = ReplaceURLs(bp.BP_Content); // http://stackoverflow.com/questions/16389234/create-dropdown-with-predefined-values-in-asp-net-mvc-3-using-razor-view/16389278#16389278 ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new { value = x, text = x }), "value", "text", "15"); System.Collections.Generic.List <SelectListItem> ls = new System.Collections.Generic.List <SelectListItem>(); ls.Add(new SelectListItem() { Text = "Yes", Value = "true", Selected = true }); ls.Add(new SelectListItem() { Text = "No", Value = "false", Selected = false }); ls.Add(new SelectListItem() { Text = "Not Applicable", Value = "NULL", Selected = false }); ViewData["myList"] = ls; ViewData["myList"] = new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Selected = x == "25", Text = x, Value = x }); ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Value = x, Text = x }), "Value", "Text", "15"); ViewData["myList"] = from c in new[] { "10", "15", "25", "50", "100", "1000" } select new SelectListItem { Selected = (c == "25"), Text = c, Value = c }; return(View(bp)); } // End Action ShowEntry
} // End Function GetMachineId public ActionResult ShowEntry(System.Guid?id, string domain) { // var routeHandler = this.HttpContext.RequestServices.GetService(typeof(MvcRouteHandler)); // System.Console.WriteLine(routeHandler); T_BlogPost bp = new T_BlogPost(); bp.BP_UID = System.Guid.NewGuid(); bp.BP_Title = "hello"; bp.BP_Content = "<html><body><h1>" + domain + "</h1></body></html>"; // bp.BP_PostType = null; ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new { value = x, text = x }), "value", "text", "15"); System.Collections.Generic.List <SelectListItem> ls = new System.Collections.Generic.List <SelectListItem>(); ls.Add(new SelectListItem() { Text = "Yes", Value = "true", Selected = true }); ls.Add(new SelectListItem() { Text = "No", Value = "false", Selected = false }); ls.Add(new SelectListItem() { Text = "Not Applicable", Value = "NULL", Selected = false }); ViewData["myList"] = ls; ViewData["myList"] = new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Selected = x == "25", Text = x, Value = x }); ViewData["myList"] = new SelectList(new[] { "10", "15", "25", "50", "100", "1000" } .Select(x => new SelectListItem { Value = x, Text = x }), "Value", "Text", "15"); ViewData["myList"] = from c in new[] { "10", "15", "25", "50", "100", "1000" } select new SelectListItem { Selected = (c == "25"), Text = c, Value = c }; // If you do return View("~/Views/Wherever/SomeDir/MyView.aspx") You can return any View you'd like. return(View(bp)); }