public ActionResult Add(string content, string url) { if (string.IsNullOrWhiteSpace(content)) { ViewBag.ErrorMessage = "信息内容不能为空"; return this.View("ShowError"); } try { var message = new message { UserId = int.Parse(Session["UID"].ToString()), CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Message1 = content, PicUrl = url, PId = 0 }; new MessageService().Add(message); } catch (Exception exception) { ViewBag.ErrorMessage = exception.InnerException; return this.View("ShowError"); } return RedirectToAction("Index"); }
public void Update(message message) { accessor.UpdateEntity(message); }
public message Add(message message) { return accessor.AddEntity(message); }
/// <summary> /// 创建新的 message 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="userId">UserId 属性的初始值。</param> /// <param name="pId">PId 属性的初始值。</param> /// <param name="message1">Message1 属性的初始值。</param> public static message Createmessage(global::System.Int64 id, global::System.Int64 userId, global::System.Int64 pId, global::System.String message1) { message message = new message(); message.ID = id; message.UserId = userId; message.PId = pId; message.Message1 = message1; return message; }
/// <summary> /// 用于向 message EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddTomessage(message message) { base.AddObject("message", message); }