コード例 #1
0
 public IActionResult OnGet(string user)
 {
     UserData = repo.GetUserByUsername(user);
     if (string.IsNullOrEmpty(HttpContext.Session.GetString("username")) &&
         HttpContext.Session.GetString("username") != user)
     {
         return(RedirectToPage("/Index"));
     }
     return(Page());
 }
コード例 #2
0
        public IActionResult OnPost(int mId)
        {
            var Username  = HttpContext.Session.GetString("username");
            var MovieData = repo.GetMoviesById(mId);

            if (string.IsNullOrEmpty(Username))
            {
                return(RedirectToPage("/Login"));
            }
            var newRecord = new Records()
            {
                User       = repo.GetUserByUsername(Username),
                Movies     = MovieData,
                TakenDate  = DateTime.Now,
                ReturnDate = DateTime.Now.AddDays(MovieData.ReturnDays)
            };

            repo.AddRecord(newRecord);
            repo.Commit();
            return(RedirectToPage("/Dashboard/Index", new { user = Username }));
        }