public ChargeModel(DbCharge dbCharge) { this.Id = dbCharge.ChargeId; this.BilledAmount = dbCharge.BilledAmount; this.Description = dbCharge.Description; this.ExpenseDate = dbCharge.ExpenseDate; this.Location = dbCharge.Location; this.Merchant = dbCharge.Merchant; this.Notes = dbCharge.Notes; this.TransactionAmount = dbCharge.TransactionAmount; }
public DbCharge SaveCharge(DbCharge charge) { using (var context = new ExpensesContext()) { if (charge.ChargeId != 0) { context.Charges.Attach(charge); context.Entry<DbCharge>(charge).State = System.Data.Entity.EntityState.Modified; } else { context.Charges.Add(charge); } context.SaveChanges(); return charge; } }
public DbCharge SaveCharge(DbCharge charge) { using (var context = new ExpensesContext()) { if (charge.ChargeId != 0) { context.Charges.Attach(charge); context.Entry <DbCharge>(charge).State = System.Data.Entity.EntityState.Modified; } else { context.Charges.Add(charge); } context.SaveChanges(); return(charge); } }
public DbCharge ConvertToDbCharge(int employeeId) { DbCharge dbCharge = new DbCharge() { ChargeId = this.Id, BilledAmount = this.BilledAmount, Description = this.Description, EmployeeId = employeeId, ExpenseDate = this.ExpenseDate, Location = this.Location, Merchant = this.Merchant, Notes = this.Notes, TransactionAmount = this.TransactionAmount, }; return dbCharge; }