|
- <%
- Class board_columns_Repository_Class
-
- Public Function FindByID(id)
- Dim sql : sql = "SELECT [id],[board_id],[name],[position],[created_at],[created_by],[updated_at],[updated_by] FROM [board_columns] WHERE [id] = ?"
- Dim rs : Set rs = DAL.Query(sql, Array(id))
- If rs.EOF Then
- Err.Raise 1, "board_columns_Repository_Class", "Column not found with id = " & id
- Else
- Set FindByID = Automapper.AutoMap(rs, "POBO_board_columns")
- End If
- Destroy rs
- End Function
-
- Public Function FindByBoardId(boardId)
- Dim sql : sql = "SELECT [id],[board_id],[name],[position],[created_at],[created_by],[updated_at],[updated_by] FROM [board_columns] WHERE [board_id] = ? ORDER BY [position] ASC"
- Dim rs : Set rs = DAL.Query(sql, Array(boardId))
- Dim list : Set list = New LinkedList_Class
- Do Until rs.EOF
- list.Push Automapper.AutoMap(rs, "POBO_board_columns")
- rs.MoveNext
- Loop
- Set FindByBoardId = list
- Destroy rs
- End Function
-
- Public Function MaxPosition(boardId)
- Dim sql : sql = "SELECT MAX([position]) FROM [board_columns] WHERE [board_id] = ?"
- Dim rs : Set rs = DAL.Query(sql, Array(boardId))
- If rs.EOF Or IsNull(rs(0)) Then
- MaxPosition = -1
- Else
- MaxPosition = CLng(rs(0))
- End If
- Destroy rs
- End Function
-
- Public Sub AddNew(ByRef model)
- Dim sql : sql = "INSERT INTO [board_columns] ([board_id],[name],[position],[created_at],[created_by],[updated_at],[updated_by]) VALUES (?,?,?,?,?,?,?)"
- DAL.Execute sql, Array(model.board_id, model.name, model.position, model.created_at, model.created_by, model.updated_at, model.updated_by)
- Dim rsId : Set rsId = DAL.Query("SELECT @@IDENTITY AS NewID", Empty)
- If Not rsId.EOF Then
- If Not IsNull(rsId(0)) Then model.id = rsId(0)
- End If
- Destroy rsId
- End Sub
-
- Public Sub Update(model)
- Dim sql : sql = "UPDATE [board_columns] SET [name]=?,[position]=?,[updated_at]=?,[updated_by]=? WHERE [id]=?"
- DAL.Execute sql, Array(model.name, model.position, model.updated_at, model.updated_by, model.id)
- End Sub
-
- Public Sub UpdatePosition(id, position, updatedAt, updatedBy)
- Dim sql : sql = "UPDATE [board_columns] SET [position]=?,[updated_at]=?,[updated_by]=? WHERE [id]=?"
- DAL.Execute sql, Array(position, updatedAt, updatedBy, id)
- End Sub
-
- Public Sub Delete(id)
- DAL.Execute "DELETE FROM [board_columns] WHERE [id]=?", Array(id)
- End Sub
-
- Public Sub DeleteByBoardId(boardId)
- DAL.Execute "DELETE FROM [board_columns] WHERE [board_id]=?", Array(boardId)
- End Sub
-
- End Class
-
- Dim board_columns_Repository__Singleton
- Function board_columns_Repository()
- If IsEmpty(board_columns_Repository__Singleton) Then
- Set board_columns_Repository__Singleton = New board_columns_Repository_Class
- End If
- Set board_columns_Repository = board_columns_Repository__Singleton
- End Function
- %>
|