public void PrepareEncashmentForUser(string userId, string userName, CashEncashmentTrx cet) { userId.IsNullOrWhiteSpaceThrowArgumentException("You must be logged in"); cet.PaymentMethodId.IsNullOrWhiteSpaceThrowException("No method selected"); decimal currBalanceForUser = BalanceFor_User(userId, CashTypeENUM.Refundable); if (currBalanceForUser != cet.CurrentBalance_Refundable) { throw new Exception("Something is wrong. Previous balance does not match current balance."); } if (currBalanceForUser >= cet.Amount) { cet.IsApproved.MarkTrue(UserName, UserId); RandomNoGenerator randomGen = new RandomNoGenerator(3); cet.SecretNumber = randomGen.GetRandomNumber(1); PaymentMethod paymentMethod = PaymentMethodBiz.Find(cet.PaymentMethodId); paymentMethod.IsNullThrowException(); cet.SystemMessageToApplicant = paymentMethod.DetailInfoToDisplayOnWebsite; Person userPerson = UserBiz.GetPersonFor(userId); userPerson.IsNullThrowException("Person not found"); cet.PersonRequestingPaymentId = userPerson.Id; if (userPerson.CashEncashmentTrxs.IsNull()) { userPerson.CashEncashmentTrxs = new List <CashEncashmentTrx>(); } userPerson.CashEncashmentTrxs.Add(cet); CashEncashmentTrxBiz.CreateAndSave(cet); ErrorsGlobal.AddMessage("Encashment certificate created and approved."); } else { throw new Exception("Something went wrong. You do not have the balance"); } }