public ActionResult Create(User user) { if (ModelState.IsValid) { BlahggerData data = BlahggerData.GetInstance(); data.AddUser(user); return(RedirectToAction("Index", "Posts")); } return(View(user)); }
// GET: Posts public ActionResult Index() { BlahggerData data = BlahggerData.GetInstance(); List <Post> posts = data.GetPosts(); PostsViewModel postsViewModel = new PostsViewModel() { Posts = posts }; return(View(postsViewModel)); }
public ActionResult Login(User user) { BlahggerData data = BlahggerData.GetInstance(); if (data.AuthenticateUser(user)) { return(RedirectToAction("Index", "Posts")); } else { return(View(user)); } }
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)); }