Exemple #1
0
        public async Task GetRate_GetsFromContext()
        {
            var rate = fixture.Create <CurrencyRate>();

            context.ActualRates.Add(rate);
            context.SaveChanges();

            var result = await repo.GetRate(rate.CurrencyFrom, rate.CurrencyTo);

            result.Should().Be(rate);
        }
Exemple #2
0
        public ActionResult MakeRate(Rate rate)
        {
            rate.UserId      = User.Identity.GetUserId();
            rate.Coefficient = double.Parse(rate.Coefficient).ToString("0.00");
            ratesDb.Rates.Add(rate);
            ratesDb.SaveChanges();

            return(RedirectToAction("FutureEvents", "Home"));
        }
Exemple #3
0
        public IActionResult Update(long id, [FromBody] RateItem item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var rate = _context.RateItems.Find(id);

            if (rate == null)
            {
                return(NotFound());
            }

            rate.Days  = item.Days;
            rate.Times = item.Times;
            rate.Price = item.Price;

            _context.RateItems.Update(rate);
            _context.SaveChanges();
            return(NoContent());
        }
        public async Task SetActualRates_UpdateOldRates_And_AddNewRates()
        {
            var oldRate = fixture.Create <CurrencyRate>();

            context.ActualRates.Add(oldRate);
            context.SaveChanges();

            var rates          = fixture.CreateMany <CurrencyRate>().ToList();
            var updatedOldRate = rates.First();

            updatedOldRate.CurrencyFrom = oldRate.CurrencyFrom;
            updatedOldRate.CurrencyTo   = oldRate.CurrencyTo;

            await writer.SetActualRates(rates);

            context.ActualRates.Should().HaveCount(1);

            await writer.SaveChanges();

            context.ActualRates.Should().BeEquivalentTo(rates);
            oldRate.Should().BeEquivalentTo(updatedOldRate);
        }