public async Task <int> ReloadUserBalance(ReloadRequestModel model) { try { if (model.ReloadRequestId.HasValue && model.ReloadRequestId > 0) { var reloadRequest = await _reloadRequest.GetSingleDataByConditionAsync(new { id = model.ReloadRequestId, isRequestAccepted = false, isDeleted = false }); if (reloadRequest != null) { reloadRequest.isRequestAccepted = true; reloadRequest.programId = model.ProgramId; reloadRequest.modifiedBy = model.BenefactorUserId; reloadRequest.modifiedDate = DateTime.UtcNow; await _reloadRequest.UpdateAsync(reloadRequest, new { Id = reloadRequest.id }); } } var checkAutoReload = await GetReloadRuleOfUser(model.ReloadUserId, model.BenefactorUserId).ConfigureAwait(false); int reloadruleId = 0; if (model.IsAutoReload) { if (checkAutoReload == null) { checkAutoReload = new ReloadRules(); } else { reloadruleId = checkAutoReload.id; } checkAutoReload.userId = model.ReloadUserId; checkAutoReload.benefactorUserId = model.BenefactorUserId; checkAutoReload.isAutoReloadAmount = model.IsAutoReload; checkAutoReload.modifiedDate = DateTime.UtcNow; checkAutoReload.programId = model.ProgramId; checkAutoReload.reloadAmount = model.AutoReloadAmount; checkAutoReload.userDroppedAmount = model.CheckDroppedAmount; checkAutoReload.isActive = true; checkAutoReload.isDeleted = false; if (reloadruleId > 0) { await _reloadRule.UpdateAsync(checkAutoReload, new { Id = reloadruleId }); } else { await _reloadRule.AddAsync(checkAutoReload); } } return(1); } catch (Exception) { throw; } }
public async Task <IEnumerable <ReloadRequestDto> > CancelReloadRule(ReloadRequestModel model) { using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync()) { try { var rule = (await sqlConnection.QueryAsync <ReloadRequestDto>(SQLQueryConstants.CancelReloadRuleQuery, new { uid = model.ReloadUserId, buid = model.BenefactorUserId })); return(rule); } catch (Exception) { throw; } finally { sqlConnection.Close(); sqlConnection.Dispose(); } } }