(feat): blog items dataprovider and controllers
This commit is contained in:
parent
3506afda39
commit
b635c3bc3b
1081
db/DML/blogcatalog.json
Normal file
1081
db/DML/blogcatalog.json
Normal file
File diff suppressed because one or more lines are too long
13
db/DML/categories.json
Normal file
13
db/DML/categories.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"_id":"e154e33f-3cc7-468d-bb66-e0390ddb9ae0",
|
||||
"siteId":"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"l10n":[
|
||||
{
|
||||
"locale":0,
|
||||
"slug":"default",
|
||||
"text":"Default category"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -1,47 +1,32 @@
|
||||
[
|
||||
{
|
||||
"_id": "bdc1aeac-2592-40c2-b9b3-a4988ce6173d",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"slug": "shop-catalog-item",
|
||||
"sku": "SKU-01",
|
||||
"image": { "src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg", "alt": "..." },
|
||||
"title": "Mongo Shop item title",
|
||||
"brandName": "Brand & Name",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"created": { "$date": "2022-01-01T00:00:00.000Z" },
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 1
|
||||
},
|
||||
{
|
||||
"_id": "0aaa0244-4b4a-4b05-8135-463ba187d78b",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"slug": "shop-catalog-item",
|
||||
"sku": "SKU-02",
|
||||
"image": { "src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg", "alt": "..." },
|
||||
"title": "Mongo Shop item title",
|
||||
"brandName": "Brand & Name",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"created": { "$date": "2022-01-01T00:00:00.000Z" },
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 2
|
||||
},
|
||||
{
|
||||
"_id": "7da86cc6-80a9-4828-b81f-421d26a8cb24",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"slug": "shop-catalog-item",
|
||||
"sku": "SKU-03",
|
||||
"image": { "src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg", "alt": "..." },
|
||||
"title": "Mongo Shop item title",
|
||||
"brandName": "Brand & Name",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"created": { "$date": "2022-01-01T00:00:00.000Z" },
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 2
|
||||
}
|
||||
{
|
||||
"_id":"bdc1aeac-2592-40c2-b9b3-a4988ce6173d",
|
||||
"siteId":"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId":"fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"sku":"SKU-01",
|
||||
"quantity":2,
|
||||
"created":{
|
||||
"$date":"2022-01-01T00:00:00.000Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id":"0aaa0244-4b4a-4b05-8135-463ba187d78b",
|
||||
"siteId":"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId":"fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"sku":"SKU-02",
|
||||
"quantity":2,
|
||||
"created":{
|
||||
"$date":"2022-01-01T00:00:00.000Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id":"7da86cc6-80a9-4828-b81f-421d26a8cb24",
|
||||
"siteId":"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"userId":"fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"sku":"SKU-03",
|
||||
"quantity":2,
|
||||
"created":{
|
||||
"$date":"2022-01-01T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -1,187 +1,194 @@
|
||||
[
|
||||
{
|
||||
"_id": "e2dd785c-f036-453a-886b-d842b7c31366",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"slug": "shop-catalog-item",
|
||||
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
{
|
||||
"_id": "e2dd785c-f036-453a-886b-d842b7c31366",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"slug": "shop-catalog-item-01",
|
||||
"description": "",
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"contentType": 0,
|
||||
"plainText": "",
|
||||
"badges": [
|
||||
"sale"
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"alt": "..."
|
||||
}
|
||||
],
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"author": {
|
||||
"_id": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"image": {
|
||||
"src": "https://dummyimage.com/40x40/ced4da/6c757d",
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"author": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
"e154e33f-3cc7-468d-bb66-e0390ddb9ae0"
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-01",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "055ede3f-7449-47d1-83b1-387dc3573711",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"slug": "shop-catalog-item-02",
|
||||
"description": "",
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"contentType": 0,
|
||||
"plainText": "",
|
||||
"badges": [
|
||||
"sale"
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"alt": "..."
|
||||
},
|
||||
"nickName": "Admin"
|
||||
},
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"badges": [
|
||||
"sale"
|
||||
],
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"_id": "e154e33f-3cc7-468d-bb66-e0390ddb9ae0",
|
||||
"slug": "default",
|
||||
"text": "Default category"
|
||||
}
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-01",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "055ede3f-7449-47d1-83b1-387dc3573711",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"slug": "shop-catalog-item",
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"author": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
"e154e33f-3cc7-468d-bb66-e0390ddb9ae0"
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-02",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "d17accca-6666-43ef-a91f-b63604e6113c",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"slug": "shop-catalog-item-03",
|
||||
"description": "",
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"contentType": 0,
|
||||
"plainText": "",
|
||||
"badges": [
|
||||
"sale"
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"alt": "..."
|
||||
}
|
||||
],
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"author": {
|
||||
"_id": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"image": {
|
||||
"src": "https://dummyimage.com/40x40/ced4da/6c757d",
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"author": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
"e154e33f-3cc7-468d-bb66-e0390ddb9ae0"
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-03",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "0dc37621-0925-41d8-90db-552224d59c2a",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"slug": "shop-catalog-item-04",
|
||||
"description": "",
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"contentType": 0,
|
||||
"plainText": "",
|
||||
"badges": [
|
||||
"sale"
|
||||
]
|
||||
}
|
||||
],
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"l10n": [
|
||||
{
|
||||
"locale": 0,
|
||||
"alt": "..."
|
||||
},
|
||||
"nickName": "Admin"
|
||||
},
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"badges": [
|
||||
"sale"
|
||||
],
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"_id": "e154e33f-3cc7-468d-bb66-e0390ddb9ae0",
|
||||
"slug": "default",
|
||||
"text": "Default category"
|
||||
}
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-02",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "d17accca-6666-43ef-a91f-b63604e6113c",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"slug": "shop-catalog-item",
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"alt": "..."
|
||||
}
|
||||
],
|
||||
"brandName": "Brand & Name",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"author": {
|
||||
"_id": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"image": {
|
||||
"src": "https://dummyimage.com/40x40/ced4da/6c757d",
|
||||
"alt": "..."
|
||||
},
|
||||
"nickName": "Admin"
|
||||
},
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"badges": [
|
||||
"sale"
|
||||
],
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"_id": "e154e33f-3cc7-468d-bb66-e0390ddb9ae0",
|
||||
"slug": "default",
|
||||
"text": "Default category"
|
||||
}
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-03",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
},
|
||||
{
|
||||
"_id": "0dc37621-0925-41d8-90db-552224d59c2a",
|
||||
"siteId": "404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"slug": "shop-catalog-item",
|
||||
"images": [
|
||||
{
|
||||
"src": "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
"alt": "..."
|
||||
}
|
||||
],
|
||||
"title": "Shop item title",
|
||||
"shortText": "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
"text": "",
|
||||
"author": {
|
||||
"_id": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"image": {
|
||||
"src": "https://dummyimage.com/40x40/ced4da/6c757d",
|
||||
"alt": "..."
|
||||
},
|
||||
"nickName": "Admin"
|
||||
},
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"badges": [
|
||||
"sale"
|
||||
],
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
{
|
||||
"_id": "e154e33f-3cc7-468d-bb66-e0390ddb9ae0",
|
||||
"slug": "default",
|
||||
"text": "Default category"
|
||||
}
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-04",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"author": "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"created": {
|
||||
"$date": "2022-01-01T00:00:00.000Z"
|
||||
},
|
||||
"tags": [
|
||||
"react",
|
||||
"redux",
|
||||
"webapi"
|
||||
],
|
||||
"categories": [
|
||||
"e154e33f-3cc7-468d-bb66-e0390ddb9ae0"
|
||||
],
|
||||
"brandName": "Mongodb Brand & Name",
|
||||
"sku": "SKU-04",
|
||||
"rating": 4.5,
|
||||
"price": 20,
|
||||
"newPrice": 10,
|
||||
"quantity": 100
|
||||
}
|
||||
]
|
||||
@ -68,7 +68,7 @@
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopCartItems/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60",
|
||||
"raw": "https://localhost:7151/api/ShopCartItems/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60?locale=en-US",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
@ -79,6 +79,12 @@
|
||||
"ShopCartItems",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "locale",
|
||||
"value": "en-US"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -141,7 +147,7 @@
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\r\n \"slug\": \"shop-catalog-item\",\r\n \"image\": {\r\n \"src\": \"https://dummyimage.com/450x300/dee2e6/6c757d.jpg\",\r\n \"alt\": \"...\"\r\n },\r\n \"title\": \"Shop item title\",\r\n \"brandName\": \"Brand & Name\",\r\n \"shortText\": \"Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...\",\r\n \"created\": \"2022-01-01T00:00:00Z\",\r\n \"price\": 20,\r\n \"newPrice\": 10,\r\n \"quantity\": 1\r\n}"
|
||||
"raw": "{\r\n \"quantity\": 1\r\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopCartItem/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60/SKU-04",
|
||||
@ -179,7 +185,7 @@
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\r\n \"slug\": \"shop-catalog-item\",\r\n \"image\": {\r\n \"src\": \"https://dummyimage.com/450x300/dee2e6/6c757d.jpg\",\r\n \"alt\": \"...\"\r\n },\r\n \"title\": \"Shop item title\",\r\n \"brandName\": \"New Brand & Name\",\r\n \"shortText\": \"Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...\",\r\n \"created\": \"2022-01-01T00:00:00Z\",\r\n \"price\": 40,\r\n \"newPrice\": 50,\r\n \"quantity\": 2\r\n}"
|
||||
"raw": "{\r\n \"quantity\": 2\r\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopCartItem/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60/SKU-04",
|
||||
@ -234,6 +240,317 @@
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ShopItems",
|
||||
"item": [
|
||||
{
|
||||
"name": "01-Get",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopCatalog/404c8232-9048-4519-bfba-6e78dc7005ca?currentPage=1&itemsPerPage=4",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopCatalog",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "currentPage",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"key": "itemsPerPage",
|
||||
"value": "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "01-Delete",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopCatalog/404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopCatalog",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ShopItem",
|
||||
"item": [
|
||||
{
|
||||
"name": "01-Get",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopItem/404c8232-9048-4519-bfba-6e78dc7005ca/SKU-01",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopItem",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"SKU-01"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "02-Post",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\r\n \"l10n\":[\r\n {\r\n \"locale\":\"en-US\",\r\n \"slug\":\"shop-catalog-item-05\",\r\n \"description\": \"\",\r\n \"title\":\"Shop item title\",\r\n \"shortText\":\"Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...\",\r\n \"text\":\"\",\r\n \"contentType\": \"HTML\",\r\n \"badges\":[\r\n \"sale\"\r\n ]\r\n }\r\n ],\r\n \r\n \"tags\":[\r\n \"react\",\r\n \"redux\",\r\n \"webapi\"\r\n ],\r\n \"categories\":[\r\n \"e154e33f-3cc7-468d-bb66-e0390ddb9ae0\"\r\n ],\r\n \"brandName\":\"Mongodb Brand & Name\",\r\n \"rating\":4.5,\r\n \"price\":20,\r\n \"newPrice\":10,\r\n \"quantity\":100\r\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopItem/404c8232-9048-4519-bfba-6e78dc7005ca/SKU-05",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopItem",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"SKU-05"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "03-Put",
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\r\n \"slug\":\"shop-catalog-item-05\",\r\n \"l10n\":[\r\n {\r\n \"locale\":\"en-US\",\r\n \"slug\":\"shop-catalog-item-05\",\r\n \"description\": \"\",\r\n \"title\":\"Shop item title\",\r\n \"shortText\":\"Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...\",\r\n \"text\":\"\",\r\n \"contentType\": \"HTML\",\r\n \"badges\":[\r\n \"sale\"\r\n ]\r\n }\r\n ],\r\n \"images\":[\r\n {\r\n \"src\":\"https://dummyimage.com/450x300/dee2e6/6c757d.jpg\",\r\n \"l10n\":[\r\n {\r\n \"locale\":\"en-US\",\r\n \"alt\":\"...\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"author\":\"fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60\",\r\n \"tags\":[\r\n \"react\",\r\n \"redux\",\r\n \"webapi\"\r\n ],\r\n \"categories\":[\r\n \"e154e33f-3cc7-468d-bb66-e0390ddb9ae0\"\r\n ],\r\n \"brandName\":\"Mongodb Brand & Name\",\r\n \"rating\":4.5,\r\n \"price\":20,\r\n \"newPrice\":10,\r\n \"quantity\":200\r\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopItem/404c8232-9048-4519-bfba-6e78dc7005ca/SKU-05",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopItem",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"SKU-05"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "04-Delete",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/ShopItem/404c8232-9048-4519-bfba-6e78dc7005ca/SKU-05",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"ShopItem",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"SKU-05"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "BlogItems",
|
||||
"item": [
|
||||
{
|
||||
"name": "01-Get",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/BlogItems/404c8232-9048-4519-bfba-6e78dc7005ca?currentPage=2&itemsPerPage=2&locale=en-US",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"BlogItems",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "currentPage",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"key": "itemsPerPage",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"key": "locale",
|
||||
"value": "en-US"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "02-Delete",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
},
|
||||
{
|
||||
"key": "Accept",
|
||||
"value": "application/json",
|
||||
"type": "default"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://localhost:7151/api/BlogItems/404c8232-9048-4519-bfba-6e78dc7005ca",
|
||||
"protocol": "https",
|
||||
"host": [
|
||||
"localhost"
|
||||
],
|
||||
"port": "7151",
|
||||
"path": [
|
||||
"api",
|
||||
"BlogItems",
|
||||
"404c8232-9048-4519-bfba-6e78dc7005ca"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "BlogItem",
|
||||
"item": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Core.Abstractions.DomainObjects {
|
||||
public class Category {
|
||||
public Guid Id { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.Abstractions.DomainObjects {
|
||||
public abstract class PageBase<T> : DomainObjectBase<T> {
|
||||
|
||||
public Header Header { get; set; }
|
||||
public TitleSection? TitleSection { get; set; }
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.L10n;
|
||||
using Core.Enumerations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -11,26 +13,19 @@ namespace Core.Abstractions.DomainObjects {
|
||||
|
||||
public Guid SiteId { get; set; }
|
||||
|
||||
public string Slug { get; set; }
|
||||
public List<PostItemL10n> L10n { get; set; }
|
||||
|
||||
public List<Image> Images { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public string ShortText { get; set; }
|
||||
|
||||
public Author Author { get; set; }
|
||||
public Guid Author { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public List<string> Badges { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
public List<Category> Categories { get; set; }
|
||||
public List<Guid> Categories { get; set; }
|
||||
|
||||
|
||||
public bool? FamilyFriendly { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Core.Abstractions.Models {
|
||||
public abstract class PostItemRequestModel<T> : ModelBase {
|
||||
public abstract class RequestModelBase<T> : ModelBase {
|
||||
public abstract T ToDomainObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
|
||||
namespace Core.DomainObjects {
|
||||
public class Category : DomainObjectBase<Category> {
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,23 @@ namespace Core.DomainObjects.Documents {
|
||||
public uint? Likes { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
throw new NotImplementedException();
|
||||
unchecked {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Id.GetHashCode();
|
||||
hash = hash * 23 + SiteId.GetHashCode();
|
||||
hash = hash * 23 + L10n.GetHashCode();
|
||||
if (Images != null)
|
||||
hash = hash * 23 + Images.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Author.GetHashCode();
|
||||
hash = hash * 23 + Created.GetHashCode();
|
||||
hash = hash * 23 + Tags.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Categories.Sum(x => x.GetHashCode());
|
||||
|
||||
hash = hash * 23 + ReadTime.GetHashCode();
|
||||
hash = hash * 23 + Likes.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
webapi/Core/DomainObjects/Documents/Category.cs
Normal file
18
webapi/Core/DomainObjects/Documents/Category.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.DomainObjects.L10n;
|
||||
|
||||
namespace Core.DomainObjects {
|
||||
public class Category : DomainObjectDocumentBase<Category> {
|
||||
public Guid SiteId { get; set; }
|
||||
public List<CategoryL10n> L10n { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
unchecked {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Id.GetHashCode();
|
||||
hash = hash * 23 + L10n.Sum(x => x.GetHashCode());
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,17 +4,10 @@ namespace Core.DomainObjects.Documents {
|
||||
public class ShopCartItem : DomainObjectDocumentBase<ShopCartItem> {
|
||||
public Guid SiteId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Sku { get; set; }
|
||||
public Image Image { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string BrandName { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
// https://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-overriding-gethashcode
|
||||
// Overflow is fine, just wrap
|
||||
@ -22,18 +15,10 @@ namespace Core.DomainObjects.Documents {
|
||||
int hash = 17;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
hash = hash * 23 + Id.GetHashCode();
|
||||
hash = hash * 23 + SiteId.GetHashCode();
|
||||
hash = hash * 23 + UserId.GetHashCode();
|
||||
hash = hash * 23 + Slug.GetHashCode();
|
||||
hash = hash * 23 + Sku.GetHashCode();
|
||||
hash = hash * 23 + Image.GetHashCode();
|
||||
hash = hash * 23 + Title.GetHashCode();
|
||||
hash = hash * 23 + BrandName.GetHashCode();
|
||||
hash = hash * 23 + ShortText.GetHashCode();
|
||||
hash = hash * 23 + Created.GetHashCode();
|
||||
hash = hash * 23 + Price.GetHashCode();
|
||||
hash = hash * 23 + NewPrice.GetHashCode();
|
||||
hash = hash * 23 + Quantity.GetHashCode();
|
||||
hash = hash * 23 + Created.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,24 +5,21 @@ namespace Core.DomainObjects.Documents {
|
||||
public string BrandName { get; set; }
|
||||
public string Sku { get; set; }
|
||||
public decimal? Rating { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double? NewPrice { get; set; }
|
||||
public uint? Quantity { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal? NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
unchecked {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Id.GetHashCode();
|
||||
hash = hash * 23 + SiteId.GetHashCode();
|
||||
hash = hash * 23 + Slug.GetHashCode();
|
||||
hash = hash * 23 + Images.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Title.GetHashCode();
|
||||
hash = hash * 23 + Text.GetHashCode();
|
||||
hash = hash * 23 + ShortText.GetHashCode();
|
||||
hash = hash * 23 + L10n.GetHashCode();
|
||||
if (Images != null)
|
||||
hash = hash * 23 + Images.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Author.GetHashCode();
|
||||
hash = hash * 23 + Created.GetHashCode();
|
||||
hash = hash * 23 + Badges.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Tags.Sum(x => x.GetHashCode());
|
||||
hash = hash * 23 + Tags.GetHashCode();
|
||||
hash = hash * 23 + Categories.Sum(x => x.GetHashCode());
|
||||
|
||||
hash = hash * 23 + BrandName.GetHashCode();
|
||||
|
||||
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Core.DomainObjects {
|
||||
|
||||
|
||||
public class User : DomainObjectDocumentBase<User> {
|
||||
public string NickName { get; set; }
|
||||
|
||||
@ -24,6 +25,8 @@ namespace Core.DomainObjects {
|
||||
public Address BillingAddress { get; set; }
|
||||
public Address ShippingAddress { get; set; }
|
||||
|
||||
// manage whitelisted tokens as salted hash
|
||||
|
||||
public override int GetHashCode() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -1,14 +1,19 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.DomainObjects.L10n;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace Core.DomainObjects {
|
||||
|
||||
|
||||
|
||||
public class Image : DomainObjectBase<Image> {
|
||||
public string Src { get; set; }
|
||||
public string Alt { get; set; }
|
||||
public List<ImageL10n> L10n { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Src.GetHashCode();
|
||||
hash = hash * 23 + Alt.GetHashCode();
|
||||
hash = hash * 23 + L10n.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
24
webapi/Core/DomainObjects/L10n/CategoryL10n.cs
Normal file
24
webapi/Core/DomainObjects/L10n/CategoryL10n.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Core.DomainObjects.L10n {
|
||||
public class CategoryL10n : DomainObjectBase<CategoryL10n> {
|
||||
public Locales Locale { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
unchecked {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Locale.GetHashCode();
|
||||
hash = hash * 23 + Text.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
webapi/Core/DomainObjects/L10n/ImageL10n.cs
Normal file
21
webapi/Core/DomainObjects/L10n/ImageL10n.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Core.DomainObjects.L10n {
|
||||
public class ImageL10n : DomainObjectBase<ImageL10n> {
|
||||
public Locales Locale { get; set; }
|
||||
public string Alt { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Locale.GetHashCode();
|
||||
hash = hash * 23 + Alt.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
webapi/Core/DomainObjects/L10n/PostItemL10n.cs
Normal file
31
webapi/Core/DomainObjects/L10n/PostItemL10n.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace Core.DomainObjects.L10n {
|
||||
public class PostItemL10n : DomainObjectBase<PostItemL10n> {
|
||||
public Locales Locale { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Text { get; set; }
|
||||
public ContentTypes ContentType { get; set; }
|
||||
public string PlainText { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public List<string> Badges { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
unchecked {
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Locale.GetHashCode();
|
||||
hash = hash * 23 + Slug.GetHashCode();
|
||||
hash = hash * 23 + Description.GetHashCode();
|
||||
hash = hash * 23 + Title.GetHashCode();
|
||||
hash = hash * 23 + Text.GetHashCode();
|
||||
hash = hash * 23 + ContentType.GetHashCode();
|
||||
hash = hash * 23 + ShortText.GetHashCode();
|
||||
hash = hash * 23 + Badges.Sum(x => x.GetHashCode());
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.DomainObjects.Pages {
|
||||
public class BlogCatalogPage : PageBase<BlogCatalogPage> {
|
||||
|
||||
public FeaturedBlogSection FeaturedBlogSection { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
@ -3,8 +3,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.DomainObjects.Pages {
|
||||
public class BlogItemPage : PageBase<BlogItemPage> {
|
||||
|
||||
|
||||
public CommentsSection CommentsSection { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
@ -3,8 +3,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.DomainObjects.Pages {
|
||||
public class HomePage : PageBase<HomePage> {
|
||||
|
||||
|
||||
public FeaturesSection FeaturesSection { get; set; }
|
||||
public TestimonialsSection TestimonialsSection { get; set; }
|
||||
public FeaturedBlogsSection FeaturedBlogsSection { get; set; }
|
||||
|
||||
@ -3,8 +3,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.DomainObjects.Pages {
|
||||
public class ShopCartPage : PageBase<ShopCartPage> {
|
||||
|
||||
|
||||
public ProductsSection ProductsSection { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
@ -3,9 +3,6 @@ using Core.DomainObjects.PageSections;
|
||||
|
||||
namespace Core.DomainObjects.Pages {
|
||||
public class ShopCatalogPage : PageBase<ShopCatalogPage> {
|
||||
|
||||
|
||||
|
||||
public ShopItemsSection ShopItemsSection { get; set; }
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
11
webapi/Core/Enumerations/ContentTypes.cs
Normal file
11
webapi/Core/Enumerations/ContentTypes.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Core.Abstractions;
|
||||
|
||||
namespace Core.Enumerations {
|
||||
public class ContentTypes : Enumeration {
|
||||
|
||||
public static ContentTypes Html = new(0, "HTML");
|
||||
public static ContentTypes Md = new(1, "MD");
|
||||
|
||||
private ContentTypes(int id, string displayName) : base(id, displayName) { }
|
||||
}
|
||||
}
|
||||
17
webapi/Core/Enumerations/Locales.cs
Normal file
17
webapi/Core/Enumerations/Locales.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Core.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Core.Enumerations {
|
||||
public class Locales : Enumeration {
|
||||
|
||||
public static Locales Us = new(0, "en-US");
|
||||
public static Locales Ru = new(1, "ru-RU");
|
||||
public static Locales It = new(2, "it-IT");
|
||||
|
||||
private Locales(int id, string displayName) : base (id, displayName) { }
|
||||
}
|
||||
}
|
||||
59
webapi/DataProviders/BlogCatalogDataProvider.cs
Normal file
59
webapi/DataProviders/BlogCatalogDataProvider.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using Core.DomainObjects.Documents;
|
||||
using DataProviders.Abstractions;
|
||||
using DomainResults.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataProviders {
|
||||
|
||||
public interface IBlogCatalogDataProvider {
|
||||
(Guid?, IDomainResult) Insert(BlogItem blogItem);
|
||||
(BlogItem?, IDomainResult) Get(Guid siteId, string slug);
|
||||
(List<BlogItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
||||
(Guid?, IDomainResult) Update(BlogItem blogItem);
|
||||
IDomainResult Delete(Guid id);
|
||||
IDomainResult DeleteAll(Guid siteId);
|
||||
}
|
||||
|
||||
public class BlogCatalogDataProvider : DataProviderBase<BlogItem>, IBlogCatalogDataProvider {
|
||||
|
||||
private const string _collectionName = "blogcatalog";
|
||||
|
||||
public BlogCatalogDataProvider(
|
||||
ILogger<DataProviderBase<BlogItem>> logger,
|
||||
IMongoClient client,
|
||||
IIdGenerator idGenerator,
|
||||
ISessionService sessionService) : base(logger, client, idGenerator, sessionService) {
|
||||
}
|
||||
|
||||
public (Guid?, IDomainResult) Insert(BlogItem blogItem) =>
|
||||
Insert(blogItem, _collectionName);
|
||||
|
||||
public (BlogItem?, IDomainResult) Get(Guid siteId, string slug) {
|
||||
var (list, result) = GetWithPredicate(x => x.SiteId == siteId && x.L10n.Where(y => y.Slug == slug).Count() > 0, _collectionName);
|
||||
|
||||
if (!result.IsSuccess || list == null || list.Count == 0)
|
||||
return (null, result);
|
||||
|
||||
return (list.First(), result);
|
||||
}
|
||||
|
||||
public (List<BlogItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take) =>
|
||||
GetWithPredicate(x => x.SiteId == siteId, 0, 0, _collectionName);
|
||||
|
||||
public (Guid?, IDomainResult) Update(BlogItem blogItem) =>
|
||||
UpdateWithPredicate(blogItem, x => x.Id == blogItem.Id, _collectionName);
|
||||
|
||||
public IDomainResult Delete(Guid id) =>
|
||||
DeleteWithPredicate(x => x.Id == id, _collectionName);
|
||||
|
||||
public IDomainResult DeleteAll(Guid siteId) =>
|
||||
DeleteManyWithPredicate(x => x.SiteId == siteId, _collectionName);
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
namespace DataProviders;
|
||||
|
||||
public interface IBlogDataProvider { }
|
||||
|
||||
public class BlogDataProvider : IBlogDataProvider {
|
||||
|
||||
|
||||
|
||||
public BlogDataProvider() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
40
webapi/DataProviders/CategoryDataProvider.cs
Normal file
40
webapi/DataProviders/CategoryDataProvider.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
using DataProviders.Abstractions;
|
||||
using DomainResults.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataProviders {
|
||||
|
||||
|
||||
public interface ICategoryDataProvider {
|
||||
(Category?, IDomainResult) Get(Guid id, Guid siteId);
|
||||
}
|
||||
|
||||
public class CategoryDataProvider : DataProviderBase<Category>, ICategoryDataProvider {
|
||||
|
||||
private const string _collectionName = "categories";
|
||||
public CategoryDataProvider(
|
||||
ILogger<DataProviderBase<Category>> logger,
|
||||
IMongoClient client,
|
||||
IIdGenerator idGenerator,
|
||||
ISessionService sessionService) : base(logger, client, idGenerator, sessionService) {
|
||||
}
|
||||
|
||||
public (Category?, IDomainResult) Get(Guid id, Guid siteId) {
|
||||
var (list, result) = GetWithPredicate(x => x.Id == id && x.SiteId == siteId, 0, 0, _collectionName);
|
||||
|
||||
if (!result.IsSuccess || list == null || list.Count == 0)
|
||||
return (null, result);
|
||||
|
||||
return (list.First(), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,8 @@ namespace DataProviders.Extensions
|
||||
services.AddSingleton<IContentDataProvider, ContentDataProvider>();
|
||||
services.AddSingleton<IShopCatalogDataProvider, ShopCatalogDataProvider>();
|
||||
services.AddSingleton<IShopCartDataProvider, ShopCartDataProvider>();
|
||||
|
||||
services.AddSingleton<ICategoryDataProvider, CategoryDataProvider>();
|
||||
services.AddSingleton<IBlogCatalogDataProvider, BlogCatalogDataProvider>();
|
||||
Mappings.RegisterClassMap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ using Core.DomainObjects;
|
||||
using Core.DomainObjects.Pages;
|
||||
using Core.DomainObjects.PageSections;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.DomainObjects.L10n;
|
||||
using DataProviders.Converters;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace DataProviders {
|
||||
public class Mappings {
|
||||
@ -20,6 +23,40 @@ namespace DataProviders {
|
||||
|
||||
// https://kevsoft.net/2020/06/25/storing-guids-as-strings-in-mongodb-with-csharp.html
|
||||
BsonSerializer.RegisterSerializer(new GuidSerializer(BsonType.String));
|
||||
// https://kevsoft.net/2020/07/02/how-to-store-decimal-fields-in-mongodb-with-csharp.html
|
||||
BsonSerializer.RegisterSerializer(new DecimalSerializer(BsonType.Decimal128));
|
||||
|
||||
#region L10n
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(PostItemL10n))) {
|
||||
BsonClassMap.RegisterClassMap<PostItemL10n>(cm => {
|
||||
cm.AutoMap();
|
||||
|
||||
cm.GetMemberMap(c => c.Locale)
|
||||
.SetSerializer(new EnumerationSerializer<Locales>());
|
||||
|
||||
cm.GetMemberMap(c => c.ContentType)
|
||||
.SetSerializer(new EnumerationSerializer<ContentTypes>());
|
||||
});
|
||||
}
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ImageL10n))) {
|
||||
BsonClassMap.RegisterClassMap<ImageL10n>(cm => {
|
||||
cm.AutoMap();
|
||||
|
||||
cm.GetMemberMap(c => c.Locale)
|
||||
.SetSerializer(new EnumerationSerializer<Locales>());
|
||||
});
|
||||
}
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(CategoryL10n))) {
|
||||
BsonClassMap.RegisterClassMap<CategoryL10n>(cm => {
|
||||
cm.AutoMap();
|
||||
|
||||
cm.GetMemberMap(c => c.Locale)
|
||||
.SetSerializer(new EnumerationSerializer<Locales>());
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Primitives
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Address))) {
|
||||
@ -116,6 +153,24 @@ namespace DataProviders {
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region BlogItem
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(BlogItem))) {
|
||||
BsonClassMap.RegisterClassMap<BlogItem>(cm => {
|
||||
cm.AutoMap();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ShopItem
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ShopItem))) {
|
||||
BsonClassMap.RegisterClassMap<ShopItem>(cm => {
|
||||
cm.AutoMap();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region PageSections
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(BillingAddressSection))) {
|
||||
BsonClassMap.RegisterClassMap<BillingAddressSection>(cm => {
|
||||
@ -270,13 +325,6 @@ namespace DataProviders {
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BlogItem
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(BlogItem))) {
|
||||
BsonClassMap.RegisterClassMap<BlogItem>(cm => {
|
||||
cm.AutoMap();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Content
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Content))) {
|
||||
@ -289,13 +337,10 @@ namespace DataProviders {
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ShopItem
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ShopItem))) {
|
||||
BsonClassMap.RegisterClassMap<ShopItem>(cm => {
|
||||
cm.AutoMap();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region User
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(User))) {
|
||||
|
||||
@ -15,6 +15,7 @@ namespace DataProviders {
|
||||
(List<ShopItem>?, IDomainResult) GetAll(Guid siteId, int skip, int take);
|
||||
(Guid?, IDomainResult) Update(ShopItem shopCart);
|
||||
IDomainResult Delete(Guid id);
|
||||
IDomainResult DeleteAll(Guid siteId);
|
||||
}
|
||||
|
||||
public class ShopCatalogDataProvider : DataProviderBase<ShopItem>, IShopCatalogDataProvider {
|
||||
@ -48,5 +49,8 @@ namespace DataProviders {
|
||||
|
||||
public IDomainResult Delete(Guid id) =>
|
||||
DeleteWithPredicate(x => x.Id == id, _collectionName);
|
||||
|
||||
public IDomainResult DeleteAll(Guid siteId) =>
|
||||
DeleteManyWithPredicate(x => x.SiteId == siteId, _collectionName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Core.Models;
|
||||
|
||||
using WeatherForecast.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Core.Abstractions.Models;
|
||||
using WeatherForecast.Models.Responses;
|
||||
|
||||
namespace WeatherForecast.Controllers;
|
||||
|
||||
[AllowAnonymous]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class BlogCatalogController : ControllerBase {
|
||||
|
||||
private readonly ILogger<BlogCatalogController> _logger;
|
||||
|
||||
public BlogCatalogController(ILogger<BlogCatalogController> logger) {
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="currentPage"></param>
|
||||
/// <param name="itemsPerPage"></param>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="searchText"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Get([FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int currentPage = 1, [FromQuery] int itemsPerPage = 4) {
|
||||
|
||||
|
||||
//var blogModels = new List<BlogItemModel>();
|
||||
//for (int i = 0; i < 100; i++) {
|
||||
// var blogItemModel = new BlogItemModel {
|
||||
// Id = Guid.NewGuid(),
|
||||
// Slug = "blog-post-title",
|
||||
// Image = new ImageModel { Src = "https://dummyimage.com/850x350/dee2e6/6c757d.jpg", Alt = "..." },
|
||||
// Badge = "news",
|
||||
// Title = $"Blog post title {i}",
|
||||
// ShortText = "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
|
||||
// Text = "",
|
||||
// Author = new AuthorModel {
|
||||
// Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." },
|
||||
// NickName = "Admin"
|
||||
// },
|
||||
// Created = DateTime.UtcNow,
|
||||
// Tags = new List<string> { "react", "redux", "webapi" },
|
||||
|
||||
// ReadTime = 10,
|
||||
// Likes = 200,
|
||||
// };
|
||||
|
||||
// blogModels.Add(blogItemModel);
|
||||
//}
|
||||
|
||||
//var totalPages = blogModels.Count() / itemsPerPage;
|
||||
|
||||
var blogCatalogResponse = new GetBlogCatalogResponseModel {
|
||||
|
||||
/*
|
||||
FeaturedBlog = blogModels[0],
|
||||
BlogItemsPagination = new PaginationModelBase<BlogItemModel> {
|
||||
CurrentPage = currentPage,
|
||||
TotalPages = totalPages,
|
||||
Items = blogModels.Skip((currentPage -1) * itemsPerPage).Take(itemsPerPage).ToList()
|
||||
},
|
||||
Categories = new List<CategoryModel> {
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Web Design"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Html"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Freebies"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Javascript"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "CSS"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Tutorials"
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
return Ok(blogCatalogResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,25 +20,25 @@ namespace WeatherForecast.Controllers {
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Get() {
|
||||
//[HttpGet]
|
||||
//public IActionResult Get() {
|
||||
|
||||
var categories = new List<CategoryModel> {
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Software"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Hardware"
|
||||
},
|
||||
};
|
||||
// var categories = new List<CategoryModel> {
|
||||
// new CategoryModel {
|
||||
// Id = Guid.NewGuid(),
|
||||
// Text = "Software"
|
||||
// },
|
||||
// new CategoryModel {
|
||||
// Id = Guid.NewGuid(),
|
||||
// Text = "Hardware"
|
||||
// },
|
||||
// };
|
||||
|
||||
var response = new GetBlogCategoriesResponseModel {
|
||||
Items = categories
|
||||
};
|
||||
// var response = new GetBlogCategoriesResponseModel {
|
||||
// Items = categories
|
||||
// };
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
// return Ok(response);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
57
webapi/WeatherForecast/Controllers/BlogItemsController.cs
Normal file
57
webapi/WeatherForecast/Controllers/BlogItemsController.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Core.Models;
|
||||
|
||||
using WeatherForecast.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Core.Abstractions.Models;
|
||||
using WeatherForecast.Models.Responses;
|
||||
using DomainResults.Mvc;
|
||||
using WeatherForecast.Services;
|
||||
using Core.Abstractions;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Controllers;
|
||||
|
||||
[AllowAnonymous]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class BlogItemsController : ControllerBase {
|
||||
|
||||
private readonly ILogger<BlogItemsController> _logger;
|
||||
private readonly IBlogItemsService _blogItemsService;
|
||||
|
||||
public BlogItemsController(
|
||||
ILogger<BlogItemsController> logger,
|
||||
IBlogItemsService blogItemsService
|
||||
) {
|
||||
_logger = logger;
|
||||
_blogItemsService = blogItemsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="currentPage"></param>
|
||||
/// <param name="itemsPerPage"></param>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="searchText"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{siteId}")]
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] string? searchText, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? locale) {
|
||||
var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us, searchText);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{siteId}")]
|
||||
public IActionResult Delete([FromRoute] Guid siteId) {
|
||||
var result = _blogItemsService.Delete(siteId);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using DomainResults.Mvc;
|
||||
using Core.Abstractions;
|
||||
using Core.Enumerations;
|
||||
using DomainResults.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WeatherForecast.Models.Requests;
|
||||
@ -49,8 +51,8 @@ namespace WeatherForecast.Controllers {
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{siteId}/{userId}/{sku}")]
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku) {
|
||||
var result = _shopCartItemService.Get(siteId, userId, sku);
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromQuery] string locale) {
|
||||
var result = _shopCartItemService.Get(siteId, userId, sku, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using DomainResults.Mvc;
|
||||
using Core.Abstractions;
|
||||
using Core.Enumerations;
|
||||
using DomainResults.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WeatherForecast.Models.Requests;
|
||||
@ -35,8 +37,8 @@ namespace WeatherForecast.Controllers {
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{siteId}/{userId}")]
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId) {
|
||||
var result = _shopCartItemsService.Get(siteId, userId);
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string locale) {
|
||||
var result = _shopCartItemsService.Get(siteId, userId, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
|
||||
@ -15,25 +15,25 @@ namespace WeatherForecast.Controllers {
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Get() {
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//public IActionResult Get() {
|
||||
|
||||
var categories = new List<CategoryModel> {
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Software"
|
||||
},
|
||||
new CategoryModel {
|
||||
Id = Guid.NewGuid(),
|
||||
Text = "Hardware"
|
||||
},
|
||||
};
|
||||
// var categories = new List<CategoryModel> {
|
||||
// new CategoryModel {
|
||||
// Id = Guid.NewGuid(),
|
||||
// Text = "Software"
|
||||
// },
|
||||
// new CategoryModel {
|
||||
// Id = Guid.NewGuid(),
|
||||
// Text = "Hardware"
|
||||
// },
|
||||
// };
|
||||
|
||||
return Ok(categories);
|
||||
}
|
||||
// return Ok(categories);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using WeatherForecast.Services;
|
||||
using DomainResults.Mvc;
|
||||
using Core.Abstractions;
|
||||
using Core.Enumerations;
|
||||
using WeatherForecast.Models.Requests;
|
||||
|
||||
namespace WeatherForecast.Controllers {
|
||||
|
||||
@ -21,6 +24,19 @@ namespace WeatherForecast.Controllers {
|
||||
_shopItemService = shopItemService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <param name="sku"></param>
|
||||
/// <param name="requestData"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{siteId}/{sku}")]
|
||||
public IActionResult Post([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] PostShopItemRequestModel requestData) {
|
||||
var result = _shopItemService.Post(siteId, sku, requestData);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -28,8 +44,33 @@ namespace WeatherForecast.Controllers {
|
||||
/// <param name="sku"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{siteId}/{sku}")]
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku) {
|
||||
var result = _shopItemService.Get(siteId, sku);
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromRoute] string sku, [FromQuery] string locale) {
|
||||
var result = _shopItemService.Get(siteId, sku, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <param name="sku"></param>
|
||||
/// <param name="requestData"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{siteId}/{sku}")]
|
||||
public IActionResult Update([FromRoute] Guid siteId, [FromRoute] string sku, [FromBody] PutShopItemRequestModel requestData) {
|
||||
var result = _shopItemService.Update(siteId, sku, requestData);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <param name="sku"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{siteId}/{sku}")]
|
||||
public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] string sku) {
|
||||
var result = _shopItemService.Delete(siteId, sku);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.Abstractions;
|
||||
using Core.Abstractions.Models;
|
||||
using Core.Enumerations;
|
||||
using Core.Models;
|
||||
using DomainResults.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -35,8 +37,19 @@ public class ShopItemsController : ControllerBase {
|
||||
/// <param name="itemsPerPage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{siteId}")]
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string? searchText) {
|
||||
var result = _shopItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, searchText);
|
||||
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] Guid? category, [FromQuery] int? currentPage, [FromQuery] int? itemsPerPage, [FromQuery] string locale, [FromQuery] string? searchText) {
|
||||
var result = _shopItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, Enumeration.FromDisplayName<Locales>(locale) ?? Locales.Us, searchText);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="siteId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{siteId}")]
|
||||
public IActionResult Delete([FromRoute] Guid siteId) {
|
||||
var result = _shopItemsService.Delete(siteId);
|
||||
return result.ToActionResult();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,13 +4,15 @@ using Core.DomainObjects;
|
||||
|
||||
namespace WeatherForecast.Models.Abstractions {
|
||||
public abstract class PersonModelBase<T> : ModelBase {
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public ImageModel? Image { get; set; }
|
||||
|
||||
public PersonModelBase() { }
|
||||
|
||||
public PersonModelBase(PersonBase<T> person) {
|
||||
if(person.Image != null)
|
||||
Image = new ImageModel(person.Image);
|
||||
//if(person.Image != null)
|
||||
// Image = new ImageModel(person.Image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,17 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.Abstractions.Models;
|
||||
using WeatherForecast.Models.L10n;
|
||||
|
||||
namespace WeatherForecast.Models.Abstractions {
|
||||
public abstract class PostItemRequestModelBase<T> : PostItemRequestModel<T> {
|
||||
|
||||
public string Slug { get; set; }
|
||||
public abstract class PostItemRequestModelBase<T> : RequestModelBase<T> {
|
||||
|
||||
public List<ImageModel> Images { get; set; }
|
||||
public List<PostItemL10nModel> L10n { get; set; }
|
||||
|
||||
public List<string> Badges { get; set; }
|
||||
public List<Guid>? Categories { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
public List<string>? Tags { get; set; }
|
||||
|
||||
public string? ShortText { get; set; }
|
||||
|
||||
public string? Text { get; set; }
|
||||
|
||||
public AuthorModel Author { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
public bool? FamilyFriendly { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,26 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.Abstractions.Models;
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Models.Abstractions {
|
||||
public abstract class PostItemResponseModelBase<T> : ResponseModelBase {
|
||||
|
||||
public string Slug { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<ImageModel> Images { get; set; }
|
||||
|
||||
public List<string> Badges { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string? ShortText { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
|
||||
public string? Text { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public string PlainText { get; set; }
|
||||
|
||||
public AuthorModel Author { get; set; }
|
||||
|
||||
@ -22,16 +28,35 @@ namespace WeatherForecast.Models.Abstractions {
|
||||
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
public PostItemResponseModelBase(PostItemBase<T> postItem) {
|
||||
Slug = postItem.Slug;
|
||||
Images = postItem.Images.Select(x => new ImageModel(x)).ToList();
|
||||
Badges = postItem.Badges;
|
||||
Title = postItem.Title;
|
||||
Text = postItem.Text;
|
||||
ShortText = postItem.ShortText;
|
||||
Author = new AuthorModel(postItem.Author);
|
||||
public List<CategoryModel> Categories { get; set; }
|
||||
|
||||
public bool? FamilyFriendly { get; set; }
|
||||
|
||||
public PostItemResponseModelBase(PostItemBase<T> postItem, List<Category> categories, Locales locale) {
|
||||
|
||||
var postItemL10n = postItem.L10n.SingleOrDefault(x => x.Locale == locale);
|
||||
if (postItemL10n != null) {
|
||||
Slug = postItemL10n.Slug;
|
||||
Badges = postItemL10n.Badges;
|
||||
Title = postItemL10n.Title;
|
||||
ShortText = postItemL10n.ShortText;
|
||||
Text = postItemL10n.Text;
|
||||
PlainText = postItemL10n.PlainText;
|
||||
Badges = postItemL10n.Badges;
|
||||
}
|
||||
|
||||
|
||||
Categories = categories.Select(x => new CategoryModel(x, locale)).ToList();
|
||||
|
||||
// Author = new AuthorModel(postItem.Author);
|
||||
|
||||
Created = postItem.Created;
|
||||
Tags = postItem.Tags;
|
||||
|
||||
|
||||
Images = postItem.Images.Select(x => new ImageModel(x, locale)).ToList();
|
||||
|
||||
FamilyFriendly = postItem.FamilyFriendly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using Core.Abstractions.DomainObjects;
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.Enumerations;
|
||||
using WeatherForecast.Models.Abstractions;
|
||||
|
||||
namespace WeatherForecast.Models {
|
||||
@ -9,9 +11,10 @@ namespace WeatherForecast.Models {
|
||||
|
||||
public uint? Likes { get; set; }
|
||||
|
||||
public BlogItemModel(BlogItem postItem) : base(postItem) {
|
||||
ReadTime = postItem.ReadTime;
|
||||
Likes = postItem.Likes;
|
||||
public BlogItemModel(BlogItem blogItem, List<Category> categories, Locales locale) : base(blogItem, categories, locale) {
|
||||
|
||||
ReadTime = blogItem.ReadTime;
|
||||
Likes = blogItem.Likes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
namespace WeatherForecast.Models {
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Models {
|
||||
public class CategoryModel {
|
||||
public Guid Id { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public CategoryModel(Category category, Locales locale) {
|
||||
|
||||
var categoryL10n = category.L10n.SingleOrDefault(x => x.Locale == locale);
|
||||
if (categoryL10n != null) {
|
||||
Slug = categoryL10n.Slug;
|
||||
Text = categoryL10n.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Models {
|
||||
public class ImageModel {
|
||||
@ -7,9 +8,13 @@ namespace WeatherForecast.Models {
|
||||
|
||||
public ImageModel() { }
|
||||
|
||||
public ImageModel(Image image) {
|
||||
public ImageModel(Image image, Locales locale) {
|
||||
Src = image.Src;
|
||||
Alt = image.Alt;
|
||||
|
||||
var l10n = image.L10n.SingleOrDefault(x => x.Locale == locale);
|
||||
if (l10n != null) {
|
||||
Alt = l10n.Alt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
37
webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs
Normal file
37
webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Core.Abstractions;
|
||||
using Core.Abstractions.Models;
|
||||
using Core.DomainObjects.L10n;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Models.L10n {
|
||||
public class PostItemL10nModel : RequestModelBase<PostItemL10n> {
|
||||
public string Locale { get; set; }
|
||||
public string Slug { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
public string ShortText { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public string ContentType { get; set; }
|
||||
public List<string> Badges { get; set; }
|
||||
|
||||
public override PostItemL10n ToDomainObject() => new PostItemL10n {
|
||||
Locale = Enumeration.FromDisplayName<Locales>(Locale),
|
||||
Slug = Slug,
|
||||
Description = Description,
|
||||
Title = Title,
|
||||
Text = Text,
|
||||
ShortText = ShortText,
|
||||
|
||||
// TODO: create plain text creation logic
|
||||
PlainText = "TODO",
|
||||
|
||||
ContentType = Enumeration.FromDisplayName<ContentTypes>(ContentType),
|
||||
Badges = Badges
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -14,8 +14,8 @@ namespace WeatherForecast.Models.PageSections {
|
||||
|
||||
public TitleSectionModel(TitleSection titleSection) : base(titleSection) {
|
||||
|
||||
if(titleSection.Image != null)
|
||||
Image = new ImageModel(titleSection.Image);
|
||||
//if(titleSection.Image != null)
|
||||
// Image = new ImageModel(titleSection.Image);
|
||||
|
||||
if (titleSection.PrimaryLink != null)
|
||||
PrimaryLink = new LinkModel(titleSection.PrimaryLink);
|
||||
|
||||
@ -3,31 +3,12 @@ using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
|
||||
namespace WeatherForecast.Models.Requests {
|
||||
public class PostShopCartItemRequestModel : PostItemRequestModel<ShopCartItem> {
|
||||
|
||||
public string Slug { get; set; }
|
||||
public ImageModel Image { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string BrandName { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double NewPrice { get; set; }
|
||||
public class PostShopCartItemRequestModel : RequestModelBase<ShopCartItem> {
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
public override ShopCartItem ToDomainObject() => new ShopCartItem {
|
||||
Slug = Slug,
|
||||
Image = new Image {
|
||||
Src = Image.Src,
|
||||
Alt = Image.Alt
|
||||
},
|
||||
Title = Title,
|
||||
BrandName = BrandName,
|
||||
ShortText = ShortText,
|
||||
Created = Created,
|
||||
Price = Price,
|
||||
NewPrice = NewPrice,
|
||||
Quantity = Quantity
|
||||
Quantity = Quantity,
|
||||
Created = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.DomainObjects.L10n;
|
||||
using ExtensionMethods;
|
||||
using WeatherForecast.Models.Abstractions;
|
||||
|
||||
namespace WeatherForecast.Models.Requests {
|
||||
public class PostShopItemRequestModel : PostItemRequestModel<ShopItem> {
|
||||
public string Slug { get; set; }
|
||||
public List<ImageModel> Images { get; set; }
|
||||
public string Title { get; set; }
|
||||
public class PostShopItemRequestModel : PostItemRequestModelBase<ShopItem> {
|
||||
public string BrandName { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double NewPrice { get; set; }
|
||||
public decimal? Rating { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal? NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
public override ShopItem ToDomainObject() => new ShopItem {
|
||||
Slug = Slug,
|
||||
Images = Images.Select(x => new Image {
|
||||
Src = x.Src,
|
||||
Alt = x.Alt
|
||||
}).ToList(),
|
||||
Title = Title,
|
||||
L10n = L10n.Select(x => x.ToDomainObject()).ToList(),
|
||||
// Images
|
||||
// Author
|
||||
Created = DateTime.UtcNow,
|
||||
Tags = Tags,
|
||||
Categories = Categories,
|
||||
FamilyFriendly = FamilyFriendly,
|
||||
|
||||
BrandName = BrandName,
|
||||
ShortText = ShortText,
|
||||
Created = Created,
|
||||
Rating = Rating,
|
||||
Price = Price,
|
||||
NewPrice = NewPrice,
|
||||
Quantity = Quantity
|
||||
|
||||
@ -3,31 +3,12 @@ using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
|
||||
namespace WeatherForecast.Models.Requests {
|
||||
public class PutShopCartItemRequestModel : PostItemRequestModel<ShopCartItem> {
|
||||
public class PutShopCartItemRequestModel : RequestModelBase<ShopCartItem> {
|
||||
|
||||
public string Slug { get; set; }
|
||||
public ImageModel Image { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string BrandName { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
|
||||
public override ShopCartItem ToDomainObject() => new ShopCartItem {
|
||||
Slug = Slug,
|
||||
Image = new Image {
|
||||
Src = Image.Src,
|
||||
Alt = Image.Alt
|
||||
},
|
||||
Title = Title,
|
||||
BrandName = BrandName,
|
||||
ShortText = ShortText,
|
||||
Created = Created,
|
||||
Price = Price,
|
||||
NewPrice = NewPrice,
|
||||
Quantity = Quantity
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,10 +1,31 @@
|
||||
using Core.Abstractions.Models;
|
||||
using WeatherForecast.Models.Abstractions;
|
||||
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
|
||||
namespace WeatherForecast.Models.Requests {
|
||||
public class PutShopItemRequestModel : PostItemRequestModel<ShopItem> {
|
||||
public override ShopItem ToDomainObject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public class PutShopItemRequestModel : PostItemRequestModelBase<ShopItem> {
|
||||
|
||||
public string BrandName { get; set; }
|
||||
public decimal? Rating { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal? NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
|
||||
public override ShopItem ToDomainObject() => new ShopItem {
|
||||
L10n = L10n.Select(x => x.ToDomainObject()).ToList(),
|
||||
// Images
|
||||
// Author
|
||||
Created = DateTime.UtcNow,
|
||||
Tags = Tags,
|
||||
Categories = Categories,
|
||||
FamilyFriendly = FamilyFriendly,
|
||||
|
||||
BrandName = BrandName,
|
||||
Rating = Rating,
|
||||
Price = Price,
|
||||
NewPrice = NewPrice,
|
||||
Quantity = Quantity
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.Models;
|
||||
|
||||
namespace WeatherForecast.Models.Responses {
|
||||
public class GetBlogCatalogResponseModel : ResponseModelBase {
|
||||
|
||||
public BlogItemModel FeaturedBlog { get; set; }
|
||||
|
||||
public List<CategoryModel> Categories { get; set; }
|
||||
|
||||
public PaginationModelBase<BlogItemModel> BlogItemsPagination { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.Enumerations;
|
||||
using Core.Models;
|
||||
using WeatherForecast.Models.Abstractions;
|
||||
|
||||
namespace WeatherForecast.Models.Responses {
|
||||
public class GetBlogItemResponseModel : PostItemResponseModelBase<BlogItem> {
|
||||
|
||||
public uint? ReadTime { get; set; }
|
||||
|
||||
public uint? Likes { get; set; }
|
||||
|
||||
public GetBlogItemResponseModel(BlogItem blogItem, List<Category> categories, Locales locale) : base(blogItem, categories, locale) {
|
||||
ReadTime = blogItem.ReadTime;
|
||||
Likes = blogItem.Likes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.Models;
|
||||
|
||||
namespace WeatherForecast.Models.Responses {
|
||||
public class GetBlogItemsResponseModel : PaginationModelBase<GetBlogItemResponseModel> {
|
||||
|
||||
|
||||
//public BlogItemModel FeaturedBlog { get; set; }
|
||||
|
||||
//public List<CategoryModel> Categories { get; set; }
|
||||
|
||||
|
||||
|
||||
public GetBlogItemsResponseModel(int currentPage, int totalPages, List<GetBlogItemResponseModel> items)
|
||||
: base(currentPage, totalPages, items) { }
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using Core.Abstractions.Models;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Models.Responses {
|
||||
public class GetShopCartItemResponseModel : ResponseModelBase {
|
||||
@ -10,24 +11,29 @@ namespace WeatherForecast.Models.Responses {
|
||||
public string BrandName { get; set; }
|
||||
public string ShortText { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double NewPrice { get; set; }
|
||||
public uint Quantity { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal? NewPrice { get; set; }
|
||||
public uint? Quantity { get; set; }
|
||||
|
||||
public GetShopCartItemResponseModel() { }
|
||||
|
||||
public GetShopCartItemResponseModel(ShopCartItem shopCartItem) {
|
||||
Slug = shopCartItem.Slug;
|
||||
Sku = shopCartItem.Sku;
|
||||
Image = new ImageModel(shopCartItem.Image);
|
||||
Title = shopCartItem.Title;
|
||||
BrandName = shopCartItem.BrandName;
|
||||
ShortText = shopCartItem.ShortText;
|
||||
Created = shopCartItem.Created;
|
||||
Price = shopCartItem.Price;
|
||||
NewPrice = shopCartItem.NewPrice;
|
||||
public GetShopCartItemResponseModel(ShopItem shopItem, ShopCartItem shopCartItem, Locales locale) {
|
||||
|
||||
Sku = shopItem.Sku;
|
||||
BrandName = shopItem.BrandName;
|
||||
Created = shopItem.Created;
|
||||
Price = shopItem.Price;
|
||||
NewPrice = shopItem.NewPrice;
|
||||
Quantity = shopCartItem.Quantity;
|
||||
|
||||
|
||||
var shopItemL10n = shopItem.L10n.Single(x => x.Locale == locale);
|
||||
Slug = shopItemL10n.Slug;
|
||||
Title = shopItemL10n.Title;
|
||||
ShortText = shopItemL10n.ShortText;
|
||||
|
||||
Image = new ImageModel(shopItem.Images.First(), locale);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.DomainObjects.Pages;
|
||||
using Core.Enumerations;
|
||||
using WeatherForecast.Models.Abstractions;
|
||||
|
||||
namespace WeatherForecast.Models {
|
||||
public class GetShopItemResponseModel : PostItemResponseModelBase<ShopItem> {
|
||||
public List<ImageModel>? Images { get; set; }
|
||||
|
||||
public string Sku { get; set; }
|
||||
public decimal? Rating { get; set; }
|
||||
public double Price { get; set; }
|
||||
public double? NewPrice { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal? NewPrice { get; set; }
|
||||
public uint? Quantity { get; set; }
|
||||
|
||||
public GetShopItemResponseModel(ShopItem shopCatalogItem) : base(shopCatalogItem) {
|
||||
Images = shopCatalogItem.Images.Select(x => new ImageModel(x)).ToList();
|
||||
public GetShopItemResponseModel(ShopItem shopCatalogItem, List<Category> categories, Locales locale) : base(shopCatalogItem, categories, locale) {
|
||||
Sku = shopCatalogItem.Sku;
|
||||
Rating = shopCatalogItem.Rating;
|
||||
Price = shopCatalogItem.Price;
|
||||
|
||||
56
webapi/WeatherForecast/Services/BlogItemsService.cs
Normal file
56
webapi/WeatherForecast/Services/BlogItemsService.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
using DataProviders;
|
||||
using DomainResults.Common;
|
||||
using WeatherForecast.Models.Responses;
|
||||
|
||||
namespace WeatherForecast.Services {
|
||||
|
||||
public interface IBlogItemsService {
|
||||
(GetBlogItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText);
|
||||
IDomainResult Delete(Guid siteId);
|
||||
}
|
||||
|
||||
public class BlogItemsService : IBlogItemsService {
|
||||
|
||||
private readonly ILogger<BlogItemsService> _logger;
|
||||
private readonly IBlogCatalogDataProvider _blogCatalogDataProvider;
|
||||
private readonly ICategoryDataProvider _categoryDataProvider;
|
||||
|
||||
public BlogItemsService(
|
||||
ILogger<BlogItemsService> logger,
|
||||
IBlogCatalogDataProvider blogCatalogDataProvider,
|
||||
ICategoryDataProvider categoryDataProvider
|
||||
) {
|
||||
_logger = logger;
|
||||
_blogCatalogDataProvider = blogCatalogDataProvider;
|
||||
_categoryDataProvider = categoryDataProvider;
|
||||
}
|
||||
|
||||
public (GetBlogItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText) {
|
||||
var (items, result) = _blogCatalogDataProvider.GetAll(siteId, currentPage > 0 ? ((currentPage - 1) * itemsPerPage) : 0, itemsPerPage);
|
||||
if (!result.IsSuccess || items == null)
|
||||
return (null, result);
|
||||
|
||||
var blogItems = new List<GetBlogItemResponseModel>();
|
||||
foreach (var item in items) {
|
||||
var categories = new List<Category>();
|
||||
foreach (var catId in item.Categories) {
|
||||
var (cat, getCategoryResult) = _categoryDataProvider.Get(catId, siteId);
|
||||
if (!getCategoryResult.IsSuccess || cat == null)
|
||||
return (null, getCategoryResult);
|
||||
|
||||
categories.Add(cat);
|
||||
}
|
||||
blogItems.Add(new GetBlogItemResponseModel(item, categories, locale));
|
||||
}
|
||||
|
||||
return blogItems.Count > 0
|
||||
? IDomainResult.Success(new GetBlogItemsResponseModel(currentPage, 0, blogItems))
|
||||
: IDomainResult.NotFound<GetBlogItemsResponseModel?>();
|
||||
}
|
||||
|
||||
public IDomainResult Delete(Guid siteId) =>
|
||||
_blogCatalogDataProvider.DeleteAll(siteId);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
using DataProviders;
|
||||
using Core.Abstractions;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.Enumerations;
|
||||
using DataProviders;
|
||||
using DomainResults.Common;
|
||||
|
||||
using WeatherForecast.Models.Requests;
|
||||
@ -8,7 +11,7 @@ namespace WeatherForecast.Services {
|
||||
|
||||
public interface IShopCartItemService {
|
||||
(Guid?, IDomainResult) Post(Guid siteId, Guid userId, string sku, PostShopCartItemRequestModel requestModel);
|
||||
(GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku);
|
||||
(GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku, Locales locale);
|
||||
(Guid?, IDomainResult) Update(Guid siteId, Guid userId, string sku, PutShopCartItemRequestModel requestData);
|
||||
IDomainResult Delete(Guid siteId, Guid userId, string sku);
|
||||
}
|
||||
@ -16,13 +19,16 @@ namespace WeatherForecast.Services {
|
||||
public class ShopCartItemService : IShopCartItemService {
|
||||
|
||||
ILogger<ShopCartItemService> _logger;
|
||||
IShopCatalogDataProvider _shopCatalogDataProvider;
|
||||
IShopCartDataProvider _shopCartDataProvider;
|
||||
|
||||
public ShopCartItemService(
|
||||
ILogger<ShopCartItemService> logger,
|
||||
IShopCatalogDataProvider shopCatalogDataProvider,
|
||||
IShopCartDataProvider shopCartDataprovider
|
||||
) {
|
||||
_logger = logger;
|
||||
_shopCatalogDataProvider = shopCatalogDataProvider;
|
||||
_shopCartDataProvider = shopCartDataprovider;
|
||||
}
|
||||
|
||||
@ -45,13 +51,17 @@ namespace WeatherForecast.Services {
|
||||
return IDomainResult.Success(id);
|
||||
}
|
||||
|
||||
public (GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku) {
|
||||
var (item, result) = _shopCartDataProvider.Get(siteId, userId, sku);
|
||||
public (GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku, Locales locale) {
|
||||
|
||||
var (cartItem, getCartItemResult) = _shopCartDataProvider.Get(siteId, userId, sku);
|
||||
if (!getCartItemResult.IsSuccess || cartItem == null)
|
||||
return (null, getCartItemResult);
|
||||
|
||||
var (item, result) = _shopCatalogDataProvider.Get(siteId, cartItem.Sku);
|
||||
if (!result.IsSuccess || item == null)
|
||||
return (null, result);
|
||||
|
||||
return IDomainResult.Success(new GetShopCartItemResponseModel(item));
|
||||
return IDomainResult.Success(new GetShopCartItemResponseModel(item, cartItem, locale));
|
||||
}
|
||||
|
||||
public (Guid?, IDomainResult) Update(Guid siteId, Guid userId, string sku, PutShopCartItemRequestModel requestData) {
|
||||
@ -65,6 +75,7 @@ namespace WeatherForecast.Services {
|
||||
newItem.SiteId = siteId;
|
||||
newItem.UserId = userId;
|
||||
newItem.Sku = sku;
|
||||
newItem.Created = item.Created;
|
||||
|
||||
if (!item.Equals(newItem)) {
|
||||
var (id, updateResult) = _shopCartDataProvider.Update(newItem);
|
||||
|
||||
@ -1,35 +1,53 @@
|
||||
using DataProviders;
|
||||
using DomainResults.Common;
|
||||
using DomainResults.Common;
|
||||
|
||||
using WeatherForecast.Models.Responses;
|
||||
|
||||
using DataProviders;
|
||||
|
||||
using Core.Abstractions;
|
||||
using Core.DomainObjects.Documents;
|
||||
using Core.Enumerations;
|
||||
|
||||
namespace WeatherForecast.Services {
|
||||
|
||||
public interface IShopCartItemsService {
|
||||
(List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId);
|
||||
(List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale);
|
||||
}
|
||||
|
||||
public class ShopCartItemsService : IShopCartItemsService {
|
||||
|
||||
ILogger<ShopCartItemsService> _logger;
|
||||
IShopCatalogDataProvider _shopCatalogDataProvider;
|
||||
IShopCartDataProvider _shopCartDataProvider;
|
||||
|
||||
public ShopCartItemsService(
|
||||
ILogger<ShopCartItemsService> logger,
|
||||
IShopCatalogDataProvider shopCatalogDataProvider,
|
||||
IShopCartDataProvider shopCartDataprovider
|
||||
) {
|
||||
_logger = logger;
|
||||
_shopCatalogDataProvider = shopCatalogDataProvider;
|
||||
_shopCartDataProvider = shopCartDataprovider;
|
||||
}
|
||||
|
||||
public (List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId) {
|
||||
public (List<GetShopCartItemResponseModel>?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale) {
|
||||
|
||||
var (items, result) = _shopCartDataProvider.GetAll(siteId, userId);
|
||||
var (cartItems, getCartItemsResult) = _shopCartDataProvider.GetAll(siteId, userId);
|
||||
if (!getCartItemsResult.IsSuccess || cartItems == null)
|
||||
return (null, getCartItemsResult);
|
||||
|
||||
if (!result.IsSuccess || items == null)
|
||||
return (null, result);
|
||||
var items = new List<GetShopCartItemResponseModel>();
|
||||
foreach (var cartItem in cartItems) {
|
||||
var (item, result) = _shopCatalogDataProvider.Get(siteId, cartItem.Sku);
|
||||
if (!result.IsSuccess || item == null)
|
||||
return (null, result);
|
||||
|
||||
return IDomainResult.Success(items.Select(x => new GetShopCartItemResponseModel(x)).ToList());
|
||||
items.Add(new GetShopCartItemResponseModel(item, cartItem, locale));
|
||||
}
|
||||
|
||||
return items.Count > 0
|
||||
? IDomainResult.Success(items)
|
||||
: IDomainResult.NotFound<List<GetShopCartItemResponseModel>?>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,35 @@
|
||||
using DataProviders;
|
||||
using Core.DomainObjects;
|
||||
using Core.DomainObjects.L10n;
|
||||
using Core.Enumerations;
|
||||
using DataProviders;
|
||||
using DomainResults.Common;
|
||||
using ExtensionMethods;
|
||||
using WeatherForecast.Models;
|
||||
using WeatherForecast.Models.Requests;
|
||||
|
||||
namespace WeatherForecast.Services {
|
||||
|
||||
public interface IShopItemService {
|
||||
(GetShopItemResponseModel, IDomainResult) Get(Guid siteId, string sku);
|
||||
(Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel);
|
||||
(GetShopItemResponseModel, IDomainResult) Get(Guid siteId, string sku, Locales locale);
|
||||
(Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData);
|
||||
IDomainResult Delete(Guid siteId, string sku);
|
||||
}
|
||||
|
||||
public class ShopItemService : IShopItemService {
|
||||
|
||||
private readonly ILogger<ShopItemService> _logger;
|
||||
private readonly IShopCatalogDataProvider _shopCatalogDataProvider;
|
||||
private readonly ICategoryDataProvider _categoryDataProvider;
|
||||
|
||||
public ShopItemService(
|
||||
ILogger<ShopItemService> logger,
|
||||
IShopCatalogDataProvider shopCatalogDataProvider
|
||||
IShopCatalogDataProvider shopCatalogDataProvider,
|
||||
ICategoryDataProvider categoryDataProvider
|
||||
) {
|
||||
_logger = logger;
|
||||
_shopCatalogDataProvider = shopCatalogDataProvider;
|
||||
_categoryDataProvider = categoryDataProvider;
|
||||
}
|
||||
|
||||
public (Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel) {
|
||||
@ -32,6 +42,25 @@ namespace WeatherForecast.Services {
|
||||
item.SiteId = siteId;
|
||||
item.Sku = sku;
|
||||
|
||||
// TODO: should be recovered from users by jwt
|
||||
item.Author = "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60".ToGuid();
|
||||
|
||||
// TODO: should be placed to object storage
|
||||
item.Images = new List<Image>() {
|
||||
new Image {
|
||||
Src = "https://dummyimage.com/450x300/dee2e6/6c757d.jpg",
|
||||
L10n = new List<ImageL10n> {
|
||||
new ImageL10n {
|
||||
Locale = Locales.Us,
|
||||
Alt = "..."
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: default value shoud not be hardcoded by database id
|
||||
item.Categories ??= new List<Guid> { "e154e33f-3cc7-468d-bb66-e0390ddb9ae0".ToGuid() };
|
||||
|
||||
var (id, insertResult) = _shopCatalogDataProvider.Insert(item);
|
||||
|
||||
if (!insertResult.IsSuccess)
|
||||
@ -40,13 +69,22 @@ namespace WeatherForecast.Services {
|
||||
return IDomainResult.Success(id);
|
||||
}
|
||||
|
||||
public (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku) {
|
||||
public (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku, Locales locale) {
|
||||
var (item, result) = _shopCatalogDataProvider.Get(siteId, sku);
|
||||
|
||||
if (!result.IsSuccess || item == null)
|
||||
return (null, result);
|
||||
|
||||
return IDomainResult.Success(new GetShopItemResponseModel(item));
|
||||
var categories = new List<Category>();
|
||||
foreach (var catId in item.Categories) {
|
||||
var (category, getCategoryResult) = _categoryDataProvider.Get(catId, siteId);
|
||||
if (!getCategoryResult.IsSuccess || category == null)
|
||||
return (null, getCategoryResult);
|
||||
|
||||
categories.Add(category);
|
||||
}
|
||||
|
||||
return IDomainResult.Success(new GetShopItemResponseModel(item, categories, locale));
|
||||
}
|
||||
|
||||
public (Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData) {
|
||||
@ -59,6 +97,8 @@ namespace WeatherForecast.Services {
|
||||
newItem.Id = item.Id;
|
||||
newItem.SiteId = siteId;
|
||||
newItem.Sku = sku;
|
||||
newItem.Created = item.Created;
|
||||
newItem.Author = item.Author;
|
||||
|
||||
if (!item.Equals(newItem)) {
|
||||
var (id, updateResult) = _shopCatalogDataProvider.Update(newItem);
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using DataProviders;
|
||||
using Core.DomainObjects;
|
||||
using Core.Enumerations;
|
||||
using DataProviders;
|
||||
using DomainResults.Common;
|
||||
using WeatherForecast.Models;
|
||||
using WeatherForecast.Models.Responses;
|
||||
@ -6,28 +8,52 @@ using WeatherForecast.Models.Responses;
|
||||
namespace WeatherForecast.Services {
|
||||
|
||||
public interface IShopItemsService {
|
||||
(GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? searchText);
|
||||
(GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText);
|
||||
IDomainResult Delete(Guid siteId);
|
||||
}
|
||||
|
||||
public class ShopItemsService : IShopItemsService {
|
||||
ILogger<ShopItemsService> _logger;
|
||||
IShopCatalogDataProvider _shopCatalogDataProvider;
|
||||
private readonly ILogger<ShopItemsService> _logger;
|
||||
private readonly IShopCatalogDataProvider _shopCatalogDataProvider;
|
||||
private readonly ICategoryDataProvider _categoryDataProvider;
|
||||
|
||||
public ShopItemsService(
|
||||
ILogger<ShopItemsService> logger,
|
||||
IShopCatalogDataProvider shopCatalogDataprovider
|
||||
IShopCatalogDataProvider shopCatalogDataprovider,
|
||||
ICategoryDataProvider categoryDataProvider
|
||||
) {
|
||||
_logger = logger;
|
||||
_shopCatalogDataProvider = shopCatalogDataprovider;
|
||||
_categoryDataProvider = categoryDataProvider;
|
||||
}
|
||||
|
||||
public (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? searchText) {
|
||||
public (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText) {
|
||||
var (items, result) = _shopCatalogDataProvider.GetAll(siteId, currentPage > 0 ? ((currentPage - 1) * itemsPerPage) : 0, itemsPerPage);
|
||||
|
||||
if (!result.IsSuccess || items == null)
|
||||
return (null, result);
|
||||
|
||||
return IDomainResult.Success(new GetShopItemsResponseModel(currentPage, 0, items.Select(x => new GetShopItemResponseModel(x)).ToList()));
|
||||
|
||||
var shopItems = new List<GetShopItemResponseModel>();
|
||||
foreach (var item in items) {
|
||||
var categories = new List<Category>();
|
||||
foreach (var catId in item.Categories) {
|
||||
var (cat, getCategoryResult) = _categoryDataProvider.Get(catId, siteId);
|
||||
if (!getCategoryResult.IsSuccess || cat == null)
|
||||
return (null, getCategoryResult);
|
||||
|
||||
categories.Add(cat);
|
||||
}
|
||||
shopItems.Add(new GetShopItemResponseModel(item, categories, locale));
|
||||
}
|
||||
|
||||
return shopItems.Count > 0
|
||||
? IDomainResult.Success(new GetShopItemsResponseModel(currentPage, 0, shopItems))
|
||||
: IDomainResult.NotFound<GetShopItemsResponseModel?>();
|
||||
}
|
||||
|
||||
|
||||
public IDomainResult Delete(Guid siteId)
|
||||
=> _shopCatalogDataProvider.DeleteAll(siteId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@ namespace WeatherForecast {
|
||||
services.AddScoped<IShopItemsService, ShopItemsService>();
|
||||
services.AddScoped<IShopCartItemService, ShopCartItemService>();
|
||||
services.AddScoped<IShopCartItemsService, ShopCartItemsService>();
|
||||
|
||||
//services.AddScoped<IBlogItemService, BlogItemService>();
|
||||
services.AddScoped<IBlogItemsService, BlogItemsService>();
|
||||
services.RegisterDataproviders(appSettings);
|
||||
|
||||
#region Swagger
|
||||
|
||||
Loading…
Reference in New Issue
Block a user