/// <summary> /// Returns the Coefficient using KC List /// witch Day After Sowing and Name are passed by parameters /// </summary> /// <param name="pName"></param> /// <param name="pDays"></param> /// <returns></returns> private Double getKCFromList(long pSpecieId, int pDays) { Double lReturn = 0; KC lKC = null; try { foreach (KC item in this.KCList .Where(kc => kc.SpecieId == pSpecieId)) { if (item.DayAfterSowing == pDays) { lKC = item; break; } } lReturn = lKC.Coefficient; } catch (Exception ex) { logger.Error(ex, "Exception in CropCoefficient.getKCFromList " + "\n" + ex.Message + "\n" + ex.StackTrace); lReturn = -1; } return(lReturn); }
/// <summary> /// Add or Update a value to the list of KC /// Index 0 value == 0; /// </summary> /// <param name="pDayAfterSowing"></param> /// <param name="pCoefficient"></param> /// <returns></returns> public bool AddOrUpdateKCforDayAfterSowing(long pSpecieId, int pDayAfterSowing, double pCoefficient) { bool lReturn = false; KC lKC = null; try { foreach (KC item in this.KCList) { if (item.DayAfterSowing == pDayAfterSowing) { item.SpecieId = pSpecieId; item.Coefficient = pCoefficient; lKC = item; lReturn = true; break; } } if (!lReturn) { lKC = new KC(this.KCList.Count, pSpecieId, pDayAfterSowing, pCoefficient); this.KCList.Add(lKC); lReturn = true; } } catch (Exception ex) { logger.Error(ex, "Exception in CropCoefficient.AddOrUpdateKCforDayAfterSowing " + "\n" + ex.Message + "\n" + ex.StackTrace); } return(lReturn); }
/// <summary> /// Returns the Coefficient using KC List /// witch Day After Sowing is passed by parameters /// </summary> /// <param name="pDays"></param> /// <returns></returns> private Double getKCFromList(int pDays) { Double lReturn = 0; KC lKC = null; try { if (pDays >= this.KCList.Count) { return(-1); } foreach (KC item in this.KCList) { if (item.DayAfterSowing == pDays) { lKC = item; break; } } lReturn = lKC.Coefficient; } catch (Exception ex) { logger.Error(ex, "Exception in CropCoefficient.getKCFromList " + "\n" + ex.Message + "\n" + ex.StackTrace); lReturn = -1; } return(lReturn); }
// private methods used only to support external API Methods #endregion #region Public Methods #endregion #region Overrides // Different region for each class override /// <summary> /// Overrides equals /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null || obj.GetType() != this.GetType()) { return(false); } KC lKC = obj as KC; return(this.SpecieId == lKC.SpecieId && this.DayAfterSowing == lKC.DayAfterSowing); }