/// <summary>
        /// Check if taxon is correct
        /// </summary>
        /// <param name="inputTaxonId"></param>
        /// <param name="taxon"></param>
        /// <returns></returns>
        protected bool CheckTaxonVaildity(string inputTaxonId, ITaxon taxon)
        {
            string errorMsg;
            bool   valid = true;

            if (taxon.IsNull())
            {
                errorMsg = Resources.DyntaxaResource.RevisonAddInvalidTaxonErrorText;
                ModelState.AddModelError("", errorMsg);
                valid = false;
            }
            if (taxon.IsNotNull() && !taxon.Id.ToString().Equals(inputTaxonId))
            {
                errorMsg = Resources.DyntaxaResource.RevisionSharedNoValidTaxonIdErrorText;
                string propName  = string.Empty;
                string propValue = string.Empty;
                if (taxon.IsNotNull())
                {
                    propName = ReflectionUtility.GetPropertyName(() => taxon.Id);
                    PropertyInfo pi = taxon.GetType().GetProperty(propName);
                    propValue = pi.GetValue(taxon, null).ToString();
                    ModelState.AddModelError("", errorMsg + " " + propValue);
                }
                else
                {
                    ModelState.AddModelError("", errorMsg);
                }
                valid = false;
            }
            return(valid);
        }
示例#2
0
 private ITaxon GetTaxon(Boolean refresh = false, TaxonId?taxonId = null)
 {
     if (_taxon.IsNull() || refresh)
     {
         if (taxonId.HasValue)
         {
             _taxon = CoreData.TaxonManager.GetTaxon(GetUserContext(), taxonId.Value);
         }
         else
         {
             _taxon = CoreData.TaxonManager.GetTaxon(GetUserContext(), 246126);
         }
     }
     return(_taxon);
 }