private NetworkItem GetNetworkItem(NetworksContainer networkContainer, string networkName) { foreach (var item in networkContainer.Networks) { if (item.NetworkName == networkName) { return item; } } return null; }
private void DisplayNetworks(NetworksContainer networksContainer) { this.Items.Clear(); foreach (NetworkItem network in networksContainer.Networks) { var time = TimeSpan.FromMinutes(network.MinutesInWeek); var lastWeek = string.Empty; if (network.LastWeekHours > 0) { var weekTime = TimeSpan.FromMinutes(network.LastWeekHours); lastWeek = string.Format(" [ Last week worked: {0:hh}:{1:mm} ]", weekTime, weekTime); } string formatedTime = string.Format("{0:hh}:{1:mm} {2}", time, time, lastWeek); this.Items.Add(new ItemViewModel() { LineOne = network.NetworkName, LineTwo = formatedTime }); } }
public void InitializeNetworkInformation() { string currentNetworkName = _networkUtility.GetCurrentNetworkName(); NetworksContainer contanier = _networkUtility.GetNetworksFromFile(); if (contanier == null) { contanier = new NetworksContainer(); _networkUtility.AddCurrentNetworkToFile(contanier, currentNetworkName); return; } else { bool networkFound = false; foreach (NetworkItem item in contanier.Networks) { networkFound |= item.NetworkName == currentNetworkName; } if (!networkFound) _networkUtility.AddCurrentNetworkToFile(contanier, currentNetworkName); } }