// GET: api/Currency public IEnumerable <Currency> Get() { CurrencyRepository c = new CurrencyRepository(); List <Currency> getcurrency = c.GetList(); return(getcurrency); }
static async Task Main(string[] args) { int i = 0; string path = Environment.CurrentDirectory + @"\guardado"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } currencyRepository = new CurrencyRepository(); //currencyRepository.cargarAsync(); currencyRepository.Currencies = await currencyRepository.currencyService.getCurrenciesAsync(); foreach (Currency cur in currencyRepository.Currencies) { cur.Todolar = (await currencyRepository.currencyService.ToDolarRatio("ARS")).Ratio; if (i++ == 1) { File.WriteAllText(path + @"\save.csv", cur.Todolar.ToString()); } else { File.AppendAllText(path + @"\save.csv", "," + cur.Todolar.ToString()); } } currencyRepository.guardar(); }
public ActionResult GetAllCurrencies() { CurrencyRepository currencyRepository = new CurrencyRepository(); IList <Currency> currencies = currencyRepository.List(); return(Content(JsonConvert.SerializeObject(currencies))); }
public void FillCurrencySymbols() { var repo = new CurrencyRepository(); var sym = repo.FillSymbol(); ViewBag.symbols = new SelectList(sym.Symbols, "SymbolId", "SymbolName"); }
public void A_ChangedCountry_modifies_Existing_country_in_the_database() { var bootStrapper = new BootStrapper(); bootStrapper.StartServices(); var serviceEvents = bootStrapper.GetService<IServiceEvents>(); //1.- Create message var aggr = GenerateRandomAggregate(); //2.- Create the tuple in the database var repository = new CurrencyRepository(_configuration.TestServer); repository.Insert(aggr); //3.- Change the aggregate aggr.IsoCodeChar = StringExtension.RandomString(3); aggr.IsoCodeNum = StringExtension.RandomString(3); aggr.SapCode = StringExtension.RandomString(2); //4.- Emit message var message = GenerateMessage(aggr); message.MessageType = typeof(ChangedCurrency).Name; serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message }); //5.- Load the saved country var currency = repository.Get(aggr.Id); //6.- Check equality Assert.True(ObjectExtension.AreEqual(aggr, currency)); }
public decimal ConvertCurrency(string toISO, decimal value) { decimal convertedValue = 0.0M; #region //Currency c = new Currency //{ // Name = "Europe", // ISO = "EUR", // ExchangeRate = 745.99M //}; #endregion CurrencyRepository c = new CurrencyRepository(); List <Currency> getcurrency = c.GetList(); foreach (var item in getcurrency) { if (toISO == item.ISO) { convertedValue = value / item.ExchangeRate; } } return(convertedValue); }
public void Get_Returns_Sorted_Items() { var data = new List <Currency> { new Currency { IsoCode = "BB", Name = "YYY" }, new Currency { IsoCode = "AA", Name = "XXX" }, new Currency { IsoCode = "CC", Name = "UUU" }, }; var mockSet = new Mock <DbSet <Currency> >().SetupData(data); var mockContext = new Mock <CountryContext>(); mockContext.Setup(c => c.Currencies).Returns(mockSet.Object); var service = new CurrencyRepository(mockContext.Object); // Act var items = service.Get().ToList(); Assert.IsNotNull(items); Assert.AreEqual(items.Count, data.Count); Assert.AreEqual(items[0].IsoCode, "AA"); Assert.AreEqual(items[1].IsoCode, "BB"); Assert.AreEqual(items[2].IsoCode, "CC"); }
public void Add_AddsItemToDbSet() { var newItem = new Currency() { CurrencyId = 4, IsoCode = "DD", Name = "TestName" }; var mockSet = new Mock <DbSet <Currency> >().SetupData(new List <Currency>()); mockSet.Setup(m => m.Add(It.IsAny <Currency>())).Returns(newItem); var mockContext = new Mock <CountryContext>(); mockContext.Setup(c => c.Set <Currency>()).Returns(mockSet.Object); var service = new CurrencyRepository(mockContext.Object); // Act var item = service.Add(newItem); mockSet.Verify(m => m.Add(newItem), Times.Once); Assert.IsNotNull(item); Assert.AreEqual(item.IsoCode, newItem.IsoCode); Assert.AreEqual(item.Name, newItem.Name); }
public async Task GetAsync_ById_Returns_FoundItem() { var data = new List <Currency> { new Currency { CurrencyId = 2, IsoCode = "BB", Name = "YYY" }, new Currency { CurrencyId = 1, IsoCode = "AA", Name = "XXX" }, new Currency { CurrencyId = 3, IsoCode = "CC", Name = "UUU" }, }; var mockSet = new Mock <DbSet <Currency> >().SetupData(data, objects => data.SingleOrDefault(d => d.CurrencyId == (long)objects.First())); var mockContext = new Mock <CountryContext>(); mockContext.Setup(c => c.Currencies).Returns(mockSet.Object); mockContext.Setup(c => c.Set <Currency>()).Returns(mockSet.Object); var service = new CurrencyRepository(mockContext.Object); // Act var item = await service.GetAsync(2); Assert.IsNotNull(item); Assert.AreEqual(item.IsoCode, "BB"); }
public async Task GetAsync_ByIsoCode_Returns_FoundItem() { var data = new List <Currency> { new Currency { IsoCode = "BB", Name = "YYY" }, new Currency { IsoCode = "AA", Name = "XXX" }, new Currency { IsoCode = "CC", Name = "UUU" }, }; var mockSet = new Mock <DbSet <Currency> >().SetupData(data); var mockContext = new Mock <CountryContext>(); mockContext.Setup(c => c.Currencies).Returns(mockSet.Object); var service = new CurrencyRepository(mockContext.Object); // Act var item = await service.GetAsync("BB"); Assert.IsNotNull(item); Assert.AreEqual(item.IsoCode, "BB"); }
public async Task FindAsync_Returns_Sorted_FoundByIsoCode() { var data = new List <Currency> { new Currency { IsoCode = "CC", Name = "UUU" }, new Currency { IsoCode = "BB", Name = "XXX" }, new Currency { IsoCode = "DD", Name = "YYY" }, new Currency { IsoCode = "AA", Name = "YYY" }, }; var mockSet = new Mock <DbSet <Currency> >().SetupData(data); var mockContext = new Mock <CountryContext>(); mockContext.Setup(c => c.Currencies).Returns(mockSet.Object); var service = new CurrencyRepository(mockContext.Object); // Act var items = (await service.FindAsync(new string[] { "BB", "CC" })).ToList(); Assert.IsNotNull(items); Assert.AreEqual(items.Count, 2); Assert.AreEqual(items[0].IsoCode, "BB"); Assert.AreEqual(items[1].IsoCode, "CC"); }
// var result=new CurrencyRepository().InsertCurrency(model); // if (result.CurrencyId > 0) // { // TempData["Success"] = "Added Successfully!"; // TempData["RefNo"] = result.CurrencyRefNo; // return RedirectToAction("Create"); // } // else // { // FillCurrencySymbols(); // TempData["error"] = "Oops!!..Something Went Wrong!!"; // TempData["RefNo"] = null; // return View("Create", model); // } //} public ActionResult Edit(int Id) { FillCurrencySymbols(); Currency model = new CurrencyRepository().GetCurrency(Id); return(View("Create", model)); }
public HttpResponseMessage GetAllCurrency(BaseViewModel aCurrencyModel) { IUnitOfWork uWork = new UnitOfWork(); ICurrencyRepository repo = new CurrencyRepository(uWork); ICurrencyService Service = new CurrencyService(repo); try { if (this.ModelState.IsValid) { var currencyList = Service.GetAllCurrencyList(aCurrencyModel); if (currencyList != null) { return(Request.CreateResponse(HttpStatusCode.OK, currencyList)); } else { string message = "Error in getting Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public dynamic GetAllCurrency() { CurrencyRepository repo = new CurrencyRepository(); var currency = repo.GetAll(); return(currency); }
public ActionResult Edit(Currency model) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new CurrencyRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "Currency", "CurrencyName", model.CurrencyName, "CurrencyId", model.CurrencyId); if (!isexists) { var result = new CurrencyRepository().UpdateCurrency(model); if (result.CurrencyId > 0) { TempData["Success"] = "Updated Successfully!"; TempData["RefNo"] = result.CurrencyRefNo; return(RedirectToAction("Create")); } else { FillCurrencySymbols(); TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } } else { FillCurrencySymbols(); TempData["error"] = "This Name Alredy Exists!!"; TempData["RefNo"] = null; return(View("Create", model)); } }
public void PrimeAddCurrencyToExpense(Dropdown dropdown) { CurrencyRepository repo = GetComponent <CurrencyRepository>(); TripDetails details = GetComponent <TripDetails>(); ClearOptions(dropdown); foreach (Currency currency in repo.Currencies) { bool isCurrencyNotYetInTrip = true; foreach (Currency currencyInTrip in details.Trip.Currencies) { if (isCurrencyNotYetInTrip) { isCurrencyNotYetInTrip = currencyInTrip.CurrencyCode != currency.CurrencyCode; } else { break; } } if (!isCurrencyNotYetInTrip) { dropdownOptions.Add(currency.CurrencyCode); } } dropdown.AddOptions(dropdownOptions); if (dropdownOptions.Count != 0) { selectedCurrency = dropdownOptions[0]; } }
// GET: Currency public ActionResult Index() { var repo = new CurrencyRepository(); var currencyList = repo.GetCurrency(); return(View(currencyList)); }
// GET: Currency/Delete/5 public ActionResult Delete(int id) { var repo = new CurrencyRepository(); var currency = repo.EditCurrency(id); return(View(currency)); }
public void TestExistingCurrency() { string iso = "USD"; CurrencyRepository currency = CurrencyRepository.GetCurrencyRepositoryByISO(iso); Assert.IsNotNull(currency, "currency should not be null due implemented repositories"); }
// GET: Currency/Create public ActionResult Create() { var repo = new CurrencyRepository(); var currency = repo.CreateCurrency(); return(View(currency)); }
public void UpdateComponent(Component component, CompositionData compositionData) { MaterialRepository materialRepository = new MaterialRepository(); MaterialDto material = materialRepository.GetByName(component.Name); component.Density = material.Density; component.IsSemiProduct = material.IsIntermediate; component.SemiProductNrD = material.IntermediateNrD; component.PriceKg = (double)material.Price; component.VocPercent = material.VOC; component.SemiStatus = ""; if (material.Id > 0) { CurrencyRepository currencyRepository = new CurrencyRepository(); CurrencyDto currency = currencyRepository.GetById(material.CurrencyId, CurrencyRepository.GetByIdQuery); component.Rate = (double)currency.Rate; UpdatePriceAndVoc(component, material.VOC); } CompositionSubRecipeDto recipeDto = new CompositionSubRecipeDto(component.Id, component.Level, component.SemiProductNrD, component.Operation, component.Amount, component.Mass, component.ParentsId); component.SemiRecipe = component.IsSemiProduct ? GetSemiRecipe(recipeDto) : new List <Component>(); }
public UnitOfWork(RestaurantContext context) { _context = context; Adjustments = new AdjustmentRepository(_context); AdjustmentsItems = new AdjustmentItemRepository(_context); Branches = new BranchRepository(_context); Categories = new CategoryRepository(_context); Customers = new CustomerRepository(_context); Deliveries = new DeliveryRepository(_context); DeliveryItems = new DeliveryItemRepository(_context); Divisions = new DivisionRepository(_context); Expirations = new ExpirationRepository(_context); Groups = new GroupRepository(_context); Stocks = new InventoryItemRepository(_context); Locations = new LocationRepository(_context); Units = new MeasurementUnitRepository(_context); Productions = new ProductionRepository(_context); Ingredients = new ProductionItemRepository(_context); Products = new ProductRepository(_context); Purchases = new PurchaseRepository(_context); PurchaseItems = new PurchaseItemRepository(_context); PurchaseOrders = new PurchaseOrderRepository(_context); PurchaseOrderItems = new PurchaseOrderItemRepository(_context); SalesInvoices = new SalesInvoiceRepository(_context); SalesInvoiceItems = new SalesInvoiceItemRepository(_context); Suppliers = new SupplierRepository(_context); Transfers = new TransferRepository(_context); TransferItems = new TransferItemRepository(_context); Wastages = new WastageRepository(_context); WastageItems = new WastageItemRepository(_context); Workers = new WorkerRepository(_context); ItemLocation = new ItemLocationRepository(_context); StockHistory = new StockHistoryRepository(_context); Currencies = new CurrencyRepository(_context); }
public void TestMethod1() { CurrencyRepository repository = new CurrencyRepository(); var rate = repository.ConversionRate(Currency.USD, Currency.RUB); Assert.IsNotNull(rate > 0); }
//public IExpenseClaimRepositoryAsync ClaimRepository { get; set; } public ClaimUnitOfWork(ApplicationDbContext context) { _context = context; ClaimRepository = new ExpenseClaimRepositoryAsync(_context); CategoryRepository = new CategoryRepository(_context); CurrencyRepository = new CurrencyRepository(_context); ClaimItemRepository = new ClaimItemRepository(_context); }
public UnitOfWork(string connectionString) { _connectionString = connectionString; _db = new BankingContext(_connectionString); _bankAccountRepository = new BankAccountRepository(_db); _currencyRepository = new CurrencyRepository(_db); _transactionRepository = new TransactionRepository(_db); }
public ChangeCalculator(string currency) { if (currency == null) { throw new ArgumentNullException(nameof(currency)); } _banknotes = CurrencyRepository.GetAllBanknotesDescendingFor(currency); }
public CurrencyService() { Bootstrapper.ReadConfigFromFile(); InitialConfigurationFactory InitialConfigurationFactory = new InitialConfigurationFactory(); ServiceConfiguration = InitialConfigurationFactory.GetInitialConfiguration(); CurrencyRepository = new CurrencyRepository(ServiceConfiguration.CurrencyDataWriter, ServiceConfiguration.CurrencyDataReader); }
/// <summary> /// Instantiates a new AddAgentViewModel. /// </summary> /// <param name="settingsSvc"></param> /// <param name="messageBus"></param> public AgentManagementViewModel(ISettingsSvc settingsSvc, IMessageBus messageBus) { _settingsSvc = settingsSvc; _messageBus = messageBus; _countryRepository = new CountryRepository(); _countrySubdivisionRepository = new CountrySubdivisionRepository(); _currencyRepository = new CurrencyRepository(); }
/// <summary> /// Get Currencys /// </summary> /// <returns></returns> // GET: api/Currency public IHttpActionResult Get() { CurrencyRepository CurrencyRepository = new CurrencyRepository(Convert.ToInt32(Request.Headers.GetValues("CurrentUserID").First())); List <Currency> CurrencyList = CurrencyRepository.GetCurrencys(); return(Json(new { Currencys = CurrencyList })); }
/// <summary> /// Save Currencys /// </summary> /// <param name="CurrencyList"></param> /// <returns></returns> // POST: api/Currency public IHttpActionResult Post([FromBody] List <Currency> CurrencyList) { CurrencyRepository CurrencyRepository = new CurrencyRepository(Convert.ToInt32(Request.Headers.GetValues("CurrentUserID").First())); CurrencyRepository.SaveCurrencys(CurrencyList); return(Json(new { count = CurrencyList.Count.ToString() })); }
public bool Delete(int id) { bool status = false; CurrencyRepository repo = new CurrencyRepository(); status = repo.Delete(id); return(status); }
public void A_RegisteredCurrency_creates_a_new_currency_in_the_database() { var bootStrapper = new BootStrapper(); bootStrapper.StartServices(); var serviceEvents = bootStrapper.GetService<IServiceEvents>(); //1.- Create message var aggr = GenerateRandomAggregate(); var message = GenerateMessage(aggr); //2.- Emit message serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message }); //3.- Load the saved country var repository = new CurrencyRepository(_configuration.TestServer); var currency = repository.Get(aggr.Id); //4.- Check equality Assert.True(ObjectExtension.AreEqual(aggr, currency)); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; bc.Commont.initRadComboBox(ref rcbCustomerID, "CustomerName", "CustomerID", DataProvider.DataTam.B_BCUSTOMERS_GetAll()); // CurrencyRepository cr = new CurrencyRepository(); Util.LoadData2RadCombo(rcbCurrentcy, cr.GetAll().ToList(), "Code", "Code", "-Select Currency-", false); // ProduceLineRepository pr = new ProduceLineRepository(); Util.LoadData2RadCombo(rcbProductLine, pr.LoadProductLineList("6").ToList(), "Description", "Description", "-Select Product Line-", true); if (!string.IsNullOrEmpty(Request.QueryString["tid"])) { tbDepositCode.Text = Request.QueryString["tid"]; loadDetail(); } else LoadNewsID(); }
public void A_UnregisteredCountry_modifies_Existing_country_in_the_database() { var bootStrapper = new BootStrapper(); bootStrapper.StartServices(); var serviceEvents = bootStrapper.GetService<IServiceEvents>(); //1.- Create message var aggr = GenerateRandomAggregate(); //2.- Create the tuple in the database var repository = new CurrencyRepository(_configuration.TestServer); repository.Insert(aggr); //2.- Emit message var message = GenerateMessage(aggr); message.MessageType = typeof(UnregisteredCurrency).Name; serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message }); var country = repository.Get(aggr.Id); Assert.Null(country); }