public void AddFactionNotice(FactionNotice fan) { using (LdxyDBEntities dbcontext = new LdxyDBEntities()) { dbcontext.FactionNotices.AddObject(fan); dbcontext.SaveChanges(); } }
public ActionResult CreatNotice(FactionNotice notice) { try { notice.Author = UserInfo.Instence.CurrentUser.Name; notice.Creator = UserInfo.Instence.CurrentUser.UserID; notice.FactionID = UserInfo.Instence.CurrentFaction.FactionID; notice.State = (int)StateEnum.正常; notice.CreatTime = DateTime.Now; notice.Content = Server.UrlDecode(notice.Content); FactionBLL.AddFactionNotice(notice); return Json(new { isok=true}, JsonRequestBehavior.AllowGet); } catch (Exception ex) { //TODO:异常处理 return Json(new { isok = false }, JsonRequestBehavior.AllowGet); } }
/// <summary> /// 用于向 FactionNotices EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToFactionNotices(FactionNotice factionNotice) { base.AddObject("FactionNotices", factionNotice); }
/// <summary> /// 创建新的 FactionNotice 对象。 /// </summary> /// <param name="noticeID">NoticeID 属性的初始值。</param> /// <param name="title">Title 属性的初始值。</param> /// <param name="content">Content 属性的初始值。</param> /// <param name="creator">Creator 属性的初始值。</param> /// <param name="author">Author 属性的初始值。</param> /// <param name="creatTime">CreatTime 属性的初始值。</param> /// <param name="state">State 属性的初始值。</param> /// <param name="factionID">FactionID 属性的初始值。</param> public static FactionNotice CreateFactionNotice(global::System.Int32 noticeID, global::System.String title, global::System.String content, global::System.Int32 creator, global::System.String author, global::System.DateTime creatTime, global::System.Int32 state, global::System.Int32 factionID) { FactionNotice factionNotice = new FactionNotice(); factionNotice.NoticeID = noticeID; factionNotice.Title = title; factionNotice.Content = content; factionNotice.Creator = creator; factionNotice.Author = author; factionNotice.CreatTime = creatTime; factionNotice.State = state; factionNotice.FactionID = factionID; return factionNotice; }