public static AExpense.DataAccessLayer.Expense GetExpenseById(string databaseConnectionString, Guid expenseId) { using (var db = new ExpensesDataContext(databaseConnectionString)) { return db.Expenses.SingleOrDefault(e => e.Id == expenseId); } }
public static void CreateExpense(string databaseConnectionString, Model.Expense expense) { using (var db = new ExpensesDataContext(databaseConnectionString)) { db.Expenses.InsertOnSubmit(expense.ToEntity()); db.SubmitChanges(); } }
public static void BypassRepositoryAndDeleteExpense(string databaseConnectionString, Guid guid) { using (var db = new ExpensesDataContext(databaseConnectionString)) { DataAccessLayer.Expense expense = db.Expenses.Where(e => e.Id == guid).ToList().FirstOrDefault(); db.Expenses.DeleteOnSubmit(expense); db.SubmitChanges(); } }
public static void DeleteDatabase(string connectionString) { using (var db = new ExpensesDataContext(connectionString)) { if (db.DatabaseExists()) { db.DeleteDatabase(); } } }
internal static void DeleteExpenseInDB(string TestDatabaseConnectionString, Guid testGuid) { using (var db = new ExpensesDataContext(TestDatabaseConnectionString)) { var expDetails = db.ExpenseDetails.Where(e => e.ExpenseId == testGuid); db.ExpenseDetails.DeleteAllOnSubmit(expDetails); var exp = db.Expenses.Where(e => e.Id == testGuid); db.Expenses.DeleteAllOnSubmit(exp); db.SubmitChanges(); } }