/// <summary> /// Inserts an expense log row. /// </summary> /// <param name="expense">An ExpenseLog object.</param> public void Create(ExpenseLog log) { using (ExpenseDataContext ctx = new ExpenseDataContext()) { ctx.AddObject(ENTITY_SET_NAME, log); ctx.SaveChanges(); } }
/// <summary> /// Logs the status of the Expense. /// </summary> /// <param name="expense">An Expense object.</param> private void LogStatus(Expense expense) { ExpenseLog log = new ExpenseLog(); log.ExpenseID = expense.ExpenseID; log.Status = expense.Status; log.DateCreated = DateTime.Now; // Persist data. ExpenseLogDataAccess dac = new ExpenseLogDataAccess(); try { dac.Create(log); } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } }