public ActionResult LogIn(string username, string password) { UserManager manager = new UserManager(Properties.Settings.Default.ConStr); User user = manager.Login(username, password); if(user == null) { TempData["Error"] = "Invalid Username Or Password"; return Redirect("LogIn"); } FormsAuthentication.SetAuthCookie(user.Username, true); return Redirect("index"); }
public ActionResult Image(int id) { ImageManager manager = new ImageManager(Properties.Settings.Default.ConStr); ImageViewModel model = new ImageViewModel(); UserManager userManager = new UserManager(Properties.Settings.Default.ConStr); manager.AddView(id); model.Image = manager.GetImage(id); model.LikesCount = manager.GetLikesCount(id); if(User.Identity.IsAuthenticated) { model.User = userManager.GetUser(User.Identity.Name); model.Liked = manager.CheckIfUserLikedImage(model.User.Id, id); } return View(model); }
public ActionResult Index() { ImageManager manager = new ImageManager(Properties.Settings.Default.ConStr); IndexViewModel model = new IndexViewModel(); UserManager userManager = new UserManager(Properties.Settings.Default.ConStr); if(User.Identity.IsAuthenticated) { model.User = userManager.GetUser(User.Identity.Name); } model.MostRecent = manager.GetRecentImages(); model.MostViewed = manager.GetMostViewedImages(); model.MostLiked = manager.TopMostLiked(); if (TempData["url"] != null) { model.Url = (string)TempData["url"]; } return View(model); }
public ActionResult SignUp(string username, string password) { UserManager manager = new UserManager(Properties.Settings.Default.ConStr); manager.AddUser(username, password); return Redirect("LogIn"); }