public static Post post(T_Post item) { if (item == null) { return(null); } var data = new Post() { id = item.id, title = item.title, detail = item.detail, typeId = item.typeId, isActive = item.isActive, author = item.author, authorId = item.authorId, targetDate = item.targetDate, createDate = item.createDate, updateDate = item.updateDate, updateBy = item.updateBy, }; if (item.M_PostType != null) { data.postType = Masters.postType(item.M_PostType); } return(data); }
//[ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "PostID,Title,Desciption,TimeSlotStart,TimeSlotEnd,PhotoID,UserID,PetID,IsDeleted,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy")] T_Post t_Post) { if (ModelState.IsValid) { db.Entry(t_Post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PetID = new SelectList(db.T_Pet, "PetID", "Name", t_Post.PetID); ViewBag.PhotoID = new SelectList(db.T_Photo, "PhotoID", "Name", t_Post.PhotoID); ViewBag.UserID = new SelectList(db.T_User, "UserID", "Username", t_Post.UserID); return(View(t_Post)); }
// GET: Post/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } T_Post t_Post = db.T_Post.Find(id); if (t_Post == null) { return(HttpNotFound()); } return(View(t_Post)); }
// GET: Post/Create public ActionResult Create() { //ViewBag.PetID = new SelectList(db.T_Pet, "PetID", "Name"); //ViewBag.PhotoID = new SelectList(db.T_Photo, "PhotoID", "Name"); //ViewBag.UserID = new SelectList(db.T_User, "UserID", "Username"); T_Post newPost = new T_Post { IsDeleted = false, CreatedOn = DateTime.Now, CreatedBy = "Test1", ModifiedOn = DateTime.Now, ModifiedBy = "Test1" }; return(View(newPost)); }
public Post addPost(Post item) { T_Post data = new T_Post(); data.title = item.title; data.detail = item.detail; data.typeId = item.typeId; data.isActive = item.isActive; data.author = item.author; data.authorId = item.authorId; data.targetDate = item.targetDate; data.createDate = DateTime.Now; data.updateDate = DateTime.Now; data.updateBy = item.updateBy; return(ConvertToScreenModel.Transactions.post(dao.adddPost(data))); }
// GET: Post/Delete/5 public ActionResult Delete(Guid?id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //T_Post t_Post = db.T_Post.Find(id); //if (t_Post == null) //{ // return HttpNotFound(); //} //return View(t_Post); T_Post t_Post = db.T_Post.Find(id); db.T_Post.Remove(t_Post); db.SaveChanges(); return(RedirectToAction("Index")); }
public Post updatePost(Post item) { T_Post data = new T_Post() { id = item.id, title = item.title, detail = item.detail, typeId = item.typeId, isActive = item.isActive, author = item.author, authorId = item.authorId, targetDate = item.targetDate, createDate = item.createDate, updateDate = DateTime.Now, updateBy = item.updateBy }; return(ConvertToScreenModel.Transactions.post(dao.updatePost(data))); }
// GET: Post/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } T_Post t_Post = db.T_Post.Find(id); if (t_Post == null) { return(HttpNotFound()); } else { t_Post.ModifiedOn = DateTime.Now; t_Post.ModifiedBy = "SomeoneElse"; } return(View(t_Post)); }
public ActionResult AddNews(NewsNoticeModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { var sessionModel = GetSessionModel(); IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL"); T_Post newPost = new T_Post() { Title = model.Title, Content = model.Content, PropertyPlaceId = sessionModel.PropertyPlaceId.Value, SubmitUserId = sessionModel.UserID, SubmitTime = DateTime.Now.ToLocalTime(), PublishedFlag = model.PublishedFlag ? 1 : 0, PublishedTime = DateTime.Now.ToLocalTime() }; // 保存到数据库 postBll.Save(newPost); // 若选中“发布选项”则即时推送 if (model.PublishedFlag) { // 公告推送 //推送给业主客户端 IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL"); var userIds = placeBll.GetEntity(p => p.Id == newPost.PropertyPlaceId).UserPlaces.Select(m => m.UserId); if (userIds != null) { userIds = userIds.ToList(); } IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var registrationIds = userPushBLL.GetList(p => userIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray(); bool flag = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_OWNER, registrationIds); //推送给物业客户端 IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); var PropertyUserIds = userBll.GetList(u => u.PropertyPlaceId == newPost.PropertyPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).Select(u => u.Id); if (PropertyUserIds != null) { PropertyUserIds = PropertyUserIds.ToList(); } IPropertyUserPushBLL propertyUserPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL"); var propertyRegistrationIds = propertyUserPushBLL.GetList(p => PropertyUserIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray(); bool flag1 = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_PROPERTY, propertyRegistrationIds); if (!flag || !flag1) { jm.Msg = "推送发生异常"; } } //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }