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();
            }
        }
 private static UpdateReport ToUpdateReport(CalculationReport report)
 =>
 new UpdateReport
 {
     CustomerAgreementDescription = report.CustomerAgreementDescription,
     CurrentBaseRateCode          = report.CurrentBaseRateCode,
     CurrentInterestRate          = report.CurrentInterestRate,
     NewBaseRateCode = report.NewBaseRateCode,
     NewInterestRate = report.NewInterestRate,
     Difference      = report.Difference
 };