示例#1
0
        private void FindLastCheckin(int memberId)
        {
            var member = _context.Members.FirstOrDefault(x => x.MemberId == memberId);

            if (member == null)
            {
                return;
            }

            var lastCheckin = _context.Checkins.OrderByDescending(x => x.CheckinId)
                              .FirstOrDefault(x => x.MemberId == memberId);



            if (lastCheckin != null)
            {
                if (lastCheckin.CheckOutTime == null)
                {
                    Checkin = lastCheckin;
                }
                else
                {
                    Checkin = new Models.Checkin()
                    {
                        MemberId    = lastCheckin.MemberId,
                        CheckInTime = DateTime.Now
                    }
                };
            }
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            CabinId = GetCabinFromCookie();
            if (CabinId == 0) // no cabin set yet
            {
                return(Redirect("~/Checkin/SetCabin"));
            }

            // on any get start with blank checkin
            Checkin = new Models.Checkin()
            {
                CheckInTime = DateTime.Now
            };


            // see if the user has been here before
            var memberId = GetMemberFromCookie();

            if (memberId > 0)
            {
                FindLastCheckin(memberId);
            }



            MemberId = Checkin.MemberId;
            InitializeLookups();


            return(Page());
        }