nahidjamalli

Service Layer

Sep 20th, 2021
1,129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace _____
  2. {
  3.     [SessionRequestFilter]
  4.     public class AdminService : Service
  5.     {
  6.         private readonly ICacheClient _cache;
  7.         private readonly JetonPaymentService _jetonService;
  8.         private readonly AsanaService _asanaService;
  9.         private readonly RocketPaymentService _rocketService;
  10.         private readonly ILogger _logger = Log.ForContext<AdminService>();
  11.         private readonly DbRepo _repo;
  12.         private readonly IMailService _mailService;
  13.         private readonly IRedisService _redisService;
  14.  
  15.         public AdminService(DbRepo repo, ICacheClient cache, JetonPaymentService jetonService, AsanaService asanaService, RocketPaymentService rocketService, IMailService mailService, IRedisService redisService)
  16.         {
  17.             _cache = cache;
  18.             _repo = repo;
  19.             _mailService = mailService;
  20.             _jetonService = jetonService;
  21.             _asanaService = asanaService;
  22.             _rocketService = rocketService;
  23.             _redisService = redisService;
  24.         }
  25.  
  26.         public async Task<object> Any(UpdateWithdrawRocketTransferRequest request)
  27.         {
  28.             _logger.Information("UpdateWithdrawRocketTransferRequest : UserId : {userId} , Lang : {lang}, {request}", Request.UserId(), Request.Lang(), request.SerializeToString());
  29.  
  30.             var withdrawDetails = await _repo.WithdrawRocketTransferDetail(request.Id);
  31.  
  32.             var result = await _repo.UpdateWithdrawRocketTransfer(Request.Lang(), Request.UserId(), request.SiteId,
  33.                     request.Id, request.Status, request.CancelReason);
  34.  
  35.             if (request.Status != 2 || withdrawDetails.Status == 2) return Request.ToOptimizedResult(result);
  36.             var updatedDetails = await _repo.WithdrawRocketTransferDetail(request.Id);
  37.             if (updatedDetails.Status != 2) return Request.ToOptimizedResult(result);
  38.  
  39.             try
  40.             {
  41.                 var withdrawResponse = await _rocketService.WithdrawRequest(withdrawDetails.BankId, request.Id.ToString(), withdrawDetails.PlayerId.ToString(),
  42.                 withdrawDetails.Username, withdrawDetails.RequestAmount, withdrawDetails.Iban, "");
  43.             }
  44.             catch (Exception e)
  45.             {
  46.                 await _repo.UpdateWithdrawRocketTransfer(Request.Lang(), Request.UserId(), request.SiteId,
  47.                     request.Id, 3, e.Message);
  48.                 throw e;
  49.             }
  50.  
  51.             return Request.ToOptimizedResult(result);
  52.         }
  53.  
  54.         public async Task<object> Any(AccountingPlayersWithSameIpRequest request)
  55.         {
  56.             _logger.Information("AccountingPlayersWithSameIpRequest : UserId : {userId} , Lang : {lang}, {request}",
  57.                 Request.UserId(), Request.Lang(), request.SerializeToString());
  58.             var result = await _repo.AccountingPlayersWithSameIp(request.PlayerId);
  59.             return Request.ToOptimizedResult(result);
  60.         }
  61.  
  62.         public async Task<object> Any(CreateNewDynamicFormRequest req)
  63.         {
  64.             return Request.ToOptimizedResult(await _repo.CreateNewDynamicForm(req.Id, req.SiteId, req.Name, req.Lang, Request.Lang(), req.Currency, req.Active, req.ImageURL));
  65.         }
  66.         public async Task<object> Any(SiteTournamentMarketRequest req)
  67.         {
  68.             return Request.ToOptimizedResult(await _repo.SiteTournamentMarkets(Request.Lang(), req.SiteId, req.TournamentId, req.Live));
  69.         }
  70.         public async Task<object> Any(UpdateSiteTournamentMarketRequest req)
  71.         {
  72.             return Request.ToOptimizedResult(await _repo.UpdateSiteTournamentMarket(Request.Lang(), req.SiteId, req.MarketId, req.TournamentId, req.PrematchActive, req.LiveActive, req.OddsKey1, req.OddsKey2, req.OddsKey3, req.MinimumOffer, req.MaximumCap, req.Intervals));
  73.         }
  74.         public async Task<object> Any(SiteCategoryMarketRequest request)
  75.         {
  76.             _logger.Information("SiteCategoryMarketRequest : UserId : {userId} , Lang : {lang}, {request}",
  77.                Request.UserId(), Request.Lang(), request.SerializeToString());
  78.  
  79.             var result = await _repo.SiteCategoryMarkets(Request.Lang(), request.SiteId, request.CategoryId, request.Live);
  80.             return Request.ToOptimizedResult(result);
  81.         }
  82.         public async Task<object> Any(UpdateSiteCategoryMarketRequest request)
  83.         {
  84.             _logger.Information("UpdateSiteCategoryMarketRequest : UserId : {userId} , Lang : {lang}, {request}",
  85.                 Request.UserId(), Request.Lang(), request.SerializeToString());
  86.             var result = await _repo.UpdateSiteCategoryMarket(Request.Lang(), request.SiteId, request.MarketId, request.CategoryId, request.PrematchActive, request.LiveActive, request.OddsKey1, request.OddsKey2, request.OddsKey3, request.MinimumOffer, request.MaximumCap, request.Intervals);
  87.             return Request.ToOptimizedResult(result);
  88.         }
  89.  
  90.         public async Task<object> Any(SiteSportMarketRequest request)
  91.         {
  92.             _logger.Information("SiteSportMarketRequest : UserId : {userId} , Lang : {lang}, {request}",
  93.                Request.UserId(), Request.Lang(), request.SerializeToString());
  94.             var result = await _repo.SiteSportMarkets(Request.Lang(), request.SiteId, request.SportId, request.Live);
  95.             return Request.ToOptimizedResult(result);
  96.         }
  97.     }
  98. }
RAW Paste Data