@@ -21,9 +21,9 @@ public class LayoutController(ILayoutService layoutService) : Controller
21
21
[ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
22
22
[ HttpGet ( "pages" ) ]
23
23
public async Task < ActionResult < Pages > > GetPages (
24
- [ FromRoute ] string org ,
25
- [ FromRoute ] string app ,
26
- [ FromRoute ] string layoutSetId
24
+ [ FromRoute ] string org ,
25
+ [ FromRoute ] string app ,
26
+ [ FromRoute ] string layoutSetId
27
27
)
28
28
{
29
29
string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
@@ -37,16 +37,20 @@ [FromRoute] string layoutSetId
37
37
[ ProducesResponseType ( StatusCodes . Status409Conflict ) ]
38
38
[ HttpPost ( "pages" ) ]
39
39
public async Task < ActionResult < Page > > CreatePage (
40
- [ FromRoute ] string org ,
41
- [ FromRoute ] string app ,
42
- [ FromRoute ] string layoutSetId ,
43
- [ FromBody ] Page page
40
+ [ FromRoute ] string org ,
41
+ [ FromRoute ] string app ,
42
+ [ FromRoute ] string layoutSetId ,
43
+ [ FromBody ] Page page
44
44
)
45
45
{
46
46
string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
47
47
var editingContext = AltinnRepoEditingContext . FromOrgRepoDeveloper ( org , app , developer ) ;
48
48
49
- Page existingPage = await layoutService . GetPageById ( editingContext , layoutSetId , page . id ) ;
49
+ Page existingPage = await layoutService . GetPageById (
50
+ editingContext ,
51
+ layoutSetId ,
52
+ page . id
53
+ ) ;
50
54
if ( existingPage != null )
51
55
{
52
56
return Conflict ( ) ;
@@ -61,10 +65,10 @@ [FromBody] Page page
61
65
[ HttpGet ( "pages/{pageId}" ) ]
62
66
[ ProducesResponseType < Page > ( StatusCodes . Status200OK ) ]
63
67
public async Task < ActionResult < Page > > GetPage (
64
- [ FromRoute ] string org ,
65
- [ FromRoute ] string app ,
66
- [ FromRoute ] string layoutSetId ,
67
- [ FromRoute ] string pageId
68
+ [ FromRoute ] string org ,
69
+ [ FromRoute ] string app ,
70
+ [ FromRoute ] string layoutSetId ,
71
+ [ FromRoute ] string pageId
68
72
)
69
73
{
70
74
string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
@@ -82,16 +86,20 @@ [FromRoute] string pageId
82
86
[ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
83
87
[ HttpPut ( "pages/{pageId}" ) ]
84
88
public async Task < ActionResult < Page > > ModifyPage (
85
- [ FromRoute ] string org ,
86
- [ FromRoute ] string app ,
87
- [ FromRoute ] string layoutSetId ,
88
- [ FromRoute ] string pageId ,
89
- [ FromBody ] Page page
89
+ [ FromRoute ] string org ,
90
+ [ FromRoute ] string app ,
91
+ [ FromRoute ] string layoutSetId ,
92
+ [ FromRoute ] string pageId ,
93
+ [ FromBody ] Page page
90
94
)
91
95
{
92
96
string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
93
97
var editingContext = AltinnRepoEditingContext . FromOrgRepoDeveloper ( org , app , developer ) ;
94
- Page existingPage = await layoutService . GetPageById ( editingContext , layoutSetId , pageId ) ;
98
+ Page existingPage = await layoutService . GetPageById (
99
+ editingContext ,
100
+ layoutSetId ,
101
+ pageId
102
+ ) ;
95
103
if ( existingPage == null )
96
104
{
97
105
return NotFound ( ) ;
@@ -106,10 +114,10 @@ [FromBody] Page page
106
114
[ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
107
115
[ HttpDelete ( "pages/{pageId}" ) ]
108
116
public async Task < ActionResult > DeletePage (
109
- [ FromRoute ] string org ,
110
- [ FromRoute ] string app ,
111
- [ FromRoute ] string layoutSetId ,
112
- [ FromRoute ] string pageId
117
+ [ FromRoute ] string org ,
118
+ [ FromRoute ] string app ,
119
+ [ FromRoute ] string layoutSetId ,
120
+ [ FromRoute ] string pageId
113
121
)
114
122
{
115
123
string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
@@ -123,5 +131,25 @@ [FromRoute] string pageId
123
131
await layoutService . DeletePage ( editingContext , layoutSetId , pageId ) ;
124
132
return Ok ( ) ;
125
133
}
134
+
135
+ [ EndpointSummary ( "Modify pages" ) ]
136
+ [ ProducesResponseType ( StatusCodes . Status200OK ) ]
137
+ [ HttpPut ( "pages" ) ]
138
+ public async Task < ActionResult > ModifyPages (
139
+ [ FromRoute ] string org ,
140
+ [ FromRoute ] string app ,
141
+ [ FromRoute ] string layoutSetId ,
142
+ [ FromBody ] Pages pages
143
+ )
144
+ {
145
+ string developer = AuthenticationHelper . GetDeveloperUserName ( HttpContext ) ;
146
+ AltinnRepoEditingContext editingContext = AltinnRepoEditingContext . FromOrgRepoDeveloper (
147
+ org ,
148
+ app ,
149
+ developer
150
+ ) ;
151
+ await layoutService . UpdatePageOrder ( editingContext , layoutSetId , pages ) ;
152
+ return Ok ( ) ;
153
+ }
126
154
}
127
155
}
0 commit comments