public TransactionController(TransactionDbContext context) { _context = context; if (!_context.Transactions.Any()) { Random r = new Random(); for (int i = 0; i < 10; i++) { Transaction t = new Transaction(); t.Amount = r.NextDouble(); Address a = new Address { Line1 = String.Format("{0}{0}{0} Home Lame", r.Next(10), r.Next(10), r.Next(10)), City = "Dallas", State = State.TX, ZipCode = "7526" + r.Next(10) }; t.Payee = new Person { FirstName = "Payer" + i, LastName = "McPayerson", EmailAddress = "*****@*****.**", PhoneNumber = "(111) 111-1111", HomeAddress = a }; t.Payer = new Person { FirstName = "Apayee" + i, LastName = "Payeeson", EmailAddress = "*****@*****.**", PhoneNumber = "(222) 151-1213", HomeAddress = a }; _context.Addresses.Add(a); _context.People.Add(t.Payee); _context.People.Add(t.Payer); _context.Transactions.Add(t); } _context.SaveChanges(); } }
public TransactionServiceTests() { var builder = new DbContextOptionsBuilder <TransactionDbContext>(); builder.UseInMemoryDatabase("test_db"); _dbContext = new TransactionDbContext(builder.Options); PopulateDatabase(); _transactionService = new TransactionService(_dbContext, NullLoggerFactory.Instance.CreateLogger <TransactionService>()); }
public TransactionTests() { LoggedInAccountId = 1; var testTransactionOptions = new DbContextOptionsBuilder <TransactionDbContext>() .UseInMemoryDatabase("TestTransactionsDatabase") .Options; _testTransactionDbContext = new TransactionDbContext(testTransactionOptions); _testTransactionQueries = new TransactionQueries(_testTransactionDbContext, LoggedInAccountId); _testDepositService = new DepositService(_testTransactionQueries); _testWithdrawalService = new WithdrawalService(_testTransactionQueries); _testAccountHistoryService = new AccountHistoryService(_testTransactionQueries); }
public async Task <List <T_Arrival_Header> > GetArrival(string arrno, string docno, int?arrType, int?rawMatType, DateTime?arrdateF, DateTime?arrdateT, DateTime?docdateF, DateTime?docdateT) { try { using (var context = new TransactionDbContext(contextOptions)) { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strArrivalNo", arrno), new MySqlParameter("strDocumentNo", docno), new MySqlParameter("strArrivalTypeId", arrType), new MySqlParameter("strRawMatTypeId", rawMatType), new MySqlParameter("strArrivalDateF", arrdateF), new MySqlParameter("strArrivalDateT", arrdateT), new MySqlParameter("strDocRefDateF", docdateF), new MySqlParameter("strDocRefDateT", docdateT), new MySqlParameter("strCompanyCode", this.compCode), }; var objList = await context.Query <T_Arrival_HeaderObj>().FromSql("call sp_arrival_hdr_gets(?, ?, ?, ?, ?, ?, ?, ?, ?)", parameters: sqlParams).ToListAsync(); return(objList.ConvertAll(a => new T_Arrival_Header { Id = a.Id, ArrivalNo = a.ArrivalNo, ArrivalDate = a.ArrivalDate, RawMatTypeId = a.RawMatTypeId, RawMatTypeName = a.RawMatTypeName, VendorId = a.VendorId, VendorCode = a.VendorCode, VendorName = a.VendorName, VendorAddress = a.VendorAddress, ArrivalTypeId = a.ArrivalTypeId, ArrivalTypeName = a.ArrivalTypeName, PurchaseOrderNo = a.PurchaseOrderNo, DocRefNo = a.DocRefNo, DocRefDate = a.DocRefDate, ArrivalRemark = a.ArrivalRemark, CompanyCode = a.CompanyCode, Is_Active = a.Is_Active, Created_Date = a.Created_Date, Created_By = a.Created_By, Updated_Date = a.Updated_Date, Updated_By = a.Updated_By })); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Seed database /// </summary> /// <param name="context"></param> /// <returns></returns> private static void Seed(TransactionDbContext context) { if (!context.Addresses.Any()) { Address wAddress = new Address(); wAddress.Line1 = "111 Work Place Circle"; wAddress.City = "Tucson"; wAddress.State = State.AZ; wAddress.ZipCode = "85747"; context.Addresses.Add(wAddress); Address hAddress = new Address(); hAddress.Line1 = "222 Home Lane"; hAddress.City = "Dallas"; hAddress.State = State.TX; hAddress.ZipCode = "75261"; context.Addresses.Add(hAddress); } if (!context.People.Any()) { for (int i = 0; i < 5; i++) { Person p = new Person(); p.EmailAddress = String.Format("p{0}@gmail.com", i); p.FirstName = String.Format("First{0}", i); p.LastName = String.Format("First{0}", i); p.PhoneNumber = String.Format("({0}{0}{0}) {0}{0}{0}-{0}{0}{0}{0}", i); p.HomeAddress = context.Addresses.FirstOrDefault(); context.People.Add(p); } } if (!context.Transactions.Any()) { Random r = new Random(); for (int i = 10; i < 10; i++) { Transaction t = new Transaction(); t.Amount = r.NextDouble(); t.Payee = context.People.Where(x => x.Id == 1).FirstOrDefault(); t.Payer = context.People.Where(x => x.Id == 2).FirstOrDefault(); } } context.SaveChangesAsync(); }
public void SaveTransaction(Transaction transaction) { try { using (var transactionCtx = new TransactionDbContext(GetConnectionString())) { transactionCtx.Transactions.Add(transaction); transactionCtx.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <List <T_Arrival_Detail> > GetArrivalDetails(int?arrId) { try { using (var context = new TransactionDbContext(contextOptions)) { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strArrivalId", arrId) }; var objList = await context.Query <T_Arrival_DetailObj>().FromSql("call sp_arrival_dtl_get(?)", parameters: sqlParams).ToListAsync(); return(objList.ConvertAll(a => new T_Arrival_Detail { Id = a.Id, ArrivalId = a.ArrivalId, LineNo = a.LineNo, PoLineNo = a.PoLineNo, MaterialId = a.MaterialId, MaterialCode = a.MaterialCode, MaterialName = a.MaterialName, MaterialDesc = a.MaterialDesc, OrderQty = a.OrderQty, RecvQty = a.RecvQty, LotNo = a.LotNo, LotDate = a.LotDate, DetailRemark = a.DetailRemark, GenLabelStatus = a.GenLabelStatus, NoOfLabel = a.NoOfLabel, CompanyCode = a.CompanyCode, RecordFlag = a.RecordFlag, Is_Active = a.Is_Active, Created_Date = a.Created_Date, Created_By = a.Created_By, Updated_Date = a.Updated_Date, Updated_By = a.Updated_By, PackageStdQty = a.PackageStdQty })); } } catch (Exception ex) { throw ex; } }
public override List <Transaction> GetAll(int id = 0) { List <Transaction> transactions; try { using (var transactionCtx = new TransactionDbContext(GetConnectionString())) { transactions = transactionCtx.Transactions.Where(t => t.Id == id).ToList(); } } catch (Exception e) { Console.WriteLine(e); throw; } return(transactions); }
public async Task <List <T_Arrival_Header> > GetArrival(int?id) { try { using (var context = new TransactionDbContext(contextOptions)) { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strId", id) }; var objList = await context.Query <T_Arrival_HeaderObj>().FromSql("call sp_arrival_hdr_get(?)", parameters: sqlParams).ToListAsync(); return(objList.ConvertAll(a => new T_Arrival_Header { Id = a.Id, ArrivalNo = a.ArrivalNo, ArrivalDate = a.ArrivalDate, RawMatTypeId = a.RawMatTypeId, RawMatTypeName = a.RawMatTypeName, VendorId = a.VendorId, VendorCode = a.VendorCode, VendorName = a.VendorName, VendorAddress = a.VendorAddress, ArrivalTypeId = a.ArrivalTypeId, ArrivalTypeName = a.ArrivalTypeName, PurchaseOrderNo = a.PurchaseOrderNo, DocRefNo = a.DocRefNo, DocRefDate = a.DocRefDate, ArrivalRemark = a.ArrivalRemark, CompanyCode = a.CompanyCode, Is_Active = a.Is_Active, Created_Date = a.Created_Date, Created_By = a.Created_By, Updated_Date = a.Updated_Date, Updated_By = a.Updated_By })); } } catch (Exception ex) { throw ex; } }
public static async Task DispatchDomainEventsAsync(this IMediator mediator, TransactionDbContext ctx) { var domainEntities = ctx.ChangeTracker .Entries <Entity>() .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any()); var domainEvents = domainEntities .SelectMany(x => x.Entity.DomainEvents) .ToList(); domainEntities.ToList() .ForEach(entity => entity.Entity.ClearDomainEvents()); var tasks = domainEvents .Select(async(domainEvent) => { await mediator.Publish(domainEvent); }); await Task.WhenAll(tasks); }
static void Main(string[] args) { var transactionDbContext = new TransactionDbContext(); try { transactionDbContext.Database.Migrate(); } catch (Exception e) { Console.WriteLine("Migrations went wrong"); Console.WriteLine(e); } try { Console.WriteLine("Starting to produce messages"); var producer = new Producer(); while (true) { producer.StartProducing(100000).Wait(); Console.WriteLine("Finished procducing. Press q to quit or any key to produce again"); var readLine = Console.ReadLine(); if ("q".Equals(readLine)) { break; } } } catch (Exception e) { Console.WriteLine("Producing went wrong"); Console.WriteLine(e); } Console.ReadLine(); Thread.Sleep(1000000); transactionDbContext.Dispose(); }
public async Task <List <T_Arrival_Detail_Sub> > GetArrivalDetailSub(int?arrDtlId, int?arrDtlLine) { try { using (var context = new TransactionDbContext(contextOptions)) { MySqlParameter[] sqlParams = new MySqlParameter[] { new MySqlParameter("strArrivalId", arrDtlId), new MySqlParameter("strLineNo", arrDtlLine) }; var objList = await context.Query <T_Arrival_Detail_SubObj>().FromSql("call sp_arrival_dtl_sub_get(?, ?)", parameters: sqlParams).ToListAsync(); return(objList.ConvertAll(a => new T_Arrival_Detail_Sub { Id = a.Id, ArrivalId = a.ArrivalId, DtlLineNo = a.DtlLineNo, SubLineNo = a.SubLineNo, MaterialId = a.MaterialId, NoOfLabel = a.NoOfLabel, LabelQty = a.LabelQty, TotalQty = a.TotalQty, SubDetail = a.SubDetail, CompanyCode = a.CompanyCode, RecordFlag = a.RecordFlag, Is_Active = a.Is_Active, Created_Date = a.Created_Date, Created_By = a.Created_By, Updated_Date = a.Updated_Date, Updated_By = a.Updated_By })); } } catch (Exception ex) { throw ex; } }
public async Task <ResultObject> GenerateLabel(List <T_Arrival_Detail> lstArrDtl, int?userid) { var resultObj = new ResultObject { RowAffected = -1, ObjectValue = lstArrDtl }; using (var context = new TransactionDbContext(contextOptions)) { using (var transaction = context.Database.BeginTransaction()) { try { MySqlParameter[] sqlParams; foreach (T_Arrival_Detail arrDtl in lstArrDtl) { sqlParams = new MySqlParameter[] { new MySqlParameter("strArrivalId", arrDtl.ArrivalId), new MySqlParameter("strLineNo", arrDtl.LineNo), new MySqlParameter("strMaterialId", arrDtl.MaterialId), new MySqlParameter("strCreated_By", userid) }; resultObj.RowAffected += await context.Database.ExecuteSqlCommandAsync("call sp_generate_material_card(?, ?, ?, ?)", parameters : sqlParams); } transaction.Commit(); return(resultObj); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
public TransactionRepository(TransactionDbContext context) { this._context = context; this._dbSet = _context.Set <TransactionOrder>(); }
public TransactionRepository(TransactionDbContext transactionDbContext) { this._context = transactionDbContext; }
public TransactionRepository() { context = new TransactionDbContext(); }
public UnitOfWork(TransactionDbContext dbContext) { _dbContext = dbContext; }
public TransactionStatusRepository(TransactionDbContext dbContext, IMapper mapper) { m_mapper = mapper; m_dbContext = dbContext; }
public EmpleadoController(TransactionDbContext context, EmpleadoRepository repository) { _context = context; this._repository = repository ?? throw new ArgumentNullException(nameof(repository)); // Inyecto el repositorio de procedimientos almacenados }
public LedgerRepository(TransactionDbContext transactionDbContext) { _transactionDbContext = transactionDbContext; }
protected UnitOfWorkBaseEf(TransactionDbContext dbContext, IRepositoryFactory repositoryFactory) { _dbContext = dbContext; _repositoryFactory = repositoryFactory; _repository = _repositoryFactory.Create <TEntity, TRepository, TransactionDbContext>(_dbContext); }
public GetTransactionsByStatusQueryHandler(TransactionDbContext context) { _context = context; }
public FileRepository(TransactionDbContext transactionDbContext) { _transactionDbContext = transactionDbContext; }
public UnitOfWork(TransactionDbContext db, IRepository r) { this._context = db; this.r = r; }
public TransactionReader(TransactionDbContext dbContext) => _dbContext = dbContext;
public CurrencyController(TransactionDbContext dbContext) { this._dbContext = dbContext; }
static async Task Main(string[] args) { const string endpointName = "Bank.Transaction"; Console.Title = endpointName; var endpointConfiguration = new EndpointConfiguration(endpointName); endpointConfiguration.EnableInstallers(); //if in development endpointConfiguration.PurgeOnStartup(true); var appSettings = ConfigurationManager.AppSettings; string transactionConnection = ConfigurationManager.ConnectionStrings["TransactionConnectionString"].ToString(); var transportConnection = ConfigurationManager.ConnectionStrings["TransportConnection"].ToString(); var auditQueue = appSettings.Get("AuditQueue"); var userEndpoint = appSettings.Get("UserEndpoint"); var schemaName = appSettings.Get("SchemaName"); var tablePrefix = appSettings.Get("TablePrefix"); var serviceControlQueue = appSettings.Get("ServiceControlQueue"); var timeToBeReceivedSetting = appSettings.Get("TimeToBeReceived"); var timeToBeReceived = TimeSpan.Parse(timeToBeReceivedSetting); var containerSettings = endpointConfiguration.UseContainer(new DefaultServiceProviderFactory()); containerSettings.ServiceCollection.AddScoped(typeof(ITransactionRepository), typeof(TransactionRepository)); //containerSettings.ServiceCollection.AddAutoMapper(typeof(Program)); containerSettings.ServiceCollection.AddAutoMapper(typeof(DataMappingProfile)); using (var transactionDataContext = new TransactionDbContext(new DbContextOptionsBuilder <TransactionDbContext>() .UseSqlServer(new SqlConnection(transactionConnection)) .Options)) { await transactionDataContext.Database.EnsureCreatedAsync(); } var persistence = endpointConfiguration.UsePersistence <SqlPersistence>(); persistence.SqlDialect <SqlDialect.MsSqlServer>(); persistence.ConnectionBuilder( connectionBuilder: () => { return(new SqlConnection(transactionConnection)); }); var dialect = persistence.SqlDialect <SqlDialect.MsSqlServer>(); dialect.Schema(schemaName); var outboxSettings = endpointConfiguration.EnableOutbox(); outboxSettings.KeepDeduplicationDataFor(TimeSpan.FromDays(6)); outboxSettings.RunDeduplicationDataCleanupEvery(TimeSpan.FromMinutes(15)); var transport = endpointConfiguration.UseTransport <RabbitMQTransport>(); transport.UseConventionalRoutingTopology() .ConnectionString(transportConnection); var routing = transport.Routing(); routing.RouteToEndpoint( messageType: typeof(ICommitTransaction), destination: userEndpoint); var recoverability = endpointConfiguration.Recoverability(); recoverability.Delayed( customizations: delayed => { delayed.NumberOfRetries(0); delayed.TimeIncrease(TimeSpan.FromMinutes(3)); }); recoverability.Immediate( customizations: delayed => { delayed.NumberOfRetries(1); }); var conventions = endpointConfiguration.Conventions(); conventions.DefiningCommandsAs(type => type.Namespace == "Messages.Commands"); conventions.DefiningEventsAs(type => type.Namespace == "Messages.Events"); conventions.DefiningMessagesAs(type => type.Namespace == "Messages.Messages"); var subscriptions = persistence.SubscriptionSettings(); subscriptions.CacheFor(TimeSpan.FromMinutes(10)); endpointConfiguration.AuditProcessedMessagesTo( auditQueue: auditQueue, timeToBeReceived: timeToBeReceived); endpointConfiguration.AuditSagaStateChanges( serviceControlQueue: "Particular.Servicecontrol"); endpointConfiguration.RegisterComponents(c => { c.ConfigureComponent(b => { var session = b.Build <ISqlStorageSession>(); var context = new TransactionDbContext(new DbContextOptionsBuilder <TransactionDbContext>() .UseSqlServer(session.Connection) .Options); //Use the same underlying ADO.NET transaction context.Database.UseTransaction(session.Transaction); //Ensure context is flushed before the transaction is committed session.OnSaveChanges(s => context.SaveChangesAsync()); return(context); }, DependencyLifecycle.InstancePerUnitOfWork); }); var endpointInstance = await Endpoint.Start(endpointConfiguration); Console.WriteLine("Press Enter to exit."); Console.ReadLine(); await endpointInstance.Stop(); }
public TransactionService(TransactionDbContext transactionDbContext) { _transactionDbContext = transactionDbContext; }
public TransactionsController(TransactionDbContext context) { _context = context; }
protected ProviderBaseEf(TransactionDbContext dbContext, TRepository repository, IUnitOfWork <TEntity> unitOfWork) : base(repository) { _unitOfWork = unitOfWork; _dbContext = dbContext; }