コード例 #1
0
 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");
 }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public ActionResult SignUp(string username, string password)
 {
     UserManager manager = new UserManager(Properties.Settings.Default.ConStr);
     manager.AddUser(username, password);
     return Redirect("LogIn");
 }