/// <summary> /// Creates a new Business Client /// </summary> /// <param name="businessId">businessId</param> /// <param name="businessVersion">businessVersion</param> /// <param name="client">client to be created</param> public void CreateNewBusinessClient(int businessId, int businessVersion, BusinessClient client) { 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 (BusinessClient existingClient in businessInformation.BusinessClients) { if (existingClient.Name == client.Name) { //Throw an exception and indicate the product already exists throw new ZiblerBusinessComponentsException ( Resources.LoanRequestOperationsMsgBusinessAlreadyHasClient); } } //Since no exception was thrown, then we add the new client to the list. businessInformation.AddBusinessClient (client); } } /* 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 RemoveBusinessClient(BusinessClient businessClient) { BusinessClients.Remove(businessClient); }
public virtual void AddBusinessClient(BusinessClient newBusinessClient) { newBusinessClient.BusinessInformation = this; BusinessClients.Add(newBusinessClient); }