Example #1
0
        public async override Task ProcessAsync(int dummy)
        {
            // _mcApi.Client.GetAsync()
            var user = await _repo.GetUser("paedelm");

            Console.WriteLine($"userid: {user.Id} knownAs:{user.KnownAs} lastactive:{user.LastActive}");
            PagedList <Mutation> pg = await _repo.GetMutationsForUserAccount(new Helpers.MutationParams {
                UserId = 1, AccountId = 1, PageNumber = 1, PageSize = 20
            });

            Console.WriteLine($"PageSize={pg.PageSize} en Count={pg.Count}");
            Console.WriteLine($"version={GetType().GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version}");
            foreach (var mut in pg)
            {
                Console.WriteLine($"{mut.Account.Accountname} - {mut.Amount} - {mut.Balance} - {mut.Created}");
            }
            string json = JsonConvert.SerializeObject(value: pg, formatting: Formatting.Indented, settings: new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            // Console.WriteLine($"json={json}");
            _logger.LogInformation("PollerProcess via logger");
            await Task.Run(() =>
            {
                //    logger.LogInformation("In de poller Process procedure"));
                Console.WriteLine($"In de poller Process procedure");
            });
        }
Example #2
0
        public async Task <IActionResult> GetMutationsForUserAccount(int userId, int accountId, MutationParams mutationParams)
        {
            var currentUserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (currentUserId != userId)
            {
                return(Unauthorized());
            }

            var account = await _repo.GetAccount(accountId);

            if (account == null || account.UserId != userId)
            {
                return(Unauthorized());
            }

            var user = await _repo.GetUser(userId);

            mutationParams.UserId    = userId;
            mutationParams.AccountId = accountId;

            var pgMutationsFromRepo = await _repo.GetMutationsForUserAccount(mutationParams);

            var accDisply = _map.Map <AccountForDetailedDto>(account);
            var mutations = _map.Map <ICollection <MutationForListDto> >(pgMutationsFromRepo);

            Response.AddPagination(pgMutationsFromRepo.CurrentPage, pgMutationsFromRepo.PageSize,
                                   pgMutationsFromRepo.TotalCount, pgMutationsFromRepo.TotalPages);
            return(Ok(new MutationForPageDto {
                Account = accDisply, Mutations = mutations
            }));
        }