Initial commit
This commit is contained in:
37
Proyecto/crear_post.aspx.cs
Executable file
37
Proyecto/crear_post.aspx.cs
Executable file
@@ -0,0 +1,37 @@
|
||||
using DAL;
|
||||
using HeyRed.MarkdownSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class crear_post : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Session["user_id"] == null)
|
||||
{
|
||||
Response.Redirect("/index.aspx");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnCrear(object sender, EventArgs e)
|
||||
{
|
||||
Markdown markdown = new Markdown();
|
||||
Entities entities = new Entities();
|
||||
|
||||
Post post = new Post();
|
||||
post.user_id = Convert.ToInt32(Session["user_id"]);
|
||||
post.title = title_box.Text.Trim();
|
||||
post.markdown = markdown_box.Text;
|
||||
post.html = markdown.Transform(post.markdown);
|
||||
|
||||
entities.Posts.Add(post);
|
||||
entities.SaveChanges();
|
||||
|
||||
Response.Redirect("/index.aspx");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user