public static void DecreaseCostOfSmsSend(Guid userGuid, Common.SmsSendType smsSendType, decimal price, string description, Guid smsSentGuid, DataAccessBase dataAccessBase) { Business.Transaction transactionController = new Business.Transaction(dataAccessBase); Business.User userController = new Business.User(dataAccessBase); Common.User user = new Common.User(); lock (lockDecreaseCostOfSmsSend) { transactionController.BeginTransaction(); try { userController.Load(userGuid, user); if (price > user.Credit) { throw new UserCreditNotEnoughException(); } Decrease(userGuid, price, GetTypeCreditChanges(smsSendType), description, smsSentGuid, transactionController.DataAccessProvider); transactionController.CommitTransaction(); } catch (Exception ex) { transactionController.RollbackTransaction(); throw new InnerTransactionException(ex); } } }
private static TypeCreditChanges GetTypeCreditChanges(Common.SmsSendType smsSendType) { switch (smsSendType) { case Common.SmsSendType.SendSms: return(Business.TypeCreditChanges.SendSms); } return(Business.TypeCreditChanges.SendSms); }