public async Task <string> AddEditProgramAccoutDetails(ProgramAccountViewModel model, string clientIpAddress) { try { var Id = await AddEditProgramAccount(model); if (Id > 0) { if (model.id == 0) { var id = model.Jpos_ProgramAccountId; var progIssuerId = (await _program.FindAsync(new { id = model.programId }))?.JPOS_IssuerId; var paid = "PA1000-" + Id.ToString(); var oPlanJPOS = new AccountsJposDto() { dailyLimit = Convert.ToDouble(model.flexMaxSpendPerDay.Value), weeklyLimit = Convert.ToDouble(model.flexMaxSpendPerWeek.Value), initialBalance = Convert.ToDouble(model.intialBalanceCount), monthlyLimit = Convert.ToDouble(model.flexMaxSpendPerMonth), issuer = progIssuerId, active = true, name = model.accountName, layer = "001", roleOver = model.isRollOver.HasValue && model.isRollOver.Value ? "Y" : "N" // accounts = accounts.Count > 0 ? String.Join(", ", accounts.Select(x => x.accountName).ToList()) : "" }; int result = await _sharedJPOSService.PostRespectiveDataJPOS(JPOSAPIURLConstants.Accounts, oPlanJPOS, id, clientIpAddress, JPOSAPIConstants.Accounts); var chkExist = await FindAsync(new { id = Id }); chkExist.ProgramAccountId = paid; await UpdateAsync(chkExist, new { id = Id }); } return(Cryptography.EncryptPlainToCipher(Id.ToString())); } return("0"); } catch (Exception) { throw; } }
public async Task <int> AddEditProgramAccount(ProgramAccountViewModel model) { try { var chkExist = await FindAsync(new { id = model.id }); if (chkExist == null) { chkExist = new ProgramAccounts(); } if (model.accountName != null) { chkExist.accountName = model.accountName; } if (model.accountTypeId != 0) { chkExist.accountTypeId = model.accountTypeId; } if (model.createdBy != null) { chkExist.createdBy = model.createdBy; } if (model.createdDate != null) { chkExist.createdDate = model.createdDate; } chkExist.exchangePassValue = model.exchangePassValue; chkExist.exchangeResetDay = model.exchangeResetDay; chkExist.exchangeResetPeriodType = model.exchangeResetPeriodType; chkExist.exchangeResetTime = model.exchangeResetTime; chkExist.flexEndDate = model.flexEndDate; if (model.intialBalanceCount != null) { chkExist.intialBalanceCount = model.intialBalanceCount; } if (model.isActive != null) { chkExist.isActive = model.isActive; } if (model.isDeleted != null) { chkExist.isDeleted = model.isDeleted; } if (model.isPassExchangeEnabled != null) { chkExist.isPassExchangeEnabled = model.isPassExchangeEnabled; } chkExist.isRollOver = model.isRollOver; if (model.maxPassUsage != null) { chkExist.maxPassUsage = model.maxPassUsage; } if (model.modifiedBy != null) { chkExist.modifiedBy = model.modifiedBy; } if (model.modifiedDate != null) { chkExist.modifiedDate = model.modifiedDate; } chkExist.passType = model.passType; if (model.ProgramAccountId != null) { chkExist.ProgramAccountId = model.ProgramAccountId; } chkExist.resetDay = model.resetDay; if (model.resetPeriodType != 0) { chkExist.resetPeriodType = model.resetPeriodType; } if (model.programId != null) { chkExist.programId = model.programId; } if (model.resetTime != null) { chkExist.resetTime = model.resetTime; } chkExist.maxPassPerWeek = model.maxPassPerWeek; chkExist.maxPassPerMonth = model.maxPassPerMonth; chkExist.resetDateOfMonth = model.resetDateOfMonth; chkExist.flexMaxSpendPerDay = model.flexMaxSpendPerDay; chkExist.flexMaxSpendPerWeek = model.flexMaxSpendPerWeek; chkExist.flexMaxSpendPerMonth = model.flexMaxSpendPerMonth; chkExist.exchangeResetDateOfMonth = model.exchangeResetDateOfMonth; chkExist.vplMaxBalance = model.vplMaxBalance; chkExist.vplMaxAddValueAmount = model.vplMaxAddValueAmount; chkExist.vplMaxNumberOfTransaction = model.vplMaxNumberOfTransaction; chkExist.id = model.id; return(await InsertOrUpdateAsync(chkExist, new { id = model.id })); } catch (Exception) { throw; } }