Ejemplo n.º 1
0
        public List <DoorListDto> GetListByDoorIds(List <string> idsList)
        {
            if (idsList == null || idsList.Count < 1)
            {
                return(null);
            }
            var query = _doorRepository.Table.Where(t => idsList.Contains(t.DoorUUID)).ToList();

            if (query == null || query.Count < 1)
            {
                return(null);
            }
            var doorList = new List <DoorListDto>();

            foreach (var item in query.ToList())
            {
                var device = item.Device;
                var model  = new DoorListDto();
                model.DoorUUID        = item.DoorUUID;
                model.DoorName        = item.DoorName;
                model.Floor           = item.Floor;
                model.DoorNo          = item.DoorNo;
                model.Status          = item.Status;
                model.DeviceIP        = device.IPAddress;
                model.DevicePort      = device.Port;
                model.DeviceSN        = device.SNNumber;
                model.CardConvertType = device.CardConvertType;
                model.DeviceType      = device.DeviceType.HasValue ? device.DeviceType.Value : 0;
                model.AreaUUID        = item.AreaUUID;
                doorList.Add(model);
            }
            return(doorList);
        }
Ejemplo n.º 2
0
        public IList <DoorListDto> GetDoorListBy(string areaUUID, int floor = 0, string communityId = null)
        {
            var query = _doorRepository.Table.Where(a => a.Status == 1);

            if (floor > 0)
            {
                query = query.Where(a => a.Floor == floor);
            }
            if (!string.IsNullOrWhiteSpace(areaUUID))
            {
                query = query.Where(a => a.AreaUUID == areaUUID);
            }
            if (!communityId.IsBlank())
            {
                query = query.Where(a => a.CommunityUUID == communityId);
            }

            var doorList = new List <DoorListDto>();

            foreach (var item in query.ToList())
            {
                var device = item.Device;
                var model  = new DoorListDto();
                model.DoorUUID        = item.DoorUUID;
                model.DoorName        = item.DoorName;
                model.Floor           = item.Floor;
                model.DoorNo          = item.DoorNo;
                model.Status          = item.Status;
                model.DeviceIP        = device.IPAddress;
                model.DevicePort      = device.Port;
                model.DeviceSN        = device.SNNumber;
                model.CardConvertType = device.CardConvertType;
                model.DeviceType      = device.DeviceType.HasValue ? device.DeviceType.Value : 0;
                model.AreaUUID        = item.AreaUUID;
                model.DoorTypeName    = item.DoorTypeDict.DictName;
                doorList.Add(model);
            }
            return(doorList);
        }