37 lines
970 B
C#
Executable File
37 lines
970 B
C#
Executable File
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");
|
|
}
|
|
} |