//
        // GET: /Checkout/
        public IActionResult AddressAndPayment()
        {
            var nameGenerator      = new PersonNameGenerator();
            var placeNameGenerator = new PlaceNameGenerator();
            var rndNum             = new Random();

            var firstName = nameGenerator.GenerateRandomMaleFirstName();
            var lastName  = nameGenerator.GenerateRandomLastName();

            var orderCreateDto = new CheckoutDto
            {
                FirstName        = firstName,
                LastName         = lastName,
                Address          = rndNum.Next(1000, 9999) + " " + placeNameGenerator.GenerateRandomPlaceName(),
                PostalCode       = rndNum.Next(10000, 99999).ToString(),
                City             = placeNameGenerator.GenerateRandomPlaceName(),
                State            = "OH",
                Phone            = "(" + rndNum.Next(100, 999) + ")" + rndNum.Next(100, 999) + "-" + rndNum.Next(1000, 9999),
                Email            = firstName + "@" + "hotmail.com",
                CreditCardNumber = "4111 1111 1111 1111",
                CardholderName   = $"{firstName} {lastName}",
                SecurityCode     = "123",
                ExpirationDate   = DateTime.Today.AddYears(1),
            };

            return(View(orderCreateDto));
        }
Ejemplo n.º 2
0
        public void LoadDomain(string ID, string api_key = "")
        {
            if (Directory.Exists("domains"))
            {
                if (File.Exists($"domains/{ID}.json"))
                {
                    lock (_lck)
                    {
                        MemoryItem   mi1  = new MemoryItem();
                        DomainObject obj1 = JsonConvert.DeserializeObject <DomainObject>(File.ReadAllText($"domains/{ID}.json"));
                        mi1.Obj = obj1;
                        Itms.Add(obj1.DomainID, mi1);
                        return;
                    }
                }
            }

            MemoryItem   mi  = new MemoryItem();
            DomainObject obj = new DomainObject
            {
                DomainID = ID
            };
            PlaceNameGenerator pngl = new PlaceNameGenerator();

            obj.PlaceName = pngl.GenerateRandomPlaceName() + "-" + pngl.GenerateRandomPlaceName() + "-" + (new Random()).Next(500, 8000).ToString(); //<-- Does this need to be changed in the future??
            obj.IPAddr    = Session.Instance.CFG.DefaultIceServerAddress;
            obj.API_Key   = api_key;
            mi.Obj        = obj;

            Itms.Add(obj.DomainID, mi);
        }
Ejemplo n.º 3
0
        private Facility CreateFacility()
        {
            int nFacility = ++_nFacilities;
            var timeZone  = _timeZones[_timeZoneIndex];

            _timeZoneIndex = ++_timeZoneIndex % _timeZones.Length;

            var state = _states[_stateIndex];

            _stateIndex = ++_stateIndex % _states.Length;

            var city = _placeGenerator.GenerateRandomPlaceName();

            var facility = new Facility()
            {
                Id     = String.Format("Site{0:000}", nFacility),
                Name   = String.Format("Facility{0:000}", nFacility),
                City   = city,
                State  = state,
                ZoneId = timeZone,
                Active = true,
                OperatingHoursDlogThrottleSpeed    = 1000,
                NonOperatingHoursDlogThrottleSpeed = 10000
            };

            return(facility);
        }
Ejemplo n.º 4
0
        public RESTReplyData get_temporary_name(RESTRequestData pReq, List <string> pArgs)
        {
            RESTReplyData replyData = new RESTReplyData();
            ResponseBody  respBody  = new ResponseBody();

            PersonNameGenerator png  = new PersonNameGenerator();
            PlaceNameGenerator  plng = new PlaceNameGenerator();

            DomainEntity newDomain = new DomainEntity()
            {
                PlaceName            = png.GenerateRandomFirstName() + "-" + plng.GenerateRandomPlaceName() + "-" + new Random().Next(500, 9000).ToString(),
                DomainID             = Guid.NewGuid().ToString(),
                IPAddrOfFirstContact = pReq.RemoteUser.ToString()
            };

            newDomain.API_Key = Tools.MD5Hash($":{newDomain.PlaceName}::{newDomain.DomainID}:{newDomain.IceServerAddr}");
            Domains.Instance.AddDomain(newDomain.DomainID, newDomain);

            respBody.Data = new bodyDomainResponse()
            {
                domain = new bodyDomainReplyData()
                {
                    id      = newDomain.DomainID,
                    name    = newDomain.PlaceName,
                    api_key = newDomain.API_Key
                }
            };
            replyData.Body = respBody;  // serializes JSON
            Context.Log.Debug("{0} Returning temporary domain: id={1}, name={2}",
                              _logHeader, newDomain.DomainID, newDomain.PlaceName);

            replyData.CustomOutputHeaders.Add("X-Rack-CORS", "miss; no-origin");
            replyData.CustomOutputHeaders.Add("Access-Control-Allow-Origin", "*");
            return(replyData);
        }
Ejemplo n.º 5
0
        static void _addRandomTeamMember()
        {
            var randomFirstName = personNameGenerator.GenerateRandomFirstName();
            var randomLastName  = personNameGenerator.GenerateRandomLastName();

            _addTeamMember(randomFirstName, randomLastName, random.Next(19, 120), $"{randomFirstName}{randomLastName}@quickenloans.com", random.NextDouble() * 100000.0);
            ((TeamMember)(object)_people[_people.Count - 1]).Address = placeNameGenerator.GenerateRandomPlaceName();
        }
        public static void Initialize(IPlaysContext context)
        {
            if (!context.Plays.Find(_ => true).Any())
            {
                var personGenerator = new PersonNameGenerator();

                var placeGenerator = new PlaceNameGenerator();

                var random = new Random(250);

                var plays = Enumerable.Range(1, 250)
                            .Select(i => new Play
                {
                    Game = new Game
                    {
                        Id    = Guid.NewGuid(),
                        Title = placeGenerator.GenerateRandomPlaceName()
                    },
                    Id           = Guid.NewGuid(),
                    Notes        = placeGenerator.GenerateRandomPlaceName(),
                    PlayedDate   = DateTime.Now.AddDays(-i),
                    PlayerScores = new PlayScore[]
                    {
                        new()
                        {
                            Player = new IdName(Guid.NewGuid(), personGenerator.GenerateRandomFirstAndLastName()),
                            Score  = random.Next()
                        },

                        new()
                        {
                            Player = new IdName(Guid.NewGuid(), personGenerator.GenerateRandomFirstAndLastName()),
                            Score  = random.Next()
                        },

                        new()
                        {
                            Player = new IdName(Guid.NewGuid(),
                                                personGenerator
                                                .GenerateRandomFirstAndLastName()),
                            Score = random.Next()
                        },
                    }
                });
Ejemplo n.º 7
0
        public static async Task Employee(int number)
        {
            var employee = new Employee();

            var personGenerator    = new PersonNameGenerator();
            var placeNameGenerator = new PlaceNameGenerator();

            var client = new RestClient("https://api.tripletex.io/v2/");

            for (var i = 0; i < number; i++)
            {
                var name = personGenerator.GenerateRandomFirstAndLastName().Split(' ');

                employee.firstName                    = name[0];
                employee.lastName                     = name[1];
                employee.email                        = name[0] + name[1] + "@gmail.com";
                employee.department.name              = placeNameGenerator.GenerateRandomPlaceName();
                employee.phoneNumberMobile            = Random.Next(10000000, 99999999).ToString();
                employee.dateOfBirth                  = new DateTime(Random.Next(1950, 2001), Random.Next(1, 13), Random.Next(1, 29)).ToString("yyyy-MM-dd");
                employee.employments[0].startDate     = new DateTime(Random.Next(1900, 2020), Random.Next(1, 13), Random.Next(1, 29)).ToString("yyyy-MM-dd");
                employee.employments[0].division.name = placeNameGenerator.GenerateRandomPlaceName();
                employee.employments[0].employmentDetails[0].percentageOfFullTimeEquivalent = Random.Next(5, 51);

                var request = new RestRequest("employee");

                request.AddJsonBody(employee);
                request.AddHeader("Authorization", $"Basic {Authentication.EncodedCredentials}");

                var response = await client.ExecutePostAsync <SingleValueResponse <KeyInfo> >(request);

                if (HttpStatusCode.Created != response.StatusCode)
                {
                    throw new ArgumentException($"Employee post error: {response.StatusCode}");
                }

                Console.Write($"\r{i + 1} Employee created");
            }

            Console.WriteLine("\n");
            Console.Write("> ");
        }
Ejemplo n.º 8
0
        public void generatePerson()
        {
            IndexController.mainMenu.message = null;

            IndexController.mainMenu.stackPersons.Push(new Person()
            {
                newEntry = "New Entry " + (IndexController.mainMenu.stackPersons.Count + 1).ToString(),
                name     = person.GenerateRandomMaleFirstAndLastName(),
                age      = random.Next(1, 101),
                location = place.GenerateRandomPlaceName()
            });
        }
        private static string GetNewMothershipName()
        {
            while (true)
            {
                string newName = s_placeNameGenerator.GenerateRandomPlaceName();

                // Only allow names with just normal letters
                // and skip names that are already in use
                if (newName.All(c => Char.IsLetter(c)) && !Motherships.Any(i => i.Name == newName))
                {
                    return(newName);
                }
            }
        }
Ejemplo n.º 10
0
        //
        // GET: /Checkout/
        public IActionResult AddressAndPayment()
        {
            var nameGenerator      = new PersonNameGenerator();
            var placeNameGenerator = new PlaceNameGenerator();
            var rndNum             = new Random();

            var firstName = nameGenerator.GenerateRandomMaleFirstName();

            var orderCreateDto = new OrderCreateDto
            {
                FirstName  = firstName,
                LastName   = nameGenerator.GenerateRandomLastName(),
                Address    = rndNum.Next(1000, 9999).ToString() + " " + placeNameGenerator.GenerateRandomPlaceName(),
                PostalCode = rndNum.Next(10000, 99999).ToString(),
                City       = placeNameGenerator.GenerateRandomPlaceName(),
                State      = "OH",
                Phone      = "(" + rndNum.Next(100, 999).ToString() + ")" + rndNum.Next(100, 999).ToString() + "-" + rndNum.Next(1000, 9999).ToString(),
                Country    = "USA",
                Email      = firstName + "@" + "hotmail.com"
            };

            return(View(orderCreateDto));
        }
        public void generatePerson()
        {
            IndexController.mainMenu.message = null;

            IndexController.mainMenu.dictionaryPersons.Add
            (
                "New Index " + (IndexController.mainMenu.dictionaryPersons.Count + 1).ToString(),
                new Person()
            {
                name     = person.GenerateRandomMaleFirstAndLastName(),
                age      = random.Next(1, 101),
                location = place.GenerateRandomPlaceName()
            }
            );
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create a default course.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static async Task <Course> CreateCourseAsync(ApplicationDbContext context)
        {
            var placeGenerator = new PlaceNameGenerator();
            var course         = new Course
            {
                Name = $"The People of {placeGenerator.GenerateRandomPlaceName()}"
            };

            course.SisId = course.GetHashCode().ToString();
            await context.Courses.AddAsync(course);

            await context.SaveChangesAsync();

            return(course);
        }
Ejemplo n.º 13
0
        public static async Task Product(int number)
        {
            var product = new Product
            {
                supplier =
                {
                    name      = "Supp",
                    category1 = { name = "C1" },
                    category2 = { name = "C2" },
                    category3 = { name = "C3" }
                }
            };

            var client = new RestClient("https://api.tripletex.io/v2/");

            var placeGenerator = new PlaceNameGenerator();

            for (var i = 0; i < number; i++)
            {
                product.name   = placeGenerator.GenerateRandomPlaceName();
                product.number = FileDoc.GetNumber("Product.csv");
                product.costExcludingVatCurrency  = Random.Next(5, 800);
                product.priceExcludingVatCurrency = Random.Next(800, 1501);

                var request = new RestRequest("product");

                request.AddJsonBody(product);
                request.AddHeader("Authorization", $"Basic {Authentication.EncodedCredentials}");

                var response = await client.ExecutePostAsync <SingleResponse <KeyInfo> >(request);

                if (!response.IsSuccessful)
                {
                    ErrorHandler.Handel(response.Content);
                }

                var data       = response.Data.Value;
                var dataString = $"{data.number},{data.name},{data.id}";

                FileDoc.AppendFile(dataString, "Product.csv");

                Console.Write($"\r{i + 1} Product created");
            }

            Console.WriteLine("\n");
            Console.Write("> ");
        }
Ejemplo n.º 14
0
        public static async Task Product(Employee employee, int number)
        {
            var product = new Product
            {
                supplier =
                {
                    name            = "Supp",
                    accountManager  = employee,
                    deliveryAddress = { employee = employee },
                    category1       = { name = "C1" },
                    category2       = { name = "C2" },
                    category3       = { name = "C3" }
                }
            };

            var client = new RestClient("https://api.tripletex.io/v2/");

            var placeGenerator = new PlaceNameGenerator();

            for (var i = 0; i < number; i++)
            {
                product.name   = placeGenerator.GenerateRandomPlaceName();
                product.number = FileDoc.GetNumber("Product.csv");
                product.costExcludingVatCurrency  = Random.Next(5, 800);
                product.priceExcludingVatCurrency = Random.Next(800, 1501);

                var request = new RestRequest("product");

                request.AddJsonBody(product);
                request.AddHeader("Authorization", $"Basic {Authentication.EncodedCredentials}");

                var response = await client.ExecutePostAsync <SingleValueResponse <KeyInfo> >(request);

                if (HttpStatusCode.Created != response.StatusCode)
                {
                    throw new ArgumentException($"Product post error: {response.StatusCode}");
                }

                FileDoc.WriteFile(response.Data.Value, "Product.csv");

                Console.Write($"\r{i + 1} Product created");
            }

            Console.WriteLine("\n");
            Console.Write("> ");
        }
Ejemplo n.º 15
0
        public ReplyData get_temporary_name(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers)
        {
            ReplyData rd = new ReplyData();

            PersonNameGenerator png  = new PersonNameGenerator();
            PlaceNameGenerator  plng = new PlaceNameGenerator();

            // We're generating the entire domain entry in the data store
            DomainMemory.DomainObject DO = new DomainMemory.DomainObject()
            {
                PlaceName = png.GenerateRandomFirstName() + "-" + plng.GenerateRandomPlaceName() + "-" + new Random().Next(500, 9000).ToString(),
                DomainID  = Guid.NewGuid().ToString(),
                IPAddr    = remoteIP.ToString()
            };


            DO.API_Key = Tools.MD5Hash($":{DO.PlaceName}::{DO.DomainID}:{DO.IPAddr}");

            DomainReplyDataWithKey drd = new DomainReplyDataWithKey();

            drd.ice_server_address = DO.IPAddr;
            drd.api_key            = DO.API_Key;
            drd.id   = DO.DomainID;
            drd.name = DO.PlaceName;

            TemporaryPlaceNameReply tpnr = new TemporaryPlaceNameReply();

            tpnr.status = "success";
            tpnr.data   = new Dictionary <string, DomainReplyDataWithKey>();
            tpnr.data.Add("domain", drd);

            rd.Status = 200;
            rd.Body   = JsonConvert.SerializeObject(tpnr);

            DomainMemory.MemoryItem mi = new DomainMemory.MemoryItem();
            mi.Obj = DO;
            Session.Instance.DomainsMem.Itms.Add(DO.DomainID, mi);

            rd.CustomOutputHeaders = new Dictionary <string, string>();
            rd.CustomOutputHeaders.Add("X-Rack-CORS", "miss; no-origin");
            rd.CustomOutputHeaders.Add("Access-Control-Allow-Origin", "*");
            return(rd);
        }
        protected override void Seed(MorenoContext context)
        {
            var personGenerator = new PersonNameGenerator();
            var placeGenerator  = new PlaceNameGenerator();
            var randNum         = new Random(50);


            //Student Section
            Section section = new Section()
            {
                Name = "Section 1"
            };

            Section section2 = new Section()
            {
                Name = "Section 2"
            };
            Section section3 = new Section()
            {
                Name = "Section 3"
            };
            Section section4 = new Section()
            {
                Name = "Section 4"
            };
            Section section5 = new Section()
            {
                Name = "Section 5"
            };
            Section section6 = new Section()
            {
                Name = "Section 6"
            };
            Section section7 = new Section()
            {
                Name = "Section 7"
            };
            Section section8 = new Section()
            {
                Name = "Section 8"
            };
            Section section9 = new Section()
            {
                Name = "Section 9"
            };
            Section section10 = new Section()
            {
                Name = "Section 10"
            };

            //Student Year Level
            YearLevel yearLvl = new YearLevel()

            {
                Name     = "Grade 1",
                Sections = new List <Section>()
                {
                    section,
                    section2
                }
            };
            YearLevel yearLvl2 = new YearLevel()

            {
                Name     = "Grade 2",
                Sections = new List <Section>
                {
                    section3,
                    section4
                },
            };
            YearLevel yearLvl3 = new YearLevel()

            {
                Name     = "Grade 3",
                Sections = new List <Section>
                {
                    section5,
                    section6
                },
            };
            YearLevel yearLvl4 = new YearLevel()

            {
                Name     = "Grade 4",
                Sections = new List <Section>
                {
                    section7,
                    section8
                },
            };
            YearLevel yearLvl5 = new YearLevel()

            {
                Name     = "Grade 5",
                Sections = new List <Section>()
                {
                    section9,
                    section10
                },
            };

            //Book Conditions
            IList <Condition> conditions = new List <Condition>();

            conditions.Add(new Condition()
            {
                Name = "Good",
            });
            conditions.Add(new Condition()
            {
                Name = "Outdated",
            });
            conditions.Add(new Condition()
            {
                Name = "Damaged",
            });

            //Book Sources
            IList <Source> sources = new List <Source>();

            sources.Add(new Source()
            {
                Name = "Purchased",
            });
            sources.Add(new Source()
            {
                Name = "Donated",
            });

            //Student Requirements
            var requirements = new List <Requirement>()
            {
                new Requirement()
                {
                    Name = "NSO",
                },
                new Requirement()
                {
                    Name = "2 x 2 Picture",
                },
                new Requirement()
                {
                    Name = "Good Moral Certificate",
                },
            };

            IList <Student> students = new List <Student>();



            for (int i = 1; i < 100; i++)
            {
                var newSection = i > 51 ? section10 : section9;
                students.Add(new Student()
                {
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    BirthDate  = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    Contact    = "09179496408",
                    SchoolYear = "2016-2017",
                    LRN        = i.ToString(),
                    YearLevel  = yearLvl5,
                    Section    = newSection,
                }
                             );
            }
            for (int i = 101; i < 200; i++)
            {
                var newSection = i > 151 ? section7 : section8;
                students.Add(new Student()
                {
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    BirthDate  = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    Contact    = "09179496408",
                    SchoolYear = "2016-2017",
                    LRN        = i.ToString(),
                    YearLevel  = yearLvl4,
                    Section    = newSection,
                }
                             );
            }

            for (int i = 301; i < 400; i++)
            {
                var newSection = i > 351 ? section5 : section6;
                students.Add(new Student()
                {
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    BirthDate  = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    Contact    = "09179496408",
                    SchoolYear = "2016-2017",
                    LRN        = i.ToString(),
                    YearLevel  = yearLvl3,
                    Section    = newSection,
                }
                             );
            }
            for (int i = 401; i < 500; i++)
            {
                var newSection = i > 451 ? section3 : section4;
                students.Add(new Student()
                {
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    BirthDate  = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    Contact    = "09179496408",
                    SchoolYear = "2016-2017",
                    LRN        = i.ToString(),
                    YearLevel  = yearLvl2,
                    Section    = newSection,
                }
                             );
            }
            for (int i = 501; i < 600; i++)
            {
                var newSection = i > 551 ? section : section2;
                students.Add(new Student()
                {
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    BirthDate  = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    Contact    = "09179496408",
                    SchoolYear = "2016-2017",
                    LRN        = i.ToString(),
                    YearLevel  = yearLvl,
                    Section    = newSection,
                }
                             );
            }


            context.Students.AddRange(students);

            var studentUsers = new List <User>();

            foreach (var student in students)
            {
                var newUser = new User()
                {
                    UserName      = student.LRN,
                    Password      = $"{student.FirstName[0]}{student.MiddleName[0]}{student.LastName[0]}{student.BirthDate.Date.ToString("dMyyyy")}".ToLower(),
                    Authorization = "Student",
                    Student       = student
                };
                studentUsers.Add(newUser);
            }
            context.Users.AddRange(studentUsers);

            //Teachers
            List <Teacher> teachers = new List <Teacher>();

            for (int i = 1001; i < 1011; i++)
            {
                teachers.Add(new Teacher()
                {
                    Id         = i,
                    FirstName  = personGenerator.GenerateRandomFirstName(),
                    MiddleName = personGenerator.GenerateRandomLastName(),
                    Gender     = randNum.Next(1, 3) == 1 ? "Male" : "Female",
                    LastName   = personGenerator.GenerateRandomLastName(),
                    Birthday   = DateTime.Now.Date,
                    Address    = placeGenerator.GenerateRandomPlaceName(),
                    ContactNo  = "09179496408",
                });
            }

            context.Teachers.AddRange(teachers);

            var user2 = new List <User>();

            foreach (var teacher in teachers)
            {
                var newUser = new User()
                {
                    UserName      = teacher.Id.ToString(),
                    Password      = $"{teacher.FirstName[0]}{teacher.MiddleName[0]}{teacher.LastName[0]}{teacher.Birthday.Date.ToString("dMyyyy")}".ToLower(),
                    Authorization = "Teacher",
                    Student       = null,
                    Teacher       = teacher
                };
                user2.Add(newUser);
            }

            context.Users.AddRange(user2);

            //var user1 = new List<User>();

            //foreach (var student in students)
            //{
            //    var newUser = new User()
            //    {
            //        UserName = student.LRN,
            //        Password = $"{student.FirstName[0]}{student.MiddleName[0]}{student.LastName[0]}{student.BirthDate.Date.ToString("dMyyyy")}".ToLower(),
            //        Authorization = "Student",
            //        Student = student
            //    };
            //    user1.Add(newUser);
            //}


            //User Login Details
            IList <User> user = new List <User>();

            user.Add(new User()
            {
                UserName      = "******",
                Password      = "******",
                Authorization = "Library",
                Student       = null
            });
            user.Add(new User()
            {
                UserName      = "******",
                Password      = "******",
                Authorization = "Administrator",
                Student       = null
            });
            user.Add(new User()
            {
                UserName      = "******",
                Password      = "******",
                Authorization = "Registrar",
                Student       = null
            });


            //Council Positions
            IList <CouncilPosition> councilPositions = new List <CouncilPosition>
            {
                new CouncilPosition()
                {
                    Position = "President"
                },
                new CouncilPosition()
                {
                    Position = "Vice President"
                },
                new CouncilPosition()
                {
                    Position = "Secretary"
                },
                new CouncilPosition()
                {
                    Position = "Treasurer"
                },
                new CouncilPosition()
                {
                    Position = "Auditor"
                }
            };


            //Sections to List
            var sectionList = new List <Section>()
            {
                section,
                section2,
                section3,
                section4,
                section5,
                section6,
                section7,
                section8,
                section9,
                section10
            };

            context.Sections.AddRange(sectionList);


            //Grade to List
            var gradeList = new List <YearLevel>()
            {
                yearLvl,
                yearLvl2,
                yearLvl3,
                yearLvl4,
                yearLvl5,
            };

            context.YearLevels.AddRange(gradeList);



            for (int i = 0; i < 10; i++)
            {
                foreach (var councilPosition in councilPositions)
                {
                    var number          = randNum.Next(1, 50);
                    var dateTime        = new DateTime(2001 + i, 1, 1);
                    var electionHistory = new ElectionHistory()
                    {
                        Position  = councilPosition.Position,
                        Name      = personGenerator.GenerateRandomFirstAndLastName(),
                        DateYear  = dateTime,
                        VoteCount = number
                    };
                    context.ElectionHistory.Add(electionHistory);
                }
            }

            //Book Category

            //Book
            var booklist = new List <Book>
            {
                new Book()
                {
                    Title             = "Florante at Laura",
                    Author            = "Francisco Balagtas ",
                    PublishedYear     = DateTime.Now.Date,
                    Publisher         = "Rex Books",
                    Quantity          = 295,
                    AvailableQuantity = 295,
                    Category          = new Category()
                    {
                        Name = "Romance"
                    },
                },
                new Book()
                {
                    Title             = "El Filibusterismo",
                    Author            = "José Rizal ",
                    PublishedYear     = DateTime.Now.Date,
                    Publisher         = "National Books",
                    Quantity          = 295,
                    AvailableQuantity = 295,
                    Category          = new Category()
                    {
                        Name = "Romance"
                    },
                },
                new Book()
                {
                    Title             = "Luha ng Buwaya",
                    Author            = "José Rizal ",
                    PublishedYear     = DateTime.Now.Date,
                    Publisher         = "Manok Books",
                    Quantity          = 295,
                    AvailableQuantity = 295,
                    Category          = new Category()
                    {
                        Name = "Fiction"
                    },
                }
            };


            context.Books.AddRange(booklist);


            context.Students.AddRange(students);
            context.Requirements.AddRange(requirements);
            context.CouncilPositions.AddRange(councilPositions);
            context.Users.AddRange(user);
            //context.Users.AddRange(user1);
            context.Conditions.AddRange(conditions);
            context.Sources.AddRange(sources);
            base.Seed(context);
        }
Ejemplo n.º 17
0
        protected override void Seed(HHAM.Models.ApplicationDbContext context)
        {
            var roleManager     = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager     = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var personGenerator = new PersonNameGenerator();
            var placeGenerator  = new PlaceNameGenerator();

            DateTime        DateAdmited  = RandomDay();
            UserProfileInfo NurseProfile = null;

            if (context.Roles.ToList().Count == 0)
            {
                roleManager.Create(new IdentityRole
                {
                    Name = "Admin"
                });

                roleManager.Create(new IdentityRole
                {
                    Name = "Doctor"
                });

                roleManager.Create(new IdentityRole
                {
                    Name = "Nurse"
                });

                var AdminUser = new ApplicationUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                string AdminUserPWD = "DietForCoke123)";

                var AdminUserCreationStatus = UserManager.Create(AdminUser, AdminUserPWD);

                if (AdminUserCreationStatus.Succeeded)
                {
                    var result = UserManager.AddToRole(AdminUser.Id, "Admin");
                }

                context.UserProfileInfo.Add(new UserProfileInfo
                {
                    Description       = "I am an ADMIN",
                    FirstName         = "Nancy",
                    LastName          = "Cook",
                    Role              = "Admin",
                    User              = AdminUser,
                    UrlProfilePicture = "https://randomuser.me/api/portraits/women/64.jpg",
                });


                // Doctor Users
                CreateDoctorUser(context, UserManager, "*****@*****.**", "YOLo123)", "Mirna", "Jegatheeswaran", "64");
                CreateDoctorUser(context, UserManager, "*****@*****.**", "YOLo1234)", "Harminder", "Paink", "64");
                CreateDoctorUser(context, UserManager, "*****@*****.**", "YOLo1235)", "Huda", "Sarwar", "64");
                CreateDoctorUser(context, UserManager, "*****@*****.**", "YOLo1236)", "Jing", "Ren", "64");

                // Nurse User

                var NurseUser = new ApplicationUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                string NurseUserPWD = "YOLo1234)";

                var NurseUserCreationStatus = UserManager.Create(NurseUser, NurseUserPWD);

                if (NurseUserCreationStatus.Succeeded)
                {
                    var result = UserManager.AddToRole(NurseUser.Id, "Nurse");
                }

                NurseProfile = context.UserProfileInfo.Add(new UserProfileInfo
                {
                    Description       = "I am a Nurse !!! YAY ME",
                    User              = NurseUser,
                    Role              = "Nusre",
                    FirstName         = "Max",
                    LastName          = "Tucker",
                    UrlProfilePicture = "https://randomuser.me/api/portraits/men/21.jpg",
                });
            }


            // added all the blood types
            if (context.BloodTypes.ToList().Count == 0)
            {
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "AB - Negative",
                    Text  = "AB - Negative"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "B - Negative",
                    Text  = "B - Negative"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "AB - Postive",
                    Text  = "AB - Postive"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "A - Negative",
                    Text  = "A - Negative"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "O - Negative",
                    Text  = "O - Negative"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "B - Postive",
                    Text  = "B - Postive"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "A - Postive",
                    Text  = "A - Postive"
                });
                context.BloodTypes.Add(new Models.BloodType
                {
                    Value = "O - Postive",
                    Text  = "O - Postive"
                });
            }

            // added gender Types
            if (context.Genders.ToList().Count == 0)
            {
                context.Genders.Add(new Models.Gender
                {
                    Value = "Male",
                    Text  = "Male"
                });
                context.Genders.Add(new Models.Gender
                {
                    Value = "Female",
                    Text  = "Female"
                });
                context.Genders.Add(new Models.Gender
                {
                    Value = "Other",
                    Text  = "Other"
                });
            }

            if (context.Patient.ToList().Count == 0)
            {
                for (int i = 0; i < 100; i++)
                {
                    if (i % 2 == 0)
                    {
                        context.Patient.Add(new Models.Patient
                        {
                            FirstName        = personGenerator.GenerateRandomFirstName(),
                            LastName         = personGenerator.GenerateRandomLastName(),
                            BirthDate        = RandomDay(),
                            patientNumber    = Guid.NewGuid().ToString(),
                            Weight           = gen.Next(120, 205),
                            Height           = gen.Next(100, 200),
                            Gender           = context.Genders.Where(x => x.Text == "Male").FirstOrDefault(),
                            DateAdmited      = DateAdmited,
                            DateReleased     = DateAdmited.AddDays(20),
                            Notes            = LoremNET.Lorem.Paragraph(5, 6, 4, 10),
                            Married          = false,
                            PrimaryAddress   = placeGenerator.GenerateRandomPlaceName() + "Street",
                            SecondaryAddress = placeGenerator.GenerateRandomPlaceName() + "Street",
                            BloodType        = context.BloodTypes.FirstOrDefault(),
                            CareGivers       = context.UserProfileInfo.ToList()
                        });
                    }
                    else
                    {
                        context.Patient.Add(new Models.Patient
                        {
                            FirstName        = personGenerator.GenerateRandomFirstName(),
                            LastName         = personGenerator.GenerateRandomLastName(),
                            BirthDate        = RandomDay(),
                            patientNumber    = Guid.NewGuid().ToString(),
                            Weight           = gen.Next(120, 205),
                            Height           = gen.Next(100, 200),
                            Gender           = context.Genders.Where(x => x.Text == "Female").FirstOrDefault(),
                            DateAdmited      = DateAdmited,
                            DateReleased     = DateAdmited.AddDays(20),
                            Notes            = LoremNET.Lorem.Paragraph(5, 6, 4, 10),
                            Married          = true,
                            PrimaryAddress   = placeGenerator.GenerateRandomPlaceName() + "Street",
                            SecondaryAddress = placeGenerator.GenerateRandomPlaceName() + "Street",
                            BloodType        = context.BloodTypes.FirstOrDefault(),
                            CareGivers       = context.UserProfileInfo.ToList()
                        });
                    }
                }
            }

            if (context.Scans.ToList().Count == 0)
            {
                foreach (var patient in context.Patient.ToList())
                {
                    for (int i = 0; i < 6; i++)
                    {
                        context.Scans.Add(CreateRandScan(patient.patientNumber, i, DateAdmited, patient));
                    }
                }
            }

            context.SaveChanges();
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Generate a place name randomly.
 /// </summary>
 /// <returns>Random place name</returns>
 public static string NextPlaceName()
 {
     return(_placeGenerator.GenerateRandomPlaceName());
 }
Ejemplo n.º 19
0
        public static void Seed(MyContext _context)
        {
            if (_context.Ljekari.Count() != 0)
            {
                return;
            }
            var personGenerator = new PersonNameGenerator();
            var placeGenerator  = new PlaceNameGenerator();
            var muski           = new Spol {
                Naziv = "Male"
            };
            var zenski = new Spol {
                Naziv = "Female"
            };
            var unknown = new Spol {
                Naziv = "Unknown"
            };
            var Ljekari   = new List <Ljekar>();
            var Pacijenti = new List <Pacijent>();

            for (int i = 0; i < 5; i++)
            {
                Ljekari.Add(new Ljekar
                {
                    Ime     = personGenerator.GenerateRandomMaleFirstName(),
                    Prezime = personGenerator.GenerateRandomLastName(),
                    Sifra   = MyRandomExtensions.MyRandomString(5),
                    Titula  = (Titula)MyRandomExtensions.RandomNumber(0, 2)
                });
            }
            for (int i = 0; i < 5; i++)
            {
                Ljekari.Add(new Ljekar
                {
                    Ime     = personGenerator.GenerateRandomFemaleFirstName(),
                    Prezime = personGenerator.GenerateRandomLastName(),
                    Sifra   = MyRandomExtensions.MyRandomString(5),
                    Titula  = (Titula)MyRandomExtensions.RandomNumber(0, 2),
                });
            }
            for (int i = 0; i < 10; i++)
            {
                Pacijenti.Add(new Pacijent
                {
                    Ime           = personGenerator.GenerateRandomMaleFirstName(),
                    Prezime       = personGenerator.GenerateRandomLastName(),
                    Adresa        = placeGenerator.GenerateRandomPlaceName(),
                    BrojTelefona  = "+387" + MyRandomExtensions.RandomNumber(61, 66) + MyRandomExtensions.RandomNumber(100, 200) + MyRandomExtensions.RandomNumber(400, 500),
                    DatumRodjenja = DateTime.Now.AddYears(-MyRandomExtensions.RandomNumber(41, 71)),
                    Spol          = muski
                });;
            }
            for (int i = 0; i < 10; i++)
            {
                Pacijenti.Add(new Pacijent
                {
                    Ime           = personGenerator.GenerateRandomFemaleFirstName(),
                    Prezime       = personGenerator.GenerateRandomLastName(),
                    Adresa        = placeGenerator.GenerateRandomPlaceName(),
                    BrojTelefona  = "+387" + MyRandomExtensions.RandomNumber(61, 66) + MyRandomExtensions.RandomNumber(100, 200) + MyRandomExtensions.RandomNumber(400, 500),
                    DatumRodjenja = DateTime.Now.AddYears(-MyRandomExtensions.RandomNumber(41, 71)),
                    Spol          = zenski
                });
            }
            _context.Spol.Add(muski);
            _context.Spol.Add(zenski);
            _context.Spol.Add(unknown);
            foreach (var item in Ljekari)
            {
                _context.Ljekari.Add(item);
            }
            foreach (var item in Pacijenti)
            {
                _context.Pacijenti.Add(item);
            }
            _context.SaveChanges();
        }
Ejemplo n.º 20
0
        public void ShouldGenerateRandomName()
        {
            var name = _placeGenerator.GenerateRandomPlaceName();

            Assert.False(string.IsNullOrWhiteSpace(name));
        }
Ejemplo n.º 21
0
        protected override void Seed(CannDash.API.Infrastructure.CannDashDataContext context)
        {
            var    placeGenerator = new PlaceNameGenerator();
            string city           = "San Diego";
            string companyName    = string.Empty;
            string state          = "CA";
            int    zipcode        = 92101;

            if (!context.Dispensaries.Any())
            {
                for (int i = 0; i < 20; i++)
                {
                    companyName = placeGenerator.GenerateRandomPlaceName();

                    context.Dispensaries.Add(new Models.Dispensary
                    {
                        CompanyName = companyName,
                        Street      = Generator.GenerateAddress().AddressLine,
                        City        = city,
                        State       = state,
                        ZipCode     = zipcode,
                        Email       = companyName + "@me.com",
                        Phone       = "619 123 5678"
                    });
                    context.SaveChanges();
                }
            }

            var      personGenerator = new PersonNameGenerator();
            string   firstName       = String.Empty;
            string   lastName        = String.Empty;
            DateTime dob             = DateTime.MinValue;

            if (!context.Customers.Any())
            {
                for (int i = 0; i < 20; i++)
                {
                    dob       = Generator.GenerateDOB(21, 90);
                    firstName = personGenerator.GenerateRandomFirstName();
                    lastName  = personGenerator.GenerateRandomLastName();

                    context.Customers.Add(new Models.Customer
                    {
                        DispensaryId = 14,
                        FirstName    = firstName,
                        LastName     = lastName,
                        Street       = Generator.GenerateAddress().AddressLine,
                        City         = city,
                        State        = state,
                        ZipCode      = zipcode,
                        Email        = firstName + '.' + lastName + "@me.com",
                        Phone        = "619 123 8798",
                        DateOfBirth  = dob,
                        Age          = (DateTime.Today).Year - dob.Year
                    });
                    context.SaveChanges();
                }
            }

            if (!context.Drivers.Any())
            {
                for (int i = 0; i < 5; i++)
                {
                    dob       = Generator.GenerateDOB(21, 90);
                    firstName = personGenerator.GenerateRandomFirstName();
                    lastName  = personGenerator.GenerateRandomLastName();

                    context.Drivers.Add(new Models.Driver
                    {
                        DispensaryId = 14,
                        FirstName    = firstName,
                        LastName     = lastName,
                        Email        = firstName + '.' + lastName + "@me.com",
                        Phone        = "619 123 2345",
                    });
                    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. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
Ejemplo n.º 22
0
        //public List<TestModel> GetAllTest(string playerID)
        //{
        //    List<TestModel> matches = new List<TestModel>();

        //    using (MySqlConnection connection = CreateConnection())
        //    {
        //        matches = connection.Query<TestModel>("SELECT * FROM matches NATURAL JOIN (SELECT * FROM played_match WHERE player_id = @PlayerID) AS matches_played_by_player", new { PlayerID = playerID }).ToList();
        //    }

        //    return matches;
        //}



        public void InsertRandomData(int amount)
        {
            var personGenerator = new PersonNameGenerator();
            var placeGenerator  = new PlaceNameGenerator();

            intrusiveContext context = null;

            Random rnd = new Random(DateTime.UtcNow.Millisecond);

            int index = 105000;

            try
            {
                context = new intrusiveContext();

                context.ChangeTracker.AutoDetectChangesEnabled = false;

                for (int i = 0; i < amount; i++)
                {
                    Accounts tempAccount = new Accounts()
                    {
                        AccountId    = placeGenerator.GenerateRandomPlaceName() + index.ToString() + personGenerator.GenerateRandomFirstName(),
                        Email        = index.ToString(),
                        PasswordHash = index.ToString()
                    };

                    Players tempPlayer = new Players()
                    {
                        Experience = (uint)rnd.Next(10000001),
                        PlayerId   = tempAccount.AccountId
                    };


                    context.Add(tempAccount);
                    context.Add(tempPlayer);

                    if (i % 100 == 0)
                    {
                        context.SaveChanges();

                        context.Dispose();
                        context = new intrusiveContext();
                        context.ChangeTracker.AutoDetectChangesEnabled = false;
                    }


                    context.SaveChanges();

                    //connection.Query<AccountModel>("select * from accounts");
                    //Console.WriteLine("{0} inserted succesfully!", tempPlayer.PlayerId);
                    index++;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }



            //using (MySqlConnection connection = CreateConnection())
            //{
            //    int index = 0;
            //    try
            //    {
            //        connection.Open();

            //        for (int i = 0; i < amount; i++)
            //        {
            //            Accounts tempAccount = new Accounts()
            //            {
            //                AccountId = placeGenerator.GenerateRandomPlaceName() + index.ToString() + personGenerator.GenerateRandomFirstName(),
            //                Email = index.ToString(),
            //                PasswordHash = index.ToString()
            //            };

            //            Players tempPlayer = new Players()
            //            {
            //                Experience = (uint)rnd.Next(10000001),
            //                PlayerId = tempAccount.AccountId
            //            };
            //            connection.Insert(tempAccount);
            //            connection.Insert(tempPlayer);

            //            //connection.Query<AccountModel>("select * from accounts");
            //            Console.WriteLine("{0} inserted succesfully!", tempPlayer.PlayerId);
            //            index++;
            //        }

            //    }
            //    catch (Exception e)
            //    {
            //        Console.WriteLine(e.Message);
            //    }
            //}
            Console.WriteLine("All inserted");
        }