Example #1
0
        //[Authorize]
        public IActionResult CheckIn(string userName)
        {
            IActionResult result = Unauthorized();

            try
            {
                UserItem myUser = _db.GetUserItemByLogin(userName);
                // UserItem myUser = _db.GetUserItemByLogin(User.Identity.Name);
                VisitItem newVisit = new VisitItem()
                {
                    UserId  = myUser.Id,
                    CheckIn = DateTime.UtcNow
                };
                newVisit.Id = _db.CreateVisit(newVisit);

                // Switch to 200 OK
                if (newVisit.Id > 0)
                {
                    result = Ok(newVisit.Id);
                }
            }
            catch (Exception)
            {
                result = BadRequest(new { Message = "Failed to checkin user" });
            }
            return(result);
        }