public bool AddPost(PostDTO model) { Post post = new Post(); post.Title = model.Title; post.ShortContent = model.ShortContent; post.PostContent = model.PostContent; post.Slider = model.Slider; post.Area1 = model.Area1; post.Area2 = model.Area2; post.Area3 = model.Area3; post.Notification = model.Notification; post.CategoryID = model.CategoryID; post.SeoLink = SeoLink.GenerateUrl(model.Title); post.LanguageName = model.Language; post.AddDate = DateTime.Now; post.AddUserID = UserStatic.UserID; post.LastUpdateDate = DateTime.Now; post.LastUpdateUserID = UserStatic.UserID; int ID = dao.AddPost(post); LogDAO.AddLog(General.ProcessType.PostAdd, General.TableName.Post, ID); SavePostImages(model.PostImages, ID); AddTags(model.TagText, ID); return(true); }
protected void btnPost_Click(object sender, EventArgs e) { try { var newPost = new BLL.Post(); newPost.Content = activity.Text; newPost.DateTime = DateTime.Now; newPost.UserId = currentUser.Id; newPost.CircleId = DropDownList1.SelectedValue; newPost.Image = GeneralHelpers.UploadFile(FileUpload1); PostDAO.AddPost(newPost); rptUserPosts.DataSource = PostDAO.GetPostsByCircle("gym"); rptUserPosts.DataBind(); UserCircleDAO.ChangeUserCirclePoints( userId: currentUser.Id, circleName: newPost.CircleId, points: 30, source: "creating a new post", addNotification: true ); } catch (DbEntityValidationException ex) { var err = ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage; } }
private void buttonAdd_Click(object sender, EventArgs e) { if (!CheckData()) { return; } DataRow[] matches = tablePost.Select("Name='" + name + "'"); if (matches.Length > 0) // 岗位名称已经存在 { MessageBox.Show("岗位名称已经存在", "信息提示", MessageBoxButtons.OK); return; } string stat = "Level='" + level + "'"; matches = tablePost.Select(stat); if (matches.Length > 0) // 岗位层级编码已经存在 { MessageBox.Show("岗位层级已经存在", "信息提示", MessageBoxButtons.OK); return; } PostBean b = new PostBean(); b.Level = level; b.Name = name; b.BaseSalary = salary; PostDAO dao = new PostDAO(); dao.AddPost(b); LoadData(); }
public ActionResult AddPost(PostPO form) { ActionResult response = null; if (ModelState.IsValid) { try { PostDO dataObject = PostMapper.PostPOToDO(form); _dataAccess.AddPost(dataObject); response = RedirectToAction("ViewPostsByThreadId", "Post", new { ThreadId = form.ThreadId }); } catch (Exception ex) { Logger.Log("Fatal", ex.TargetSite.ToString(), ex.Message, ex.StackTrace); } } else { response = View(form); } return(response); }
protected void Comment_Click(object sender, EventArgs e) { try { foreach (RepeaterItem item in rptUserPosts.Items) { TextBox comment = (TextBox)item.FindControl("hello"); var newPost = new BLL.Post(); newPost.Comment = comment.Text; newPost.UserId = currentUser.Id; newPost.CircleId = "gym"; PostDAO.AddPost(newPost); rptUserPosts.DataSource = PostDAO.GetPostsByCircle("gym"); rptUserPosts.DataBind(); } refreshGv(); } catch (DbEntityValidationException ex) { var err = ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage; } }
public static void AddPost(Post newPost) { PostDAO.AddPost(newPost); }