Example #1
0
        public async void RepoEthTooOldAsync()
        {
            // Arrange
            var all     = RatesOfCurrency.GetTestRates(setIds: false, now: timeService.Now);
            var ethRate = all[3];

            ethRate.DateTime = timeService.Now.AddDays(-1);
            currencyRateContext.CurrencyRates.AddRange(all);
            await currencyRateContext.SaveChangesAsync();

            // Act
            var averageRate = await currencyRateRepository.GetAverageRateBy24hAsync("eth");

            // Assert
            Assert.Null(averageRate);
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Rate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RateExists(Rate.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Example #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Rate.Add(Rate);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Example #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Service = await _context.Service.FindAsync(id);

            if (Service != null)
            {
                _context.Service.Remove(Service);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }