public async Task UpdateAsync(ILykkeEntity lykkeEntity) { await _storage.MergeAsync(GetPartitionKey(), GetRowKey(lykkeEntity.Id), entity => { Mapper.Map(lykkeEntity, entity); return(entity); }); }
public Task AddLykkeEntityAsync(ILykkeEntity entity) { var tasks = new List <Task> { _database.HashSetAsync(GetLykkeEntityKey(entity.Id), entity.ToHashEntries()), _database.SetAddAsync(GetLykkeEntityIdsKey(), entity.Id) }; return(Task.WhenAll(tasks)); }
public async Task <ILykkeEntity> InsertAsync(ILykkeEntity lykkeEntity) { var entity = new LykkeEntityEntity(GetPartitionKey(), GetRowKey(lykkeEntity.Id)); Mapper.Map(lykkeEntity, entity); await _storage.InsertAsync(entity); return(Mapper.Map <LykkeEntity>(entity)); }
public static HashEntry[] ToHashEntries(this ILykkeEntity entity) { return(new[] { new HashEntry(nameof(LykkeEntity.Id), entity.Id), new HashEntry(nameof(LykkeEntity.Name), entity.Name ?? string.Empty), new HashEntry(nameof(LykkeEntity.Description), entity.Description ?? string.Empty), new HashEntry(nameof(LykkeEntity.Priority), entity.Priority.ToString() ?? string.Empty), }); }
public async Task <bool> CheckWithdrawalAsync(string clientId, string lykkeEntityId) { ILykkeEntity lykkeEntity = await _redisService.GetLykkeEntityAsync(lykkeEntityId); if (lykkeEntity == null) { throw new LykkeEntityNotFoundException(lykkeEntityId); } return(await CheckDisclaimerAsync(clientId, lykkeEntity.Id, DisclaimerType.Withdrawal)); }
public async Task <IActionResult> GetAsync(string lykkeEntityId) { ILykkeEntity lykkeEntity = await _lykkeEntityService.GetAsync(lykkeEntityId); if (lykkeEntity == null) { return(NotFound()); } var model = Mapper.Map <LykkeEntityModel>(lykkeEntity); return(Ok(model)); }
public async Task <IDisclaimer> AddAsync(IDisclaimer disclaimer) { ILykkeEntity lykkeEntity = await _redisService.GetLykkeEntityAsync(disclaimer.LykkeEntityId); if (lykkeEntity == null) { throw new LykkeEntityNotFoundException(disclaimer.LykkeEntityId); } IDisclaimer createdDisclaimer = await _disclaimerRepository.InsertAsync(disclaimer); await _redisService.AddDisclaimerAsync(createdDisclaimer); _log.Info("Lykke entity disclaimer added", disclaimer); return(createdDisclaimer); }
public async Task <bool> CheckDepositAsync(string clientId, string lykkeEntityId) { ILykkeEntity lykkeEntity = await _redisService.GetLykkeEntityAsync(lykkeEntityId); if (lykkeEntity == null) { throw new LykkeEntityNotFoundException(lykkeEntityId); } if (!string.IsNullOrEmpty(_depositDelayDisclaimerId) && !await _fxPaygateClient.IsClientSuspicious(clientId)) { await ApproveAsync(clientId, _depositDelayDisclaimerId); } return(await CheckDisclaimerAsync(clientId, lykkeEntity.Id, DisclaimerType.Deposit)); }
public async Task <ILykkeEntity> AddAsync(ILykkeEntity lykkeEntity) { ILykkeEntity existingLykkeEntity = await _redisService.GetLykkeEntityAsync(lykkeEntity.Id); if (existingLykkeEntity != null) { throw new LykkeEntityAlreadyExistsException(lykkeEntity.Id); } ILykkeEntity createdLykkeEntity = await _lykkeEntityRepository.InsertAsync(lykkeEntity); await _redisService.AddLykkeEntityAsync(createdLykkeEntity); _log.Info("Lykke entity added", createdLykkeEntity); return(createdLykkeEntity); }
public async Task UpdateAsync(ILykkeEntity lykkeEntity) { ILykkeEntity existingLykkeEntity = await _redisService.GetLykkeEntityAsync(lykkeEntity.Id); if (existingLykkeEntity == null) { throw new LykkeEntityNotFoundException(lykkeEntity.Id); } var tasks = new List <Task> { _lykkeEntityRepository.UpdateAsync(lykkeEntity), _redisService.AddLykkeEntityAsync(lykkeEntity) }; await Task.WhenAll(tasks); _log.Info("Lykke entity updated", lykkeEntity); }
public async Task <bool> CheckTradableAsync(string clientId, string lykkeEntityId1, string lykkeEntityId2) { ILykkeEntity lykkeEntity1 = await _redisService.GetLykkeEntityAsync(lykkeEntityId1); if (lykkeEntity1 == null) { throw new LykkeEntityNotFoundException(lykkeEntityId1); } ILykkeEntity lykkeEntity2 = await _redisService.GetLykkeEntityAsync(lykkeEntityId2); if (lykkeEntity2 == null) { throw new LykkeEntityNotFoundException(lykkeEntityId2); } ILykkeEntity lykkeEntity = lykkeEntity1.Priority > lykkeEntity2.Priority ? lykkeEntity1 : lykkeEntity2; return(await CheckDisclaimerAsync(clientId, lykkeEntity.Id, DisclaimerType.Tradable)); }
public async Task <IActionResult> AddAsync([FromBody] CreateLykkeEntityModel model) { if (!ModelState.IsValid) { return(BadRequest(new ErrorResponse().AddErrors(ModelState))); } try { var lykkeEntity = Mapper.Map <LykkeEntity>(model); ILykkeEntity createdLykkeEntity = await _lykkeEntityService.AddAsync(lykkeEntity); return(Ok(Mapper.Map <LykkeEntityModel>(createdLykkeEntity))); } catch (LykkeEntityAlreadyExistsException exception) { _log.Error(exception, context: model); return(BadRequest(ErrorResponse.Create(exception.Message))); } }