/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(int id) { var item = new UserMessagePO { Id = id }; return(Delete(item)); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool Delete(UserMessagePO item) { using (var context = new SchoolContext()) { context.UserMessages.Attach(item); context.UserMessages.Remove(item); context.SaveChanges(); } return(true); }
public static UserMessageModel ToModel(this UserMessagePO item) { if (item == null) { return(null); } return(new UserMessageModel { Id = item.Id, UserId = item.UserId, Message = item.Message, Status = item.Status, Createtime = item.Createtime, Updatetime = item.Updatetime, }); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool Save(UserMessagePO item) { using (var context = new SchoolContext()) { if (item.Id == 0) { context.UserMessages.Add(item); } else { context.Entry(item).State = EntityState.Modified; } context.SaveChanges(); } return(true); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static UserMessagePO GetDataForSave(int id) { UserMessagePO item; if (id == 0) { item = new UserMessagePO() { UserId = 0, Message = "", Status = 0, Createtime = DateTime.Now, Updatetime = DateTime.Now, }; } else { item = GetItem(id); } return(item); }