private void CreatePlantList() { ObservableCollection <PlantVariety> list = new ObservableCollection <PlantVariety>(); List <PlantVariety> list1 = new List <PlantVariety>(); list1 = context.PlantVariety.Local.ToList(); if (checkBoxAll.IsChecked != true) { if (checkGenus.IsChecked == true) { list1 = list1.Where(x => x.Genus == SelectedGenus).Select(x => x).ToList(); } if (checkLifeForm.IsChecked == true) { list1 = list1.Where(x => x.LifeForm == SelectedLifeForm).Select(x => x).ToList(); } } if (textBoxSearch.Text != "") { list1 = list1.Where(x => x.FullName.ToLower().Contains(textBoxSearch.Text.ToLower()) == true).Select(x => x).ToList(); } PlantList.Clear(); foreach (var item in list1) { PlantList.Add(item); } }
//Solo recibe objetos de la clase TerrainVehicle public void SavePlantPokemon(PlantPokemon plantPokemon) { var searchResult = PlantList.Where(p => p.Name == plantPokemon.Name).ToList(); //if it didnt find any coincidence, then searchresult is null if (searchResult.Count() > 0) { throw new Exception("pokemon already stored"); } else { //otherwise it stores the pokemon successfully PlantList.Add(plantPokemon); } }
private bool NewPlant(string itemID) { Plant newItem = new Plant(); //all new records will be give a negative int autoid... //when they are updated then sql will generate one for them overiding this set value... //it will allow us to give uniqueness to the tempory new records... //Before they are updated to the entity and given an autoid... //we use a negative number and keep subtracting by 1 for each new item added... //This will allow it to alwasy be unique and never interfere with SQL's positive autoid... _newPlantAutoId = _newPlantAutoId - 1; newItem.AutoID = _newPlantAutoId; newItem.PlantID = itemID; newItem.CompanyID = ClientSessionSingleton.Instance.CompanyID; newItem.IsValid = 1; newItem.NotValidMessage = "New Record Key Field/s Are Required."; PlantList.Add(newItem); _serviceAgent.AddToPlantRepository(newItem); SelectedPlant = PlantList.LastOrDefault(); AllowEdit = true; Dirty = false; return(true); }