Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is good API route template? I other words, is there template that i more expectable, or it is not important at all?
first:
"api/{controller}/{action}/{id}"
http://example.com/WorkItem/details/5
second:
"api/{controller}/{id}/{action}"
http://example.com/WorkItem/5/details
I consider it good practice to use your second approach in a RESTful szenario. Common frameworks handle it this way:
Example 1: Rails
see the docs at 2.2 CRUD, Verbs, and Actions, where
GET /photos/{:id}/edit refers to the PhotosControllers edit-method to return an HTML form for editing a photo
Example 2: Laravel
see the docs at RESTful Resource Controllers, where
GET /photo/{photo}/edit also refers to a PhotoControllers edit-method.
Also, see the section on Nested Resources below which looks a bit more like your use case:
Route::resource('photos.comments', 'PhotoCommentController');
registers a nested route in the way of photos/{photos}/comments/{comments} which is your use case and looks more like your second approach.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
In Blazor, certain things like injected objects and parameters must use properties, that part is clear.
But what about those page-specific variables, such as data/DTOs and misc strings/booleans etc used to control the page content and flow?
Is it better to use automatic properties with these all the way (public or private?) or private fields?
I'm asking this because in the various examples, tutorials and documentations related Blazor, use of both properties and fields are all over the place. I cannot seem to find any official best-practice guides on this.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Is it possible to create an API using EF Core and ASP .NET Core that is flexible and allows you to eager load?
For example: you would call groups with a post call and you could tell the API "include the users list in those loaded entities".
Also it would be nice to pass conditions to the API.
Do you have to create specific methods for this like LoadGroups for groups and LoadGroupsWithUsers for a include of users or is it possible to create a single method in the Controller for this that is capable of handling both?
As #vsarunov mentioned this can be achieved by using GraphQL.
Here his link.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
We have to microservices.
How can we use an entity model from one microservice to another microservice without needing to maintain codes on both end?
The goal is to take the jsonData from a microservice and map it to entity model that exist in another microservice.
What is the best practice here?
You will need the assembly that contains the types you want to serialize/deserialize jsons. I think it is ok because when you have one service, you expect it to run autonomously, so, if you provide additional fields it should work (because it will not be affected by the deserialization). Now missing fields, the service will thrown exceptions and it is expected as part of the business.
One option, but not recommended (in my opinion), is to deserialize your json into dynamic and you will be able to navigate on the result as you want. I am not sure about the performance of this.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have a controller method called GetCustomer(int id=0)
This smells weird in my opinion, but was already here, and I'm wondering if this is a good practice!
I would rather in this case use nullable type!
Assuming that action maps onto GET /customers/id, making the id optional (by means of a parameter with a default value or a nullable type) is bad API design.
Traditionally, GET /customers maps onto an action that retrieves all existing customers, not onto GET /customers/0. You can also simply not support calls to GET /customers.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working with several developers who develop .net components for me.
I manage the licensing mechanism and want to hide the implementation.
I would like to just provide them the interface, with for example the methodIsLicenseValid() so they must use it in the code but cannot access the implementation.
Which pattern or technology should I use to reach that objective?
You should be using a Web Service to expose the methodIsLicenseValid(), and let your devs invoke it whenever necessary.
This will be suitable for your production environment anyways and also will allow you to change the implementation of the methodIsLicenseValid(), without causing hasles to the devs, as opposed to providing a library/dll to them