///<Note> // saves Reimbursement to databsase ///</Note> private bool LogReimbursement(Reimbursement r) { var _query = $@" INSERT INTO reimbursement (cart_id, hsmv_report_number, timely, reporting_agency, reimbursement_amount, reimbursement_date) VALUES (@cart, @hsmv, @timely, @agency, @amount, @date)"; var _params = new { cart = r.cart_id, hsmv = r.hsmv_report_number, timely = r.timely, agency = r.reporting_agency, amount = r.reimbursement_amount, date = DateTime.Now }; using (var conn = new NpgsqlConnection(_conn)) { var result = conn.Execute(_query, _params); return(result == 1); } }
///<Note> TODO // create a stripe transfer to reimburse the reporting agency // create a reimbursement object (holding transfer token) to save for s4 records ///</Note> private Reimbursement FormatReimbursement(CrashEvent crash_report, string cart_id) { var funds = new Reimbursement(crash_report, cart_id); // review order contents var accident = new { occured = crash_report.crash_date_and_time, reported = crash_report.hsmv_entry_date }; if (isWithinDateRange(accident.occured, accident.reported, 10)) { // adjsut fund allocation funds.reimbursement_amount += 5; funds.timely = true; } if (!LogReimbursement(funds)) { var error = "error writing reimbursement details"; throw new Exception(nameof(error)); } ; return(funds); }