Razor Views  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Razor Views  Topic is solved

Postby Mike.Sheen » Sat Jun 17, 2017 11:30 am

By default the Jiwa REST API will serve a built-in HTML representation of responses when viewed in a browser.

These representations are generated by built-in razor views. You can override these views, however to render your own HTML.

You do this by placing a .cshtml file in the Views folder, which is located under the folder the service is running in. The file just needs to be named the same as the request name, and contain valid Razor or markdown.

As a proof of concept, we provide one view in that folder out of the box - the SalesOrderGETRequest.cshtml.

When you visit the route corresponding to that request (e.g.: http://localhost/SalesOrders/000000001X00000000GP) the browser will render the page based on that .cshtml file:
SalesOrderGETRequest.PNG
SalesOrderGETRequest Razor output


If that file was not present, then the built-in internal representation would be shown:
DefaultView.PNG
Built in Razor output


We aim to improve things a bit in respect to the management of Razor views - we aim to redirect the file location where views are picked up from to the ProgramData folder - and then we can store the views in the database and the REST API will be able to write them to the filesystem (writing to the program files folders is a strict no-no). We'll have a caching strategy so the views are only written when invalidated (changed in the database), and also hopefully a pleasant way of creating and editing the Razor views.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Razor Views

Postby SBarnes » Sun Jun 18, 2017 2:55 pm

Hi Mike,

This is a great idea, could this be expanded a bit further to where a zip file could go into the database that would not only include the view but possibly other other assets such as images that could be used for the view?

Could it even be possible if this could be linked to the user group in a similar fashion as permissions on routes i.e. different groups could get different views?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests