Example #1
0
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedPlant.PlantID))
     {//check to see if key is part of the current companylist...
         Plant query = PlantList.Where(company => company.PlantID == SelectedPlant.PlantID &&
                                       company.AutoID != SelectedPlant.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back
             SelectedPlant.PlantID = SelectedPlantMirror.PlantID;
             //change to the newly selected company...
             SelectedPlant = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         PlantList = GetPlantByID(SelectedPlant.PlantID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (PlantList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedPlant.PlantID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedPlant = PlantList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedPlant.PlantID != SelectedPlantMirror.PlantID)
         {
             SelectedPlant.PlantID = SelectedPlantMirror.PlantID;
         }
     }
 }
        //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);
            }
        }