11.. _csharp-crud-restful-api-tutorial:
22
3- =====================================================================
4- Tutorial: Create a RESTful API with the {+driver-short+} Driver
5- =====================================================================
3+ ============================================================
4+ Tutorial: Create a RESTful API by Using the {+driver-short+}
5+ ============================================================
66
77.. facet::
88 :name: genre
@@ -36,7 +36,7 @@ Before you start this tutorial, perform the following actions:
3636- Install .NET 6.0 or later on your machine. To install .NET, visit the
3737 `Microsoft .NET download page <https://dotnet.microsoft.com/en-us/download>`__.
3838
39- .. note::
39+ .. note:: Language Compatibility
4040
4141 This tutorial uses .NET Core 8.0, but you can use any version later than .NET 6.0.
4242
@@ -87,8 +87,8 @@ the data model for your RESTful API.
8787
8888 .. step:: Update the appsettings.json file
8989
90- The data that will be stored in the class fields defined in the
91- ``MongoDBSettings`` class is found in the projects' ``appsettings.json``
90+ You can find the data that is stored in the class fields defined in the
91+ ``MongoDBSettings`` class in the projects' ``appsettings.json``
9292 file. Open this file and add the following configuration:
9393
9494 .. code-block:: json
@@ -101,18 +101,19 @@ the data model for your RESTful API.
101101 "Microsoft.AspNetCore": "Warning"
102102 }
103103 },
104- "AllowedHosts": "*",
105- "MongoDB": {
106- "ConnectionURI": "<Atlas connection string>",
107- "DatabaseName": "sample_mflix",
108- "CollectionName": "playlist"
109- }
104+ "AllowedHosts": "*",
105+ "MongoDB": {
106+ "ConnectionURI": "<Atlas connection string>",
107+ "DatabaseName": "sample_mflix",
108+ "CollectionName": "playlist"
109+ }
110110 }
111111
112112 This tutorial uses the ``sample_mflix`` database and the ``playlist``
113113 collection. Replace the ``<Atlas connection string>`` placeholder with
114114 your MongoDB Atlas connection string. For more information on how to find
115- your connection string, see the :atlas:`Connect to Your Cluster </tutorial/connect-to-your-cluster>` tutorial.
115+ your connection string, see the :atlas:`Connect to Your Cluster </tutorial/connect-to-your-cluster>`
116+ tutorial in the Atlas documentation.
116117
117118 .. step:: Create the service
118119
@@ -157,20 +158,19 @@ the data model for your RESTful API.
157158 :language: csharp
158159 :dedent:
159160
160- In the preceding code, the ``Id`` field is represented as an ``ObjectId``
161- in BSON and the ``_id`` fild within MongoDB. When you work with this
162- locally in your application, it is a string.
161+ In the preceding code, the ``Id`` field is serialized as an ``ObjectId``
162+ in the ``_id`` field. The field is represented as a string in your application.
163163
164- The ``movieIds`` field will be known as ``items``. When sending or
165- receiving JSON, the field will also be known as ``items`` instead of
164+ The ``movieIds`` field is serialized as ``items``. When you send or
165+ receive JSON values , the field is also named ``items`` instead of
166166 ``movieIds``.
167167
168168 If you plan to have your local class field match the document field
169169 directly, it isn't necessary to define custom mappings. For example, the
170- ``username`` field in the preceding code has no custom mappings. It will
170+ ``username`` field in the preceding code has no custom mappings. It is called
171171 be ``username`` in C#, in JSON, and in MongoDB.
172172
173- You now have a MongoDB service and document model for your collection to work
173+ After this step, you have a MongoDB service and document model for your collection to work
174174with .NET Core.
175175
176176Build CRUD Endpoints
@@ -181,7 +181,7 @@ different files within the project. In this section, you can learn how to define
181181the endpoint within a controller and update the corresponding work within the
182182service.
183183
184- .. note::
184+ .. note:: Data Validation
185185
186186 In this example project, there is no data validation for the HTTP requests.
187187
@@ -231,7 +231,7 @@ service.
231231 When the ``POST`` endpoint executes, the application takes the
232232 ``Playlist`` object from the ``request``, which .NET Core parses, and
233233 passes it to the ``CreateAsync`` function in the service. After the
234- insert, the code returns some information about the interaction.
234+ insert, the code returns information about the interaction.
235235
236236 .. step:: Read data through the GET endpoint
237237
@@ -311,7 +311,7 @@ service.
311311 :end-before: end-delete
312312 :dedent:
313313
314- You now have a complete set of CRUD endpoints for your RESTful API.
314+ After this step, you have a complete set of CRUD endpoints for your RESTful API.
315315
316316Test Your API Endpoints
317317-----------------------
0 commit comments