public string createPost(string PostTitle, string PostText)
{
try
{
using (var ctx = new PostContext())
{
//if (!ctx.Database.Exists())
//{
// ((IObjectContextAdapter)ctx).ObjectContext.CreateDatabase();
//}
Post post = new Post()
{
PostTitle = PostTitle,
PostText = PostText,
PostDate = DateTime.Now,
PostDeletedDate = null
};
ctx.Posts.Add(post);
ctx.SaveChanges();
}
return "ok";
}
catch (Exception)
{
return "fail";
}
}