An open API service indexing awesome lists of open source software.

https://github.com/programando-ideas/webapi.mongodb

ASP.NET Core WebApi + MongoDb
https://github.com/programando-ideas/webapi.mongodb

aspnetcore csharp mongodb video webapi-core webapi-mongodb

Last synced: 10 days ago
JSON representation

ASP.NET Core WebApi + MongoDb

Awesome Lists containing this project

README

          

# ASP.NET Core WebApi + MongoDb

Proyecto con operaciones CRUD sobre **MongoDb** expuestas en una WebApi hecha con **ASP.NET Core 3.1***

## Videos Youtube (𝖠𝖲𝖯.𝖭𝖀𝖳 π–’π—ˆπ—‹π–Ύ 𝖢𝖾𝖻𝖠𝗉𝗂 + π–¬π—ˆπ—‡π—€π—ˆπ–£π–‘ πŸš€πŸƒπŸŽž)
- [πŸŽ₯ Parte I](https://youtu.be/mI64TjWxVgI)
- [πŸŽ₯ Parte II](https://youtu.be/j2f07ZGKqpo)

### Herramientas necesarias para este video

- [x] [MongoDb Server Community](https://www.mongodb.com/download-center/community)
- [x] [MongoDb Compass](https://www.mongodb.com/download-center/compass)
- [x] [Visual Studio 2019 Community](https://visualstudio.microsoft.com/es/vs/community/)
- [x] [.net Core](https://dotnet.microsoft.com/download)
- [x] [Postman free](https://www.postman.com/downloads/)
- [x] [SoapUI Open source](https://www.soapui.org/downloads/soapui/)

### Links con DocumentaciΓ³n utilizada en los Videos
- [x] [MongoDB db.createUser](https://docs.mongodb.com/manual/reference/method/db.createUser/)
- [x] [MongoClient instance global](http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/connecting/#re-use)
- [x] [IQueryable Interface](https://docs.microsoft.com/en-us/dotnet/api/system.linq.iqueryable?view=netcore-3.1)
- [x] [IMongoQueryable](https://mongodb.github.io/mongo-csharp-driver/2.4/apidocs/html/Methods_T_MongoDB_Driver_Linq_IMongoQueryable_1.htm)
- [x] [Async dotnet](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/)

## Startup.cs
```csharp
services.Configure(
Configuration.GetSection(nameof(ClientesStoreDatabaseSettings)));

services.AddSingleton(sp =>
sp.GetRequiredService>().Value);

services.AddSingleton();
services.AddSingleton();
services.AddSingleton();

// http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/connecting/#re-use
services.AddSingleton();
```

#### Logger en acciΓ³n
![](https://raw.githubusercontent.com/programando-ideas/webapi.mongodb/master/Imagenes/img_log_mongodb.PNG)

## Elemplo de URLs para utilizar con Postman
#### GET
- http://localhost:5000/api/clientes/5eac64158a01245a2c89fb0c
- http://localhost:5000/api/clientesiq/getbydir/123
- http://localhost:5000/api/clientesasync

#### POST
- http://localhost:5000/api/clientes
```json
{
"nombre": "Cliente 1",
"apellido": "Apellido 1",
"edad": 37,
"telefonos": [
{
"id": 1,
"tel": "+555555555555"
},
{
"id": 2,
"tel": "+111111111111"
},
{
"id": 3,
"tel": "+222222222222"
},
{
"id": 4,
"tel": "+999999999999"
}
],
"direccionCliente": {
"id": 0,
"calle": "Calle 123",
"numero": "133",
"depto": "3a"
}
}
```
#### PUT
```json
{
"id": "{Id Creado}",
"nombre": "Cliente 1 12345",
"apellido": "Apellido 1",
"edad": 37,
"telefonos": [
{
"id": 1,
"tel": "+555555555555"
},
{
"id": 2,
"tel": "+111111111111"
},
{
"id": 3,
"tel": "+222222222222"
},
{
"id": 4,
"tel": "+999999999999"
}
],
"direccionCliente": {
"calle": "Calle 123",
"numero": "133",
"depto": "3a"
}
}
```
#### DEL
- http://localhost:5000/api/clientes/5eac64158a01245a2c89fb0c

## Directorio JsonTest
#### Json con ejemplos para crear y actualizar un cliente
- CREATE_POST.json
- UPDATE_PUT.json
#### Proyecto de SoapUI para ejecutar el "Load Test"
- [LoadTest_MongoDB_API.xml](https://raw.githubusercontent.com/programando-ideas/webapi.mongodb/master/JsonTest/LoadTest_MongoDB_API.xml)

![](https://raw.githubusercontent.com/programando-ideas/webapi.mongodb/master/Imagenes/img_soapui_test.PNG)

------------
#### Programando Ideas 2020



Donar con PayPal