private void FilterText() { if (_filter == null) { _filter = ""; } //Se filtran los readModels por Name var result = _readModels.Where(d => d.Name.ToLowerInvariant() .Contains(Filter.ToLowerInvariant())) .ToList(); //Se excluyen los que no aplican al filtro var toRemove = ReadModels.Except(result).ToList(); //Se eliminan los que no se quieren mostrar foreach (var x in toRemove) { ReadModels.Remove(x); } var resultCount = result.Count; for (int i = 0; i < resultCount; i++) { //Agrego a la lista var resultItem = result[i]; if (i + 1 > ReadModels.Count || !ReadModels[i].Equals(resultItem)) { ReadModels.Insert(i, resultItem); } } }
//Ya escrito private void GenerateDummyData() { var list = _readRepository.DataForView(); list.ForEach(x => { ReadModels.Add(x); }); if (ReadModels != null && ReadModels.Count > 0) { this.SelectedRead = ReadModels.First(); } //FilterText(); }
private async void LoadData() { try { _readModels = await ReadResitory.GetReadsAsync(); FilterText(); LoadingState = LoadingStates.Loaded; var random = new Random(); SelectedRead = ReadModels?.ElementAt(random.Next(0, ReadModels.Count - 1)); } catch (Exception) { LoadingState = LoadingStates.Error; } }
public void Initialize() { MMWindow.Manager = this; ReadModels.Clear(); WriteModels.Clear(); ReadCommands.Clear(); WriteCommands.Clear(); _Add(LadderModels); if (MMWindow != null) { foreach (MonitorVariableTable mvtable in MMWindow.tables) { Initialize(mvtable); } } Arrange(); }
private async Task FilterTextAsync() { if (_filter == null) { _filter = ""; } var result = await _readRepository.GetByNameAsync(this.Filter); ReadModels.Clear(); result.ForEach(x => { ReadModels.Add(x); }); if (ReadModels.Count > 0) { this.SelectedRead = ReadModels.First(); } }
private void GenerateDummyData() { //Solo se carga en el modo diseño for (int i = 0; i < 150; i++) { var readModel = new ReadModel { Email = $"mail@prueba{i}.com", Picture = "http://placehold.it/400x400", Name = $"Nombre : {i}", Last = $"Apellido : {i}", Notices = new List <NoticeModel> { new NoticeModel { Date = RandomDay().ToString(), Id = i, Tags = new List <string> { $"Tag - {i}", $"Tag - {i - 5}" }, Text = "Ex cupidatat culpa consequat enim laborum in deserunt anim occaecat. Deserunt eiusmod quis occaecat id deserunt est voluptate do fugiat adipisicing. Ut laboris in magna adipisicing amet non nulla in. Duis irure qui mollit ea et amet esse tempor dolor reprehenderit do.", Title = $"Titulo numero : {i}", Image = "http://placehold.it/400x400" }, new NoticeModel { Date = RandomDay().ToString(), Id = i, Tags = new List <string> { $"Tag - {i}", $"Tag - {i - 5}" }, Text = "Ex cupidatat culpa consequat enim laborum in deserunt anim occaecat. Deserunt eiusmod quis occaecat id deserunt est voluptate do fugiat adipisicing. Ut laboris in magna adipisicing amet non nulla in. Duis irure qui mollit ea et amet esse tempor dolor reprehenderit do.", Title = $"Titulo numero : {i}", Image = "http://placehold.it/400x400" }, new NoticeModel { Date = RandomDay().ToString(), Id = i, Tags = new List <string> { $"Tag - {i}", $"Tag - {i - 5}" }, Text = "Ex cupidatat culpa consequat enim laborum in deserunt anim occaecat. Deserunt eiusmod quis occaecat id deserunt est voluptate do fugiat adipisicing. Ut laboris in magna adipisicing amet non nulla in. Duis irure qui mollit ea et amet esse tempor dolor reprehenderit do.", Title = $"Titulo numero : {i}", Image = "http://placehold.it/400x400" }, new NoticeModel { Date = RandomDay().ToString(), Id = i, Tags = new List <string> { $"Tag - {i}", $"Tag - {i - 5}" }, Text = "Ex cupidatat culpa consequat enim laborum in deserunt anim occaecat. Deserunt eiusmod quis occaecat id deserunt est voluptate do fugiat adipisicing. Ut laboris in magna adipisicing amet non nulla in. Duis irure qui mollit ea et amet esse tempor dolor reprehenderit do.", Title = $"Titulo numero : {i}", Image = "http://placehold.it/400x400" } } }; ReadModels.Add(readModel); } if (ReadModels != null && ReadModels.Count > 0) { this.SelectedRead = ReadModels.First(); } //FilterText(); }
public QueryHandler(ReadModels readModels) { _readModels = readModels; }