public override async Task <AddAssetModel> Handle(AddAssetCommand command) { DeviceType deviceType = deviceTypeDataService.GetById(command.Model.DeviceTypeId); AssetEntity asset = await AddAsset(command, deviceType); return(new AddAssetModel { Id = asset.Id }); }
private void AddDevice(IUnitOfWork unitOfWork, ChangeDeviceCommand command) { DeviceType deviceType = deviceTypeDataService.GetById(command.Model.DeviceTypeId); DeviceEntity deviceEntity = new DeviceEntity { DeviceId = command.Model.DeviceId, DeviceTypeId = command.Model.DeviceTypeId, AssetId = command.AssetId, ProtocolPort = deviceType.Protocol.Port, IsActive = true }; unitOfWork.Add(deviceEntity); }
public DeviceModel Map(DeviceEntity source, DeviceModel destination) { destination.Id = source.Id; destination.DeviceId = source.DeviceId; destination.IsActive = source.IsActive; destination.AssetId = source.AssetId; DeviceType deviceType = deviceTypeDataService.GetById(source.DeviceTypeId); destination.DeviceType = deviceType != null ? mapper.Map <DeviceType, DeviceTypeModel>(deviceType) : null; return(destination); }
public Task <bool> DeviceIsUsed(string deviceId, int deviceTypeId, int?excludeAssetId = null) { DeviceType deviceType = deviceTypeDataService.GetById(deviceTypeId); return(deviceDataService.DeviceIsAssigned(deviceId, deviceType.Protocol.Port, excludeAssetId)); }