本文整理汇总了C#中Voodoo.Basement.DataEntities.AddToNews方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.AddToNews方法的具体用法?C# DataEntities.AddToNews怎么用?C# DataEntities.AddToNews使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voodoo.Basement.DataEntities
的用法示例。
在下文中一共展示了DataEntities.AddToNews方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserPost
/// <summary>
/// 用户投稿
/// </summary>
/// <param name="news"></param>
/// <param name="user"></param>
/// <returns></returns>
public static Result UserPost(News news, User user)
{
using (DataEntities ent = new DataEntities())
{
Result r = new Result();
UserGroup g = (from l in ent.UserGroup where l.ID == user.Group select l).FirstOrDefault();
int? maxPost = 0;
try
{
maxPost = g.MaxPost;
}
catch { }
//验证用户是否允许投稿
if (maxPost <= 0)
{
r.Success = false;
r.Text = "对不起,您没有投稿的权限!";
return r;
}
//验证本日投稿数是否已经过多
//int todayPost = NewsView.Count(string.Format("AutorID={0}", user.ID));
int todayPost = (from l in ent.News where l.AutorID == user.ID && l.NewsTime > DateTime.Now.Date && l.NewsTime < DateTime.Now.AddDays(1).Date select l).Count();
if (todayPost > maxPost && news.ID <= 0)
{
r.Success = false;
r.Text = "对不起,您本日投稿数量已经达到最大限制,请明天继续!";
return r;
}
//验证标题是否为空
if (news.Title.IsNullOrEmpty())
{
r.Success = false;
r.Text = "文章标题不能为空";
return r;
}
//验证栏目
if (news.ClassID <= 0)
{
r.Success = false;
r.Text = "栏目不能为空!";
return r;
}
news.Audit = g.PostAotuAudit;
news.AutorID = user.ID;
if (news.Author.IsNullOrEmpty())
{
news.Author = user.UserName;
}
if (news.ID <= 0)
{
ent.AddToNews(news);
}
user.Cent += (from l in ent.Class where l.ID == news.ClassID select l).FirstOrDefault().PostAddCent;
ent.SaveChanges();
r.Success = true;
r.Text = "投递成功!";
return r;
}
}
示例2: 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();
cls = WS.RequestInt("class", 0);
zt = WS.RequestInt("zt", 0);
url = string.Format("NewsList.aspx?class={0}&zt={1}", cls, zt);
News n = new News();
if (WS.RequestInt("id") > 0)
{
n = //NewsView.GetModelByID(WS.RequestString("id"));
(from l in ent.News where l.ID == id select l).FirstOrDefault();
cls = n.ClassID.ToInt32();
}
else
{
n.ClassID = cls;
n.ZtID = zt;
}
Class c = NewsAction.NewsClass.Where(p => p.ID.ToString() == ddl_Class.SelectedValue).First();
n.ClassID = ddl_Class.SelectedValue.ToInt32();
n.Title = txt_Title.Text.TrimDbDangerousChar();
n.TitleColor = cp_TitleColor.Value.TrimDbDangerousChar();
n.TitleB = chk_TitleB.Checked;
n.TitleI = chk_TitleI.Checked;
n.TitleS = chk_TitleS.Checked;
n.FTitle = txt_FTitle.Text.TrimDbDangerousChar();
n.Audit = chk_Audit.Checked;
n.Tuijian = chk_Tuijian.Checked;
n.Toutiao = chk_Toutiao.Checked;
n.KeyWords = txt_Key.Text.TrimDbDangerousChar();
//关键词写入系统
txt_Key.Text = Regex.Replace(txt_Key.Text, "\\s", ",");
string[] keys = Regex.Replace(txt_Key.Text, "\\s", ",").Split(',');
foreach (string k in keys)
{
InsertKeyWords(1, k);
}
n.NavUrl = txt_NavUrl.Text.TrimDbDangerousChar();
n.NewsTime=txt_NewsTime.Text.ToDateTime();
n.TitleImage = txt_TitleImage.Text.TrimDbDangerousChar();
n.Description = txt_Description.Text.TrimDbDangerousChar();
n.Author = txt_Author.Text.TrimDbDangerousChar();
n.Source = txt_Source.Text.TrimDbDangerousChar();
n.Content = FCKeditor1.Text.TrimDbDangerousChar();
//n.ContentEn = FCKeditor2.Text.TrimDbDangerousChar();
n.SetTop = chk_SetTop.Checked;
n.EnableReply = !chk_CloseReply.Checked;
n.ModelID = ddl_contentTemp.SelectedValue.ToInt32();
n.ClickCount = txt_ClickCount.Text.ToInt32();
n.DownCount = txt_DownCount.Text.ToInt32();
n.FileForder = txt_FileForder.Text;
n.FileName = txt_FileName.Text;
n.ReplyCount = 0;
if (id <= 0)
{
ent.AddToNews(n);
}
ent.SaveChanges();
ent.Dispose();
if (SystemSetting.EnableStatic)
{
CreatePage.CreateContentPage(n, c);
News news_pre = GetPreNews(n, c);
if (news_pre != null)
{
CreatePage.CreateContentPage(news_pre, c);
}
switch (c.EditcreateList)
{
case 0:
break;
case 1:
CreatePage.CreateListPage(c, 1);
break;
case 2:
CreatePage.GreateIndexPage();
break;
case 3:
case 4:
//.........这里部分代码省略.........