Esempio n. 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);
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        public IActionResult ExcelExport()
        {
            // https://steemit.com/utopian-io/@haig/how-to-create-excel-spreadsheets-using-npoi

            var workbook = new HSSFWorkbook();
            var sheet    = workbook.CreateSheet("Sheet 1");

            IFont fontBold = workbook.CreateFont();

            fontBold.Boldweight = (short)FontBoldWeight.Bold;

            var headerCellStyle = workbook.CreateCellStyle();

            headerCellStyle.SetFont(fontBold);

            var   header = sheet.CreateRow(0);
            ICell col1   = header.CreateCell(0); col1.CellStyle = headerCellStyle; col1.SetCellValue("Fullname");
            ICell col2   = header.CreateCell(1); col2.CellStyle = headerCellStyle; col2.SetCellValue("Country");
            ICell col3   = header.CreateCell(2); col3.CellStyle = headerCellStyle; col3.SetCellValue("Email");
            ICell col4   = header.CreateCell(3); col4.CellStyle = headerCellStyle; col4.SetCellValue("Numbers");
            ICell col5   = header.CreateCell(4); col5.CellStyle = headerCellStyle; col5.SetCellValue("Datetime");
            ICell col6   = header.CreateCell(5); col6.CellStyle = headerCellStyle; col6.SetCellValue("Sentence");

            var currencyCellStyle = workbook.CreateCellStyle();

            currencyCellStyle.Alignment  = HorizontalAlignment.Right;
            currencyCellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("₺#.##0,00");;

            int length = 50;

            for (int i = 0; i < length; i++)
            {
                var row = sheet.CreateRow(i + 1);
                row.CreateCell(0).SetCellValue(NameData.GetFullName());
                row.CreateCell(1).SetCellValue(PlaceData.GetCountry());
                row.CreateCell(2).SetCellValue(NetworkData.GetEmail());

                ICell numberCell = row.CreateCell(3);
                numberCell.CellStyle = currencyCellStyle;
                numberCell.SetCellValue(NumberData.GetDouble() * 1000);

                row.CreateCell(4).SetCellValue(DateTimeData.GetDatetime().ToShortDateString());
                row.CreateCell(5).SetCellValue(TextData.GetSentence());
            }

            var   totalRow  = sheet.CreateRow(length + 1);
            ICell totalCell = totalRow.CreateCell(3);

            ICellStyle totalCellStyle = workbook.CreateCellStyle();

            totalCellStyle.CloneStyleFrom(sheet.GetRow(length).GetCell(3).CellStyle);

            totalCell.CellStyle = totalCellStyle;
            totalCell.CellStyle.SetFont(fontBold);
            totalCell.SetCellType(CellType.Formula);
            totalCell.CellFormula = $"SUM(D2:D{length + 1})";   // Headercell den sonrası.

            string root     = _environment.WebRootPath;
            string folder   = Path.Combine(root, "Excels");
            string filename = "f_" + Guid.NewGuid().ToString() + ".xls";
            string file     = Path.Combine(folder, filename);

            if (Directory.Exists(folder) == false)
            {
                Directory.CreateDirectory(folder);
            }

            using (var fileStream = new FileStream(file, FileMode.Create))
            {
                workbook.Write(fileStream);
            }

            return(File("~/Excels/" + filename, "application/vnd.ms-excel"));
        }
Esempio n. 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();
            }
        }
Esempio n. 9
0
        protected override void Seed(LoginYap4.DataAccessLayer.DatabaseContext context)
        {
            //TRIGGER: şarkı silindiğinde log tablosuna silinme bilgilerini tutan
            context.Database.ExecuteSqlCommand(@"
            create trigger TG_SongDelete on Song after delete 
            as 
            begin
             declare @song_name nvarchar(50)
             declare @viewed_number int
             declare @olusturma_tarih Date
             declare @aciklama nvarchar(50)
             set @aciklama = 'Bir şarkı silindi';
             select @song_name = Name				from deleted 
             select @viewed_number = ViewedNumber	from deleted 
             select @olusturma_tarih = CreatedOn	from deleted 
             insert into dbo.Logs values (@song_name,@olusturma_tarih,@viewed_number,@aciklama)
            end
            ");
            //FONKSYON:sitedeki toplam şarkı sayısı
            context.Database.ExecuteSqlCommand(@"
            create function SongCount()
            returns int
            as
            begin

            declare @counter int;

            select @counter = Count(Id) from Song
            return @counter;
            end
            
            ");
            //PROSEDUR: idsi verilen kullanıcının kullanı bilgilerini verir
            context.Database.ExecuteSqlCommand(@"
            create procedure GetUsernameById
            @id int
            AS 
            Begin
 
            select Name, Surname, Username from SiteUser where Id = @id
            END  
            ");



            string[] chords = new string[] { "A", "B", "C", "D", "E", "F", "G", "Am", "Bm", "Cm", "Dm", "Em", "Fm", "Gm" };

            for (int h = 0; h < 14; h++)
            {
                Chord chord = new Chord();
                chord.Name = chords[h];
                context.Chords.Add(chord);
            }
            context.SaveChanges();

            // Adding admin user..
            SiteUser admin = new SiteUser()
            {
                Name                 = "Engin",
                Surname              = "Karataş",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Username             = "******",
                ProfileImageFilename = "user_boy.png",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUsername     = "******"
            };

            // Adding standart user..
            SiteUser standartUser = new SiteUser()
            {
                Name                 = "Engin",
                Surname              = "Karataş",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                Username             = "******",
                Password             = "******",
                ProfileImageFilename = "user_boy.png",
                CreatedOn            = DateTime.Now.AddHours(1),
                ModifiedOn           = DateTime.Now.AddMinutes(65),
                ModifiedUsername     = "******"
            };

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

            for (int i = 0; i < 8; i++)
            {
                SiteUser user = new SiteUser()
                {
                    Name                 = FakeData.NameData.GetFirstName(),
                    Surname              = FakeData.NameData.GetSurname(),
                    Email                = FakeData.NetworkData.GetEmail(),
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    ProfileImageFilename = "user_boy.png",
                    IsAdmin              = false,
                    Username             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn           = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername     = $"user{i}"
                };
                context.SiteUsers.Add(user);
            }
            context.SaveChanges();


            for (int i = 0; i < 10; i++)
            {
                SiteUser user = new SiteUser
                {
                    Name                 = FakeData.NameData.GetFirstName(),
                    Surname              = FakeData.NameData.GetSurname(),
                    Email                = FakeData.NetworkData.GetEmail(),
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    ProfileImageFilename = "user_boy.png",
                    IsAdmin              = false,
                    isArtist             = true,
                    Username             = $"user{i}",
                    Password             = "******",
                    CreatedOn            = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn           = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername     = $"user{i}"
                };
                context.SiteUsers.Add(user);
            }


            List <SiteUser> userlist = context.SiteUsers.ToList();

            // Adding fake categories..
            for (int i = 0; i < 17; i++)
            {
                Category cat = new Category()
                {
                    Title            = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 12)) + " " + FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(3, 8)),
                    Description      = FakeData.PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUsername = "******"
                };

                context.Categories.Add(cat);

                // Adding fake Songs..
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    SiteUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                    Song song = new Song()
                    {
                        Name                        = FakeData.PlaceData.GetStreetName(),
                        ViewedNumber                = FakeData.NumberData.GetNumber(22, 328),
                        RateNumber                  = FakeData.NumberData.GetNumber(0, 5),
                        Writer                      = "engin",
                        CoveredArtist               = "owner",
                        Picture                     = "song.png",
                        Artist                      = "owner",
                        Text                        = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(25, 50)),
                        IsDraft                     = false,
                        TextSalt                    = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 2)),
                        LikeCount                   = FakeData.NumberData.GetNumber(1, 9),
                        Owner                       = owner,
                        CreatedOn                   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn                  = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUsername            = owner.Username,
                        PublishedDate               = DateTimeData.GetDatetime(),
                        PublishedCoverDateOnYouTube = DateTimeData.GetDatetime(),
                    };
                    cat.Songs.Add(song);



                    // Adding fake comments
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        SiteUser comment_owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                        Comment comment = new Comment()
                        {
                            Text             = FakeData.TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn       = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUsername = comment_owner.Username
                        };

                        song.Comments.Add(comment);
                    }

                    // Adding fake likes..

                    for (int m = 0; m < song.LikeCount; m++)
                    {
                        Liked liked = new Liked()
                        {
                            LikedUser = userlist[m]
                        };

                        song.Likes.Add(liked);
                    }
                }
            }

            context.SaveChanges();
            //  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.
        }
Esempio n. 10
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();
        }