Beispiel #1
0
        public async Task <AccessResponse> AuthAsync(int code)
        {
            try
            {
                CultureInfo  ci         = new CultureInfo("en-US");
                TimeZoneInfo hrBrasilia = TZConvert.GetTimeZoneInfo("E. South America Standard Time");
                var          exist      = await _deviceRepository.FindByIdAsync(code);

                if (exist == null && code != 0)
                {
                    return(new AccessResponse($"Device {code} not found"));
                }

                Access access = await _accessRepository.AuthByDeviceAsync(exist.Code);

                access.AccessLogs = await _accessLogRepository.ListByAccessCodeAsync(access.Code);

                await _unitOfWork.CompleteAsync();

                return(new AccessResponse(access));
            }
            catch (Exception e)
            {
                return(new AccessResponse($"An error occurred when deleting the access: { e.Message }"));
            }
        }