public void Run() { BunqContext.LoadApiContext(ApiContext.Restore()); var timeSpanWeek = new TimeSpan( DAYS_IN_WEEK, TIME_UNIT_COUNT_NONE, TIME_UNIT_COUNT_NONE, TIME_UNIT_COUNT_NONE ); var dateStart = DateTime.Now.Subtract(timeSpanWeek); var dateEnd = DateTime.Now; var userId = BunqContext.UserContext.UserId; var userIdInt = userId; var monetaryAccountId = BunqContext.UserContext.PrimaryMonetaryAccountBank.Id.Value; var monetaryAccountIdInt = monetaryAccountId; var customerStatementId = CustomerStatementExport.Create(STATEMENT_FORMAT, dateStart.ToString(FORMAT_DATE_STATEMENT), dateEnd.ToString(FORMAT_DATE_STATEMENT)).Value; CustomerStatementExport.Delete(customerStatementId); BunqContext.ApiContext.Save(); }
public void Run() { var apiContext = ApiContext.Restore(); var timeSpanWeek = new TimeSpan( DAYS_IN_WEEK, TIME_UNIT_COUNT_NONE, TIME_UNIT_COUNT_NONE, TIME_UNIT_COUNT_NONE ); var dateStart = DateTime.Now.Subtract(timeSpanWeek); var dateEnd = DateTime.Now; var customerStatementMap = new Dictionary <string, object> { { CustomerStatementExport.FIELD_STATEMENT_FORMAT, STATEMENT_FORMAT }, { CustomerStatementExport.FIELD_DATE_START, dateStart.ToString(FORMAT_DATE_STATEMENT) }, { CustomerStatementExport.FIELD_DATE_END, dateEnd.ToString(FORMAT_DATE_STATEMENT) }, }; var userId = User.List(apiContext).Value[INDEX_FIRST].UserCompany.Id; if (userId != null) { var userIdInt = (int)userId; var monetaryAccountId = MonetaryAccountBank.List(apiContext, userIdInt).Value[INDEX_FIRST].Id; if (monetaryAccountId != null) { var monetaryAccountIdInt = (int)monetaryAccountId; var customerStatementId = CustomerStatementExport.Create(apiContext, customerStatementMap, userIdInt, monetaryAccountIdInt).Value; CustomerStatementExport.Delete(apiContext, userIdInt, monetaryAccountIdInt, customerStatementId); } } apiContext.Save(); }