public AccountsController( IMaskIds maskIds, //IRepository<Account> accountRepository, IAccountRepository accountRepository, IAppUserRepository appUserRepository, IDropDownListRepository <Country> countryRepository, IDropDownListRepository <Gender> genderRepository, IDropDownListRepository <Currency> currencyRepository, IAccountTypeRepository accountTypeRepository, ITransactionType transactionTypeRepository, IOrderByTypeRepository orderByTypeRepository, ISetAccountRate satAccountRate, UserManager <AppUser> userManager, IUnitOfWorkB <Account> unitOfWorkAccount, IMapper mapper) { _maskIds = maskIds; _accountRepository = accountRepository; _appUserRepository = appUserRepository; _countryRepository = countryRepository; _genderRepository = genderRepository; _currencyRepository = currencyRepository; _accountTypeRepository = accountTypeRepository; _transactionTypeRepository = transactionTypeRepository; _orderByTypeRepository = orderByTypeRepository; _userManager = userManager; _unitOfWorkAccount = unitOfWorkAccount; _cancellationToken = new CancellationToken(); _setAccounRate = satAccountRate; _mapper = mapper; }
public Transaction(IProcessExecutionContext executionContext, IAgentFactory agentFactory, ITransactionFeeListFactory transactionFeeListFactory, ITransactionContextFactory transactionContextFactory, ICustomerFactory customerFactory, ITransactionDeficienciesFactory transactionDeficienciesFactory, IDocumentService documentService, IEvidenceService evidenceService, ILocationFactory locationFactory, IRequirementEvaluator requirementEvaluator, ITransactionHistoryFactory transactionHistoryFactory, ITransactionService transactionService, ITransactionType transactionType, ITransactionRecord record) : base(record.RecordType, record.Id) { this.ExecutionContext = executionContext ?? throw new ArgumentNullException("executionContext"); this.AgentFactory = agentFactory ?? throw new ArgumentNullException("agentFactory"); this.TransactionFeeListFactory = transactionFeeListFactory ?? throw new ArgumentNullException("transactionFeeListFactory"); this.TransactionContextFactory = transactionContextFactory ?? throw new ArgumentNullException("transactionContextFactory"); this.CustomerFactory = customerFactory ?? throw new ArgumentNullException("customerFactory"); this.TransactionDeficienciesFactory = transactionDeficienciesFactory ?? throw new ArgumentNullException("transactionDeficienciesFactory"); this.DocumentService = documentService ?? throw new ArgumentNullException("documentService"); this.EvidenceService = evidenceService ?? throw new ArgumentNullException("evidenceService"); this.LocationFactory = locationFactory ?? throw new ArgumentNullException("locationFactory"); this.RequirementEvaluator = requirementEvaluator ?? throw new ArgumentNullException("requirementEvaluator"); this.TransactionHistoryFactory = transactionHistoryFactory ?? throw new ArgumentNullException("transactionHistoryFactory"); this.TransactionService = transactionService ?? throw new ArgumentNullException("transactionService"); this.TransactionType = transactionType ?? throw new ArgumentNullException("transactionType"); this.Name = record.Name; this.ReferenceNumber = record.ReferenceNumber; this.PricingDate = record.PricingDate ?? DateTime.Now.Date; this.InitiatingProcessId = record.InitiatingProcessId ?? throw new ArgumentNullException("InitiatingProcessId"); this.CurrentProcessId = record.CurrentProcessId ?? throw new ArgumentNullException("CurrentProcessId"); this.CurrentStepId = record.CurrentStepId ?? throw new ArgumentNullException("CurrentStepId"); this.ContextRecordId = record.ContextRecordId ?? throw new ArgumentNullException("contextRecordId"); this.CustomerId = record.CustomerId ?? throw new ArgumentNullException("customerId"); this.InitiatingAgentId = record.InitiatingAgentId ?? throw new ArgumentNullException("initiatingAgentId"); this.InitiatingLocationId = record.InitiatingLocationId ?? throw new ArgumentNullException("initiatingLocationId"); }
public void SaveTransaction(ITransactionType TransactionType) { using (UnitOfWork unitOfWork = new UnitOfWork((TransactionType as BaseObject).Session.DataLayer)) { ITransactionType transactionType = unitOfWork.FindObject <WorkFlowPayment>(CriteriaOperator.Parse("Oid == ?", TransactionType.Oid)); if (transactionType == null) { return; } if (transactionType.ITransaction == null) { transactionType.ITransaction = new Transaction(unitOfWork) { Vendor = transactionType.IVendor as Vendor, Payment = transactionType as WorkFlowPayment, Credit = transactionType.Amount, TransactionDate = transactionType.TransactionDate, AdditionalDescription = transactionType.AdditionalDescription }; } else { transactionType.ITransaction.IVendor = transactionType.IVendor; transactionType.ITransaction.Credit = transactionType.Amount; transactionType.ITransaction.TransactionDate = transactionType.TransactionDate; transactionType.ITransaction.AdditionalDescription = transactionType.AdditionalDescription; } unitOfWork.CommitChanges(); (TransactionType as BaseObject).Session.Reload(TransactionType); } }
public Task <int> SaveAsync(ITransactionType transactionType) { return(Task.Factory.StartNew <int>(() => { return Save(transactionType); })); }
public transactiontypesController(ITransactionType transactionService) { if (transactionService == null) { throw new Exception("Transaction service injection failed."); } _transactionService = transactionService; }
public Transaction(IClient customer, IOffer offer, ITransactionType transactionType, double price, double discount, DateTime date, int rating) { this.customer = customer; this.offer = offer; this.transactionType = transactionType; this.price = price; this.discount = discount; this.date = date; this.rating = rating; ID = Guid.NewGuid(); }
public schemeController(ISchemes schemeService, IRoutes routeService, IFees feesService, IChannels channelsService, ITransactionType transService) { if (schemeService == null) { throw new Exception("The Scheme service injection failed."); } _schemeService = schemeService; _routesService = routeService; _feesService = feesService; _channelsService = channelsService; _transTypeService = transService; }
public Transaction(DateTime transactionDate, int transactionCategory, IClient buyer, IClient seller, double transactionPrice, ITransactionType transactionType, byte transactionEvaluation, double discount) { Id = Guid.NewGuid(); TransactionDate = transactionDate; TransactionCategory = transactionCategory; Buyer = buyer; Seller = seller; TransactionPrice = transactionPrice; TransactionType = transactionType; TransactionEvaluation = transactionEvaluation; Discount = discount; }
public void CreateTransaction_ValidTest(int year, int month, int day, int rating, string transcationTypeKey) { IEmailSender emailSender = Substitute.For <IEmailSender>(); IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(); ISalesManager salesManager = new SalesManager(); ShoppingClient.Clients.Clear(); ShoppingOffers.Offers.Clear(); clientManager.RegisterUser("Pera", "Peric", "*****@*****.**", "peraPeric123", "Novi Sad", new DateTime(1992, 5, 6), new List <IAccount>()); clientManager.RegisterOrg("Prodavnica", "q234ffsad", "Novi Sad", "*****@*****.**", new DateTime(2010, 1, 1), new List <IAccount>()); IClient client = ShoppingClient.Clients.FirstOrDefault(x => x is FizickoLice); IClient company = ShoppingClient.Clients.FirstOrDefault(x => x is PravnoLice); IProduct product = new Product("Product", "Description", 3000, 1); salesManager.CreateOffer(company, new List <IProduct>() { product }, new List <ITransport>()); financeManager.CreateAccount("41234123453425", new Bank(), 100000, 0, false); financeManager.CreateAccount("456345634567456", new Bank(), 100000, 0, false); IAccount customerAccount = FinantialDB.Accounts.Values.ToList()[0]; IAccount companyAccount = FinantialDB.Accounts.Values.ToList()[1]; client.ListOfAccounts.Add(customerAccount); customerAccount.Balance = 1000000; company.ListOfAccounts.Add(companyAccount); companyAccount.Balance = 2000000; IOffer offer = ShoppingOffers.Offers.Values.ToList()[0]; offer.SubmitionDate = new DateTime(year, month, day); ITransactionManager transactionManager = new TransactionManager(clientManager, salesManager, financeManager, emailSender); ITransactionType transactionType = ShoppingTransaction.TransactionTypes[transcationTypeKey]; transactionManager.CreateTransaction(client.ID, company.ID, offer.ID, transactionType.ID, rating); Assert.IsTrue(client.ListOfBuyingTransaction.Count == 1); Assert.IsTrue(company.ListOfSellingTransaction.Count == 1); }
public void DeleteTransaction(ITransactionType TransactionType) { using (UnitOfWork unitOfWork = new UnitOfWork((TransactionType as BaseObject).Session.DataLayer)) { ITransactionType transactionType = unitOfWork.FindObject <WorkFlowPayment>(CriteriaOperator.Parse("Oid == ?", TransactionType.Oid)); if (transactionType == null) { return; } if (transactionType.ITransaction != null) { (transactionType.ITransaction as Transaction).Delete(); } unitOfWork.CommitChanges(); (TransactionType as BaseObject).Session.Reload(TransactionType); } }
public void Dispose() { transactionType = null; }
public override void Build <T>(T resultClass) { transactionType = (TransactionType)resultClass.GetType().GetMethod("Convert").Invoke(resultClass, null); }
public void DeleteTransaction(ITransactionType TransactionType) { _strategies[TransactionType.TransactionType].DeleteTransaction(TransactionType); }
public int Save(ITransactionType transactionType) { string query = @"INSERT INTO [dbo].[TransactionType] ([Name] ,[Description] ,[Color] ,[Income]) OUTPUT INSERTED.Id VALUES ( @Name , @Description , @Color , @Income)"; if (transactionType.Id != 0) { query = @"UPDATE [dbo].[TransactionType] SET [Name] = @Name ,[Description] = @Description ,[Color] = @Color ,[Income] = @Income WHERE Id = @Id"; } IList <SqlParameter> sqlParameterCollection = new List <SqlParameter>(); sqlParameterCollection.Add(new SqlParameter("@Income", transactionType.Income)); if (string.IsNullOrWhiteSpace(transactionType.Description)) { sqlParameterCollection.Add(new SqlParameter("@Description", DBNull.Value)); } else { sqlParameterCollection.Add(new SqlParameter("@Description", transactionType.Description)); } if (string.IsNullOrWhiteSpace(transactionType.Name)) { sqlParameterCollection.Add(new SqlParameter("@Name", DBNull.Value)); } else { sqlParameterCollection.Add(new SqlParameter("@Name", transactionType.Name)); } if (string.IsNullOrWhiteSpace(transactionType.Color)) { sqlParameterCollection.Add(new SqlParameter("@Color", DBNull.Value)); } else { sqlParameterCollection.Add(new SqlParameter("@Color", transactionType.Color)); } if (transactionType.Id != 0) { sqlParameterCollection.Add(new SqlParameter("@Id", transactionType.Id)); SqlService.ExecuteNonQuery(query, sqlParameterCollection.ToArray()); return(transactionType.Id); } else { return(SqlService.ExecuteScalar(query, sqlParameterCollection.ToArray())); } }
public void SaveTransaction(ITransactionType TransactionType) { _strategies[TransactionType.TransactionType].SaveTransaction(TransactionType); }
public ITransaction CreateTransaction(DateTime date, int transactionCategory, Guid buyerId, Guid sellerId, IOffer offer, double transactionPrice, ITransactionType transactionType, byte evaluation, IEmailSender emailSender) { ITransaction transaction = new Transaction(date, transactionCategory, null, null, transactionPrice, null, evaluation, 0); transaction.Buyer = ClientManager.GetClientById(buyerId); transaction.Seller = ClientManager.GetClientById(sellerId); transaction.TransactionPrice = offer.OfferPrice + offer.TransportPrice; double discount = offer.CheckDiscount(DateTime.Now); transaction.Discount = discount; IAccount accountWithEnoughMoney = null; foreach (IAccount account in transaction.Buyer.Accounts) { if (account.Amount > transaction.TransactionPrice) { accountWithEnoughMoney = account; break; } } transaction.TransactionEvaluation = evaluation; if (accountWithEnoughMoney != null) { if (transactionType is WithoutInstalmentsTransactionType) { accountWithEnoughMoney.Amount -= transaction.TransactionPrice * (1 - transaction.Discount); transaction.TransactionCategory = 0; transaction.Buyer.Transactions.Add(transaction); transaction.TransactionCategory = 1; transaction.Seller.Transactions.Add(transaction); TransactionList.AddTransaction(transaction); emailSender.SendEmail("Transaction was sucessfull", transaction.Buyer.Email); } else if (transactionType is InstalmentsTransactionType) { accountWithEnoughMoney.Amount -= ((InstalmentsTransactionType)transactionType).InstalmentPrice * transaction.Discount; transaction.TransactionCategory = 0; transaction.Buyer.Transactions.Add(transaction); transaction.TransactionCategory = 1; transaction.Seller.Transactions.Add(transaction); TransactionList.AddTransaction(transaction); emailSender.SendEmail("Transaction was sucessfull", transaction.Buyer.Email); } } else { emailSender.SendEmail("On your accounts there is not enough money", transaction.Buyer.Email); return(null); } return(transaction); }
public ITransaction NewTransaction(IProcessExecutionContext executionContext, IWorkSession workSession, ITransactionContext transactionContext, ITransactionType transactionType) { try { if (executionContext is null) { throw new ArgumentNullException("executionContext"); } if (workSession == null) { throw new ArgumentNullException("workSession"); } if (transactionContext == null) { throw new ArgumentNullException("transactionContext"); } if (transactionType == null) { throw new ArgumentNullException("transactionType"); } if (workSession.Location == null) { throw new ArgumentException("WorkSession is missing required Location."); } if (workSession.Agent == null) { throw new ArgumentException("WorkSession is missing required Agent."); } if (transactionContext.Customer == null) { throw new ArgumentException("Transaction context is missing required Customer."); } var initialProcess = transactionType.AvailableProcesses.Where(r => r.Id == transactionType.StartUpProcessId.Id).FirstOrDefault(); if (initialProcess == null) { throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessNotFound); } var initialStep = initialProcess.GetInitialStep(); if (initialStep == null) { throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessStepNotFound); } ITransactionRecord transactionRecord = DataConnector.NewTransactionRecord( executionContext.DataService, workSession.Agent, workSession.Location, transactionContext.Customer, transactionContext as IRecordPointer <Guid>, transactionType, initialProcess, initialProcess, initialStep, transactionType.Name); executionContext.TrackEvent("Created New Transaction"); var transaction = buildTransaction(executionContext, transactionRecord); transaction.TransactionHistory.AddToHistory(executionContext, workSession, transaction.CurrentStep, false); //create transaction fees entries for any items on the initial fee schedule foreach (var feeId in transactionType.InitialFeeSchedule) { var fee = FeeList.GetFee(executionContext, feeId); transaction.Fees.AddFee(executionContext, workSession, fee); } return(transaction); } catch (Exception ex) { throw ex; } }