Example #1
0
        public IActionResult OnPost(int vId)
        {
            var Username = HttpContext.Session.GetString("username");

            //var Username = "******";
            if (string.IsNullOrEmpty(Username))
            {
                return(RedirectToPage("/Index"));
            }
            var newVidRecord = new UsersVideoRecord()
            {
                Users      = userData.GetByUserName(Username),
                Videos     = videoData.GetVideosById(vId),
                IssueDate  = DateTime.Now,
                ReturnDate = DateTime.Now.AddDays(14),
                DueAmount  = 0
            };
            bool res = videoRecordData.AddVideoRecord(newVidRecord);

            if (res)
            {
                videoRecordData.Commit();
                return(RedirectToPage("Dashboard", new { urlname = Username }));
            }
            return(Page());
        }
Example #2
0
        public bool AddVideoRecord(UsersVideoRecord newVideoRecord)
        {
            db.Records.Add(newVideoRecord);
            var video = vd.GetVideosById(newVideoRecord.Videos.VideoId);

            video.NoOfCopies = video.NoOfCopies - 1;
            db.Entry(video).Property("NoOfCopies").IsModified = true;
            return(true);
        }
 public IActionResult OnGet(int rId)
 {
     confirmvideo = rd.GetRecordById(rId);
     if (confirmvideo == null)
     {
         return(RedirectToPage("./Dashboard", new { urlname = HttpContext.Session.GetString("username") }));
     }
     return(Page());
 }