Exemplo n.º 1
0
        public Utility.OpResult Deletes(int[] ids)
        {
            var op = new OpResult();

            try
            {
                var devices = DevicesRepository.GetQuery(o => ids.Contains(o.Id));
                if (!devices.Any())
                {
                    op.Message = "查不到数据";
                    return(op);
                }
                var delDeviceId = devices.Select(o => o.DeviceId);
                var authorize   = DeviceAuthorizeRepository.GetQuery(o => delDeviceId.Contains(o.DeviceId));
                if (authorize.Any())
                {
                    op.Message = "无法删除,设备授权包含了要删除的设备";
                    return(op);
                }

                DevicesRepository.RemoveRange(devices.ToList());
                op.Successed = true;
                LogEngine.WriteDelete("移除设备", LogModule.设备管理);
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                LogEngine.WriteError(ex);
            }
            return(op);
        }