Exemplo n.º 1
0
 public static BoardModel Create(UserModel user = null)
 {
     user = user ?? UserFaker.Create();
     return(BoardRepository.CreateAndGet(
                "boardName_" + Rand.SmallInt(),
                "description" + Rand.SmallInt(),
                ProjectFaker.Create(user),
                user
                ));
 }
Exemplo n.º 2
0
        public static void Run(DL.Model.Project.Project project, User creator)
        {
            if (creator != null)
            {
                ProjectTeamMemberRepository.CreateAndGet(project, creator);
                UserLibraryItemRepository.FindOrCreate(project.Creator(), project);
            }

            ProjectAliasRepository.Create(project);
            ProjectWorkUtils.SetUp(project);

            // Basic boards set up
            var board      = BoardRepository.CreateAndGet("Development", "Basic board", project, creator);
            var todoColumn = BoardColumnRepository.CreateAndGet("TODO", board, 1);

            BoardColumnRepository.CreateAndGet("In progress", board, 2);
            BoardColumnRepository.CreateAndGet("Done", board, 3);
            CardRepository.CreateAndGet(
                "Example card", DefaultCardDescription, 1, todoColumn, creator
                );
        }
Exemplo n.º 3
0
        public BoardCrudController()
        {
            Post("/api/v1/board/create", _ => {
                var me      = UserRepository.Find(CurrentRequest.UserId);
                var project = ProjectRepository.FindByGuid(GetRequestStr("project_guid"));

                var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
                    new ShouldHaveParameters(new[] { "name", "description", "project_guid" }),
                    new ExistsInTable("project_guid", "projects", "guid"),
                    new HasPermission(me, project.id, EntityType.Project)
                }, true);
                if (errors.Count > 0)
                {
                    return(HttpResponse.Errors(errors));
                }

                var board = BoardRepository.CreateAndGet(
                    (string)Request.Query["name"],
                    (string)Request.Query["description"],
                    project,
                    me
                    );

                return(HttpResponse.Item(
                           "board", new BoardTransformer().Transform(board), HttpStatusCode.Created
                           ));
            });

            Patch("/api/v1/board/edit", _ => {
                var me    = UserRepository.Find(CurrentRequest.UserId);
                var board = BoardRepository.FindByGuid(GetRequestStr("board_guid"));

                var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
                    new ShouldHaveParameters(new[] { "board_guid" }),
                    new ExistsInTable("board_guid", "boards", "guid"),
                    new HasPermission(me, board.id, EntityType.Board)
                }, true);
                if (errors.Count > 0)
                {
                    return(HttpResponse.Errors(errors));
                }

                board = BoardRepository.UpdateAndRefresh(board, new JObject()
                {
                    ["name"]        = GetRequestStr("name"),
                    ["description"] = GetRequestStr("description"),
                    ["updated_at"]  = DateTime.Now,
                });

                return(HttpResponse.Item("board", new BoardTransformer().Transform(board)));
            });

            Delete("/api/v1/board/delete", _ => {
                var me    = UserRepository.Find(CurrentRequest.UserId);
                var board = BoardRepository.FindByGuid(GetRequestStr("board_guid"));

                var errors = ValidationProcessor.Process(Request, new IValidatorRule[] {
                    new ShouldHaveParameters(new[] { "board_guid" }),
                    new ExistsInTable("board_guid", "boards", "guid"),
                    new HasPermission(me, board.id, EntityType.Board)
                }, true);
                if (errors.Count > 0)
                {
                    return(HttpResponse.Errors(errors));
                }

                board.Delete();

                return(HttpResponse.Item("board", new BoardTransformer().Transform(board)));
            });
        }