Ejemplo n.º 1
0
        private static async Task AddUserAndItem(string userName, string userEmail, Dictionary <string, double> productsList)
        {
            var user = await _userManager.FindByNameAsync(userEmail);

            if (user == null)
            {
                IdentityUser tempUser = new IdentityUser(userEmail);
                tempUser.Email = userEmail;
                await _userManager.CreateAsync(tempUser, "1234Abcd!");
            }

            foreach (var product in productsList)
            {
                var itemsTableEntity = await _repository.GetEntityAsync <ItemsTableEntity>(StorageTablesNames.Items,
                                                                                           product.Key + "-" + userEmail, AuctionAppConstants.ItemsTablePartitionKey);

                if (itemsTableEntity == null)
                {
                    itemsTableEntity = new ItemsTableEntity(product.Key, userEmail, product.Value);

                    await _repository.InsertOrReplaceEntityAsync(StorageTablesNames.Items, itemsTableEntity);
                }
            }
        }
Ejemplo n.º 2
0
        private void GenerateTestData()
        {
            _auctionsTestData1 = new List <AuctionsTableEntity>
            {
                new AuctionsTableEntity
                {
                    FinishingAt = DateTime.UtcNow.AddMinutes(60),
                    Status      = AuctionAppConstants.AuctionStatusInProgress
                }
            };

            _auctionsTestData2 = new List <AuctionsTableEntity>
            {
                new AuctionsTableEntity
                {
                    FinishingAt = DateTime.UtcNow,
                    Status      = AuctionAppConstants.AuctionStatusFinished
                }
            };

            _auctionsTestData3 = new List <AuctionsTableEntity>
            {
                new AuctionsTableEntity
                {
                    RowKey            = "fakeId",
                    FinishingAt       = DateTime.UtcNow,
                    Status            = AuctionAppConstants.AuctionStatusInProgress,
                    BiddersCollection = new Dictionary <string, double>()
                }
            };

            _auctionsTestData4 = new List <AuctionsTableEntity>
            {
                new AuctionsTableEntity
                {
                    RowKey            = "fakeId",
                    FinishingAt       = DateTime.UtcNow,
                    Status            = AuctionAppConstants.AuctionStatusInProgress,
                    BiddersCollection = new Dictionary <string, double>
                    {
                        { "user", 40 }
                    }
                }
            };

            _auctionsTestData5 = new List <AuctionsTableEntity>
            {
                new AuctionsTableEntity
                {
                    RowKey            = "fakeId",
                    FinishingAt       = DateTime.UtcNow,
                    Status            = AuctionAppConstants.AuctionStatusInProgress,
                    BiddersCollection = new Dictionary <string, double>
                    {
                        { "*****@*****.**", 60 }
                    }
                }
            };

            _itemsTableEntity = new ItemsTableEntity
            {
                RowKey = "fakeId",
                Name   = "Car",
                Price  = 50
            };
        }