Exemple #1
0
        public IActionResult CreatePost(NewPost obj)
        {
            DatabaseConnector db = new DatabaseConnector();

            if (DatabaseConnector.signeduser.id != -1)
            {
                if (ModelState.IsValid)
                {
                    signdInUser = DatabaseConnector.signeduser;
                    Post post = new Post();
                    post.content  = obj.content;
                    post.title    = obj.title;
                    post.userId   = signdInUser.id;
                    post.username = signdInUser.username;
                    post.date     = System.DateTime.Now.ToString("MMMM, dd yyyy");

                    db.AddNewPost(post);
                    List <Post> list = db.getAllUsersPost(signdInUser);
                    return(View("UsersPost", list));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View("Index"));
            }
        }