Exemple #1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                BlahggerData data = BlahggerData.GetInstance();
                data.AddUser(user);
                return(RedirectToAction("Index", "Posts"));
            }

            return(View(user));
        }
Exemple #2
0
        // GET: Posts
        public ActionResult Index()
        {
            BlahggerData   data           = BlahggerData.GetInstance();
            List <Post>    posts          = data.GetPosts();
            PostsViewModel postsViewModel = new PostsViewModel()
            {
                Posts = posts
            };

            return(View(postsViewModel));
        }
Exemple #3
0
        public ActionResult Login(User user)
        {
            BlahggerData data = BlahggerData.GetInstance();

            if (data.AuthenticateUser(user))
            {
                return(RedirectToAction("Index", "Posts"));
            }
            else
            {
                return(View(user));
            }
        }
Exemple #4
0
        public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                BlahggerData data = BlahggerData.GetInstance();

                string username = User.Identity.Name;
                int    usersId  = data.GetUsersId(username);
                post.UsersId   = usersId;
                post.CreatedOn = DateTimeOffset.Now;

                data.AddPost(post);

                return(RedirectToAction("Index"));
            }

            return(View(post));
        }