public virtual void RemoveCompetitor(Competitor competitor) { Competitors.Remove(competitor); }
/// <summary> /// Creates a new Business Competitor /// </summary> /// <param name="businessId">businessId</param> /// <param name="businessVersion">businessVersion</param> /// <param name="competitor">competitor to be created</param> public void CreateNewBusinessCompetitor(int businessId, int businessVersion, Competitor competitor) { try { IBusinessInformationDAO businessInformationDAO = _daoFactory.GetBusinessInformationDAO (); //Get all the business products. Note that I retrieve all products in a batch base //and don't care about the number of records. This is because it is not likely //the business will contain hundreds of products BusinessInformation businessInformation = businessInformationDAO.FindByIdAndVersion ( businessId, businessVersion); if (businessInformation == null) throw new ZiblerBusinessComponentsException (Resources.RecordNotFound); else { foreach (Competitor existingCompetitor in businessInformation.Competitors) { if (existingCompetitor.Name == competitor.Name) { //Throw an exception and indicate the product already exists throw new ZiblerBusinessComponentsException ( Resources.LoanRequestOperationsMsgBusinessAlreadyHasCompetitor); } } //Since no exception was thrown, then we add the new client to the list. businessInformation.AddCompetitor (competitor); } } /* If the exception was thrown here, just pass it up */ catch (ZiblerBusinessComponentsException ex) { throw; } /* Catch any Data Layer or other exception and throw an unkown exception */ catch (Exception ex) { ZiblerBusinessComponentsUnknownException exc = new ZiblerBusinessComponentsUnknownException (ex); /* Throw the new exception */ throw exc; } }
public virtual void AddCompetitor(Competitor newCompetitor) { newCompetitor.BusinessInformation = this; Competitors.Add(newCompetitor); }