Exemple #1
0
        public static DoorAccessLogViewModel GetViewModel(this DoorAccessLog doorAccessLogObject)
        {
            var doorAccessLogViewModel = new DoorAccessLogViewModel();

            if (doorAccessLogObject != null)
            {
                doorAccessLogViewModel.AccessDenied = doorAccessLogObject.accessdenied ?? true;
                doorAccessLogViewModel.Date         = doorAccessLogObject.date ?? DateTime.Now;
                doorAccessLogViewModel.Door         = doorAccessLogObject.Door.GetViewModel();
                doorAccessLogViewModel.User         = doorAccessLogObject.User.GetViewModel();
                doorAccessLogViewModel.Status       = doorAccessLogObject.state ?? true;
            }

            return(doorAccessLogViewModel);
        }
Exemple #2
0
        // DoorAccessLog repo
        public void LogAccessToDoorByUser(int doorId, int userId, bool locked, bool accessDenied)
        {
            try
            {
                var doorAccessLog = new DoorAccessLog()
                {
                    date         = DateTime.Now,
                    accessdenied = accessDenied,
                    state        = locked,
                    userid       = userId,
                    doorid       = doorId
                };

                doorAccessLogRepo.Insert(doorAccessLog);
                doorAccessLogRepo.Save();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }