Exemple #1
0
 public void addNewPost(tblPosts newPost)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         db.tblPosts.Add(newPost);
         db.SaveChanges();
     }
 }
Exemple #2
0
 public void UpdatePost(tblPosts post)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemple #3
0
 public void deletePost(int postID)
 {
     using (var db = new CSCbelgiumDatabaseEntities())
     {
         tblPosts post = getPost(postID);
         db.Entry(post).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Exemple #4
0
        public ActionResult AddPost(tblPosts Post)
        {
            tblPosts post = new tblPosts();

            if (ModelState.IsValid)
            {
                post.PostTitle       = Post.PostTitle;
                post.PostDate        = DateTime.Now;
                post.PostDescription = Post.PostDescription;
                tblPostsService service = new tblPostsService();


                HttpPostedFileBase file = Request.Files["txtAfbeelding"];

                if (file != null && file.ContentLength > 0)
                {
                    System.Diagnostics.Debug.WriteLine("image");
                    MemoryStream target = new MemoryStream();
                    file.InputStream.CopyTo(target);
                    byte[] image = target.ToArray();
                    post.PostImage = image;
                    Debug.Write("post: " + post.PostTitle + "," + post.PostDescription + "," + post.PostDate + "," + post.PostImage);
                    service.addNewPost(post);
                    return(RedirectToAction("EditPosts"));
                }
                else
                {
                    Debug.WriteLine("file null");
                    return(View());
                }
            }
            else
            {
                Debug.WriteLine("modelstate invalid");
                return(View());
            }
        }
        public void UpdatePost(tblPosts post)
        {
            tblPostsDAO dao = new tblPostsDAO();

            dao.UpdatePost(post);
        }
        public void addNewPost(tblPosts newPost)
        {
            tblPostsDAO dao = new tblPostsDAO();

            dao.addNewPost(newPost);
        }