Exemple #1
0
 public static void Seed(PhotoShareContext context)
 {
     TagGen.InitializeRandomData(context);
     System.Console.WriteLine("Tags successfuly added");
     AlbumGen.InitializeRandomData(context);
     System.Console.WriteLine("Albums successfuly added");
     AlbumTagGen.InitializeRandomData(context);
     System.Console.WriteLine("AlbumsTags successfuly added");
     PictureGen.InitializeRandomData(context);
     System.Console.WriteLine("Pictures successfuly added");
     TownGen.InitializeRandomData(context);
     System.Console.WriteLine("Towns successfuly added");
     UserGen.InitializeRandomData(context);
     System.Console.WriteLine("Users successfuly added");
 }
Exemple #2
0
        public ActionResult <UsersModel> Get([FromQuery] int id, [FromHeader] string stormuserSegment)
        {
            var envWriteBack = Environment.GetEnvironmentVariable("WRITE_BACK");

            var users = UserGen.GetUsers();

            var user = users.FirstOrDefault(_ => _.UserId == id.ToString());

            if (user == null)
            {
                return(new UsersModel
                {
                    UserId = id.ToString(),
                    UserName = "******",
                    UserSegment = "1",
                    Service = envWriteBack
                });
            }

            user.Service = envWriteBack;

            return(user);
        }
Exemple #3
0
        public static void Seed(BillsPaymentSystemContext context)
        {
            for (int countUsers = 1; countUsers <= 100; countUsers++)
            {
                var currentUser = UserGen.CreateNewUser();
                context.Users.Add(currentUser);

                var payments = random.Next(1, 6);
                for (int countPayments = 0; countPayments < payments; countPayments++)
                {
                    var currentPayment = new PaymentMethod();
                    var type           = random.Next(1, 100) % 2;

                    if (type == 1)
                    {
                        var currentAccount = BankAccountGen.CreateNewBankAccount();
                        context.BankAccounts.Add(currentAccount);

                        currentPayment.Type        = PaymentType.BankAccount;
                        currentPayment.BankAccount = currentAccount;
                    }
                    else
                    {
                        var currentAccount = CreditCardGen.CreateNewCreditCard();
                        context.CreditCards.Add(currentAccount);

                        currentPayment.Type       = PaymentType.CreditCard;
                        currentPayment.CreditCard = currentAccount;
                    }

                    currentPayment.User = currentUser;
                    context.PaymentMethods.Add(currentPayment);
                }
            }
            context.SaveChanges();
        }