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(); } }
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(); } }