Ejemplo n.º 1
0
 public ProjectService(GxDbContext dbContext)
 {
     gxDb = dbContext;
 }
Ejemplo n.º 2
0
 public PropertyService(GxDbContext dbContext)
 {
     gxDb = dbContext;
 }
Ejemplo n.º 3
0
 public UserService(GxDbContext dbContext)
 {
     gxDb = dbContext;
 }
Ejemplo n.º 4
0
 public UserController(GxDbContext gxDbContext)
 {
     gxdb        = gxDbContext;
     UserService = new UserService(gxDbContext);
 }
Ejemplo n.º 5
0
 public ProjectController(GxDbContext gxDbContext)
 {
     gxdb           = gxDbContext;
     UserService    = new UserService(gxDbContext);
     ProjectService = new ProjectService(gxDbContext);
 }
Ejemplo n.º 6
0
        public ServiceTest(ITestOutputHelper output)
        {
            this.output = output;

            gxDb            = new GxContextFactory().CreateDbContext(new string[] { "test" });
            userService     = new UserService(gxDb);
            projectService  = new ProjectService(gxDb);
            propertyService = new PropertyService(gxDb);

            // add property
            var data = TemplateConfig.ReadDefaultTemplate();

            propertyService.AddProperties(data);
            //add  template
            var template = new PropertyTemplate()
            {
                Name = "Default"
            };
            //add template-property
            List <Template_Property> template_s = new List <Template_Property>(data.Count);

            foreach (var item in data)
            {
                template_s.Add(new Template_Property()
                {
                    PropertyTemplate = template, GxProperty = item
                });
            }
            template.Template_Properties = template_s;

            gxDb.PropertyTemplates.Add(template);
            gxDb.SaveChanges();

            //add user data
            User[] users = new User[]
            {
                new User()
                {
                    Name = "Jack", PassWord = "******"
                },
                new User()
                {
                    Name = "Andy", PassWord = "******"
                },
                new User()
                {
                    Name = "Frank", PassWord = "******"
                },
                new User()
                {
                    Name = "张山", PassWord = "******"
                }
            };
            foreach (var user in users)
            {
                if (userService.Register(user.Name, user.PassWord))
                {
                    output.WriteLine($"{user.Name}注册成功!");
                }
                else
                {
                    output.WriteLine($"{user.Name}注册失败,用户名已存在!");
                }
            }
            //add project
            User    u       = userService.Login("Jack", "123");
            Project project = new Project()
            {
                Creator = u, Name = "Test Project1"
            };

            project.PropertyTemplate = template;

            userService.CreateProject(u, ref project);
        }