public CreditCardDomainEntity With( decimal limit, int extreDay, int type, string validMonth, string validYear, string securityCode, bool isInternetUsageOpen, ICreditCardOwner creditCardOwner) { if (limit <= 0) { throw new AccountManagementException.CreditCardLimitCouldNotBeZeroOrNegative(string.Format("{0} = {1}", nameof(limit), limit)); } if (extreDay <= 0) { throw new AccountManagementException.CreditCardExtreDayCouldNotZeroOrNegative(string.Format("{0} = {1}", nameof(extreDay), extreDay)); } CreditCardDomainEntity cc = null; try { cc = creditCardRepository.GetByCreditCardOwner(creditCardOwner); } catch (Exception ex) { } if (cc != null) { throw new AccountManagementException.CreditCardOwnerHasAlreadyCreditCard(string.Format("Owner:{0} - Id: {1}", creditCardOwner.CreditCardOwnerType, creditCardOwner.OwnerId)); } CreditCardNumber = GenerateCrediCardNumber(); Limit = limit; ExtreDay = extreDay; Debt = 0; Type = type; ValidMonth = string.IsNullOrWhiteSpace(validMonth) == false ? validMonth : throw new CommonException.RequiredParameterMissingException(nameof(validMonth)); ValidYear = string.IsNullOrWhiteSpace(validYear) == false ? validYear : throw new CommonException.RequiredParameterMissingException(nameof(validYear)); SecurityCode = string.IsNullOrWhiteSpace(securityCode) == false ? securityCode : throw new CommonException.RequiredParameterMissingException(nameof(securityCode)); IsInternetUsageOpen = isInternetUsageOpen; CreditCardOwner = creditCardOwner ?? throw new CommonException.RequiredParameterMissingException(nameof(creditCardOwner));; return(this); }