public ProjectDefinitionDto(ProjectDefinition projectDefinition)
        {
            Id = projectDefinition.Id;

            Name = projectDefinition.Name;

            Description = projectDefinition.Description;

            ProjectLength = new RangeDto<int>(projectDefinition.ProjectLength);

            Value = new RangeDto<decimal>(projectDefinition.Value);

            Industries = projectDefinition.Industries.Select(i => i.Id);

            Skills = projectDefinition.Skills.Select(s => new IdValuePairDto<byte, RangeDto<decimal>>(s.SkillDefinition.Id, new RangeDto<decimal>(s.Value)));
        }
Beispiel #2
0
        public static ProjectServiceData GenerateProjectServiceData(string connectionString, int projectCount)
        {
            var projects = new List<Project>();

            var definitions = new SqlSelectStatement(connectionString)
                                    .Select("Id")
                                    .From("dbo.BZ_Project_Definition")
                                    .Execute<short>();

            while (projectCount-- > 0)
            {
                var definition = new ProjectDefinition
                {
                    Id = definitions.Random()
                };

                var dbRequirements = new SqlSelectStatement(connectionString)
                                            .Select("ProjectDefinitionId")
                                            .Select("SkillDefinitionId")
                                            .Select("Minimum")
                                            .Select("Maximum")
                                            .From("dbo.BZ_Project_Definition_Skill")
                                            .WhereEquals("ProjectDefinitionId", definition.Id)
                                            .ExecuteData();

                var requirements = new List<ProjectRequirement>();

                foreach (var dbRequirement in dbRequirements)
                {
                    requirements.Add(new ProjectRequirement
                    {
                        SkillDefinition = new SkillDefinition
                        {
                            Id = (byte)dbRequirement["SkillDefinitionId"]
                        },
                        TargetValue = Utilities.GetRandomDecimal((decimal)dbRequirement["Minimum"], (decimal)dbRequirement["Maximum"])
                    });
                }

                var project = new Project(requirements)
                {
                    Id = Utilities.InvalidId,
                    ReputationRequired = Utilities.GetValues<StarCategory>().Random(),
                    Value = Utilities.GetRandomDecimal(0, 200),
                    Deadline = Utilities.GetRandomDate(),
                    ExtensionDeadline = Utilities.GetRandomDate(),
                    Definition = definition
                };

                projects.Add(project);
            }

            return new ProjectServiceData
            {
                Projects = projects
            };
        }
Beispiel #3
0
        public static Project CreateRandomProject(ProjectDefinition projectDefinition, int id)
        {
            var projectRequirements = new List<ProjectRequirement>();

            foreach(var skill in projectDefinition.Skills)
            {
                projectRequirements.Add(new ProjectRequirement
                {
                    CurrentValue = 0,
                    SkillDefinition = skill.SkillDefinition,
                    TargetValue = Utilities.GetRandomDecimal()
                });
            }

            return new Project(projectRequirements)
            {
                Deadline = Utilities.GetRandomDate(),
                Definition = projectDefinition,
                Id = id,
                ReputationRequired = Utilities.GetRandomValue<StarCategory>(),
                Value = Utilities.GetRandomDecimal()
            };
        }