public async Task DeleteAllLedgerEntriesAsync() { using (var context = new WalletContext()) { await context.Database.ExecuteSqlCommandAsync($"DELETE FROM {LedgerEntryDto.TableName}"); } }
public unit_test_UserRepo() { //Setting up In memory dbs. userdb = new SqliteConnection("DataSource=:memory:"); passdb = new SqliteConnection("DataSource=:memory:"); walletdb = new SqliteConnection("DataSource=:memory:"); userdb.Open(); passdb.Open(); walletdb.Open(); var userbuild = new DbContextOptionsBuilder <UserModelContext>() .UseSqlite(userdb).Options; var passbuild = new DbContextOptionsBuilder <PassModelContext>() .UseSqlite(passdb).Options; var walletbuild = new DbContextOptionsBuilder <WalletContext>() .UseSqlite(walletdb).Options; var userContext = new UserModelContext(userbuild); var passContext = new PassModelContext(passbuild); var walletContext = new WalletContext(walletbuild); //Drop and create userContext.Database.EnsureDeleted(); userContext.Database.EnsureCreated(); passContext.Database.EnsureDeleted(); passContext.Database.EnsureCreated(); walletContext.Database.EnsureDeleted(); walletContext.Database.EnsureCreated(); //Seeding data to test on SeedUsers.seedUsers(userContext, passContext, walletContext); _uut = new UserRepository(walletContext, userContext); }
public MoneyService( WalletContext walletContext, IRateService rateService) { _walletContext = walletContext; _rateService = rateService; }
public async Task GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry() { //// Arrange // Setup In-Memory Database at desired state DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>() .UseInMemoryDatabase(databaseName: "GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry") .Options; WalletEntry expectedEntry = new WalletEntry { Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0 }; using (WalletContext context = new WalletContext(dbContextOptions)) { context.Add(expectedEntry); context.SaveChanges(); } //// Act WalletEntry actualEntry; using (WalletContext context = new WalletContext(dbContextOptions)) { IWalletRepository walletRepository = new WalletRepository(context); actualEntry = await walletRepository.GetLastWalletEntryAsync(); } //// Assert Assert.NotNull(actualEntry); actualEntry.ShouldCompare(expectedEntry); }
public void Add(WalletContext wc) { Execute(db => { db.Execute("INSERT INTO [dbo].[wallet] ([wallettag],[nodeurl],[rpcuser],[rpcpassword]) VALUES(@wallettag, @nodeurl, @rpcuser, @rpcpassword)", new { wallettag = wc.Tag, nodeurl = wc.Url, rpcuser = wc.User, rpcpassword = wc.Passsword }); }); }
private void Hydrate() { using (var context = new WalletContext(WalletContextOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var wallet = new Wallet { Id = "1435623429", CustomerId = "ac11r21d554", Name = "default", Balance = 0, Deleted = false, CreatedAt = DateTime.Now, Timestamp = 1605032522017 }; var wallet2 = new Wallet { Id = "1735613459", CustomerId = "pl989123hj1", Name = "default", Balance = 5000, Deleted = false, CreatedAt = DateTime.Now, Timestamp = 1605032617254 }; var wallet3 = new Wallet { Id = "1735613419", CustomerId = "qx9102311a1", Name = "default", Balance = 10000, Deleted = false, CreatedAt = DateTime.Now, Timestamp = 1605032760952 }; context.AddRange(wallet, wallet2, wallet3); context.SaveChanges(); } using (var context = new TransactionContext(TransactionContextOptions)) { var transaction = new Transaction { WalletId = "1735613459", Type = TransactionType.Deposit, WalletBalance = 5000, Amount = 5000, CreatedAt = DateTime.Now, Timestamp = 1605033203009 }; context.AddRange(transaction); context.SaveChanges(); } }
public CardRepository(WalletContext context, ILogger <CardRepository> logger, IUserManagment userManagment) : base(context, logger, userManagment) { }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // számit a sorrend public void Configure(IApplicationBuilder app, WalletContext walletContext) { if (!_environment.IsDevelopment()) { walletContext.Database.Migrate(); } app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Wallet.Api v1")); app.UseCors(policy => policy .WithOrigins("http://localhost:4200", "https://localhost:4201") .AllowAnyMethod() .WithHeaders(HeaderNames.ContentType, HeaderNames.Authorization) .AllowCredentials()); app.UseRouting(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Wallet.Api v1")); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
internal void UpdateInfo(WalletContext wc, double?balance, int txcount) { Execute(db => { db.Execute("update [dbo].[wallet] set [balance] = @balance, [txcount]=@txcount where wallettag=@tag and nodeurl=@url", new { balance, txcount, tag = wc.Tag, url = wc.Url }); }); }
public async Task InsertWalletAsync_MissingId_ThrowsInvalidOperationException() { //// Arrange // Setup In-Memory Database at desired state DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>() .UseInMemoryDatabase(databaseName: "InsertWalletAsync_MissingId_ThrowsInvalidOperationException") .Options; // Initialize Entry WalletEntry missingIdEntry = new WalletEntry { Id = null, EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0 }; //// Act / Assert using (WalletContext context = new WalletContext(dbContextOptions)) { IWalletRepository walletRepository = new WalletRepository(context); await Assert.ThrowsAsync <InvalidOperationException>(() => walletRepository.InsertWalletEntryAsync(missingIdEntry) ); } }
public async Task InsertWalletAsync_NoEntries_SingleWalletEntry() { //// Arrange // Setup In-Memory Database at desired state DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>() .UseInMemoryDatabase(databaseName: "InsertWalletAsync_NoEntries_SingleWalletEntry") .Options; // Initialize Entry WalletEntry expectedEntry = new WalletEntry { Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0 }; //// Act using (WalletContext context = new WalletContext(dbContextOptions)) { IWalletRepository walletRepository = new WalletRepository(context); await walletRepository.InsertWalletEntryAsync(expectedEntry); } //// Assert DbSet <WalletEntry> actualWalletEntries; using (WalletContext context = new WalletContext(dbContextOptions)) { actualWalletEntries = context.Transactions; Assert.Collection(actualWalletEntries, actualWalletEntry => actualWalletEntry.ShouldCompare(expectedEntry)); } }
public RepositoryBase(WalletContext context, ILogger logger, IUserManagment userManagment) { dataContext = context; _userManagment = userManagment; _logger = logger; }
//private readonly IWalletIntegrationEventService _walletIntegrationEventService; public TransactionBehaviour(WalletContext dbContext, //IWalletIntegrationEventService walletIntegrationEventService, ILogger <TransactionBehaviour <TRequest, TResponse> > logger) { _dbContext = dbContext ?? throw new ArgumentException(nameof(WalletContext)); //_orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentException(nameof(orderingIntegrationEventService)); _logger = logger ?? throw new ArgumentException(nameof(ILogger)); }
public WalletUserRepository(WalletContext context, ILogger <WalletUserRepository> logger, IUserManagment userManagment, ICardRepository cardRepository) : base(context, logger, userManagment) { _cardRepository = cardRepository; }
public async Task <Contact> GetContactAsync(string rsAddress) { using (var context = new WalletContext()) { var contact = await context.Contacts.SingleOrDefaultAsync(c => c.NxtAddressRs == rsAddress); return(_mapper.Map <Contact>(contact)); } }
public async Task <List <Contact> > GetContactsAsync(IEnumerable <string> nxtRsAddresses) { using (var context = new WalletContext()) { var list = await context.Contacts.Where(c => nxtRsAddresses.Contains(c.NxtAddressRs)).ToListAsync(); return(_mapper.Map <List <Contact> >(list)); } }
public async Task <List <Contact> > GetAllContactsAsync() { using (var context = new WalletContext()) { var contactsDto = await context.Contacts.ToListAsync(); return(_mapper.Map <List <Contact> >(contactsDto)); } }
public BtcCliOperations(WalletContext wc) { _serviceTag = wc.Tag; _serviceUrl = wc.Url; _serviceUser = wc.User; _servicePassword = wc.Passsword; _balance = wc.Balance; _txcount = wc.TxCount; }
static void Main(string[] args) { using (var context = new WalletContext()) { var users = context.Users.ToList(); Console.WriteLine(users.Count); Console.ReadKey(); } }
private static async Task Update <T>(string key, T value) { using (var context = new WalletContext()) { var setting = context.Settings.Single(s => s.Key == key); setting.Value = value.ToString(); await context.SaveChangesAsync(); } }
public async Task RemoveLedgerEntriesAsync(List <LedgerEntry> ledgerEntries) { using (var context = new WalletContext()) { var dtos = _mapper.Map <List <LedgerEntryDto> >(ledgerEntries); context.LedgerEntries.AttachRange(dtos); dtos.ForEach(d => context.Entry(d).State = EntityState.Deleted); await context.SaveChangesAsync(); } }
public async Task RemoveLedgerEntriesOnBlockAsync(ulong blockId) { using (var context = new WalletContext()) { var entries = await context.LedgerEntries.Where(e => e.BlockId == (long)blockId).ToListAsync(); entries.ForEach(e => context.Entry(e).State = EntityState.Deleted); await context.SaveChangesAsync(); } }
public CardTransactionRepository(WalletContext context, ILogger <CardTransactionRepository> logger, ICardRepository cardRepo, IWalletUserRepository userRepo, IUserManagment userManagment) : base(context, logger, userManagment) { _cardRepo = cardRepo; _userRepo = userRepo; }
private async Task UpdateEntityStateAsync(Contact contact, EntityState entityState) { using (var context = new WalletContext()) { var contactDto = _mapper.Map <ContactDto>(contact); context.Contacts.Attach(contactDto); context.Entry(contactDto).State = entityState; await context.SaveChangesAsync(); } }
public AccountController(WalletContext _db, IConfiguration _configuration, UserManager <User> _userManager, SignInManager <User> _signInManager) { db = _db; configuration = _configuration; userManager = _userManager; signInManager = _signInManager; }
/// <summary> /// Initializes a new instance of the <see cref="WalletStatusRepository" /> class. /// </summary> /// <param name="repositoryContext">The repository context.</param> /// <param name="mapper">The mapper.</param> /// <param name="sortHelper">The sort helper.</param> /// <param name="dataShaper">The data shaper.</param> public WalletStatusRepository( WalletContext repositoryContext, IMapper mapper, ISortHelper <WalletStatusResponse> sortHelper, IDataShaper <WalletStatusResponse> dataShaper) : base(repositoryContext) { this.mapper = mapper; this.sortHelper = sortHelper; this.dataShaper = dataShaper; }
public async Task AddLedgerEntryAsync(LedgerEntry ledgerEntry) { using (var context = new WalletContext()) { var dto = _mapper.Map <LedgerEntryDto>(ledgerEntry); context.LedgerEntries.Add(dto); await context.SaveChangesAsync(); ledgerEntry.Id = dto.Id; } }
public async Task <Contact> AddContactAsync(Contact contact) { using (var context = new WalletContext()) { var contactDto = _mapper.Map <ContactDto>(contact); context.Contacts.Add(contactDto); await context.SaveChangesAsync(); return(_mapper.Map <Contact>(contactDto)); } }
public async Task <List <Contact> > SearchContactsContainingNameOrAddressText(string text) { using (var context = new WalletContext()) { var contacts = await context.Contacts.Where(c => c.Name.Contains(text) || c.NxtAddressRs.Contains(text)) .Distinct() .ToListAsync(); return(_mapper.Map <List <Contact> >(contacts).OrderBy(c => c.Name).ToList()); } }
public void GetAddresses_Call_Success() { var wc1 = new WalletContext(); wc1.Tag = "btccliwebsrv"; wc1.Url = "http://192.168.56.101:11111"; wc1.User = "******"; wc1.Passsword = "btcpwd"; var ops = new BtcCliOperations(wc1); var r = ops.GetAddresses(); }