public bool SaveVisitorCheckIn(VisitorCheckInVM visitorCheckInVM, string userId)
        {
            var gate = _genericService.ShitfAssignment.GetAll().Where(item => item.UserId == userId && item.IsActive).FirstOrDefault();

            if (gate != null)
            {
                VisitDetails _visitDetails = new VisitDetails();
                _visitDetails.VisitorId      = visitorCheckInVM.VisitorId;
                _visitDetails.ContactPerson  = visitorCheckInVM.ContactPerson;
                _visitDetails.NoOfPerson     = visitorCheckInVM.NoOfPerson;
                _visitDetails.PurposeOfVisit = visitorCheckInVM.PurposeOfVisit;
                _visitDetails.CheckIn        = DateTime.UtcNow;
                _visitDetails.CheckOut       = null;
                _visitDetails.CreatedBy      = visitorCheckInVM.CreatedBy;
                _visitDetails.CheckInGate    = gate.GateId;
                _visitDetails.CheckOutGate   = gate.GateId;
                _visitDetails.CompanyName    = visitorCheckInVM.CompanyName;
                _visitDetails.VahicleNumber  = visitorCheckInVM.VahicleNumber;
                _visitDetails.Floor          = visitorCheckInVM.Floor;
                _genericService.VisitDetails.Insert(_visitDetails);
                _genericService.Commit();
                return(true);
            }
            return(false);
        }
        public ReturnResult SaveVisitorCheckOut([FromBody] VisitorCheckInVM visitorCheckInVM)
        {
            visitorCheckInVM.CreatedBy   = HttpContext.Current.User.Identity.GetUserId();
            visitorCheckInVM.CheckInGate = 1;
            var result = _visitorCheckInCheckOutHelper.SaveVisitorCheckOut(visitorCheckInVM);

            return(new ReturnResult {
                Message = (result == true ? "Success" : "Failure"), Success = (result == true ? true : false)
            });
        }
        public bool SaveVisitorCheckOut(VisitorCheckInVM visitorCheckInVM)
        {
            var visitDetail = _genericService.VisitDetails.GetAll().Where(item => item.VisitorId == visitorCheckInVM.VisitorId).OrderByDescending(item => item.CheckIn).FirstOrDefault();

            if (visitDetail != null)
            {
                if (visitDetail.CheckOut == null)
                {
                    visitDetail.CheckOut = DateTime.UtcNow;
                    _genericService.Commit();
                    return(true);
                }
            }

            return(false);
        }