예제 #1
0
        public WorkHistoryDto(WorkHistory workHistory)
        {
            CompanyId = workHistory.Company.Id;

            StartDate = workHistory.StartDate;

            StartingSalary = workHistory.StartingSalary;

            EndDate = workHistory.EndDate;

            EndingSalary = workHistory.EndingSalary;
        }
예제 #2
0
        public static PersonServiceData GeneratePersonServiceData(int numberOfPeople, IEnumerable<Personality> validPersonalities, IEnumerable<SkillDefinition> validSkills = null, IEnumerable<Company> validCompanies = null)
        {
            var people = new List<Person>();

            for (var personIndex = 0; personIndex < numberOfPeople; personIndex++)
            {
                List<Skill> skills = null;

                if (validSkills != null)
                {
                    var remainingSkills = new List<SkillDefinition>(validSkills);

                    var skillCount = Utilities.GetRandomInt(1, remainingSkills.Count);

                    skills = new List<Skill>(skillCount);

                    for (var skillIndex = 0; skillIndex < skillCount; skillIndex++)
                    {
                        var skill = new Skill
                        {
                            ForgetRate = Utilities.GetRandomDecimal(0, 1),
                            LearnRate = Utilities.GetRandomDecimal(0, 1),
                            Value = Utilities.GetRandomDecimal(0, 255),
                            SkillDefinition = remainingSkills.Random()
                        };

                        remainingSkills.Remove(skill.SkillDefinition);

                        skills.Add(skill);
                    }
                }
                else
                {
                    skills = new List<Skill>();
                }

                var person = new Person(skills)
                {
                    Id = Utilities.InvalidId,
                    FirstName = Utilities.GetRandomString(16),
                    LastName = Utilities.GetRandomString(16),
                    Birthday = Utilities.GetRandomDate().Date,
                    Gender = Utilities.GetRandomValue(Gender.None),
                    Personality = validPersonalities.Random()
                };

                person.RetirementDate = person.Birthday.AddYears(Utilities.GetRandomInt(60, 100)).AddDays(Utilities.GetRandomInt(1, 360));

                if (validCompanies != null)
                {
                    var remainingCompanies = new List<Company>(validCompanies);

                    var rollingDate = new DateTime(Utilities.GetRandomInt(person.Birthday.Year + 10, person.Birthday.Year + 20), Utilities.GetRandomInt(1, 12), Utilities.GetRandomInt(1, 28));

                    while (remainingCompanies.Any())
                    {
                        var workHistory = new WorkHistory
                        {
                            Company = remainingCompanies.Random(),
                            StartDate = rollingDate,
                            EndDate = rollingDate = rollingDate.AddMonths(Utilities.GetRandomInt(1, 6)),
                            StartingSalary = Utilities.GetRandomDecimal(10, 100),
                            EndingSalary = Utilities.GetRandomDecimal(100, 250)
                        };

                        remainingCompanies.Remove(workHistory.Company);

                        person.WorkHistory.Add(workHistory);
                    }
                }

                people.Add(person);
            }

            return new PersonServiceData
            {
                People = people
            };
        }