コード例 #1
0
 public ActionResult Edit([Bind(Include = "PostID,Title,Body,Author,Status,User_UserID,SubCategory_SubCategoryID")] Post post, HttpPostedFileBase CoverImage, string currentCoverImage)
 {
     if (ModelState.IsValid)
     {
         string bodyHtml = post.Body;
         post.Body = new PostDAO().SaveImages(bodyHtml, post.PostID, currentCoverImage);
         if (CoverImage != null)
         {
             PostDAO postDAO = new PostDAO();
             postDAO.DeleteCoverImage(currentCoverImage, post.PostID);
             post.CoverImage = postDAO.SaveCoverImage(CoverImage, post.PostID);
         }
         else
         {
             post.CoverImage = currentCoverImage;
         }
         post.CreatedTime     = post.CreatedTime ?? DateTime.Now;
         post.PublishedTime   = post.CreatedTime ?? DateTime.Now;
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubCategory_SubCategoryID = new SelectList(db.SubCategories, "SubCategoryID", "Name", post.SubCategory_SubCategoryID);
     ViewBag.User_UserID = new SelectList(db.Users, "UserID", "UserName", post.User_UserID);
     return(View(post));
 }
コード例 #2
0
        public ActionResult Post()
        {
            PostDAO        postDAO = new PostDAO();
            List <BaiViet> list    = postDAO.getList();

            return(View("Post", list));
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        public ActionResult NewSide()
        {
            PostDAO        postDAO = new PostDAO();
            List <BaiViet> list    = postDAO.getList(7);

            return(View("NewSide", list));
        }
コード例 #5
0
        public ActionResult Categoria([Bind(Prefix = "id")] string c)
        {
            PostDAO      dao   = new PostDAO();
            IList <Post> lista = dao.FiltraPorCategoria(c);

            return(View("Index", lista));
        }
コード例 #6
0
        public IActionResult Index()
        {
            PostDAO      dao        = new PostDAO();
            IList <Post> publicados = dao.ListaPublicados();

            return(View(publicados));
        }
コード例 #7
0
        public ActionResult PublicaPost(int id)
        {
            PostDAO dao = new PostDAO();

            dao.Publica(id);
            return(RedirectToAction("Index"));
        }
コード例 #8
0
ファイル: PostController.cs プロジェクト: leosouza-dev/FN-23
        public IActionResult Categoria([Bind(Prefix = "id")] string categoria)
        {
            PostDAO dao   = new PostDAO();
            var     posts = dao.FiltraPorCategoria(categoria);

            return(View("Index", posts));
        }
コード例 #9
0
 private void PopularLabelAutorPost()
 {
     lblCriadoPor.Visible = true;
     lblAutorPost.Visible = true;
     lblCriadoEm.Visible  = true;
     lblHoraPost.Visible  = true;
     if (!string.IsNullOrWhiteSpace(ddlListaPosts.Text))
     {
         string  nome    = "";
         string  hora    = "";
         PostDAO postDAO = new PostDAO();
         var     list    = postDAO.ObterTextoPorPost(Convert.ToInt32(ddlListaPosts.SelectedItem.Value));
         list.ForEach(item => nome = item.user_name);
         lblAutorPost.Text         = nome;
         list.ForEach(item => hora = item.hora.ToString());
         lblHoraPost.Text          = hora;
         postDAO.Dispose();
     }
     else
     {
         lblCriadoPor.Visible = false;
         lblAutorPost.Visible = false;
         lblCriadoEm.Visible  = false;
         lblHoraPost.Visible  = false;
     }
 }
コード例 #10
0
        public ActionResult SearchPosts(string creationDate)
        {
            PostDAO dao = new PostDAO();

            //DateTime data = new DateTime(1900, 1, 1);
            DateTime data = DateTime.Parse(creationDate);

            List <PostDO> posts = dao.CarregarPorData(data);

            List <PostViewModel> viewModelList = new List <PostViewModel>();

            foreach (var post in posts)
            {
                PostViewModel vm = new PostViewModel()
                {
                    Id           = post.Id,
                    Message      = post.Message,
                    Description  = post.Description,
                    PermalinkUrl = post.PermalinkUrl,
                    CreatedTime  = post.CreatedTime.ToString(cultInf)
                };

                viewModelList.Add(vm);
            }

            return(View("Posts", viewModelList));
        }
コード例 #11
0
        protected void LinkbtnLixeiraBlog_Click(object sender, EventArgs e)
        {
            BlogDAO blogDAO = new BlogDAO();
            Blog    blog    = new Blog();

            PostDAO postDAO = new PostDAO();
            Post    post    = new Post();

            ComentarioDAO comentarioDAO = new ComentarioDAO();
            Comentario    comentario    = new Comentario();

            var list = postDAO.ObterPostsPorBlog(Convert.ToInt32(ddlListaBlogs.SelectedItem.Value));

            foreach (var item in list)
            {
                DeletarUmPost(item.id);
            }

            blog.id = Convert.ToInt32(ddlListaBlogs.SelectedItem.Value);
            blogDAO.DeletarUm(blog);
            blogDAO.Dispose();
            PopularListBlogs();
            PopularListPost();
            PopularLabelAutorPost();
            PopularLabelTemaPost();
            PopularLabelTextPost();
            lblBlogExcluido.Visible = true;
        }
コード例 #12
0
        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;
            }
        }
コード例 #13
0
        //
        // GET: /Post/

        public ActionResult Index()
        {
            IEnumerable <Post>       listPosts      = PostDAO.GetAllPosts();
            IEnumerable <PostsModel> listModelPosts = PostsModel.GetListPosts(listPosts);

            return(View(listModelPosts));
        }
コード例 #14
0
        public ActionResult Create(Post post, int?Category)
        {
            ViewBag.Category = new SelectList(CategoryDAO.CategoryList(), "CategoryId", "Name");
            post.Category    = CategoryDAO.FindId(Category);
            post.Status      = 0;
            post.Date        = DateTime.Now;
            post.User        = UserDAO.FindId(Sessao.user.UserId);

            if (Category != null)
            {
                if (PostDAO.CreatePost(post))
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Já existe um post com o titulo " + post.Title);
                    return(View(post));
                }
            }
            else
            {
                ModelState.AddModelError("", "Por favor, selecione uma categoria!");
                return(View(post));
            }
        }
コード例 #15
0
        public ActionResult Editar(int id)
        {
            PostDAO dao = new PostDAO();
            Post    p   = dao.ReadById(id);

            return(View(p));
        }
コード例 #16
0
        public ActionResult Edit(int id)
        {
            var post = new PostDAO().ViewDetail(id);

            SetViewBag(post.CategoryID);
            return(View(post));
        }
コード例 #17
0
        public PostController()
        {
            string connection = ConfigurationManager.ConnectionStrings["dataSource"].ConnectionString;

            _dataAccess       = new PostDAO(connection);
            _threadDataAccess = new ThreadDAO(connection);
        }
コード例 #18
0
        public IActionResult Index()
        {
            PostDAO      dao   = new PostDAO();
            IList <Post> lista = dao.Lista();

            return(View(lista));
        }
コード例 #19
0
        public IActionResult Busca(string termo)
        {
            PostDAO      dao   = new PostDAO();
            IList <Post> posts = dao.BuscaPeloTermo(termo);

            return(View("Index", posts));
        }
コード例 #20
0
        public IActionResult Visualiza(int id)
        {
            PostDAO dao  = new PostDAO();
            Post    post = dao.BuscaPorId(id);

            return(View(post));
        }
コード例 #21
0
        public ActionResult edit(int id)
        {
            dao = new PostDAO();
            var model = dao.findById(id);

            return(View(model));
        }
コード例 #22
0
        public ActionResult create(Post entity)
        {
            dao = new PostDAO();
            bool result = dao.create(entity);

            return(View(entity));
        }
コード例 #23
0
        public ActionResult Edit(Post postEdited)
        {
            Post postOrig = PostDAO.FindId(postEdited.PostId);

            postOrig.Body  = postEdited.Body;
            postOrig.Title = postEdited.Title;
            postOrig.Date  = DateTime.Now;

            if (PostDAO.EditPost(postOrig))
            {
                if (postOrig.User.Admin == 1)
                {
                    return(RedirectToAction("AdminPanel", "User"));
                }
                else
                {
                    return(RedirectToAction("UserPanel", "User"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Já existe um post com esse Nome!");
                return(View(postOrig));
            }
        }
コード例 #24
0
        public ActionResult RemovePost(int id)
        {
            PostDAO dao = new PostDAO();

            dao.RemovePost(id);
            return(RedirectToAction("Index"));
        }
コード例 #25
0
 public ActionResult PostPanel()
 {
     ViewBag.Categories = CategoryDAO.CategoryList();
     ViewBag.Users      = UserDAO.UserList();
     ViewBag.Posts      = PostDAO.PostList();
     return(View(PostDAO.PostList()));
 }
コード例 #26
0
        public ActionResult CategoriaAutoComplete(string termoDigitado)
        {
            PostDAO dao   = new PostDAO();
            var     model = dao.ListaCategoriasPorTermo(termoDigitado);

            return(Json(model));
        }
コード例 #27
0
        protected void rptUserPosts_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Repeater repeater = (e.Item.FindControl("rptComment") as Repeater);

            if (e.CommandName == "Comment")
            {
                TextBox comment    = (e.Item.FindControl("hello") as TextBox);
                var     comt       = comment.Text;
                var     newComment = new BLL.Comment();
                newComment.UserId       = currentUser.Id;
                newComment.PostId       = Convert.ToInt32(e.CommandArgument);
                newComment.comment_date = DateTime.Now;
                newComment.comment_text = comment.Text;
                CommentDAO.AddComment(newComment);
                comment.Text = String.Empty;

                repeater.DataSource = CommentDAO.GetCommentByPost(Convert.ToInt32(e.CommandArgument));
                repeater.DataBind();
            }
            if (e.CommandName == "Report")
            {
                RadioButtonList report           = (e.Item.FindControl("RadioButtonList1") as RadioButtonList);
                var             userpostindex    = e.Item.ItemIndex;
                var             rpt              = report.SelectedValue;
                List <UserPost> userposts        = new List <UserPost>();
                UserPost        selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex];
                var             newReport        = new BLL.ReportedPost();
                newReport.postId         = selecteduserpost.Post.Id;
                newReport.reason         = rpt;
                newReport.dateCreated    = DateTime.Now;
                newReport.reporterUserId = currentUser.Id;
                ReportedPostDAO.AddReport(newReport);
            }

            if (e.CommandName == "Delete")
            {
                var      deleteId         = Convert.ToInt32(e.CommandArgument);
                var      userpostindex    = e.Item.ItemIndex;
                UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex];



                if (currentUser.Id == selecteduserpost.User.Id)
                {
                    CommentDAO.DeleteCommentByPostId(selecteduserpost.Post.Id);
                    ReportedPostDAO.DeleteReportedPostByPostId(selecteduserpost.Post.Id);
                    PostDAO.DeletePost(deleteId);
                    refreshGv();

                    UserCircleDAO.ChangeUserCirclePoints(
                        userId: currentUser.Id,
                        circleName: selecteduserpost.Post.CircleId,
                        points: -30,
                        source: "removing a post",
                        addNotification: true
                        );
                }
            }
        }
コード例 #28
0
 public CommonController()
 {
     postCategoryDAO = new PostCategoryDAO(db);
     menuDAO         = new MenuDAO(db);
     postDAO         = new PostDAO(db);
     systemInfoDAO   = new SystemInfoDAO(db);
     adDAO           = new AdDAO(db);
 }
コード例 #29
0
        // GET: Admin/Post
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new PostDAO();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
コード例 #30
0
ファイル: SinglePost.aspx.cs プロジェクト: GUIZHOUET/ET04
 public void initPost()
 {
     //获取帖子ID
     long postID = Convert.ToInt64(Request.QueryString["postID"]);
     //通过ID查询帖子信息
     PostDAO postDAO = new PostDAO();
     post = postDAO.queryPost(postID);
 }
コード例 #31
0
ファイル: PostDAO.cs プロジェクト: mentrixmax/AvatecW
 public static PostDAO getInstance()
 {
     if (dao == null)
     {
         dao = new PostDAO();
     }
     return(dao);
 }
コード例 #32
0
ファイル: PostList.aspx.cs プロジェクト: GUIZHOUET/ET04
 /// <summary>
 /// 初始化所有的帖子
 /// </summary>
 public void initPage()
 {
     PostDAO postDAO = new PostDAO();
     postList = postDAO.queryAll();
 }