Пример #1
0
        private static void AddInitialData()
        {
            DatabaseContext db = new DatabaseContext();

            if (db.Users.Any() == false)
            {
                db.Users.Add(new User {
                    Username = "******", Password = "******"
                });
                db.SaveChanges();
            }

            if (db.Expenses.Any() == false)
            {
                string[] categories = new string[] { "Market", "Elektronik", "Tatil", "Taký" };
                int      userId     = db.Users.FirstOrDefault().Id;

                for (int i = 0; i < 50; i++)
                {
                    db.Expenses.Add(new Expense
                    {
                        Category    = CollectionData.GetElement(categories),
                        Date        = DateTimeData.GetDatetime(),
                        Description = TextData.GetSentence(),
                        Price       = NumberData.GetNumber(100, 500),
                        UserId      = userId
                    });
                }

                db.SaveChanges();
            }
        }
Пример #2
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 T RandomiseNullable <T>(T value, double nullFraction)
            where T : class
        {
            var rnd = NumberData.GetNumber(0, 100);

            if (rnd / 100d <= nullFraction)
            {
                return(null);
            }

            return(value);
        }
Пример #4
0
        public static void Initialize()
        {
            Items = new List <TodoItem>();

            for (int i = 0; i < NumberData.GetNumber(10, 25); i++)
            {
                Items.Add(new TodoItem
                {
                    Id             = i,
                    Text           = TextData.GetSentence(),
                    IsHighPriority = BooleanData.GetBoolean(),
                    Status         = EnumData.GetElement <TodoStatus>()
                });
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
        protected override void Seed(AppWithEF.DatabaseContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            if (!context.Albums.Any())
            {
                for (int i = 0; i < 10; i++)
                {
                    context.Albums.Add(new Album
                    {
                        Name        = NameData.GetCompanyName(),
                        Description = TextData.GetSentence(),
                        Duration    = NumberData.GetNumber(),
                        Author      = NameData.GetFullName()
                    });
                }

                context.SaveChanges();
            }
            else
            {
                context.Albums.ToList().ForEach(x =>
                {
                    if (x.Duration == null || x.Duration == 0)
                    {
                        x.Duration = NumberData.GetNumber(500, 1000);
                    }

                    if (string.IsNullOrEmpty(x.Author))
                    {
                        x.Author = NameData.GetFullName();
                    }
                });

                if (context.ChangeTracker.HasChanges())
                {
                    context.SaveChanges();
                }
            }
        }
Пример #7
0
        private static void CreateFakeData(AlbumManager albumManager)
        {
            if (albumManager.Query().Any() == false)
            {
                for (int i = 0; i < 5; i++)
                {
                    albumManager.Create(new Album
                    {
                        Name    = NameData.GetCompanyName(),
                        Price   = (decimal)NumberData.GetDouble() * NumberData.GetNumber(100, 4000),
                        IsSales = BooleanData.GetBoolean(),
                        Year    = NumberData.GetNumber(1980, DateTime.Now.Year)
                    });
                }

                Console.WriteLine("Sample data created. Please enter for continue..");
                Console.WriteLine();
                Console.ReadKey();
            }
        }
        private static AllTypesModel GenerateSimpleModel(Random random, int min, int max)
        {
            var itemToAdd = new AllTypesModel
            {
                Long         = NumberData.GetNumber(min, max),
                LongNullable = RandomiseNullable(NumberData.GetNumber(min, max)),
#if USE_UTYPES
                ULong         = (ulong)NumberData.GetNumber(0, max),
                ULongNullable = RandomiseNullable((ulong)NumberData.GetNumber(0, max)),
#else
                ULong         = (long)NumberData.GetNumber(0, max),
                ULongNullable = (long?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                Integer         = random.Next(min, max),
                IntegerNullable = RandomiseNullable(FakeData.NumberData.GetNumber(min, max)),

#if USE_UTYPES
                UInt         = (uint)NumberData.GetNumber(0, max),
                UIntNullable = (uint?)RandomiseNullable(NumberData.GetNumber(0, max)),
#else
                UInt         = (int)NumberData.GetNumber(0, max),
                UIntNullable = (int?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                DoubleProperty = NumberData.GetDouble(),
                DoubleNullable = RandomiseNullable(NumberData.GetDouble()),

                Float         = (float)NumberData.GetDouble(),
                FloatNullable = RandomiseNullable((float)NumberData.GetDouble()),

                DecimalProperty = (decimal)NumberData.GetDouble(),
                DecimalNullable = (decimal?)RandomiseNullable(NumberData.GetDouble()),

                Short         = (short)NumberData.GetNumber(min, max),
                ShortNullable = (short?)(NumberData.GetNumber(min, max)),
#if USE_UTYPES
                UShort         = (ushort)NumberData.GetNumber(0, max),
                UShortNullable = (ushort?)RandomiseNullable(NumberData.GetNumber(0, max)),
#else
                UShort         = (short)NumberData.GetNumber(0, max),
                UShortNullable = (short?)RandomiseNullable(NumberData.GetNumber(0, max)),
#endif
                ByteProperty = RandomByte(),
                ByteNullable = RandomiseNullable(RandomByte()),
#if USE_STYPES
                SByteProperty = RandomSByte(),
                SByteNullable = RandomiseNullable(RandomSByte()),
#else
                SByteProperty = RandomByte(),
                SByteNullable = RandomiseNullable(RandomByte()),
#endif

#if USE_CHARTYPE
                CharProperty = FakeData.TextData.GetAlphabetical(1)[0],
                CharNullable = RandomiseNullable(FakeData.TextData.GetAlphabetical(1)[0]),
#else
                CharProperty = FakeData.TextData.GetAlphabetical(1)[0].ToString(),
                CharNullable = RandomiseNullable(TextData.GetAlphaNumeric(1), 0.3),
#endif

                BooleanProperty = BooleanData.GetBoolean(),
                BooleanNullable = RandomiseNullable(BooleanData.GetBoolean()),

                StringProperty = RandomiseNullable(TextData.GetAlphaNumeric(NumberData.GetNumber(0, 20)), 0.3),

                DateTimeProperty = RandomDate(max),
                DateTimeNullable = RandomiseNullable(RandomDate(max)),
#if USE_DTOFFSET
                DateTimeOffsetProperty = RandomDateTimeOffset(max),
                DateTimeOffsetNullable = RandomiseNullable(RandomDateTimeOffset(max))
#else
                DateTimeOffsetProperty = RandomDate(max),
                DateTimeOffsetNullable = RandomiseNullable(RandomDate(max)),
#endif
            };

            return(itemToAdd);
        }
 private static byte RandomByte()
 {
     return((byte)NumberData.GetNumber(byte.MinValue, byte.MaxValue));
 }
 private static sbyte RandomSByte()
 {
     return((sbyte)NumberData.GetNumber(sbyte.MinValue, sbyte.MaxValue));
 }
 private static DateTime RandomDate(int max)
 {
     return(DateTime.Now.AddDays(NumberData.GetNumber(max * (-1), 0)));
 }
Пример #12
0
        public static T GetElement <T>(params T[] array)
        {
            int index = NumberData.GetNumber(0, (int)array.Length);

            return((T)array.GetValue(index));
        }
Пример #13
0
 public static bool GetBoolean()
 {
     return(NumberData.GetNumber(2) == 1);
 }
Пример #14
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();
            }
        }
Пример #15
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();
        }
Пример #16
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);
            }
        }
Пример #17
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);
            }
        }
Пример #18
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();
            }
        }
Пример #19
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();
            }
        }