public Device ToRepositoryType(IRepositoryModelCache cache, INetworkRepository networkRepository, IScriptRepository scriptRepository, ITaskRepository taskRepository) { IDeviceState state = null; if (!string.IsNullOrEmpty(Notes)) { var element = XElement.Parse(Notes); state = element.ToDeviceState(); } var result = new Device( address: Address, lastPing: LastPing, id: Id, name: Name, network: NetworkModel.ToRepositoryType(cache, Network_Id, networkRepository), scripts: scriptRepository, state: state, tasks: taskRepository, type: DeviceType.GetTypeFromString(Type_Name) ); cache?.Set(result.Id, result); return(result); }
public static NetworkModel FromRepositoryType(Network repositoryModel) { if (repositoryModel == null) { return(null); } var attachedComputerRepositoryModel = ComputerModel.FromRepositoryType(repositoryModel.AttatchedComputer); var ownerRepositoryModel = UserModel.FromRepositoryType(repositoryModel.Owner); var result = new NetworkModel { Address = repositoryModel.Address, AttatchedComputer_Id = attachedComputerRepositoryModel?.Id, Id = repositoryModel.Id, LastPing = repositoryModel.LastPing, Name = repositoryModel.Name, Owner_Id = ownerRepositoryModel?.Id, }; return(result); }
public static DeviceModel FromRepositoryType(Device repositoryModel) { if (repositoryModel == null) { return(null); } var networkRepositoryModel = NetworkModel.FromRepositoryType(repositoryModel.Network); var result = new DeviceModel { Address = repositoryModel.Address, Id = repositoryModel.Id, IsConnected = repositoryModel.IsConnected, LastPing = repositoryModel.LastPing, Name = repositoryModel.Name, Network_Id = networkRepositoryModel?.Id, Notes = repositoryModel.ToXElement().ToString(), Type_Name = repositoryModel.Type.Name, }; return(result); }