本文整理汇总了C#中Voodoo.Basement.DataEntities.AddToQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.AddToQuestion方法的具体用法?C# DataEntities.AddToQuestion怎么用?C# DataEntities.AddToQuestion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voodoo.Basement.DataEntities
的用法示例。
在下文中一共展示了DataEntities.AddToQuestion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btn_Save_Click
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Save_Click(object sender, EventArgs e)
{
DataEntities ent = new DataEntities();
int clsid = ddl_Class.SelectedValue.ToInt32();
int quID = WS.RequestInt("id");
Class cls = ObjectExtents.Class(clsid);
Question qu = (from l in ent.Question where l.ID == quID select l).FirstOrDefault();
qu.ClassID = ddl_Class.SelectedValue.ToInt32();
qu.Title = txt_Title.Text.TrimDbDangerousChar();
try
{
qu.UserID = ddl_Author.SelectedValue.ToInt32();
qu.UserName = ddl_Author.SelectedItem.Text;
}
catch
{
qu.UserID = 0;
qu.UserName = "";
}
qu.ClickCount = txt_ClickCount.Text.ToInt32(0);
if (qu.ID <= 0)
{
qu.AskTime = DateTime.Now;
}
qu.Content = txt_Content.Text.TrimDbDangerousChar();
qu.Title = txt_Title.Text;
qu.ZtID = 0;
if (qu.ID <= 0)
{
ent.AddToQuestion(qu);
}
ent.SaveChanges();
ent.Dispose();
//生成页面
try
{
CreatePage.CreateContentPage(qu, cls);
Question pre = GetPreQuestion(qu, cls);
if (pre != null)
{
CreatePage.CreateContentPage(pre, cls);
}
CreatePage.CreateListPage(cls, 1);
}
catch { }
Js.AlertAndChangUrl("保存成功!", url);
}
示例2: btn_Submit_Click
protected void btn_Submit_Click(object sender, EventArgs e)
{
DataEntities ent = new DataEntities();
if (UserAction.HasPostRight(ddl_Class.SelectedValue.ToInt32()) == false)
{
Js.AlertAndGoback("对不起,对于本栏目您没有提问的权限!如有疑问,请联系管理员");
ent.Dispose();
return;
}
User u=UserAction.opuser;
int rclass = WS.RequestInt("ddl_Class", WS.RequestInt("class"));
string content = WS.RequestString("txt_Content").TrimDbDangerousChar().Trim().HtmlDeCode();
string title = WS.RequestString("txt_Title").TrimDbDangerousChar().Trim();
if (rclass < 0)
{
Js.AlertAndGoback("栏目不能为空");
return;
}
if (content.IsNullOrEmpty())
{
Js.AlertAndGoback("提问内容不能为空");
return;
}
if (title.IsNullOrEmpty())
{
Js.AlertAndGoback("标题不能为空");
return;
}
Question qs = new Question();
qs.AskTime = DateTime.Now;
qs.ClassID = rclass;
qs.ClickCount = 0;
qs.Content = content;
qs.Title = title;
qs.UserID = u.ID;
qs.UserName = u.UserName;
qs.ZtID = 0;
ent.AddToQuestion(qs);
ent.SaveChanges();
CreatePage.CreateContentPage(qs, qs.GetClass());
CreatePage.CreateListPage(qs.GetClass(), 1);
string url = BasePage.GetQuestionUrl(qs, qs.GetClass());
ent.Dispose();
Js.AlertAndChangUrl("提问发布成功!", url);
}