public List <Agreement> GetAgreements(int customerId) { using (var context = new SebContext()) { return(context.Agreements.Where(x => x.Customer.Id == customerId).Select(ToAgreement).ToList()); } }
public UpdateReport UpdateAgreement(Agreement agreement) { SebContext context = null; try { context = new SebContext(); var id = agreement.Id; var current = context.Agreements.Include(x => x.Customer).First(x => x.Id == id); var oldBaseRateCode = current.BaseRateCode; current.BaseRateCode = agreement.BaseRateCode; var report = CalculationReport.Build(current, oldBaseRateCode).Result; // if we are here let save new value context.SaveChanges(); return(ToUpdateReport(report)); } catch { return(UpdateReport.Failed); } finally { context?.Dispose(); } }
public List <Customer> GetCustomers() { using (var context = new SebContext()) { return(context.Customers.Select(ToCustomer).ToList()); } }