Esempio n. 1
0
        public async Task UpdateAccount(string userId, Currency currency)
        {
            var acc = await _nexplorerDb.Users.FirstOrDefaultAsync(x => x.Id == userId);

            if (acc == null)
            {
                return;
            }

            acc.Currency = currency;

            await _nexplorerDb.SaveChangesAsync();
        }
        public async Task <int> CreateAsync(string userId, int addressId)
        {
            var user = await _nexplorerDb.Users.FirstOrDefaultAsync(x => x.Id == userId);

            if (user == null)
            {
                throw new ApplicationException($"Address watch failed because user {userId} cannot be found.");
            }

            var address = await _nexusDb.Addresses.Where(x => x.AddressId == addressId).Select(x => x.AddressId).FirstOrDefaultAsync();

            if (address == 0)
            {
                throw new ApplicationException($"Address watch failed because address {addressId} cannot be found.");
            }

            await _nexplorerDb.FavouriteAddresses.AddAsync(new FavouriteAddress
            {
                User      = user,
                AddressId = address
            });

            return(await _nexplorerDb.SaveChangesAsync());
        }