public int AddCommonName(CommonName commonName) { int returnCode = 0; String commandText = "usp_InsertSpeciesCommonName"; try { using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context))) { SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = commandText; cmd.Parameters.AddWithValue("@taxonomy_species_id", commonName.SpeciesID); cmd.Parameters.AddWithValue("@language_description", commonName.LanguageDescription); cmd.Parameters.AddWithValue("@name", commonName.Name); cmd.Parameters.AddWithValue("@simplified_name", commonName.SimplifiedName); if (commonName.AlternateTranscription == null) { cmd.Parameters.AddWithValue("@alternate_transcription", DBNull.Value); } else { cmd.Parameters.AddWithValue("@alternate_transcription", commonName.AlternateTranscription); } //cmd.Parameters.AddWithValue("@citation_id", commonName); cmd.Parameters.AddWithValue("@citation_id", DBNull.Value); if (commonName.Note == null) { cmd.Parameters.AddWithValue("@note", DBNull.Value); } else { cmd.Parameters.AddWithValue("@note", commonName.Note); } cmd.Parameters.AddWithValue("@created_by", commonName.CreatedByCooperatorID); SqlParameter retParam = new SqlParameter(); retParam.SqlDbType = System.Data.SqlDbType.Int; retParam.ParameterName = "@new_taxonomy_common_name_id "; retParam.Direction = System.Data.ParameterDirection.Output; retParam.Value = 0; cmd.Parameters.Add(retParam); cmd.ExecuteNonQuery(); returnCode = Int32.Parse(cmd.Parameters["@new_taxonomy_common_name_id "].Value.ToString()); return(returnCode); } } catch (Exception ex) { throw ex; } return(returnCode); }
public void DeleteCommonName(CommonName commonNameToBeDeleted) { //Validate Input if (commonNameToBeDeleted == null) { throw (new ArgumentNullException("commonNameToBeDeleted")); } // Validate Primary key value if (commonNameToBeDeleted.CommonNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("CommonNameID"); } OnCommonNameSaving(commonNameToBeDeleted); OnCommonNameDeleting(commonNameToBeDeleted); if (commonNameToBeDeleted.EntityState == EntityState.Detached) { _DatabaseContext.CommonNames.Attach(commonNameToBeDeleted); } _DatabaseContext.CommonNames.DeleteObject(commonNameToBeDeleted); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No CommonName deleted!"); } OnCommonNameDeleted(commonNameToBeDeleted); OnCommonNameSaved(commonNameToBeDeleted); }
public void DeleteCommonNames(List <int> commonNameIDsToDelete) { //Validate Input foreach (int commonNameID in commonNameIDsToDelete) { if (commonNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("CommonNameID"); } } List <CommonName> commonNamesToBeDeleted = new List <CommonName>(); foreach (int commonNameID in commonNameIDsToDelete) { CommonName commonName = new CommonName { CommonNameID = commonNameID }; _DatabaseContext.CommonNames.Attach(commonName); _DatabaseContext.CommonNames.DeleteObject(commonName); commonNamesToBeDeleted.Add(commonName); OnCommonNameDeleting(commonName); } int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows != commonNameIDsToDelete.Count) { throw new DataNotUpdatedException("One or more commonName records have not been deleted."); } foreach (CommonName commonNameToBeDeleted in commonNamesToBeDeleted) { OnCommonNameDeleted(commonNameToBeDeleted); } }
public void UpdateCommonName(CommonName updatedCommonName) { // Validate Parameters if (updatedCommonName == null) { throw (new ArgumentNullException("updatedCommonName")); } // Validate Primary key value if (updatedCommonName.CommonNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("CommonNameID"); } // Apply business rules OnCommonNameSaving(updatedCommonName); OnCommonNameUpdating(updatedCommonName); //attaching and making ready for parsistance if (updatedCommonName.EntityState == EntityState.Detached) { _DatabaseContext.CommonNames.Attach(updatedCommonName); } _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedCommonName, System.Data.EntityState.Modified); //this line makes the code un-testable! int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No commonName updated!"); } //Apply business workflow OnCommonNameUpdated(updatedCommonName); OnCommonNameSaved(updatedCommonName); }
public virtual int CreateNewCommonName(CommonName newCommonName) { // Validate Parameters if (newCommonName == null) { throw (new ArgumentNullException("newCommonName")); } // Apply business rules OnCommonNameSaving(newCommonName); OnCommonNameCreating(newCommonName); _DatabaseContext.CommonNames.AddObject(newCommonName); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No commonName created!"); } // Apply business workflow OnCommonNameCreated(newCommonName); OnCommonNameSaved(newCommonName); return(newCommonName.CommonNameID); }
public void UpdateCommonName(CommonName commonName) { StoredProcUpdate("spCommonNameUpdate", _P("intCommonNameID", commonName.CommonNameID), _P("intBiotaID", commonName.BiotaID), _P("vchrCommonName", commonName.Name), _P("intRefID", commonName.RefID, DBNull.Value), _P("vchrRefPage", commonName.RefPage), _P("txtNotes", commonName.Notes) ); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Categories != null) { hashCode = hashCode * 59 + Categories.GetHashCode(); } if (Nutrients != null) { hashCode = hashCode * 59 + Nutrients.GetHashCode(); } if (CalorieConversionFactor != null) { hashCode = hashCode * 59 + CalorieConversionFactor.GetHashCode(); } if (ProteinConversionFactor != null) { hashCode = hashCode * 59 + ProteinConversionFactor.GetHashCode(); } if (Components != null) { hashCode = hashCode * 59 + Components.GetHashCode(); } if (Portions != null) { hashCode = hashCode * 59 + Portions.GetHashCode(); } if (CommonName != null) { hashCode = hashCode * 59 + CommonName.GetHashCode(); } if (Footnote != null) { hashCode = hashCode * 59 + Footnote.GetHashCode(); } if (SearchTerm != null) { hashCode = hashCode * 59 + SearchTerm.GetHashCode(); } if (Score != null) { hashCode = hashCode * 59 + Score.GetHashCode(); } return(hashCode); } }
public int UpdateCommonName(CommonName commonName) { int returnCode = 0; String commandText = "usp_UpdateSpeciesCommonName"; try { using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context))) { SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = commandText; cmd.Parameters.AddWithValue("@taxonomy_common_name_id", commonName.ID); cmd.Parameters.AddWithValue("@taxonomy_species_id", commonName.SpeciesID); cmd.Parameters.AddWithValue("@language_description", commonName.LanguageDescription); cmd.Parameters.AddWithValue("@name", commonName.Name); cmd.Parameters.AddWithValue("@simplified_name", commonName.SimplifiedName); if (commonName.AlternateTranscription == null) { cmd.Parameters.AddWithValue("@alternate_transcription", DBNull.Value); } else { cmd.Parameters.AddWithValue("@alternate_transcription", commonName.AlternateTranscription); } //cmd.Parameters.AddWithValue("@citation_id", commonName); cmd.Parameters.AddWithValue("@citation_id", DBNull.Value); if (commonName.Note == null) { cmd.Parameters.AddWithValue("@note", DBNull.Value); } else { cmd.Parameters.AddWithValue("@note", commonName.Note); } cmd.Parameters.AddWithValue("@modified_by", commonName.ModifiedByCooperatorID); returnCode = cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw ex; } return(returnCode); }
private void AddNewName() { CommonName data = new CommonName(); data.BiotaID = Taxon.TaxaID.Value; data.CommonNameID = -1; var viewModel = new CommonNameViewModel(data); viewModel.Name = NextNewName("<Name name {0}>", _model, () => viewModel.Name); _model.Add(viewModel); lstNames.SelectedItem = viewModel; lstNames.ScrollIntoView(viewModel); RegisterPendingChange(new InsertCommonNameCommand(data)); }
public void InsertCommonName(CommonName commonName) { var retval = ReturnParam("RetVal"); StoredProcUpdate("spCommonNameInsert", _P("intBiotaID", commonName.BiotaID), _P("vchrCommonName", commonName.Name), _P("intRefID", commonName.RefID, DBNull.Value), _P("vchrRefPage", commonName.RefPage), _P("txtNotes", commonName.Notes), retval ); commonName.CommonNameID = (int)retval.Value; }
public override int GetHashCode() { unchecked { int hashCode = TaxonId; hashCode = (hashCode * 397) ^ (ScientificName != null ? ScientificName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CommonName != null ? CommonName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SearchMatchName != null ? SearchMatchName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Author != null ? Author.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NameCategory != null ? NameCategory.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)TaxonStatus; return(hashCode); } }
public virtual bool ShouldMerge(Tree otherTree) { if (!CommonName.Equals(otherTree.CommonName, StringComparison.OrdinalIgnoreCase) || !ScientificName.Equals(otherTree.ScientificName, StringComparison.OrdinalIgnoreCase)) { return(false); } if (!Coordinates.IsSpecified || !otherTree.Coordinates.IsSpecified || !Coordinates.Equals(otherTree.Coordinates)) { return(false); } return(true); }
public CommonName GetOrCreateCommonName(string commonNameDesc, User user) { CommonName commonName = new CommonNameBLL().GetCommonNameByCommonName(commonNameDesc); if (commonName == null) { commonName = new CommonName(); commonName.CommonNameDesc = commonNameDesc; commonName.CreatedDate = DateTime.Now; commonName.CreatorUserID = user.UserID; commonName.EditedDate = DateTime.Now; commonName.EditorUserID = user.UserID; int commonNameID = new CommonNameBLL().CreateNewCommonName(commonName); } return(commonName); }
static void ReadCommonName(bool invalid) { if (invalid) { Console.WriteLine("Invalid common name!"); Console.WriteLine("Please enter a valid common name: (length must greater than 0 and without any white space)"); } else { Console.WriteLine("Please enter the common name:"); } CommonName = Console.ReadLine(); if (string.IsNullOrWhiteSpace(CommonName) || CommonName.Contains(" ")) { ReadCommonName(true); } }
public List <CommonName> FindAllCommonNames(int speciesId) { String commandText = "usp_GetSpeciesCommonNames"; List <CommonName> commonNames = new List <CommonName>(); try { using (SqlConnection conn = DataContext.GetConnection(this.GetConnectionStringKey(_context))) { using (SqlCommand cmd = new SqlCommand(commandText, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@taxonomy_species_id", speciesId); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) { while (reader.Read()) { CommonName commonName = new CommonName(); commonName.ID = Int32.Parse(reader["taxonomy_common_name_id"].ToString()); commonName.LanguageDescription = reader["language_description"].ToString(); commonName.Name = reader["name"].ToString(); commonName.SimplifiedName = reader["simplified_name"].ToString(); commonName.AlternateTranscription = reader["alternate_transcription"].ToString(); commonName.CitationTitle = reader["citation_title"].ToString(); commonName.ReferenceTitle = reader["citation_title"].ToString(); if (reader["modified_date"] != DBNull.Value) { commonName.ModifiedDate = DateTime.Parse(reader["modified_date"].ToString()); } commonNames.Add(commonName); } } } } } catch (Exception ex) { throw ex; } return(commonNames); }
public override int GetHashCode() { unchecked { var hashCode = SentBy?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (CommonName?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (DirectoryEntry?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Type?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(Members); hashCode = (hashCode * 397) ^ (Role?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (ParticipationStatus?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Rsvp.GetHashCode(); hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(DelegatedTo); hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(DelegatedFrom); hashCode = (hashCode * 397) ^ (Value?.GetHashCode() ?? 0); return(hashCode); } }
protected bool Equals(LipidTarget other) { if (LipidClass != LipidClass.Unknown && other.LipidClass != LipidClass.Unknown) { return(LipidClass == other.LipidClass && FragmentationMode == other.FragmentationMode && Equals(Composition, other.Composition) && AcylChainList.OrderBy(x => x.NumCarbons) .ThenBy(x => x.NumDoubleBonds) .ThenBy(x => x.AcylChainType) .SequenceEqual( other.AcylChainList.OrderBy(x => x.NumCarbons) .ThenBy(x => x.NumDoubleBonds) .ThenBy(x => x.AcylChainType))); } return(LipidClass == other.LipidClass && FragmentationMode == other.FragmentationMode && CommonName.Equals(other.CommonName)); }
public SpeciesCommonNameEditViewModel(CommonName commonName) { ID = commonName.ID; SpeciesID = commonName.SpeciesID; SpeciesName = commonName.SpeciesName; GenusID = commonName.GenusID; GenusName = commonName.GenusName; LanguageID = commonName.LanguageID; LanguageDescription = commonName.LanguageDescription; Name = commonName.Name; SimplifiedName = commonName.SimplifiedName; AlternateTranscription = commonName.AlternateTranscription; CreatedByCooperatorID = commonName.CreatedByCooperatorID; CreatedByCooperatorName = commonName.CreatedByCooperatorName; CreatedDate = commonName.CreatedDate; ModifiedByCooperatorID = commonName.ModifiedByCooperatorID; ModifiedByCooperatorName = commonName.ModifiedByCooperatorName; ModifiedDate = commonName.ModifiedDate; }
public IEnumerable <CommonName> GetCommonNames(int speciesId) { List <CommonName> commonNames = new List <CommonName>(); try { String commandText = "usp_TaxonomyCommonNames_Select"; using (SqlConnection conn = DataContext.GetConnection(this.GetConnectionStringKey(_context))) { using (SqlCommand cmd = new SqlCommand(commandText, conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@taxonomy_species_id", speciesId); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) { while (reader.Read()) { CommonName commonName = new CommonName(); commonName.ID = GetInt(reader["taxonomy_common_name_id"].ToString()); commonName.SpeciesID = GetInt(reader["taxonomy_species_id"].ToString()); commonName.LanguageDescription = reader["language_description"].ToString(); commonName.Name = reader["name"].ToString(); commonName.SimplifiedName = reader["simplified_name"].ToString(); commonName.AlternateTranscription = reader["alternate_transcription"].ToString(); commonNames.Add(commonName); } } } } } catch (SqlException ex) { throw ex; } return(commonNames); }
/// <summary> /// Deprecated Method for adding a new object to the CommonNames EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCommonNames(CommonName commonName) { base.AddObject("CommonNames", commonName); }
partial void OnCommonNameUpdated(CommonName commonName);
partial void OnCommonNameSaved(CommonName commonName);
public void NameShouldOnlyAppendTheCommonNameQualifierIfNecessary() { var auth = new CommonName("CN=Curtis Mitchell"); Assert.That(auth.Name.Equals("CN=Curtis Mitchell")); }
public void NameShouldHavePrependedQualifier() { var auth = new CommonName("Curtis Mitchell"); Assert.That(auth.Name.Equals("CN=Curtis Mitchell")); }
partial void OnCommonNameDeleting(CommonName commonName);
partial void OnCommonNameDeleted(CommonName commonName);
public ResultContainer UpdateCommonName(CommonName commonName) { return(_speciesDAO.UpdateCommonName(commonName)); }
public ResultContainer AddCommonName(CommonName commonName) { return(_speciesDAO.AddCommonName(commonName)); }
/// <summary> /// Returns true if IngredientObjectItems instances are equal /// </summary> /// <param name="other">Instance of IngredientObjectItems to be compared</param> /// <returns>Boolean</returns> public bool Equals(IngredientObjectItems other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Categories == other.Categories || Categories != null && Categories.SequenceEqual(other.Categories) ) && ( Nutrients == other.Nutrients || Nutrients != null && Nutrients.SequenceEqual(other.Nutrients) ) && ( CalorieConversionFactor == other.CalorieConversionFactor || CalorieConversionFactor != null && CalorieConversionFactor.Equals(other.CalorieConversionFactor) ) && ( ProteinConversionFactor == other.ProteinConversionFactor || ProteinConversionFactor != null && ProteinConversionFactor.Equals(other.ProteinConversionFactor) ) && ( Components == other.Components || Components != null && Components.SequenceEqual(other.Components) ) && ( Portions == other.Portions || Portions != null && Portions.SequenceEqual(other.Portions) ) && ( CommonName == other.CommonName || CommonName != null && CommonName.Equals(other.CommonName) ) && ( Footnote == other.Footnote || Footnote != null && Footnote.Equals(other.Footnote) ) && ( SearchTerm == other.SearchTerm || SearchTerm != null && SearchTerm.Equals(other.SearchTerm) ) && ( Score == other.Score || Score != null && Score.Equals(other.Score) )); }
public GetAnimalsByCommonName(CommonName commonName) { _commonName = commonName; }
protected void FormViewCommonName_ItemUpdating(object sender, FormViewUpdateEventArgs e) { TextBox txtCommonName = (TextBox)formViewCommonName.FindControl("txtCommonName"); TextBox txtScientificName = (TextBox)formViewCommonName.FindControl("txtScientificName"); CommonNameActionStatus status = Validate(txtCommonName.Text, txtScientificName.Text, actionType.update); if (status == CommonNameActionStatus.Success) { Type myType = (typeof(Organism)); PropertyInfo[] props = myType.GetProperties(); string[] arrNewValues = new string[e.NewValues.Keys.Count]; e.NewValues.Keys.CopyTo(arrNewValues, 0); Organism organism = new OrganismBLL().GetOrganismByOrganismID((int)e.Keys["OrganismId"]); User editor = new UserBLL().GetUserByUserName((HttpContext.Current.User.Identity).Name); CommonName commonName = new CommonNameBLL().GetOrCreateCommonName(txtCommonName.Text, editor); ScientificName scientificName = new ScientificNameBLL().GetScientificNameByScientificName(txtScientificName.Text); using (DatabaseContext _DatabaseContext = new DatabaseContext()) { if (commonName.CommonNameID == organism.CommonNameID) { CommonName dbContCommonName = _DatabaseContext.CommonNames.First(instance => instance.CommonNameID == organism.CommonNameID); dbContCommonName.CommonNameDesc = txtCommonName.Text; dbContCommonName.EditorUserID = editor.UserID; dbContCommonName.EditedDate = DateTime.Now; } else { Organism dbContOrganism = _DatabaseContext.Organisms.First(instance => instance.OrganismID == organism.OrganismID); dbContOrganism.CommonNameID = commonName.CommonNameID; dbContOrganism.CommonNameReference.EntityKey = commonName.EntityKey; } if (scientificName.ScientificNameID != organism.ScientificNameID) { Organism dbContOrganism = _DatabaseContext.Organisms.First(instance => instance.OrganismID == organism.OrganismID); dbContOrganism.ScientificNameID = scientificName.ScientificNameID; dbContOrganism.ScientificNameReference.EntityKey = scientificName.EntityKey; } _DatabaseContext.SaveChanges(); } foreach (var prop in props) { if (("System.String,System.Int32,System.Int,System.DateTime,System.Guid").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int o DateTime { if (!arrNewValues.Contains(prop.Name)) { e.NewValues[prop.Name] = prop.GetValue(organism, null); } } } e.NewValues["ScientificNameID"] = scientificName.ScientificNameID.ToString(); e.NewValues["CommonNameID"] = commonName.CommonNameID.ToString(); e.NewValues["EditorUserID"] = editor.UserID.ToString(); e.NewValues["EditedDate"] = DateTime.Now; } else { ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status)); e.Cancel = true; } }
public IEnumerable<Animal> GetAnimalsByCommonName(CommonName commonName) { return _database.Query(new GetAnimalsByCommonName(commonName)); }
public IEnumerable <Animal> GetAnimalsByCommonName(CommonName commonName) { return(_database.Query(new GetAnimalsByCommonName(commonName))); }