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(); } }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }