public ServerEditViewModel(ITabController tabController, ServerData data) : base(tabController) { Name = data.Code; CurrentServerData = data; TransportDictionary dic = new TransportDictionary(); Transfers = dic.Transfers.ToArray(); SelectedTransfer = Transfers.FirstOrDefault(x => x.Name == data.Protocol); OnPropertyChanged(nameof(Transfers)); }
private async Task UpdateTransfers(HostState hostState) { await hostState.BoincState.UpdateFileTransfers(); if (!_useObservableCollections) { return; } foreach (BoincRpc.FileTransfer fileTransfer in hostState.BoincState.FileTransfers) { ObservableTransfer transfer = Transfers.FirstOrDefault(tvm => tvm.HostId == hostState.Id && tvm.FileName == fileTransfer.Name); if (transfer == null) { transfer = new ObservableTransfer(hostState, fileTransfer); if (string.IsNullOrEmpty(SearchString)) { Transfers.Add(transfer); } else { foreach (var content in transfer.GetContentsForFiltering()) { if (content != null && content.IndexOf(SearchString, StringComparison.InvariantCultureIgnoreCase) != -1) { // The search string is found in any of the Models's property Transfers.Add(transfer); break; } } } } else { transfer.Update(fileTransfer); } } }
public void EditTransfer(Transfer transfer) { var editTransfer = Transfers.FirstOrDefault(x => x.Id == transfer.Id); editTransfer = transfer; }
public ActionResult <Transfer> Get(int id) { return(Transfers.FirstOrDefault(x => x.Id == id)); }
public void Delete(int id) { _db.Transfers.Remove(Transfers.FirstOrDefault(x => x.Id == id)); }