/// <summary> /// Delete a currency /// </summary> /// <param name="currencyId">currency external id</param> /// <param name="deletedBy">username of the deletor</param> /// <returns>true=currency deleted,false=currency not found</returns> public static bool DeleteCurrency(Guid currencyId, string deletedBy) { // Connect to the MSSQL database using (MSSqlConnection connection = MSSqlConnection.GetConnection()) { // Get the table Table <CurrencyTable> currencies = connection.GetTable <CurrencyTable>(); // Get the currency CurrencyTable currency = currencies.FirstOrDefault(x => x.ExternalId == currencyId && !x.Deleted); if (currency == null) { return(false); } // Set the currency deleted state currency.Deleted = true; // Set the deleted by currency.DeletedBy = AccountsManager.GetAccountId(connection, deletedBy); // Submit the changes connection.SubmitChanges(); // Currency set to deleted, return true return(true); } }
public List <CurrencyTable> LoadCurrency() { try { accessManager.SqlConnectionOpen(DataBase.SQQeye); List <CurrencyTable> currencyTables = new List <CurrencyTable>(); List <SqlParameter> aList = new List <SqlParameter>(); SqlDataReader dr = accessManager.GetSqlDataReader("sp_LoadCurrency"); while (dr.Read()) { CurrencyTable currency = new CurrencyTable(); currency.CurrencyId = (int)dr["CurrencyId"]; currency.CurrencyName = dr["CurrencyName"].ToString(); currencyTables.Add(currency); } return(currencyTables); } catch (Exception exception) { throw exception; } finally { accessManager.SqlConnectionClose(); } }
private ITablesProvider InitMockedDb() { CategoryTable categoryTable = new CategoryTable(); CurrencyTable currencyTable = new CurrencyTable(); PersonTable personTable = new PersonTable(); BidTable bidTable = new BidTable(); PersonBidderTable personBidderTable = new PersonBidderTable(bidTable); AuctionsTable auctionsTable = new AuctionsTable(); ProductTable productTable = new ProductTable(); PersonMarkTable personMarkTable = new PersonMarkTable(); PersonOfferorTable personOfferorTable = new PersonOfferorTable(); Mock <ITablesProvider> mock = new Mock <ITablesProvider>(); mock.Setup(x => x.GetCategoryTable()).Returns(categoryTable); mock.Setup(x => x.GetCurrencyTable()).Returns(currencyTable); mock.Setup(x => x.GetPersonTable()).Returns(personTable); mock.Setup(x => x.GetBidTable()).Returns(bidTable); mock.Setup(x => x.GetPersonBidderTable()).Returns(personBidderTable); mock.Setup(x => x.GetAuctionTable()).Returns(auctionsTable); mock.Setup(x => x.GetProductTable()).Returns(productTable); mock.Setup(x => x.GetPersonMarkTable()).Returns(personMarkTable); mock.Setup(x => x.GetPersonOfferorTable()).Returns(personOfferorTable); return(mock.Object); }
public CurrencyConverterTests() { ICurrencyTable currencyTable = new CurrencyTable(); Mock <ITablesProvider> table = new Mock <ITablesProvider>(); table.Setup(x => x.GetCurrencyTable()).Returns(currencyTable); this.tablesProvider = table.Object; }
/// <summary> /// Create a new comment /// </summary> /// <param name="currencyId">currency id</param> /// <param name="message">message</param> /// <param name="vote">vote</param> /// <param name="createdBy">username of the comment author</param> /// <returns>comment id</returns> public static Guid CreateComment(Guid currencyId, string message, int vote, string createdBy) { // Connect to the MSSQL database using (MSSqlConnection connection = MSSqlConnection.GetConnection()) { // Get the tables Table <CurrencyTable> currencies = connection.GetTable <CurrencyTable>(); Table <CurrencyCommentTable> comments = connection.GetTable <CurrencyCommentTable>(); Table <AccountTable> accounts = connection.GetTable <AccountTable>(); // Get the currency CurrencyTable currency = currencies.FirstOrDefault(x => x.ExternalId == currencyId && !x.Deleted); if (currency == null) { throw new InvalidOperationException("Currency not found"); } // Create the external id for the comment Guid externalId = Guid.NewGuid(); // Insert the comment comments.InsertOnSubmit(new CurrencyCommentTable() { ExternalId = externalId, Currency = currency.Id, Message = message, Vote = vote, CreatedBy = AccountsManager.GetAccountId(connection, createdBy), DateCreated = DateTime.Now, Deleted = false, }); // Submit the changes connection.SubmitChanges(); // Return the external id of the new comment return(externalId); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); currencyTable = new CurrencyTable(); }
public IsoService(IOptions <DTO.ISO> isoOptions) { currencyTable = isoOptions.Value.ISO_4217.CcyTbl; mccTable = isoOptions.Value.ISO_18245.MccTbl; }