Exemple #1
0
        private static void SeedRequestTypes(RequestsDbContext db)
        {
            if (db.RequestTypes.Any())
            {
                return;
            }

            var requestTypes = new List <RequestType>()
            {
                new RequestType()
                {
                    Type = "Create Account"
                },
                new RequestType()
                {
                    Type = "Block Account"
                },
                new RequestType()
                {
                    Type = "Close Account"
                }
            };

            db.RequestTypes.AddRange(requestTypes);

            db.SaveChanges();
        }
Exemple #2
0
        private static void SeedRequests(IIdentityService identityService, RequestsDbContext db)
        {
            if (db.ExchangeratRequests.Any())
            {
                return;
            }

            Task.Run(async() =>
            {
                var userIds = await identityService.GetRegisteredUsersIds();

                var random = new Random();

                var requestTypeId = db.RequestTypes.FirstOrDefault().Id;

                var requests = new List <ExchangeratRequest>();

                for (int i = 0; i < 10; i++)
                {
                    var status      = random.Next(0, 2);
                    var userIdIndex = random.Next(0, userIds.Count - 1);

                    var request = new ExchangeratRequest()
                    {
                        RequestTypeId = requestTypeId,
                        IssuedAt      = DateTime.UtcNow,
                        Status        = (Data.Enums.Status)status,
                        UserId        = userIds.ElementAt(userIdIndex)
                    };

                    requests.Add(request);
                }

                db.ExchangeratRequests.AddRange(requests);
                db.SaveChanges();
            })
            .GetAwaiter()
            .GetResult();
        }
Exemple #3
0
 public RequestService(RequestsDbContext dbContext, IExchangeAccountService exchangeAccounts, IBus publisher)
     : base(dbContext)
 {
     this.exchangeAccounts = exchangeAccounts;
     this.publisher        = publisher;
 }
Exemple #4
0
 public RequestTypeService(RequestsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }