Exemplo n.º 1
0
        public EmployeeDto(Employee employee)
        {
            PersonId = employee.Person.Id;

            Salary = employee.Salary;

            IsFounder = employee.IsFounder;

            Happiness = employee.Happiness;
        }
Exemplo n.º 2
0
 public void FireEmployee(Company company, Employee employee)
 {
 }
Exemplo n.º 3
0
 public void AdjustSalary(Company company, Employee employee, decimal salary)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public void AdjustAllocation(Company company, Employee employee, Project project, decimal percentage, ProjectRole role)
 {
     throw new NotImplementedException();
 }
        protected decimal CalculateEmployeeSkillValue(Employee employee, Skill skill)
        {
            var output = skill.Value;

            return output;
        }
Exemplo n.º 6
0
        public static CompanyServiceData GenerateCompanyServiceData(CompanyServiceDataSetup setup)
        {
            var companies = new List<Company>();

            if (setup.NumberOfCompanies < 0)
            {
                setup.NumberOfCompanies = Utilities.GetRandomInt(1, 5);
            }

            for (var companyIndex = 0; companyIndex < setup.NumberOfCompanies; companyIndex++)
            {
                // Actions
                var actions = new List<CompanyAction>();

                if (setup.ValidActions != null)
                {
                    foreach (var validAction in setup.ValidActions)
                    {
                        var accumulations = new List<CompanyActionAccumulation>();

                        foreach (var requirement in validAction.Requirements)
                        {
                            accumulations.Add(new CompanyActionAccumulation
                            {
                                SkillDefinition = requirement.SkillDefinition,
                                Value = Utilities.GetRandomDecimal(0, requirement.Value)
                            });
                        }

                        var action = new CompanyAction(accumulations)
                        {
                            Action = validAction,
                            Count = Utilities.GetRandomInt(0, validAction.MaxCount),
                            IsActive = Utilities.GetRandomBool()
                        };

                        actions.Add(action);
                    }
                }

                var company = new Company(actions)
                {
                    Id = Utilities.InvalidId,
                    InitialAccuracy = Utilities.GetRandomDecimal(0, 1),
                    Money = Utilities.GetRandomDecimal(1, 100000),
                    Name = Utilities.GetRandomString(16)
                };

                company.UserId = companyIndex == 0 ? TestUserId : Utilities.GetRandomInt();

                if (companyIndex == 1)
                {
                    companies[0].Rival = company;
                }

                // Projects
                if (setup.ValidProjects != null && setup.ValidProjects.Any())
                {
                    var maxProjectsPerCompany = setup.ValidProjects.Count() / setup.NumberOfCompanies;

                    var projectCount = Utilities.GetRandomInt(1, maxProjectsPerCompany);

                    var remainingProjects = new List<Project>(setup.ValidProjects);

                    while (projectCount-- > 0)
                    {
                        var project = remainingProjects.Random();

                        remainingProjects.Remove(project);

                        company.Projects.Add(project);
                    }
                }

                // Employees
                if (setup.ValidPeople != null && setup.ValidPeople.Any())
                {
                    var employeeCount = setup.NumberOfEmployees;

                    var remainingPeople = new List<Person>(setup.ValidPeople);

                    while (employeeCount-- > 0)
                    {
                        var person = remainingPeople.Random();

                        remainingPeople.Remove(person);

                        var employee = new Employee
                        {
                            Person = person,
                            Happiness = Utilities.GetRandomDecimal(0, 1),
                            IsFounder = employeeCount == 1,
                            Salary = Utilities.GetRandomDecimal(0, 100)
                        };

                        company.Employees.Add(employee);
                    }
                }

                // Allocations
                if (company.Employees.Any() && company.Projects.Any())
                {
                    var percent = Math.Round(1.0m / company.Projects.Count, 6);

                    foreach (var employee in company.Employees)
                    {
                        foreach (var project in company.Projects)
                        {
                            var allocation = new Allocation
                            {
                                Employee = employee,
                                Project = project,
                                Percent = percent,
                                Role = Utilities.GetRandomValue(ProjectRole.None)
                            };

                            company.Allocations.Add(allocation);
                        }
                    }
                }

                // Perks
                if (setup.ValidPerks != null && setup.ValidPerks.Any())
                {
                    var perkCount = Utilities.GetRandomInt(1, setup.ValidPerks.Count());

                    var remainingPerks = new List<Perk>(setup.ValidPerks);

                    while (perkCount-- > 0)
                    {
                        var perk = remainingPerks.Random();

                        remainingPerks.Remove(perk);

                        var instanceCount = Utilities.GetRandomInt(1, perk.MaxCount);

                        company.Perks.Add(new CompanyPerk
                        {
                            Perk = perk,
                            Count = instanceCount
                        });
                    }
                }

                // Prospects
                if (setup.ValidPeople != null && setup.ValidPeople.Any())
                {
                    var prospectCount = setup.NumberOfProspects;

                    var remainingPeople = new List<Person>(setup.ValidPeople);

                    while (prospectCount-- > 0)
                    {
                        var person = remainingPeople.Random();

                        remainingPeople.Remove(person);

                        var skills = new List<ProspectSkill>();

                        foreach (var skill in person.Skills)
                        {
                            var pSkill = new ProspectSkill
                            {
                                SkillDefinition = skill.SkillDefinition
                            };

                            pSkill.Value.Minimum = skill.Value - 1;

                            pSkill.Value.Maximum = skill.Value + 1;

                            skills.Add(pSkill);
                        }

                        var prospect = new Prospect(skills)
                        {
                            Person = person,
                            Accuracy = Utilities.GetRandomDecimal(0, 1),
                            Salary = new Range<decimal>(Utilities.GetRandomDecimal(10, 25), Utilities.GetRandomDecimal(50, 100))
                        };

                        company.Prospects.Add(prospect);
                    }
                }

                // Reputation
                company.Reputation.PossibleStars = Utilities.GetRandomInt(0, 100);

                company.Reputation.EarnedStars = Utilities.GetRandomInt(0, company.Reputation.PossibleStars);

                // Transactions
                if (setup.NumberOfTransactions > 0)
                {
                    var transactionCount = Utilities.GetRandomInt(1, setup.NumberOfTransactions);

                    while (transactionCount-- > 0)
                    {
                        var transaction = new Transaction
                        {
                            Id = Utilities.InvalidId,
                            Description = Utilities.GetRandomString(),
                            Date = Utilities.GetRandomDate(),
                            Type = Utilities.GetRandomValue<TransactionType>(),
                            Amount = Utilities.GetRandomDecimal(100, 1000),
                            EndingBalance = Utilities.GetRandomDecimal(1000, 2000)
                        };

                        company.Transactions.Add(transaction);
                    }
                }

                // Messages
                if(setup.NumberOfMessages > 0)
                {
                    var messageCount = Utilities.GetRandomInt(1, setup.NumberOfMessages);

                    while(messageCount-- > 0)
                    {
                        company.Messages.Add(new CompanyMessage
                        {
                            Id = Utilities.InvalidId,
                            DateCreated = Utilities.GetRandomDate(),
                            Message = Utilities.GetRandomString(64),
                            Source = Utilities.GetRandomString(64),
                            Status = Utilities.GetRandomValue(CompanyMessageStatus.None),
                            Subject = Utilities.GetRandomString(128)
                        });
                    }
                }

                companies.Add(company);
            }

            return new CompanyServiceData
            {
                Companies = companies
            };
        }