public void DeleteScientificName(ScientificName scientificNameToBeDeleted) { //Validate Input if (scientificNameToBeDeleted == null) { throw (new ArgumentNullException("scientificNameToBeDeleted")); } // Validate Primary key value if (scientificNameToBeDeleted.ScientificNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID"); } OnScientificNameSaving(scientificNameToBeDeleted); OnScientificNameDeleting(scientificNameToBeDeleted); if (scientificNameToBeDeleted.EntityState == EntityState.Detached) { _DatabaseContext.ScientificNames.Attach(scientificNameToBeDeleted); } _DatabaseContext.ScientificNames.DeleteObject(scientificNameToBeDeleted); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No ScientificName deleted!"); } OnScientificNameDeleted(scientificNameToBeDeleted); OnScientificNameSaved(scientificNameToBeDeleted); }
public virtual int CreateNewScientificName(ScientificName newScientificName) { // Validate Parameters if (newScientificName == null) { throw (new ArgumentNullException("newScientificName")); } // Apply business rules OnScientificNameSaving(newScientificName); OnScientificNameCreating(newScientificName); _DatabaseContext.ScientificNames.AddObject(newScientificName); int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No scientificName created!"); } // Apply business workflow OnScientificNameCreated(newScientificName); OnScientificNameSaved(newScientificName); return(newScientificName.ScientificNameID); }
public void UpdateScientificName(ScientificName updatedScientificName) { // Validate Parameters if (updatedScientificName == null) { throw (new ArgumentNullException("updatedScientificName")); } // Validate Primary key value if (updatedScientificName.ScientificNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID"); } // Apply business rules OnScientificNameSaving(updatedScientificName); OnScientificNameUpdating(updatedScientificName); //attaching and making ready for parsistance if (updatedScientificName.EntityState == EntityState.Detached) { _DatabaseContext.ScientificNames.Attach(updatedScientificName); } _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedScientificName, System.Data.EntityState.Modified); //this line makes the code un-testable! int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows == 0) { throw new DataNotUpdatedException("No scientificName updated!"); } //Apply business workflow OnScientificNameUpdated(updatedScientificName); OnScientificNameSaved(updatedScientificName); }
public void DeleteScientificNames(List <int> scientificNameIDsToDelete) { //Validate Input foreach (int scientificNameID in scientificNameIDsToDelete) { if (scientificNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID"); } } List <ScientificName> scientificNamesToBeDeleted = new List <ScientificName>(); foreach (int scientificNameID in scientificNameIDsToDelete) { ScientificName scientificName = new ScientificName { ScientificNameID = scientificNameID }; _DatabaseContext.ScientificNames.Attach(scientificName); _DatabaseContext.ScientificNames.DeleteObject(scientificName); scientificNamesToBeDeleted.Add(scientificName); OnScientificNameDeleting(scientificName); } int numberOfAffectedRows = _DatabaseContext.SaveChanges(); if (numberOfAffectedRows != scientificNameIDsToDelete.Count) { throw new DataNotUpdatedException("One or more scientificName records have not been deleted."); } foreach (ScientificName scientificNameToBeDeleted in scientificNamesToBeDeleted) { OnScientificNameDeleted(scientificNameToBeDeleted); } }
public IActionResult EditName(int id, ScientificName scientific) { if (id != scientific.Id) { return(ViewBag.Message = "Invalid Id"); } _db.EditName(scientific); return(RedirectToAction(nameof(GetScientificNames))); }
public void EditName(ScientificName scientific) { var newName = _db.ScientificNames.Where(c => c.Id == scientific.Id).FirstOrDefault(); newName.Name = scientific.Name; newName.UpdatedOn = DateTime.Now; _db.SaveChanges(); }
public string AddName(ScientificName scientific) { scientific.CreatedOn = DateTime.Now; scientific.UpdatedOn = DateTime.Now; _db.ScientificNames.Add(scientific); _db.SaveChanges(); var sucess = "Sucess"; return(sucess); }
protected void formViewScientificName_DataBinding(object sender, EventArgs e) { string scientificNameID = Page.RouteData.Values["ScientificName_id"] as string; if (scientificNameID != null && scientificNameID != "0") { ScientificName scientificName = new ScientificNameBLL().GetScientificNameByScientificNameID(Convert.ToInt32(scientificNameID)); this.editor = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(scientificName.EditorUserID); this.creator = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(scientificName.CreatorUserID); this.scientificName = scientificName; } }
public IActionResult AddScientificNames(ScientificName scientific) { var name = _db.GetColors().FindAll(a => a.Name == scientific.Name).Count(); if (name == 0) { _db.AddName(scientific); return(RedirectToAction(nameof(GetScientificNames))); } ViewBag.Message = "already exists"; return(View()); }
public ScientificName GetScientificNameByScientificNameId2(int scientificNameID) { //Validate Input if (scientificNameID.IsInvalidKey()) { BusinessLayerHelper.ThrowErrorForInvalidDataKey("scientificNameID"); } ScientificName scientificName = (_DatabaseContext.ScientificNames.FirstOrDefault(instance => instance.ScientificNameID == scientificNameID)); // var ass = scientificName.ScientificNameCreator.UserName; return(scientificName); }
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); }
protected void FormViewScientificName_ItemUpdating(object sender, FormViewUpdateEventArgs e) { TextBox txtScientificName = (TextBox)formViewScientificName.FindControl("txtScientificName"); ScientificNameActionStatus status = Validate(txtScientificName.Text, actionType.update); if (status == ScientificNameActionStatus.Success) { Type myType = (typeof(ScientificName)); PropertyInfo[] props = myType.GetProperties(); string[] arrNewValues = new string[e.NewValues.Keys.Count]; e.NewValues.Keys.CopyTo(arrNewValues, 0); ScientificNameBLL scientificNameBLL = new ScientificNameBLL(); ScientificName scientificName = scientificNameBLL.GetScientificNameByScientificNameId2((int)e.Keys["ScientificNameId"]); foreach (var prop in props) { if (("System.String,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(scientificName, null); } } } User editor = new UserBLL().GetUserByUserName((HttpContext.Current.User.Identity).Name); e.NewValues["EditorUserId"] = editor.UserID.ToString(); e.NewValues["EditedDate"] = DateTime.Now; } else { ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status)); e.Cancel = true; } }
partial void OnScientificNameSaved(ScientificName scientificName);
partial void OnScientificNameCreated(ScientificName scientificName);
public void DeleteScientificName(ScientificName scientific) { _db.ScientificNames.Remove(scientific); _db.SaveChanges(); }
partial void OnScientificNameSaving(ScientificName scientificName);
public IActionResult NameDelete(ScientificName scientific) { _db.DeleteScientificName(scientific); return(RedirectToAction(nameof(GetScientificNames))); }
partial void OnScientificNameUpdated(ScientificName scientificName);
/// <summary> /// Deprecated Method for adding a new object to the ScientificNames EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToScientificNames(ScientificName scientificName) { base.AddObject("ScientificNames", scientificName); }
partial void OnScientificNameDeleted(ScientificName scientificName);
public override int GetHashCode() { return(ScientificName.GetHashCode()); }