public ActionResult CurrencyChange() { CurrencyChangeModel model = new CurrencyChangeModel(); Rate ORGIN = new Rate() { Currency = "złoty", Code = "PLN", Ask = 1, Bid = 1 }; model.Currency = model.GetCurrency(); model.Currency.Rates.Insert(0, ORGIN); model.CurrencyList = model.GetCurrencyNames(model.Currency.Rates); ViewBag.OrginCourrency = ORGIN; ViewBag.Title = "Waluty"; return(View("CurrencyChange", model)); }
public async Task <IActionResult> ChangeUserCurrency(CurrencyChangeModel model) { var response = new APIResponse(); var(entity, message) = await _currencyManager.ChangeMainCurrency(model.Symbol, model.UserId); if (entity != null) { response.Result = entity; response.ApiMessage = message; response.StatusCode = "00"; return(Ok(response)); } response.ApiMessage = message; response.Result = entity; return(BadRequest(response)); }
public ActionResult CurrencyChange(double amount, string sellCode, string buyCode) { CurrencyChangeModel model = new CurrencyChangeModel(); Rate ORGIN = new Rate() { Currency = "złoty", Code = "PLN", Ask = 1, Bid = 1 }; model.Currency = model.GetCurrency(); model.Currency.Rates.Insert(0, ORGIN); model.Amount = amount; model.SellCode = model.PickRateFromList(model.Currency.Rates, sellCode); model.BuyCode = model.PickRateFromList(model.Currency.Rates, buyCode); model.CurrencyList = model.GetCurrencyNames(model.Currency.Rates); model.ConversionResoult = model.ConvertCurrencies(amount, model.Currency.Rates, sellCode, buyCode, ORGIN.Code); ViewBag.Title = "Waluty"; return(View("CurrencyChange", model)); }
public async Task Test_To_Change_CurrencyAsync_BadResult() { //Arrange var model = new CurrencyChangeModel { Symbol = "USD", UserId = 2 }; var cur = new CurrencyChange { FormerMainCurrencyTitle = "eur", NewMainCurrencySymbol = "USD" }; var currMgr = new Mock <ICurrencyManager>(); currMgr.Setup(t => t.ChangeMainCurrency("oob", model.UserId)).ReturnsAsync((cur, string.Empty)); var _sut = new CurrencyController(currMgr.Object); //Act var result = await _sut.ChangeUserCurrency(model); Assert.IsType <BadRequestObjectResult>(result); Assert.Equal(model.Symbol, cur.NewMainCurrencySymbol); }
public async Task Test_To_Change_CurrencyAsync() { //Arrange var model = new CurrencyChangeModel { Symbol = "EUR", UserId = 2 }; var cur = new CurrencyChange { FormerMainCurrencyTitle = "usd", NewMainCurrencySymbol = "EUR" }; var currMgr = new Mock <ICurrencyManager>(); currMgr.Setup(t => t.ChangeMainCurrency(model.Symbol, model.UserId)).ReturnsAsync((cur, "success")); var _sut = new CurrencyController(currMgr.Object); //Act var output = await _sut.ChangeUserCurrency(model); Assert.IsType <OkObjectResult>(output); Assert.Equal(model.Symbol, cur.NewMainCurrencySymbol); }