Пример #1
0
        public dynamic GetReportData()
        {
            // Generating employee list
            var employees = Enumerable
                            .Range(0, NumberData.GetNumber(10, 50))
                            .Select(i =>
            {
                dynamic newEmployee       = new ExpandoObject();
                newEmployee.BirthDate     = DateTimeData.GetDatetime(new DateTime(1973, 1, 1), new DateTime(1997, 12, 1));
                newEmployee.FirstName     = NameData.GetFirstName();
                newEmployee.LastName      = NameData.GetSurname();
                newEmployee.Company       = NameData.GetCompanyName();
                newEmployee.Email         = NetworkData.GetEmail();
                newEmployee.PhoneNumber   = PhoneNumberData.GetInternationalPhoneNumber();
                newEmployee.Address       = string.Format("{0} {1} {2}\n{3},{4} {5}", PlaceData.GetStreetName(), PlaceData.GetStreetNumber(), PlaceData.GetAddress(), PlaceData.GetCity(), PlaceData.GetState(), PlaceData.GetZipCode());
                newEmployee.PersonalQuote = TextData.GetSentences(5);
                // NOTE: Even though ExpandoObject is compatible with IDictionary<string,object>,
                //       The template engine only accepts Dictionary<string,object>
                return(new Dictionary <string, object>(newEmployee));
            })
                            .ToList();

            dynamic reportData = new ExpandoObject();

            reportData.Employees = employees;
            return(reportData);
        }
        public static string GetCompanyName()
        {
            string surname = NameData.GetSurname();

            string[] strArrays = new string[] { "Inc", "Incorporated", "LLC", "Ltd", "Group", "and Sons", "and Partners", "CIC", "CIO", "Co-Operative", "Society", "LP", "LLP", "General Partnership", "PLC", "Cyf", "Ccc", "Corp.", "Corporation" };
            string   str       = string.Concat(surname, " ", ArrayData.GetElement <string>(strArrays));

            return(str);
        }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 1; i <= 100; i++)
            {
                Ogrenci ogr = new Ogrenci();
                ogr.Id         = i;
                ogr.Ad         = NameData.GetFirstName();  // fakedata dan aldık
                ogr.Soyad      = NameData.GetSurname();
                ogr.BolumId    = NumberData.GetNumber(10); // 0 la 10 arası numara getirir
                ogr.TcKimlikNo = NumberData.GetNumber(12311232, 999999999);

                ogr.AdresNesnesi.Sokak  = PlaceData.GetStreetName();
                ogr.AdresNesnesi.Cadde  = NumberData.GetNumber(100);
                ogr.AdresNesnesi.KapiNo = NumberData.GetNumber(200);

                olist.Add(ogr);
            }
        }
Пример #4
0
        protected override void Seed(DatabaseContext context)
        {
            EverNoteUser admin = new EverNoteUser()
            {
                Name                 = "Ayan",
                Surname              = "Ünal",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                UserName             = "******",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUserName     = "******",
                ProfileImageFileName = "userimg.jfif"
            };
            EverNoteUser standartuser = new EverNoteUser()
            {
                Name                 = "Can",
                Surname              = "Ünal",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                UserName             = "******",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUserName     = "******",
                ProfileImageFileName = "userimg.jfif"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartuser);

            //Adding fake user
            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fakeuser = new EverNoteUser()
                {
                    Name                 = NameData.GetFirstName(),
                    Surname              = NameData.GetSurname(),
                    Email                = NetworkData.GetEmail(),
                    ActiveGuid           = Guid.NewGuid(),
                    IsActive             = true,
                    IsAdmin              = false,
                    UserName             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName     = $"user{i}",
                    ProfileImageFileName = "userimg.jfif"
                };
                context.EverNoteUsers.Add(fakeuser);
            }

            context.SaveChanges();

            //user lidt for using
            List <EverNoteUser> userlist = context.EverNoteUsers.ToList();

            //adding fake categories
            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };
                context.Categories.Add(cat);
                //adding fake notes
                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);
                    //adding fake comment
                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName
                                               //Note=note
                        };
                        note.Comments.Add(comment);

                        //adding fake likes
                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userlist[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }
                context.SaveChanges();
            }
        }
Пример #5
0
        protected override void Seed(ZeroDbContext context)
        {
            var admin = new ApplicationUser()
            {
                Id        = 1,
                FirstName = "Ekin",
                LastName  = "Memiş",
                Email     = "*****@*****.**",
                Password  = "******",
                Active    = true,
                Deleted   = false,
            };

            context.ApplicationUser.AddOrUpdate(admin);

            Random rnd = new Random();

            for (int i = 0; i < 100; i++)
            {
                Customer customer = new Customer
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                };
                context.Customer.AddOrUpdate(customer);

                Employee employee = new Employee
                {
                    Id                    = i,
                    Active                = true,
                    DateOfBirth           = DateTimeData.GetDatetime(),
                    Deleted               = false,
                    Email                 = NetworkData.GetEmail(),
                    FirstName             = NameData.GetFirstName(),
                    LastName              = NameData.GetSurname(),
                    PalceOfBirth          = FakeData.PlaceData.GetAddress(),
                    PhoneNumber           = PhoneNumberData.GetPhoneNumber(),
                    TurkishIdentityNumber = NumberData.GetDouble().ToString(),
                    Sallary               = NumberData.GetNumber(),
                    Title                 = NameData.GetCompanyName()
                };
                context.Employee.AddOrUpdate(employee);

                AppointmentType appointmentType = new AppointmentType
                {
                    Id = i,
                    DefaultSeanceQuantity = NumberData.GetNumber(1, 10),
                    Name    = TextData.GetAlphabetical(5),
                    Deleted = false,
                };
                context.AppointmentType.AddOrUpdate(appointmentType);

                Appointment appointment = new Appointment
                {
                    Id                  = i,
                    Deleted             = false,
                    StartDate           = DateTimeData.GetDatetime(),
                    EndDate             = DateTimeData.GetDatetime(),
                    Price               = NumberData.GetNumber(),
                    PriceIncludedTax    = NumberData.GetNumber(),
                    Name                = TextData.GetAlphabetical(5),
                    AppointmentStatusId = 0,
                    AppointmentTypeId   = rnd.Next(100),
                };
                context.Appointment.AddOrUpdate(appointment);
            }
        }
Пример #6
0
        protected override void Seed(DatabaseContext context)
        {
            //admin kullanıcı ekleme işlemi.
            EverNoteUser admin = new EverNoteUser()
            {
                Name                = "Aydan",
                SurName             = "Torun",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "user.png"
            };

            //standart kullanıcı ekleme.

            EverNoteUser standartUser = new EverNoteUser()
            {
                Name                = "Maykıl",
                SurName             = "Ceksın",
                Email               = "ceksı[email protected]",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = false,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "user.png"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartUser);


            //fake kullanıcı ekleme.

            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fakeuser = new EverNoteUser()
                {
                    Name                = NameData.GetFirstName(),
                    SurName             = NameData.GetSurname(),
                    Email               = NetworkData.GetEmail(),
                    ActivateGuid        = Guid.NewGuid(),
                    IsActive            = true,
                    IsAdmin             = false,
                    UserName            = $"user{i}",
                    Password            = "******",
                    CreatedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn          = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName    = $"user{i}",
                    ProfilImageFileName = "user.png"
                };
                context.EverNoteUsers.Add(fakeuser);
            }

            context.SaveChanges();

            //User List For using


            List <EverNoteUser> userList = context.EverNoteUsers.ToList();

            //Adding fake Categories
            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };

                context.Categories.Add(cat);
                //Adding fake Notes

                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);

                    //Adding fake comments

                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName,
                            //  Note=note
                        };
                        note.Comments.Add(comment);

                        //Adding sahte beğeniler

                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userList[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }

                context.SaveChanges();
            }
        }
Пример #7
0
        public void Generate()
        {
            var random = new Random();

            client.PutIndex(new RavenDocumentsByEntityName());
            client.PutIndex(new OrdersByCompany());
            client.PutIndex(new OrdersTotals());
            client.PutIndex(new ProductSales());
            client.PutIndex(new OrdersByEmployeeAndCompany());
            client.PutIndex(new OrdersByEmployeeAndCompanyReduce());

            var nextOrderId    = 1;
            var nextCompanyId  = 1;
            var nextProductId  = 1;
            var nextEmployeeId = 1;

            for (var it = 0; it < numberOfIterations; it++)
            {
                var entities = new List <object>();

                for (var i = 0; i < NumberOfOrdersPerIteration; i++)
                {
                    entities.Add(new Order
                    {
                        Id      = "orders/" + nextOrderId++,
                        Company = "companies/" + random.Next(1, ExpectedNumberOfCompanies - 1),
                        Lines   = CollectionData.GetElement(10, new List <OrderLine>
                        {
                            new OrderLine
                            {
                                Product      = "products/" + random.Next(1, ExpectedNumberOfProducts - 1),
                                Quantity     = random.Next(1, 100),
                                PricePerUnit = random.Next(1000)
                            }
                        }).ToList(),
                        Employee  = "employees/" + random.Next(1, ExpectedNumberOfEmployees - 1),
                        OrderedAt = DateTimeData.GetDatetime(),
                        RequireAt = DateTime.UtcNow.AddDays(7),
                        ShipTo    = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfCompaniesPerIteration; i++)
                {
                    entities.Add(new Company
                    {
                        Id      = "companies/" + nextCompanyId++,
                        Name    = NameData.GetCompanyName(),
                        Fax     = PhoneNumberData.GetInternationalPhoneNumber(),
                        Address = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfEmployeesPerIteration; i++)
                {
                    entities.Add(new Employee
                    {
                        Id        = "employees/" + nextEmployeeId++,
                        Birthday  = DateTimeData.GetDatetime(),
                        FirstName = NameData.GetFirstName(),
                        LastName  = NameData.GetSurname(),
                        HomePhone = PhoneNumberData.GetPhoneNumber(),
                        HiredAt   = DateTimeData.GetDatetime(),
                        Address   = new Address
                        {
                            Country    = PlaceData.GetCountry(),
                            City       = PlaceData.GetCity(),
                            PostalCode = PlaceData.GetZipCode(),
                            Line1      = PlaceData.GetStreetName()
                        }
                    });
                }

                for (var i = 0; i < NumberOfProductsPerIteration; i++)
                {
                    entities.Add(new Product
                    {
                        Id           = "products/" + nextProductId++,
                        Category     = TextData.GetAlphabetical(5),
                        Name         = NameData.GetSurname(),
                        Discontinued = BooleanData.GetBoolean(),
                        PricePerUnit = NumberData.GetNumber()
                    });
                }

                client.PutEntities(entities);
            }
        }
Пример #8
0
        // Adding Admin User
        protected override void Seed(DatabaseContext context) // db den context türettik
        {
            EverNoteUser admin = new EverNoteUser()
            {
                Name                = "Melike",
                Surname             = "Arıkan",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "userImage.jfif"
            };

            // Adding Standart User

            EverNoteUser standartUser = new EverNoteUser()
            {
                Name                = "Muhammet",
                Surname             = "Tiryaki",
                Email               = "*****@*****.**",
                ActivateGuid        = Guid.NewGuid(),
                IsActive            = true,
                IsAdmin             = true,
                UserName            = "******",
                Password            = "******",
                CreatedOn           = DateTime.Now,
                ModifiedOn          = DateTime.Now.AddMinutes(5),
                ModifiedUserName    = "******",
                ProfilImageFileName = "userImage.jfif"
            };

            context.EverNoteUsers.Add(admin);
            context.EverNoteUsers.Add(standartUser);



            // Using Fake User

            for (int i = 0; i < 8; i++)
            {
                EverNoteUser fake = new EverNoteUser()
                {
                    Name                = NameData.GetFirstName(),
                    Surname             = NameData.GetSurname(),
                    Email               = NetworkData.GetEmail(),
                    ActivateGuid        = Guid.NewGuid(),
                    IsActive            = true,
                    IsAdmin             = true,
                    UserName            = $"user{i}",
                    Password            = "******",
                    CreatedOn           = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedOn          = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                    ModifiedUserName    = $"user{i}",
                    ProfilImageFileName = "userImage.jfif"
                };

                context.EverNoteUsers.Add(fake);
            }


            context.SaveChanges();

            // User List For Using

            List <EverNoteUser> userList = context.EverNoteUsers.ToList();

            // Adding Fake Categories

            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUserName = "******"
                };

                context.Categories.Add(cat);

                // Adding Fake Notes

                for (int k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    EverNoteUser owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        Category         = cat,
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                        ModifiedUserName = owner.UserName
                    };
                    cat.Notes.Add(note);

                    //Adding Fake Comment

                    for (int j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        EverNoteUser comment_owner = userList[NumberData.GetNumber(0, userList.Count - 1)];
                        Comment      comment       = new Comment()
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-2), DateTime.Now),
                            ModifiedUserName = comment_owner.UserName,
                            Note             = note
                        };
                        note.Comments.Add(comment);

                        // Adding Fake Likes
                        for (int m = 0; m < note.LikeCount; m++)
                        {
                            Liked liked = new Liked()
                            {
                                LikedUser = userList[m]
                            };
                            note.Likes.Add(liked);
                        }
                    }
                }
                context.SaveChanges();
            }
        }
Пример #9
0
        protected override void Seed(DatabaseContext context)
        {
            //Adding Admin User
            var admin = new EvernoteUser
            {
                Name             = "Murat",
                Surname          = "Başeren",
                Email            = "*****@*****.**",
                ActivateGuid     = Guid.NewGuid(),
                IsActive         = true,
                IsAdmin          = true,
                Username         = "******",
                Password         = "******",
                CreatedOn        = DateTime.Now,
                ModifiedOn       = DateTime.Now.AddMinutes(5),
                ModifiedUsername = "******"
            };

            //Adding Standart User
            var standartuser = new EvernoteUser
            {
                Name             = "Kadir",
                Surname          = "Başeren",
                Email            = "*****@*****.**",
                ActivateGuid     = Guid.NewGuid(),
                IsActive         = true,
                IsAdmin          = false,
                Username         = "******",
                Password         = "******",
                CreatedOn        = DateTime.Now,
                ModifiedOn       = DateTime.Now.AddMinutes(65),
                ModifiedUsername = "******"
            };

            context.EvernoteUsers.Add(admin);
            context.EvernoteUsers.Add(standartuser);

            for (var z = 0; z < 8; z++)
            {
                var user = new EvernoteUser
                {
                    Name             = NameData.GetFirstName(),
                    Surname          = NameData.GetSurname(),
                    Email            = NetworkData.GetEmail(),
                    ActivateGuid     = Guid.NewGuid(),
                    IsActive         = true,
                    IsAdmin          = false,
                    Username         = $"user{z}",
                    Password         = "******",
                    CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername = $"user{z}"
                };
                context.EvernoteUsers.Add(user);
            }

            context.SaveChanges();

            //Note:UserList for using...
            var userlist = context.EvernoteUsers.ToList();

            //Note: Adding Fake Categories
            for (var i = 0; i < 10; i++)
            {
                var cat = new Category
                {
                    Title            = PlaceData.GetStreetName(),
                    Description      = PlaceData.GetStreetName(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now.AddMinutes(5),
                    ModifiedUsername = "******"
                };
                context.Categories.Add(cat);

                //Note:Adding Fake Notes
                for (var k = 0; k < NumberData.GetNumber(5, 9); k++)
                {
                    var note_owner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                    var note       = new Note
                    {
                        Title            = TextData.GetAlphabetical(NumberData.GetNumber(5, 25)),
                        Text             = TextData.GetSentences(NumberData.GetNumber(1, 3)),
                        IsDraft          = false,
                        LikeCount        = NumberData.GetNumber(1, 9),
                        Owner            = note_owner,
                        CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUsername = note_owner.Username
                    };
                    cat.Notes.Add(note);
                    //Note:Adding Fake Comments

                    for (var j = 0; j < NumberData.GetNumber(3, 5); j++)
                    {
                        var commentowner = userlist[NumberData.GetNumber(0, userlist.Count - 1)];
                        var comment      = new Comment
                        {
                            Text             = TextData.GetSentence(),
                            Owner            = userlist[NumberData.GetNumber(0, userlist.Count - 1)],
                            CreatedOn        = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn       = DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUsername = commentowner.Username
                        };
                        note.Comments.Add(comment);
                    }

                    //Note:Adding Fake Likes...


                    for (var j = 0; j < note.LikeCount; j++)
                    {
                        var likes = new Liked
                        {
                            LikedUser = userlist[j]
                        };
                        note.Likes.Add(likes);
                    }
                }
            }

            context.SaveChanges();
        }
Пример #10
0
        protected override void Seed(MasterChefDbContext context)
        {
            if (context.Users.Any())
            {
                return;
            }

            var roleStore   = new RoleStore <IdentityRole>(context);
            var roleManager = new RoleManager <IdentityRole>(roleStore);

            //Roles
            var roles     = Settings.Default.Roles.Split(',');
            var adminRole = roles[0];
            var userRole  = roles[1];

            foreach (var role in roles)
            {
                roleManager.Create(new IdentityRole {
                    Name = role
                });
            }

            var userStore   = new UserStore <AppUser>(context);
            var userManager = new UserManager <AppUser>(userStore);

            // Images
            var defaultImage = new Image {
                Path = "~/Uploaded_Files/default.png"
            };
            var adminImage = new Image {
                Path = "~/Uploaded_Files/admin.jpg"
            };

            context.Images.AddOrUpdate(
                defaultImage,
                adminImage
                );

            context.SaveChanges();

            // Countries
            var json      = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\countries.json");
            var countries = JsonConvert.DeserializeObject <IEnumerable <Country> >(json);

            foreach (var country in countries)
            {
                context.Countries.Add(country);
            }

            //Ingredient Names
            var jsonIngredientNames = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\ingredients.json");
            var ingredientNames     = JsonConvert.DeserializeObject <IEnumerable <IngredientName> >(jsonIngredientNames);

            foreach (var name in ingredientNames)
            {
                context.IngredientNames.Add(name);
            }

            // Users
            var countryBulgaria = context.Countries.Local.Single(item => item.Name == "Bulgaria");
            var userAdmin       = new AppUser
            {
                UserName  = "******",
                Email     = "admin@admin",
                FirstName = NameData.GetFirstName(),
                LastName  = NameData.GetSurname(),
                Country   = countryBulgaria,
                Image     = adminImage
            };


            userManager.Create(userAdmin, userAdmin.UserName);
            userManager.AddToRole(userAdmin.Id, adminRole);

            for (int userIndex = 0; userIndex < 100; userIndex++)
            {
                bool isSuccess = false;

                while (!isSuccess)
                {
                    var firstName = NameData.GetFirstName();
                    var lastName  = NameData.GetSurname();
                    var userName  = firstName + "@" + lastName;

                    Country country = null;
                    while (country == null)
                    {
                        var countryName = PlaceData.GetCountry();
                        country = context.Countries.Local.SingleOrDefault(item => item.Name == countryName);
                    }

                    var user = new AppUser
                    {
                        UserName  = userName,
                        Email     = userName,
                        FirstName = firstName,
                        LastName  = lastName,
                        Country   = country,
                        Image     = new Image()
                        {
                            Path = string.Format("~/Uploaded_Files/Users/{0}.jpg", userIndex + 1)
                        }
                    };
                    isSuccess = userManager.Create(user, userName).Succeeded;
                    if (isSuccess)
                    {
                        userManager.AddToRole(user.Id, userRole);
                    }
                }
            }

            // Articles
            for (int i = 0; i < 15; i++)
            {
                var content   = TextData.GetSentences(30 + ((i + 1) * 7));
                var title     = TextData.GetSentence();
                var createdOn = DateTime.Now;

                var article = new Article
                {
                    Content   = content,
                    Title     = title,
                    CreatedOn = createdOn,
                    Creator   = userAdmin,
                    Image     = new Image()
                    {
                        Path = string.Format("~/Uploaded_Files/Users/{0}.jpg", i + 1)
                    }
                };

                context.Articles.Add(article);
            }

            context.SaveChanges();
        }
        public static string GetFullName()
        {
            string str = string.Concat(NameData.GetFirstName(), " ", NameData.GetSurname());

            return(str);
        }