static void Main(string[] args) { const string fileName = @"C:\Users\MRMacDonnell\Desktop\NotepadDocs\SavingsCalc.csv"; bool inUse = false; do { try { if (!File.Exists(fileName)) { File.Create(fileName).Dispose(); } var writerService = new WriterService(fileName); var interestCalculator = new CalculateInterestService(writerService); var header = string.Join(",", "Timestamp", "Expected Value", "Interest Value", "InterestRate", "Payment/Check", "Estimated Income", "Estimated Yearly Interest"); var footer = string.Join(",", "My Age", "Final Result"); writerService.LogInformation(header); var startDate = new DateTime(2018, 6, 30); interestCalculator.CalculateInterestByMonths(4030.02m, 0.0175m, 250, 500, startDate); //writerService.LogInformation(footer); writerService.DisposeWriter(); inUse = false; } catch (Exception ex) { inUse = true; Console.WriteLine(ex); Thread.Sleep(10000); } }while (inUse); }
/// <summary> /// Adds the calculate interest service. /// </summary> /// <param name="services">Services.</param> /// <param name="configuration">Configuration.</param> public static void AddCalculateInterest(this IServiceCollection services, IConfiguration configuration) { var options = new CalculateInterestOptions(); var section = configuration.GetSection("CalculateInterest"); section.Bind(options); var calculateInterestService = new CalculateInterestService(options); services.AddScoped <ICalculateInterestService>(_ => calculateInterestService); }
/// <summary> /// Initializes a new instance of the <see cref="T:SoftplanCalc.Api.Tests.CalculateInterestControllerUnitTest"/> class. /// </summary> public CalculateInterestControllerUnitTest() { var configuration = TestHelper.GetIConfiguration(Directory.GetCurrentDirectory()); var options = new CalculateInterestOptions(); var section = configuration.GetSection("CalculateInterest"); section.Bind(options); var calculateInsterestService = new CalculateInterestService(options); var logger = new BaseLogger(); _calculateInterestController = new CalculateInterestController(logger, calculateInsterestService); }