diff --git a/postman/reactredux.postman_collection.json b/postman/reactredux.postman_collection.json index 90c732e..b7b770a 100644 --- a/postman/reactredux.postman_collection.json +++ b/postman/reactredux.postman_collection.json @@ -25,7 +25,7 @@ } ], "url": { - "raw": "https://localhost:7151/api/Content/b3f39a82-6a1b-46a4-85cc-04c3b4315511?locale=en-US", + "raw": "https://localhost:7151/api/Content/404c8232-9048-4519-bfba-6e78dc7005ca?locale=en-US", "protocol": "https", "host": [ "localhost" @@ -34,7 +34,7 @@ "path": [ "api", "Content", - "b3f39a82-6a1b-46a4-85cc-04c3b4315511" + "404c8232-9048-4519-bfba-6e78dc7005ca" ], "query": [ { @@ -112,7 +112,7 @@ } ], "url": { - "raw": "https://localhost:7151/api/ShopCartItem/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60/SKU-01", + "raw": "https://localhost:7151/api/ShopCartItem/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60/SKU-01?locale=en-US", "protocol": "https", "host": [ "localhost" @@ -124,6 +124,12 @@ "404c8232-9048-4519-bfba-6e78dc7005ca", "fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60", "SKU-01" + ], + "query": [ + { + "key": "locale", + "value": "en-US" + } ] } }, @@ -185,7 +191,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"quantity\": 2\r\n}" + "raw": "{\r\n \"quantity\": 5\r\n}" }, "url": { "raw": "https://localhost:7151/api/ShopCartItem/404c8232-9048-4519-bfba-6e78dc7005ca/fdc5aa50-ee68-4bae-a8e6-b8ae2c258f60/SKU-04", @@ -261,7 +267,7 @@ } ], "url": { - "raw": "https://localhost:7151/api/ShopCatalog/404c8232-9048-4519-bfba-6e78dc7005ca?currentPage=1&itemsPerPage=4", + "raw": "https://localhost:7151/api/ShopItems/404c8232-9048-4519-bfba-6e78dc7005ca?currentPage=1&itemsPerPage=4", "protocol": "https", "host": [ "localhost" @@ -269,7 +275,7 @@ "port": "7151", "path": [ "api", - "ShopCatalog", + "ShopItems", "404c8232-9048-4519-bfba-6e78dc7005ca" ], "query": [ @@ -286,6 +292,52 @@ }, "response": [] }, + { + "name": "01-Get localized", + "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/ShopItems/404c8232-9048-4519-bfba-6e78dc7005ca?currentPage=2&itemsPerPage=2&locale=en-US", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "ShopItems", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ], + "query": [ + { + "key": "currentPage", + "value": "2" + }, + { + "key": "itemsPerPage", + "value": "2" + }, + { + "key": "locale", + "value": "en-US" + } + ] + } + }, + "response": [] + }, { "name": "01-Delete", "request": { @@ -303,7 +355,7 @@ } ], "url": { - "raw": "https://localhost:7151/api/ShopCatalog/404c8232-9048-4519-bfba-6e78dc7005ca", + "raw": "https://localhost:7151/api/ShopItems/404c8232-9048-4519-bfba-6e78dc7005ca", "protocol": "https", "host": [ "localhost" @@ -311,7 +363,7 @@ "port": "7151", "path": [ "api", - "ShopCatalog", + "ShopItems", "404c8232-9048-4519-bfba-6e78dc7005ca" ] } @@ -356,6 +408,44 @@ }, "response": [] }, + { + "name": "01-GetSlug", + "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?slug=shop-catalog-item-01", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "ShopItem", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ], + "query": [ + { + "key": "slug", + "value": "shop-catalog-item-01" + } + ] + } + }, + "response": [] + }, { "name": "02-Post", "request": { @@ -470,6 +560,48 @@ "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", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "BlogItems", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ], + "query": [ + { + "key": "currentPage", + "value": "2" + }, + { + "key": "itemsPerPage", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "01-Get localized", "request": { "method": "GET", "header": [ @@ -550,7 +682,298 @@ }, { "name": "BlogItem", - "item": [] + "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/BlogItem/404c8232-9048-4519-bfba-6e78dc7005ca/11f2f5f8-1270-4640-b082-c2e7ea8e60b4", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "BlogItem", + "404c8232-9048-4519-bfba-6e78dc7005ca", + "11f2f5f8-1270-4640-b082-c2e7ea8e60b4" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "CategoryItems", + "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/CategoryItems/404c8232-9048-4519-bfba-6e78dc7005ca?locale=en-US", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItems", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ], + "query": [ + { + "key": "locale", + "value": "en-US" + } + ] + } + }, + "response": [] + }, + { + "name": "01-Get Copy", + "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/CategoryItems/404c8232-9048-4519-bfba-6e78dc7005ca", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItems", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "CategoryItem", + "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/CategoryItem/404c8232-9048-4519-bfba-6e78dc7005ca/e154e33f-3cc7-468d-bb66-e0390ddb9ae0", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItem", + "404c8232-9048-4519-bfba-6e78dc7005ca", + "e154e33f-3cc7-468d-bb66-e0390ddb9ae0" + ] + } + }, + "response": [] + }, + { + "name": "01-GetSlug", + "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/CategoryItem/404c8232-9048-4519-bfba-6e78dc7005ca?slug=default", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItem", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ], + "query": [ + { + "key": "slug", + "value": "default" + } + ] + } + }, + "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\": \"guides\",\r\n \"text\": \"Guides\"\r\n }\r\n ]\r\n}" + }, + "url": { + "raw": "https://localhost:7151/api/CategoryItem/404c8232-9048-4519-bfba-6e78dc7005ca", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItem", + "404c8232-9048-4519-bfba-6e78dc7005ca" + ] + } + }, + "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 \"l10n\": [\r\n {\r\n \"locale\": \"en-US\",\r\n \"slug\": \"guides\",\r\n \"text\": \"Guides\"\r\n },\r\n {\r\n \"locale\": \"it-IT\",\r\n \"slug\": \"guide\",\r\n \"text\": \"Guide\"\r\n }\r\n ]\r\n}" + }, + "url": { + "raw": "https://localhost:7151/api/CategoryItem/404c8232-9048-4519-bfba-6e78dc7005ca/2c50f4de-70f2-4414-aabc-7a0d2eb0e203", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItem", + "404c8232-9048-4519-bfba-6e78dc7005ca", + "2c50f4de-70f2-4414-aabc-7a0d2eb0e203" + ] + } + }, + "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/CategoryItem/404c8232-9048-4519-bfba-6e78dc7005ca/2c50f4de-70f2-4414-aabc-7a0d2eb0e203", + "protocol": "https", + "host": [ + "localhost" + ], + "port": "7151", + "path": [ + "api", + "CategoryItem", + "404c8232-9048-4519-bfba-6e78dc7005ca", + "2c50f4de-70f2-4414-aabc-7a0d2eb0e203" + ] + } + }, + "response": [] + } + ] } ] } \ No newline at end of file diff --git a/webapi/Core/Abstractions/Enumeration.cs b/webapi/Core/Abstractions/Enumeration.cs index a07adbe..59f2f9c 100644 --- a/webapi/Core/Abstractions/Enumeration.cs +++ b/webapi/Core/Abstractions/Enumeration.cs @@ -60,6 +60,11 @@ namespace Core.Abstractions { return matchingItem; } + /// + /// + /// + /// + /// public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id); } } \ No newline at end of file diff --git a/webapi/Core/DomainObjects/Documents/Category.cs b/webapi/Core/DomainObjects/Documents/Category.cs index bd645a2..44f8f18 100644 --- a/webapi/Core/DomainObjects/Documents/Category.cs +++ b/webapi/Core/DomainObjects/Documents/Category.cs @@ -10,7 +10,7 @@ namespace Core.DomainObjects { unchecked { int hash = 17; hash = hash * 23 + Id.GetHashCode(); - hash = hash + L10n.Sum(x => x.GetHashCode() * 23); + hash += L10n.Sum(x => x.GetHashCode() * 23); return hash; } } diff --git a/webapi/DataProviders/IDataProvidersConfig.cs b/webapi/DataProviders/IDataProvidersConfig.cs index dd47fd8..9f4064d 100644 --- a/webapi/DataProviders/IDataProvidersConfig.cs +++ b/webapi/DataProviders/IDataProvidersConfig.cs @@ -6,17 +6,17 @@ using System.Threading.Tasks; namespace DataProviders { public interface IDataProvidersConfig { - public Database Database { get; set; } + public Database? Database { get; set; } } public interface IDatabase { - string ConnectionString { get; set; } + string? ConnectionString { get; set; } } public class Database : IDatabase { - private string _connectionString; - public string ConnectionString { + private string? _connectionString; + public string? ConnectionString { get { var envVar = Environment.GetEnvironmentVariable("DB_CONN"); return envVar ?? _connectionString; diff --git a/webapi/WeatherForecast/Configuration.cs b/webapi/WeatherForecast/Configuration.cs index 9141726..ea8dace 100644 --- a/webapi/WeatherForecast/Configuration.cs +++ b/webapi/WeatherForecast/Configuration.cs @@ -1,8 +1,20 @@ using DataProviders; namespace WeatherForecast { + + /// + /// + /// public class Configuration : IDataProvidersConfig{ - public string Secret { get; set; } - public Database Database { get; set; } + + /// + /// + /// + public string? Secret { get; set; } + + /// + /// + /// + public Database? Database { get; set; } } } diff --git a/webapi/WeatherForecast/Controllers/BlogItemController.cs b/webapi/WeatherForecast/Controllers/BlogItemController.cs index 483a2b0..60f58e0 100644 --- a/webapi/WeatherForecast/Controllers/BlogItemController.cs +++ b/webapi/WeatherForecast/Controllers/BlogItemController.cs @@ -1,13 +1,17 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Core.Abstractions; -using Core.Enumerations; -using WeatherForecast.Services; + using DomainResults.Mvc; + +using WeatherForecast.Services; using WeatherForecast.Models.Requests; namespace WeatherForecast.Controllers { + + /// + /// + /// [AllowAnonymous] [ApiController] [Route("api/[controller]")] @@ -16,6 +20,11 @@ namespace WeatherForecast.Controllers { private readonly ILogger _logger; private readonly IBlogItemService _blogItemService; + /// + /// + /// + /// + /// public BlogItemController( ILogger logger, IBlogItemService blogItemService @@ -47,9 +56,10 @@ namespace WeatherForecast.Controllers { } /// - /// Returns localized object + /// /// /// + /// /// [HttpGet("{siteId}")] public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) { diff --git a/webapi/WeatherForecast/Controllers/BlogItemsController.cs b/webapi/WeatherForecast/Controllers/BlogItemsController.cs index 893d5a7..43f832a 100644 --- a/webapi/WeatherForecast/Controllers/BlogItemsController.cs +++ b/webapi/WeatherForecast/Controllers/BlogItemsController.cs @@ -1,18 +1,15 @@ 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]")] @@ -21,6 +18,11 @@ public class BlogItemsController : ControllerBase { private readonly ILogger _logger; private readonly IBlogItemsService _blogItemsService; + /// + /// + /// + /// + /// public BlogItemsController( ILogger logger, IBlogItemsService blogItemsService @@ -32,14 +34,16 @@ public class BlogItemsController : ControllerBase { /// /// /// - /// - /// + /// /// /// + /// + /// + /// /// [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(locale) ?? Locales.Us, searchText); + var result = _blogItemsService.Get(siteId, category, currentPage ?? 1, itemsPerPage ?? 8, locale, searchText); return result.ToActionResult(); } diff --git a/webapi/WeatherForecast/Controllers/CategoryItemController.cs b/webapi/WeatherForecast/Controllers/CategoryItemController.cs index 3b85e63..758dd23 100644 --- a/webapi/WeatherForecast/Controllers/CategoryItemController.cs +++ b/webapi/WeatherForecast/Controllers/CategoryItemController.cs @@ -1,13 +1,16 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using WeatherForecast.Services; + using DomainResults.Mvc; + +using WeatherForecast.Services; using WeatherForecast.Models.Requests; -using Core.Enumerations; -using Core.Abstractions; namespace WeatherForecast.Controllers { + /// + /// + /// [AllowAnonymous] [ApiController] [Route("api/[controller]")] @@ -16,6 +19,11 @@ namespace WeatherForecast.Controllers { private readonly ILogger _logger; private readonly ICategoryItemService _categoryItemService; + /// + /// + /// + /// + /// public CategoryItemController( ILogger logger, ICategoryItemService categoryItemService) { @@ -48,9 +56,10 @@ namespace WeatherForecast.Controllers { } /// - /// Returns localized object + /// /// /// + /// /// [HttpGet("{siteId}")] public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) { diff --git a/webapi/WeatherForecast/Controllers/CategoryItemsController.cs b/webapi/WeatherForecast/Controllers/CategoryItemsController.cs index edd6e79..02ab1dd 100644 --- a/webapi/WeatherForecast/Controllers/CategoryItemsController.cs +++ b/webapi/WeatherForecast/Controllers/CategoryItemsController.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Authorization; using DomainResults.Mvc; -using Core.Abstractions; -using Core.Enumerations; - using WeatherForecast.Services; namespace WeatherForecast.Controllers { + /// + /// + /// [AllowAnonymous] [ApiController] [Route("api/[controller]")] @@ -18,6 +18,11 @@ namespace WeatherForecast.Controllers { private readonly ILogger _logger; private readonly ICategoryItemsService _categoryItemsService; + /// + /// + /// + /// + /// public CategoryItemsController( ILogger logger, ICategoryItemsService categoryItemsService diff --git a/webapi/WeatherForecast/Controllers/ContentController.cs b/webapi/WeatherForecast/Controllers/ContentController.cs index 5f72412..67a2419 100644 --- a/webapi/WeatherForecast/Controllers/ContentController.cs +++ b/webapi/WeatherForecast/Controllers/ContentController.cs @@ -1,11 +1,8 @@ -using DomainResults.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using WeatherForecast.Models; -using WeatherForecast.Models.Abstractions; -using WeatherForecast.Models.Pages; -using WeatherForecast.Models.PageSections; -using WeatherForecast.Models.Responses; + +using DomainResults.Mvc; + using WeatherForecast.Services; namespace WeatherForecast.Controllers; @@ -25,6 +22,7 @@ public class ContentController : ControllerBase { /// /// /// + /// public ContentController( ILogger logger, IContentService contentService diff --git a/webapi/WeatherForecast/Controllers/ShopCartItemController.cs b/webapi/WeatherForecast/Controllers/ShopCartItemController.cs index 8519353..478be43 100644 --- a/webapi/WeatherForecast/Controllers/ShopCartItemController.cs +++ b/webapi/WeatherForecast/Controllers/ShopCartItemController.cs @@ -1,10 +1,10 @@ -using Core.Abstractions; -using Core.Enumerations; -using DomainResults.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using WeatherForecast.Models.Requests; + +using DomainResults.Mvc; + using WeatherForecast.Services; +using WeatherForecast.Models.Requests; namespace WeatherForecast.Controllers { @@ -24,6 +24,7 @@ namespace WeatherForecast.Controllers { /// /// /// + /// public ShopCartItemController( ILogger logger, IShopCartItemService shopCartItemService @@ -51,8 +52,8 @@ namespace WeatherForecast.Controllers { /// /// [HttpGet("{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(locale) ?? Locales.Us); + public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromRoute] string sku, [FromQuery] string? locale) { + var result = _shopCartItemService.Get(siteId, userId, sku, locale); return result.ToActionResult(); } diff --git a/webapi/WeatherForecast/Controllers/ShopCartItemsController.cs b/webapi/WeatherForecast/Controllers/ShopCartItemsController.cs index aeee60f..c494b95 100644 --- a/webapi/WeatherForecast/Controllers/ShopCartItemsController.cs +++ b/webapi/WeatherForecast/Controllers/ShopCartItemsController.cs @@ -1,9 +1,8 @@ -using Core.Abstractions; -using Core.Enumerations; -using DomainResults.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using WeatherForecast.Models.Requests; + +using DomainResults.Mvc; + using WeatherForecast.Services; namespace WeatherForecast.Controllers { @@ -24,6 +23,7 @@ namespace WeatherForecast.Controllers { /// /// /// + /// public ShopCartItemsController( ILogger logger, IShopCartItemsService shopCartItemsService @@ -37,12 +37,17 @@ namespace WeatherForecast.Controllers { /// /// [HttpGet("{siteId}/{userId}")] - public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string locale) { - var result = _shopCartItemsService.Get(siteId, userId, Enumeration.FromDisplayName(locale) ?? Locales.Us); + public IActionResult Get([FromRoute] Guid siteId, [FromRoute] Guid userId, [FromQuery] string? locale) { + var result = _shopCartItemsService.Get(siteId, userId, locale); return result.ToActionResult(); } - + /// + /// + /// + /// + /// + /// [HttpDelete("{siteId}/{userId}")] public IActionResult Delete([FromRoute] Guid siteId, [FromRoute] Guid userId) { var result = _shopCartItemsService.Delete(siteId, userId); diff --git a/webapi/WeatherForecast/Controllers/ShopItemController.cs b/webapi/WeatherForecast/Controllers/ShopItemController.cs index 69e3fe3..be3340f 100644 --- a/webapi/WeatherForecast/Controllers/ShopItemController.cs +++ b/webapi/WeatherForecast/Controllers/ShopItemController.cs @@ -1,13 +1,16 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using WeatherForecast.Services; + using DomainResults.Mvc; -using Core.Abstractions; -using Core.Enumerations; + +using WeatherForecast.Services; using WeatherForecast.Models.Requests; namespace WeatherForecast.Controllers { + /// + /// + /// [AllowAnonymous] [ApiController] [Route("api/[controller]")] @@ -16,6 +19,11 @@ namespace WeatherForecast.Controllers { private readonly ILogger _logger; private readonly IShopItemService _shopItemService; + /// + /// + /// + /// + /// public ShopItemController( ILogger logger, IShopItemService shopItemService @@ -50,9 +58,10 @@ namespace WeatherForecast.Controllers { } /// - /// Returns localized object + /// /// /// + /// /// [HttpGet("{siteId}")] public IActionResult GetSlug([FromRoute] Guid siteId, [FromQuery] string slug) { diff --git a/webapi/WeatherForecast/Controllers/ShopItemsController.cs b/webapi/WeatherForecast/Controllers/ShopItemsController.cs index 6dac865..b91eac7 100644 --- a/webapi/WeatherForecast/Controllers/ShopItemsController.cs +++ b/webapi/WeatherForecast/Controllers/ShopItemsController.cs @@ -1,16 +1,15 @@ -using Core.Abstractions; -using Core.Abstractions.Models; -using Core.Enumerations; -using Core.Models; -using DomainResults.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using WeatherForecast.Models; -using WeatherForecast.Models.Responses; + +using DomainResults.Mvc; + using WeatherForecast.Services; namespace WeatherForecast.Controllers; +/// +/// +/// [AllowAnonymous] [ApiController] [Route("api/[controller]")] @@ -19,26 +18,32 @@ public class ShopItemsController : ControllerBase { private readonly ILogger _logger; private readonly IShopItemsService _shopItemsService; + /// + /// + /// + /// + /// public ShopItemsController( ILogger logger, IShopItemsService shopCatalogService ) { _logger = logger; _shopItemsService = shopCatalogService; - } /// /// /// + /// /// - /// /// /// + /// + /// /// [HttpGet("{siteId}")] - 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(locale) ?? Locales.Us, 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, locale, searchText); return result.ToActionResult(); } diff --git a/webapi/WeatherForecast/Controllers/WeatherForecastController.cs b/webapi/WeatherForecast/Controllers/WeatherForecastController.cs index 740b41c..082171e 100644 --- a/webapi/WeatherForecast/Controllers/WeatherForecastController.cs +++ b/webapi/WeatherForecast/Controllers/WeatherForecastController.cs @@ -4,30 +4,38 @@ using WeatherForecast.Models.Responses; namespace WeatherForecast.Controllers; +/// +/// +/// [ApiController] [Route("[controller]")] -public class WeatherForecastController : ControllerBase -{ - private static readonly string[] Summaries = new[] - { +public class WeatherForecastController : ControllerBase { + private static readonly string[] Summaries = new[] + { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; - private readonly ILogger _logger; + private readonly ILogger _logger; - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } + /// + /// + /// + /// + public WeatherForecastController(ILogger logger) { + _logger = logger; + } - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => new GetWeatherForecastResponseModel { - Date = DateTime.Now.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }) - .ToArray(); - } + /// + /// + /// + /// + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() { + return Enumerable.Range(1, 5).Select(index => new GetWeatherForecastResponseModel { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } } diff --git a/webapi/WeatherForecast/Models/Abstractions/AddressSectionModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/AddressSectionModelBase.cs index d1c2c83..a601443 100644 --- a/webapi/WeatherForecast/Models/Abstractions/AddressSectionModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/AddressSectionModelBase.cs @@ -1,24 +1,57 @@ using Core.Abstractions.DomainObjects; namespace WeatherForecast.Models.Abstractions { + + /// + /// + /// + /// public abstract class AddressSectionModelBase : PageSectionModelBase { + /// + /// + /// public FormItemModel FirstName { get; set; } + /// + /// + /// public FormItemModel LastName { get; set; } + /// + /// + /// public FormItemModel Address { get; set; } + /// + /// + /// public FormItemModel Address2 { get; set; } + /// + /// + /// public FormItemModel Country { get; set; } + /// + /// + /// public FormItemModel State { get; set; } + /// + /// + /// public FormItemModel City { get; set; } + /// + /// + /// public FormItemModel Zip { get; set; } + /// + /// + /// + /// public AddressSectionModelBase(AddressSectionBase addressSection) : base(addressSection) { FirstName = new FormItemModel(addressSection.FirstName); LastName = new FormItemModel(addressSection.LastName); diff --git a/webapi/WeatherForecast/Models/Abstractions/PageModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/PageModelBase.cs index a9868f9..a1108fe 100644 --- a/webapi/WeatherForecast/Models/Abstractions/PageModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/PageModelBase.cs @@ -6,14 +6,32 @@ using Core.DomainObjects.PageSections; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Abstractions { + + /// + /// + /// + /// public abstract class PageModelBase : ModelBase { + /// + /// + /// public HeaderModel Header { get; set; } + /// + /// + /// public TitleSectionModel? TitleSection { get; set; } + /// + /// + /// public PageModelBase() { } + /// + /// + /// + /// public PageModelBase(PageBase pageBase) { if(pageBase.TitleSection !=null) TitleSection = new TitleSectionModel(pageBase.TitleSection); diff --git a/webapi/WeatherForecast/Models/Abstractions/PageSectionModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/PageSectionModelBase.cs index 2e123f2..f3237ec 100644 --- a/webapi/WeatherForecast/Models/Abstractions/PageSectionModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/PageSectionModelBase.cs @@ -2,17 +2,42 @@ using Core.Abstractions.Models; namespace WeatherForecast.Models.Abstractions { + + /// + /// + /// + /// public abstract class PageSectionModelBase : ModelBase { + + /// + /// + /// public string? Title { get; set; } + + /// + /// + /// public string? Text { get; set; } + /// + /// + /// public PageSectionModelBase() { } + /// + /// + /// + /// public PageSectionModelBase(PageSectionBase pageSectionBase) { Title = pageSectionBase.Title; Text = pageSectionBase.Text; } + /// + /// + /// + /// + /// public PageSectionModelBase(string? title, string? text) { Title = title; Text = text; diff --git a/webapi/WeatherForecast/Models/Abstractions/PersonModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/PersonModelBase.cs index 8b2ae6b..18c8eaa 100644 --- a/webapi/WeatherForecast/Models/Abstractions/PersonModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/PersonModelBase.cs @@ -3,13 +3,32 @@ using Core.Abstractions.Models; using Core.DomainObjects; namespace WeatherForecast.Models.Abstractions { + + /// + /// + /// + /// public abstract class PersonModelBase : ModelBase { + + /// + /// + /// public Guid Id { get; set; } + /// + /// + /// public ImageModel? Image { get; set; } + /// + /// + /// public PersonModelBase() { } + /// + /// + /// + /// public PersonModelBase(PersonBase person) { //if(person.Image != null) // Image = new ImageModel(person.Image); diff --git a/webapi/WeatherForecast/Models/Abstractions/PostItemRequestModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/PostItemRequestModelBase.cs index 704fb7e..74511f7 100644 --- a/webapi/WeatherForecast/Models/Abstractions/PostItemRequestModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/PostItemRequestModelBase.cs @@ -4,14 +4,30 @@ using WeatherForecast.Models.L10n; namespace WeatherForecast.Models.Abstractions { + /// + /// + /// + /// public abstract class PostItemRequestModelBase : RequestModelBase { + /// + /// + /// public List L10n { get; set; } + /// + /// + /// public List? Categories { get; set; } + /// + /// + /// public List? Tags { get; set; } + /// + /// + /// public bool? FamilyFriendly { get; set; } } } diff --git a/webapi/WeatherForecast/Models/Abstractions/PostItemResponseModelBase.cs b/webapi/WeatherForecast/Models/Abstractions/PostItemResponseModelBase.cs index ed9aff6..b5f2944 100644 --- a/webapi/WeatherForecast/Models/Abstractions/PostItemResponseModelBase.cs +++ b/webapi/WeatherForecast/Models/Abstractions/PostItemResponseModelBase.cs @@ -5,40 +5,105 @@ using Core.Enumerations; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models.Abstractions { + + /// + /// + /// + /// public abstract class PostItemResponseModelBase : ResponseModelBase { + /// + /// + /// public Guid Id { get; set; } + + /// + /// + /// public Guid SiteId { get; set; } + /// + /// + /// public List? L10n { get; set; } #region Localized costrutor + + /// + /// + /// 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? PlainText { get; set; } + /// + /// + /// public string? ContentType { get; set; } + + /// + /// + /// public List? Badges { get; set; } #endregion - + /// + /// + /// public List Images { get; set; } + /// + /// + /// public AuthorModel Author { get; set; } + /// + /// + /// public DateTime Created { get; set; } + /// + /// + /// public List Tags { get; set; } + /// + /// + /// public List Categories { get; set; } + /// + /// + /// public bool? FamilyFriendly { get; set; } + /// + /// + /// + /// public PostItemResponseModelBase(PostItemBase postItem) { Id = postItem.Id; SiteId = postItem.SiteId; @@ -48,12 +113,23 @@ namespace WeatherForecast.Models.Abstractions { FamilyFriendly = postItem.FamilyFriendly; } + /// + /// + /// + /// + /// public PostItemResponseModelBase(PostItemBase postItem, List categories) : this(postItem) { L10n = postItem.L10n.Select(x => new PostItemL10nModel(x)).ToList(); Categories = categories.Select(x => new CategoryModel(x)).ToList(); Images = postItem.Images.Select(x => new ImageModel(x)).ToList(); } + /// + /// + /// + /// + /// + /// public PostItemResponseModelBase(PostItemBase postItem, List categories, Locales locale) : this(postItem) { var postItemL10n = postItem.L10n.SingleOrDefault(x => x.Locale == locale); diff --git a/webapi/WeatherForecast/Models/AuthorModel.cs b/webapi/WeatherForecast/Models/AuthorModel.cs index 9b8fdc2..d4bf13d 100644 --- a/webapi/WeatherForecast/Models/AuthorModel.cs +++ b/webapi/WeatherForecast/Models/AuthorModel.cs @@ -2,9 +2,21 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models { + + /// + /// + /// public class AuthorModel : PersonModelBase { + + /// + /// + /// public string NickName { get; set; } + /// + /// + /// + /// public AuthorModel(Author author) { NickName = author.NickName; } diff --git a/webapi/WeatherForecast/Models/BlogItemModel.cs b/webapi/WeatherForecast/Models/BlogItemModel.cs index ea6825d..a1ac58c 100644 --- a/webapi/WeatherForecast/Models/BlogItemModel.cs +++ b/webapi/WeatherForecast/Models/BlogItemModel.cs @@ -5,12 +5,28 @@ using Core.Enumerations; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models { + + /// + /// + /// public class BlogItemModel : PostItemResponseModelBase { + /// + /// + /// public uint? ReadTime { get; set; } + /// + /// + /// public uint? Likes { get; set; } + /// + /// + /// + /// + /// + /// public BlogItemModel(BlogItem blogItem, List categories, Locales locale) : base(blogItem, categories, locale) { ReadTime = blogItem.ReadTime; diff --git a/webapi/WeatherForecast/Models/CategoryModel.cs b/webapi/WeatherForecast/Models/CategoryModel.cs index d154a33..6a8bcf0 100644 --- a/webapi/WeatherForecast/Models/CategoryModel.cs +++ b/webapi/WeatherForecast/Models/CategoryModel.cs @@ -3,16 +3,40 @@ using Core.Enumerations; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models { + + /// + /// + /// public class CategoryModel { + + /// + /// + /// public List? L10n { get; set; } + /// + /// + /// public string? Slug { get; set; } + + /// + /// + /// public string? Text { get; set; } + /// + /// + /// + /// public CategoryModel(Category category) { L10n = category.L10n.Select(x => new CategoryL10nModel(x)).ToList(); } + /// + /// + /// + /// + /// public CategoryModel(Category category, Locales locale) { var categoryL10n = category.L10n.SingleOrDefault(x => x.Locale == locale); if (categoryL10n != null) { diff --git a/webapi/WeatherForecast/Models/CommentModel.cs b/webapi/WeatherForecast/Models/CommentModel.cs index 30f0814..24b5b15 100644 --- a/webapi/WeatherForecast/Models/CommentModel.cs +++ b/webapi/WeatherForecast/Models/CommentModel.cs @@ -1,7 +1,23 @@ namespace WeatherForecast.Models { + + /// + /// + /// public class CommentModel { + + /// + /// + /// public AuthorModel Author { get; set; } + + /// + /// + /// public string Comment { get; set; } + + /// + /// + /// public List? Responses { get; set; } } } diff --git a/webapi/WeatherForecast/Models/FeatureModel.cs b/webapi/WeatherForecast/Models/FeatureModel.cs index 3c02ac6..08e4575 100644 --- a/webapi/WeatherForecast/Models/FeatureModel.cs +++ b/webapi/WeatherForecast/Models/FeatureModel.cs @@ -1,11 +1,31 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class FeatureModel { + + /// + /// + /// public string Icon { get; set; } + + /// + /// + /// public string Title { get; set; } + + /// + /// + /// public string Text { get; set; } + /// + /// + /// + /// public FeatureModel(Feature feature) { Icon = feature.Icon; Title = feature.Title; diff --git a/webapi/WeatherForecast/Models/FormItemModel.cs b/webapi/WeatherForecast/Models/FormItemModel.cs index 38068a4..3766f4d 100644 --- a/webapi/WeatherForecast/Models/FormItemModel.cs +++ b/webapi/WeatherForecast/Models/FormItemModel.cs @@ -1,10 +1,26 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class FormItemModel { + + /// + /// + /// public string? Title { get; set; } + + /// + /// + /// public string? PlaceHolder { get; set; } + /// + /// + /// + /// public FormItemModel(FormItem formItem) { Title = formItem.Title; PlaceHolder = formItem.PlaceHolder; diff --git a/webapi/WeatherForecast/Models/HeaderModel.cs b/webapi/WeatherForecast/Models/HeaderModel.cs index 631162a..833eb89 100644 --- a/webapi/WeatherForecast/Models/HeaderModel.cs +++ b/webapi/WeatherForecast/Models/HeaderModel.cs @@ -2,13 +2,30 @@ namespace WeatherForecast.Models { - + /// + /// + /// public class HeaderModel { + + /// + /// + /// public string? Title { get; set; } + + /// + /// + /// public Dictionary? Link { get; set; } + /// + /// + /// public Dictionary? Meta { get; set; } + /// + /// + /// + /// public HeaderModel(Header header) { Title = header.Title; Link = header.Link; diff --git a/webapi/WeatherForecast/Models/ImageModel.cs b/webapi/WeatherForecast/Models/ImageModel.cs index 1ed76e7..cb0092b 100644 --- a/webapi/WeatherForecast/Models/ImageModel.cs +++ b/webapi/WeatherForecast/Models/ImageModel.cs @@ -3,16 +3,40 @@ using Core.Enumerations; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models { + + /// + /// + /// public class ImageModel { + + /// + /// + /// public List? L10n { get; set; } + /// + /// + /// public string? Src { get; set; } + + /// + /// + /// public string? Alt { get; set; } + /// + /// + /// + /// public ImageModel(Image image) { L10n = image.L10n.Select(x => new ImageL10nModel(x)).ToList(); } + /// + /// + /// + /// + /// public ImageModel(Image image, Locales locale) { Src = image.Src; diff --git a/webapi/WeatherForecast/Models/L10n/CategoryL10nModel.cs b/webapi/WeatherForecast/Models/L10n/CategoryL10nModel.cs index 92b701c..ba08eb5 100644 --- a/webapi/WeatherForecast/Models/L10n/CategoryL10nModel.cs +++ b/webapi/WeatherForecast/Models/L10n/CategoryL10nModel.cs @@ -4,21 +4,47 @@ using Core.DomainObjects.L10n; using Core.Enumerations; namespace WeatherForecast.Models.L10n { + + /// + /// + /// public class CategoryL10nModel : ModelBase { + /// + /// + /// public string Locale { get; set; } + + /// + /// + /// public string Slug { get; set; } + + /// + /// + /// public string Text { get; set; } + /// + /// + /// public CategoryL10nModel() { } + /// + /// + /// + /// public CategoryL10nModel(CategoryL10n categoryL10n) { Locale = categoryL10n.Locale.Name; Slug = categoryL10n.Slug; Text = categoryL10n.Text; } - public CategoryL10n ToDomainObject() => new CategoryL10n { + /// + /// + /// + /// + public CategoryL10n ToDomainObject() => new() { Locale = Enumeration.FromDisplayName(Locale), Slug = Slug, Text = Text diff --git a/webapi/WeatherForecast/Models/L10n/ImageL10nModel.cs b/webapi/WeatherForecast/Models/L10n/ImageL10nModel.cs index 7b43e23..f74c97f 100644 --- a/webapi/WeatherForecast/Models/L10n/ImageL10nModel.cs +++ b/webapi/WeatherForecast/Models/L10n/ImageL10nModel.cs @@ -4,18 +4,41 @@ using Core.DomainObjects.L10n; using Core.Enumerations; namespace WeatherForecast.Models.L10n { + + /// + /// + /// public class ImageL10nModel : ModelBase { + + /// + /// + /// public string Locale { get; set; } + + /// + /// + /// public string Alt { get; set; } + /// + /// + /// public ImageL10nModel() { } + /// + /// + /// + /// public ImageL10nModel(ImageL10n imageL10n) { Locale = imageL10n.Locale.Name; Alt = imageL10n.Alt; } - public ImageL10n ToDomainObject() => new ImageL10n { + /// + /// + /// + /// + public ImageL10n ToDomainObject() => new() { Locale = Enumeration.FromDisplayName(Locale), Alt = Alt }; diff --git a/webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs b/webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs index 38e021e..7d082c8 100644 --- a/webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs +++ b/webapi/WeatherForecast/Models/L10n/PostItemL10nModel.cs @@ -4,22 +4,66 @@ using Core.DomainObjects.L10n; using Core.Enumerations; namespace WeatherForecast.Models.L10n { + + /// + /// + /// public class PostItemL10nModel : ModelBase { + + /// + /// + /// 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 PlainText { get; set; } + /// + /// + /// public string ContentType { get; set; } + + /// + /// + /// public List? Badges { get; set; } + /// + /// + /// public PostItemL10nModel() { } + /// + /// + /// + /// public PostItemL10nModel(PostItemL10n postItemL10n) { Locale = postItemL10n.Locale.Name; Slug = postItemL10n.Slug; @@ -31,7 +75,11 @@ namespace WeatherForecast.Models.L10n { Badges = postItemL10n.Badges; } - public PostItemL10n ToDomainObject() => new PostItemL10n { + /// + /// + /// + /// + public PostItemL10n ToDomainObject() => new() { Locale = Enumeration.FromDisplayName(Locale), Slug = Slug, Description = Description, diff --git a/webapi/WeatherForecast/Models/LinkModel.cs b/webapi/WeatherForecast/Models/LinkModel.cs index b57adbb..9266f93 100644 --- a/webapi/WeatherForecast/Models/LinkModel.cs +++ b/webapi/WeatherForecast/Models/LinkModel.cs @@ -1,10 +1,26 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class LinkModel { + + /// + /// + /// public string? Target { get; set; } + + /// + /// + /// public string? AnchorText { get; set; } + /// + /// + /// + /// public LinkModel(Link link) { Target = link.Target; AnchorText = link.AnchorText; diff --git a/webapi/WeatherForecast/Models/LocalizationModel.cs b/webapi/WeatherForecast/Models/LocalizationModel.cs index 5262497..6882768 100644 --- a/webapi/WeatherForecast/Models/LocalizationModel.cs +++ b/webapi/WeatherForecast/Models/LocalizationModel.cs @@ -1,19 +1,47 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class LocalizationModel { + + /// + /// + /// public string? TimeZone { get; set; } + /// + /// + /// public string? Locale { get; set; } + /// + /// + /// public string? DateFormat { get; set; } - + + /// + /// + /// public string? TimeFormat { get; set; } - + + /// + /// + /// public string? Currency { get; set; } + /// + /// + /// + public string? CurrencySymbol { get; set; } + /// + /// + /// + /// public LocalizationModel(Localization localization) { TimeZone = localization.TimeZone; Locale = localization.Locale; diff --git a/webapi/WeatherForecast/Models/MenuItemModel.cs b/webapi/WeatherForecast/Models/MenuItemModel.cs index f728863..ac33b69 100644 --- a/webapi/WeatherForecast/Models/MenuItemModel.cs +++ b/webapi/WeatherForecast/Models/MenuItemModel.cs @@ -1,12 +1,36 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class MenuItemModel { + + /// + /// + /// public string? Icon { get; set; } + + /// + /// + /// public string? Title { get; set; } + + /// + /// + /// public string? Target { get; set; } + + /// + /// + /// public List? ChildItems { get; set; } + /// + /// + /// + /// public MenuItemModel(MenuItem menuItem) { Title = menuItem.Title; Target = menuItem.Target; diff --git a/webapi/WeatherForecast/Models/PageSections/BillingAddressSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/BillingAddressSectionModel.cs index 58cb15c..1b84e4b 100644 --- a/webapi/WeatherForecast/Models/PageSections/BillingAddressSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/BillingAddressSectionModel.cs @@ -2,8 +2,16 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class BillingAddressSectionModel : AddressSectionModelBase { + /// + /// + /// + /// public BillingAddressSectionModel(BillingAddressSection billingAddressSection) : base(billingAddressSection) { } } } diff --git a/webapi/WeatherForecast/Models/PageSections/CallToActionSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/CallToActionSectionModel.cs index d6a8df4..ec89e7a 100644 --- a/webapi/WeatherForecast/Models/PageSections/CallToActionSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/CallToActionSectionModel.cs @@ -2,11 +2,26 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class CallToActionSectionModel : PageSectionModelBase { + + /// + /// + /// public string PrivacyDisclaimer { get; set; } + /// + /// + /// public FormItemModel Email { get; set; } + /// + /// + /// + /// public CallToActionSectionModel(CallToActionSection callToActionSection) : base(callToActionSection) { PrivacyDisclaimer = callToActionSection.PrivacyDisclaimer; Email = new FormItemModel(callToActionSection.Email); diff --git a/webapi/WeatherForecast/Models/PageSections/CartProductsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/CartProductsSectionModel.cs index 31f6c05..c0d8ec4 100644 --- a/webapi/WeatherForecast/Models/PageSections/CartProductsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/CartProductsSectionModel.cs @@ -4,15 +4,46 @@ using Core.DomainObjects.PageSections; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class CartProductsSectionModel : PageSectionModelBase { + /// + /// + /// public string Product { get; set; } + + /// + /// + /// public string Price { get; set; } + + /// + /// + /// public string Quantity { get; set; } + + /// + /// + /// public string Subtotal { get; set; } + + /// + /// + /// public LinkModel ContinueShopping { get; set; } + + /// + /// + /// public LinkModel Checkout { get; set; } + /// + /// + /// + /// public CartProductsSectionModel(ProductsSection productsSection) : base(productsSection) { Product = productsSection.Product; Price = productsSection.Price; diff --git a/webapi/WeatherForecast/Models/PageSections/CheckoutSettingsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/CheckoutSettingsSectionModel.cs index c0a6aa0..fd7024a 100644 --- a/webapi/WeatherForecast/Models/PageSections/CheckoutSettingsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/CheckoutSettingsSectionModel.cs @@ -2,11 +2,26 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class CheckoutSettingsSectionModel : PageSectionModelBase { + /// + /// + /// public string ShippingAddressSameAsBillingAddress { get; set; } + + /// + /// + /// public string SaveThisInformation { get; set; } + /// + /// + /// + /// public CheckoutSettingsSectionModel(SettingsSection settingsSection) : base(settingsSection) { ShippingAddressSameAsBillingAddress = settingsSection.ShippingAddressSameAsBillingAddress; SaveThisInformation = settingsSection.SaveThisInformation; diff --git a/webapi/WeatherForecast/Models/PageSections/CheckoutSummarySectionModel.cs b/webapi/WeatherForecast/Models/PageSections/CheckoutSummarySectionModel.cs index dc03460..2586fa8 100644 --- a/webapi/WeatherForecast/Models/PageSections/CheckoutSummarySectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/CheckoutSummarySectionModel.cs @@ -2,14 +2,31 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class CheckoutSummarySectionModel : PageSectionModelBase { + /// + /// + /// public string Total { get; set; } + /// + /// + /// public FormItemModel PromoCode { get; set; } + /// + /// + /// public FormItemModel Submit { get; set; } + /// + /// + /// + /// public CheckoutSummarySectionModel(SummarySection summarySection) : base(summarySection) { Total = summarySection.Total; PromoCode = new FormItemModel(summarySection.PromoCode); diff --git a/webapi/WeatherForecast/Models/PageSections/CommentsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/CommentsSectionModel.cs index 7a416ba..dc1e402 100644 --- a/webapi/WeatherForecast/Models/PageSections/CommentsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/CommentsSectionModel.cs @@ -2,9 +2,21 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class CommentsSectionModel : PageSectionModelBase { + + /// + /// + /// public string LeaveComment { get; set; } + /// + /// + /// + /// public CommentsSectionModel(CommentsSection commentsSection) : base (commentsSection) { LeaveComment = commentsSection.LeaveComment; diff --git a/webapi/WeatherForecast/Models/PageSections/FeaturedBlogSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/FeaturedBlogSectionModel.cs index 436e1b4..cabf76a 100644 --- a/webapi/WeatherForecast/Models/PageSections/FeaturedBlogSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/FeaturedBlogSectionModel.cs @@ -2,11 +2,26 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class FeaturedBlogSectionModel : PageSectionModelBase { + + /// + /// + /// public string ReadTime { get; set; } + /// + /// + /// public FeaturedBlogSectionModel() : base() { } + /// + /// + /// + /// public FeaturedBlogSectionModel(FeaturedBlogSection featuredBlogSection) : base(featuredBlogSection) { ReadTime = featuredBlogSection.ReadTime; } diff --git a/webapi/WeatherForecast/Models/PageSections/FeaturedBologsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/FeaturedBologsSectionModel.cs index 847c6ec..7944f09 100644 --- a/webapi/WeatherForecast/Models/PageSections/FeaturedBologsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/FeaturedBologsSectionModel.cs @@ -2,8 +2,16 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class FeaturedBlogsSectionModel : PageSectionModelBase { + /// + /// + /// + /// public FeaturedBlogsSectionModel(FeaturedBlogsSection featuredBlogsSection) : base(featuredBlogsSection) { } } } diff --git a/webapi/WeatherForecast/Models/PageSections/FeaturesSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/FeaturesSectionModel.cs index 5b9895c..d73b601 100644 --- a/webapi/WeatherForecast/Models/PageSections/FeaturesSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/FeaturesSectionModel.cs @@ -2,9 +2,21 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class FeaturesSectionModel : PageSectionModelBase { + + /// + /// + /// public List Items { get; set; } + /// + /// + /// + /// public FeaturesSectionModel(FeaturesSection featuresSection) : base(featuresSection) { Items = featuresSection.Items.Select(x => new FeatureModel(x)).ToList(); } diff --git a/webapi/WeatherForecast/Models/PageSections/PaymentSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/PaymentSectionModel.cs index df21c75..22fb137 100644 --- a/webapi/WeatherForecast/Models/PageSections/PaymentSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/PaymentSectionModel.cs @@ -2,13 +2,36 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class PaymentSectionModel : PageSectionModelBase { + /// + /// + /// public FormItemModel NameOnCard { get; set; } + + /// + /// + /// public FormItemModel CardNumber { get; set; } + + /// + /// + /// public FormItemModel Expiration { get; set; } + + /// + /// + /// public FormItemModel Cvv { get; set; } + /// + /// + /// + /// public PaymentSectionModel(PaymentSection paymentSection) : base(paymentSection) { NameOnCard = new FormItemModel(paymentSection.NameOnCard); CardNumber = new FormItemModel(paymentSection.CardNumber); diff --git a/webapi/WeatherForecast/Models/PageSections/ProductSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/ProductSectionModel.cs index d4c5284..a279c40 100644 --- a/webapi/WeatherForecast/Models/PageSections/ProductSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/ProductSectionModel.cs @@ -2,10 +2,26 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class ProductSectionModel : PageSectionModelBase { + + /// + /// + /// public string AvailableQuantity { get; set; } + + /// + /// + /// public string AddToCart { get; set; } + /// + /// + /// + /// public ProductSectionModel(ProductSection productSection) : base(productSection) { AvailableQuantity = productSection.AvailableQuantity; AddToCart = productSection.AddToCart; diff --git a/webapi/WeatherForecast/Models/PageSections/RelatedProductsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/RelatedProductsSectionModel.cs index 0474068..34655a5 100644 --- a/webapi/WeatherForecast/Models/PageSections/RelatedProductsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/RelatedProductsSectionModel.cs @@ -2,10 +2,21 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class RelatedProductsSectionModel : PageSectionModelBase { + /// + /// + /// public string AddToCart { get; set; } + /// + /// + /// + /// public RelatedProductsSectionModel(RelatedProductsSection relatedProductsSection) : base(relatedProductsSection) { AddToCart = relatedProductsSection.AddToCart; } diff --git a/webapi/WeatherForecast/Models/PageSections/ShippingAddressSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/ShippingAddressSectionModel.cs index 692614f..6ce188b 100644 --- a/webapi/WeatherForecast/Models/PageSections/ShippingAddressSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/ShippingAddressSectionModel.cs @@ -3,7 +3,15 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + /// + /// + /// public class ShippingAddressSectionModel : AddressSectionModelBase { + + /// + /// + /// + /// public ShippingAddressSectionModel(ShippingAddressSection shippingAddressSection) : base(shippingAddressSection) { } } } diff --git a/webapi/WeatherForecast/Models/PageSections/ShopItemsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/ShopItemsSectionModel.cs index fb1f534..c30c0e0 100644 --- a/webapi/WeatherForecast/Models/PageSections/ShopItemsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/ShopItemsSectionModel.cs @@ -2,10 +2,22 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class ShopItemsSectionModel : PageSectionModelBase { + /// + /// + /// public string AddToCart { get; set; } + + /// + /// + /// + /// public ShopItemsSectionModel(ShopItemsSection shopItemSection) : base(shopItemSection) { AddToCart = shopItemSection.AddToCart; } diff --git a/webapi/WeatherForecast/Models/PageSections/TestimonialsSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/TestimonialsSectionModel.cs index 8d181f3..5401d3d 100644 --- a/webapi/WeatherForecast/Models/PageSections/TestimonialsSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/TestimonialsSectionModel.cs @@ -2,10 +2,21 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class TestimonialsSectionModel : PageSectionModelBase { + + /// + /// + /// public List Items { get; set; } - + /// + /// + /// + /// public TestimonialsSectionModel(TestimonialsSection testimonialsSection) : base(testimonialsSection) { Items = testimonialsSection.Items.Select(x => new TestimonialModel(x)).ToList(); } diff --git a/webapi/WeatherForecast/Models/PageSections/TitleSectionModel.cs b/webapi/WeatherForecast/Models/PageSections/TitleSectionModel.cs index ae9c90c..73a424a 100644 --- a/webapi/WeatherForecast/Models/PageSections/TitleSectionModel.cs +++ b/webapi/WeatherForecast/Models/PageSections/TitleSectionModel.cs @@ -2,16 +2,41 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.PageSections { + + /// + /// + /// public class TitleSectionModel : PageSectionModelBase { + /// + /// + /// public ImageModel? Image { get; set; } + + /// + /// + /// public LinkModel? PrimaryLink { get; set; } + + /// + /// + /// public LinkModel? SecondaryLink { get; set; } + /// + /// + /// public string? PostedOnBy { get; set; } + /// + /// + /// public TitleSectionModel() { } + /// + /// + /// + /// public TitleSectionModel(TitleSection titleSection) : base(titleSection) { //if(titleSection.Image != null) diff --git a/webapi/WeatherForecast/Models/Pages/BlogCatalogPageModel.cs b/webapi/WeatherForecast/Models/Pages/BlogCatalogPageModel.cs index 81d8654..5e966e9 100644 --- a/webapi/WeatherForecast/Models/Pages/BlogCatalogPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/BlogCatalogPageModel.cs @@ -3,10 +3,21 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class BlogCatalogPageModel : PageModelBase { + /// + /// + /// public FeaturedBlogSectionModel FeaturedBlogSection { get; set; } + /// + /// + /// + /// public BlogCatalogPageModel(BlogCatalogPage blogCatalogPage) : base(blogCatalogPage) { FeaturedBlogSection = new FeaturedBlogSectionModel(blogCatalogPage.FeaturedBlogSection); } diff --git a/webapi/WeatherForecast/Models/Pages/BlogItemPageModel.cs b/webapi/WeatherForecast/Models/Pages/BlogItemPageModel.cs index 65f3612..7c1b2c4 100644 --- a/webapi/WeatherForecast/Models/Pages/BlogItemPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/BlogItemPageModel.cs @@ -3,9 +3,21 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class BlogItemPageModel : PageModelBase { + + /// + /// + /// public CommentsSectionModel CommentsSection { get; set; } + /// + /// + /// + /// public BlogItemPageModel(BlogItemPage blogItemPage) : base(blogItemPage) { CommentsSection = new CommentsSectionModel(blogItemPage.CommentsSection); } diff --git a/webapi/WeatherForecast/Models/Pages/HomePageModel.cs b/webapi/WeatherForecast/Models/Pages/HomePageModel.cs index 1aea4fe..b063278 100644 --- a/webapi/WeatherForecast/Models/Pages/HomePageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/HomePageModel.cs @@ -3,12 +3,31 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class HomePageModel : PageModelBase { + /// + /// + /// public TestimonialsSectionModel TestimonialsSection { get; set; } + + /// + /// + /// public FeaturedBlogsSectionModel FeaturedBlogsSection { get; set; } + + /// + /// + /// public CallToActionSectionModel CallToActionSection { get; set; } + /// + /// + /// + /// public HomePageModel(HomePage homePage) : base(homePage) { TestimonialsSection = new TestimonialsSectionModel(homePage.TestimonialsSection); FeaturedBlogsSection = new FeaturedBlogsSectionModel(homePage.FeaturedBlogsSection); diff --git a/webapi/WeatherForecast/Models/Pages/ShopCartPageModel.cs b/webapi/WeatherForecast/Models/Pages/ShopCartPageModel.cs index 06f4728..e0ca82f 100644 --- a/webapi/WeatherForecast/Models/Pages/ShopCartPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/ShopCartPageModel.cs @@ -4,10 +4,21 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class ShopCartPageModel : PageModelBase { + /// + /// + /// public CartProductsSectionModel ProductsSection { get; set; } + /// + /// + /// + /// public ShopCartPageModel(ShopCartPage shopCartPage) : base(shopCartPage) { ProductsSection = new CartProductsSectionModel(shopCartPage.ProductsSection); diff --git a/webapi/WeatherForecast/Models/Pages/ShopCatalogPageModel.cs b/webapi/WeatherForecast/Models/Pages/ShopCatalogPageModel.cs index d6f1761..27daafc 100644 --- a/webapi/WeatherForecast/Models/Pages/ShopCatalogPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/ShopCatalogPageModel.cs @@ -3,10 +3,21 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class ShopCatalogPageModel : PageModelBase { + /// + /// + /// public ShopItemsSectionModel ShopItemsSection { get; set; } + /// + /// + /// + /// public ShopCatalogPageModel(ShopCatalogPage shopCatalogPage) : base(shopCatalogPage) { ShopItemsSection = new ShopItemsSectionModel(shopCatalogPage.ShopItemsSection); diff --git a/webapi/WeatherForecast/Models/Pages/ShopCheckoutPageModel.cs b/webapi/WeatherForecast/Models/Pages/ShopCheckoutPageModel.cs index aa32c30..9446013 100644 --- a/webapi/WeatherForecast/Models/Pages/ShopCheckoutPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/ShopCheckoutPageModel.cs @@ -3,15 +3,46 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class ShopCheckoutPageModel : PageModelBase { + /// + /// + /// public BillingAddressSectionModel BillingAddressSection { get; set; } + + /// + /// + /// public ShippingAddressSectionModel ShippingAddressSection { get; set; } + + /// + /// + /// public CheckoutSettingsSectionModel SettingsSection { get; set; } + + /// + /// + /// public CheckoutSummarySectionModel SummarySection { get; set; } + + /// + /// + /// public PaymentSectionModel PaymentSection { get; set; } + + /// + /// + /// public FormItemModel Submit { get; set; } + /// + /// + /// + /// public ShopCheckoutPageModel(ShopCheckoutPage shopCheckoutPage) : base(shopCheckoutPage) { BillingAddressSection = new BillingAddressSectionModel(shopCheckoutPage.BillingAddressSection); @@ -21,7 +52,6 @@ namespace WeatherForecast.Models.Pages { PaymentSection = new PaymentSectionModel(shopCheckoutPage.PaymentSection); Submit = new FormItemModel(shopCheckoutPage.Submit); - } } } diff --git a/webapi/WeatherForecast/Models/Pages/ShopItemPageModel.cs b/webapi/WeatherForecast/Models/Pages/ShopItemPageModel.cs index c984c74..127a111 100644 --- a/webapi/WeatherForecast/Models/Pages/ShopItemPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/ShopItemPageModel.cs @@ -3,10 +3,26 @@ using WeatherForecast.Models.Abstractions; using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class ShopItemPageModel : PageModelBase { + + /// + /// + /// public ProductSectionModel ProductSection { get; set; } + + /// + /// + /// public RelatedProductsSectionModel RelatedProductsSection { get; set; } + /// + /// + /// + /// public ShopItemPageModel(ShopItemPage shopItemPage) : base(shopItemPage) { ProductSection = new ProductSectionModel(shopItemPage.ProductSection); RelatedProductsSection = new RelatedProductsSectionModel(shopItemPage.RelatedProductsSection); diff --git a/webapi/WeatherForecast/Models/Pages/SignInPageModel.cs b/webapi/WeatherForecast/Models/Pages/SignInPageModel.cs index 780f614..e8e8a2b 100644 --- a/webapi/WeatherForecast/Models/Pages/SignInPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/SignInPageModel.cs @@ -2,19 +2,46 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class SignInPageModel : PageModelBase { + /// + /// + /// public string Title { get; set; } + /// + /// + /// public FormItemModel Email { get; set; } + + /// + /// + /// public FormItemModel Password { get; set; } + /// + /// + /// public string DontHaveAnAccount { get; set; } + /// + /// + /// public LinkModel SignUpLink { get; set; } + /// + /// + /// public FormItemModel Submit { get; set; } + /// + /// + /// + /// public SignInPageModel(SignInPage signInPage) : base(signInPage) { Title = signInPage.Title; diff --git a/webapi/WeatherForecast/Models/Pages/SignUpPageModel.cs b/webapi/WeatherForecast/Models/Pages/SignUpPageModel.cs index 29e138d..dc9dc4f 100644 --- a/webapi/WeatherForecast/Models/Pages/SignUpPageModel.cs +++ b/webapi/WeatherForecast/Models/Pages/SignUpPageModel.cs @@ -2,17 +2,56 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Pages { + + /// + /// + /// public class SignUpPageModel : PageModelBase { + /// + /// + /// public string Title { get; set; } + + /// + /// + /// public FormItemModel Username { get; set; } + + /// + /// + /// public FormItemModel Email { get; set; } + + /// + /// + /// public FormItemModel ReEmail { get; set; } + + /// + /// + /// public FormItemModel Password { get; set; } + + /// + /// + /// public FormItemModel RePassword { get; set; } + + /// + /// + /// public string AcceptTermsAndConditions { get; set; } + + /// + /// + /// public FormItemModel Submit { get; set; } + /// + /// + /// + /// public SignUpPageModel(SignUpPage signUpPage) : base(signUpPage) { Title = signUpPage.Title; Username = new FormItemModel(signUpPage.Username); diff --git a/webapi/WeatherForecast/Models/Requests/PostBlogItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PostBlogItemRequestModel.cs index 48a9956..85644c4 100644 --- a/webapi/WeatherForecast/Models/Requests/PostBlogItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PostBlogItemRequestModel.cs @@ -3,11 +3,27 @@ using Core.DomainObjects.Documents; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PostBlogItemRequestModel : PostItemRequestModelBase { + + /// + /// + /// public uint? ReadTime { get; set; } + + /// + /// + /// public uint? Likes { get; set; } - public override BlogItem ToDomainObject() => new BlogItem { + /// + /// + /// + /// + public override BlogItem ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList(), // Images // Author diff --git a/webapi/WeatherForecast/Models/Requests/PostCategoryItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PostCategoryItemRequestModel.cs index bcb6d2a..32aa1d8 100644 --- a/webapi/WeatherForecast/Models/Requests/PostCategoryItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PostCategoryItemRequestModel.cs @@ -4,10 +4,22 @@ using Core.DomainObjects.L10n; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PostCategoryItemRequestModel : RequestModelBase { + /// + /// + /// public List L10n { get; set; } - public override Category ToDomainObject() => new Category { + + /// + /// + /// + /// + public override Category ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList() }; } diff --git a/webapi/WeatherForecast/Models/Requests/PostShopCartItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PostShopCartItemRequestModel.cs index 959b173..c1f0a75 100644 --- a/webapi/WeatherForecast/Models/Requests/PostShopCartItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PostShopCartItemRequestModel.cs @@ -3,10 +3,22 @@ using Core.DomainObjects; using Core.DomainObjects.Documents; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PostShopCartItemRequestModel : RequestModelBase { + + /// + /// + /// public uint Quantity { get; set; } - public override ShopCartItem ToDomainObject() => new ShopCartItem { + /// + /// + /// + /// + public override ShopCartItem ToDomainObject() => new() { Quantity = Quantity, Created = DateTime.UtcNow }; diff --git a/webapi/WeatherForecast/Models/Requests/PostShopItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PostShopItemRequestModel.cs index 6a15561..c3e09ec 100644 --- a/webapi/WeatherForecast/Models/Requests/PostShopItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PostShopItemRequestModel.cs @@ -6,14 +6,42 @@ using ExtensionMethods; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PostShopItemRequestModel : PostItemRequestModelBase { + + /// + /// + /// 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 { + /// + /// + /// + /// + public override ShopItem ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList(), // Images // Author diff --git a/webapi/WeatherForecast/Models/Requests/PutBlogItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PutBlogItemRequestModel.cs index 9212dcf..1a1d280 100644 --- a/webapi/WeatherForecast/Models/Requests/PutBlogItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PutBlogItemRequestModel.cs @@ -3,11 +3,27 @@ using Core.DomainObjects.Documents; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Requests { - public class PutBlogItemRequestModel : PostItemRequestModelBase { - public uint? ReadTime { get; set; } - public uint? Likes { get; set; } - public override BlogItem ToDomainObject() => new BlogItem { + /// + /// + /// + public class PutBlogItemRequestModel : PostItemRequestModelBase { + + /// + /// + /// + public uint? ReadTime { get; set; } + + /// + /// + /// + public uint? Likes { get; set; } + + /// + /// + /// + /// + public override BlogItem ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList(), // Images // Author diff --git a/webapi/WeatherForecast/Models/Requests/PutCategoryItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PutCategoryItemRequestModel.cs index 430e5c0..5d07155 100644 --- a/webapi/WeatherForecast/Models/Requests/PutCategoryItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PutCategoryItemRequestModel.cs @@ -3,9 +3,22 @@ using Core.DomainObjects; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PutCategoryItemRequestModel : RequestModelBase { + + /// + /// + /// public List L10n { get; set; } - public override Category ToDomainObject() => new Category { + + /// + /// + /// + /// + public override Category ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList() }; } diff --git a/webapi/WeatherForecast/Models/Requests/PutShopCartItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PutShopCartItemRequestModel.cs index cfe8f99..df226f9 100644 --- a/webapi/WeatherForecast/Models/Requests/PutShopCartItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PutShopCartItemRequestModel.cs @@ -3,12 +3,22 @@ using Core.DomainObjects; using Core.DomainObjects.Documents; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PutShopCartItemRequestModel : RequestModelBase { + /// + /// + /// public uint Quantity { get; set; } - - public override ShopCartItem ToDomainObject() => new ShopCartItem { + /// + /// + /// + /// + public override ShopCartItem ToDomainObject() => new() { Quantity = Quantity }; } diff --git a/webapi/WeatherForecast/Models/Requests/PutShopItemRequestModel.cs b/webapi/WeatherForecast/Models/Requests/PutShopItemRequestModel.cs index c3a3b00..2048d69 100644 --- a/webapi/WeatherForecast/Models/Requests/PutShopItemRequestModel.cs +++ b/webapi/WeatherForecast/Models/Requests/PutShopItemRequestModel.cs @@ -4,15 +4,42 @@ using Core.DomainObjects; using Core.DomainObjects.Documents; namespace WeatherForecast.Models.Requests { + + /// + /// + /// public class PutShopItemRequestModel : PostItemRequestModelBase { + /// + /// + /// 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 { + /// + /// + /// + /// + public override ShopItem ToDomainObject() => new() { L10n = L10n.Select(x => x.ToDomainObject()).ToList(), // Images // Author diff --git a/webapi/WeatherForecast/Models/Responses/GetBlogCategoriesResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetBlogCategoriesResponseModel.cs index a21576a..7090053 100644 --- a/webapi/WeatherForecast/Models/Responses/GetBlogCategoriesResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetBlogCategoriesResponseModel.cs @@ -1,7 +1,15 @@ using Core.Abstractions.Models; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetBlogCategoriesResponseModel : ResponseModelBase { + + /// + /// + /// public List Items { get; set; } } } diff --git a/webapi/WeatherForecast/Models/Responses/GetBlogItemResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetBlogItemResponseModel.cs index 8487e1c..34a71f0 100644 --- a/webapi/WeatherForecast/Models/Responses/GetBlogItemResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetBlogItemResponseModel.cs @@ -6,17 +6,38 @@ using Core.Models; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetBlogItemResponseModel : PostItemResponseModelBase { + /// + /// + /// public uint? ReadTime { get; set; } + /// + /// + /// public uint? Likes { get; set; } + /// + /// + /// + /// + /// public GetBlogItemResponseModel(BlogItem blogItem, List categories) : base(blogItem, categories) { ReadTime = blogItem.ReadTime; Likes = blogItem.Likes; } + /// + /// + /// + /// + /// + /// public GetBlogItemResponseModel(BlogItem blogItem, List categories, Locales locale) : base(blogItem, categories, locale) { ReadTime = blogItem.ReadTime; Likes = blogItem.Likes; diff --git a/webapi/WeatherForecast/Models/Responses/GetBlogItemsResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetBlogItemsResponseModel.cs index 71aa8af..6852c2b 100644 --- a/webapi/WeatherForecast/Models/Responses/GetBlogItemsResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetBlogItemsResponseModel.cs @@ -2,6 +2,10 @@ using Core.Models; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetBlogItemsResponseModel : PaginationModelBase { @@ -10,7 +14,12 @@ namespace WeatherForecast.Models.Responses { //public List Categories { get; set; } - + /// + /// + /// + /// + /// + /// public GetBlogItemsResponseModel(int currentPage, int totalPages, List items) : base(currentPage, totalPages, items) { } diff --git a/webapi/WeatherForecast/Models/Responses/GetCategoryItemResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetCategoryItemResponseModel.cs index 72e5e11..780b6f9 100644 --- a/webapi/WeatherForecast/Models/Responses/GetCategoryItemResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetCategoryItemResponseModel.cs @@ -4,16 +4,41 @@ using Core.Enumerations; using WeatherForecast.Models.L10n; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetCategoryItemResponseModel : ResponseModelBase { + + /// + /// + /// public Guid Id { get; set; } + + /// + /// + /// public Guid SiteId { get; set; } + + /// + /// + /// public string? Slug { get; set; } + + /// + /// + /// public string? Text { get; set; } + /// + /// + /// public List? L10n { get; set; } - - + /// + /// + /// + /// public GetCategoryItemResponseModel(Category category) { Id = category.Id; SiteId = category.SiteId; @@ -21,6 +46,11 @@ namespace WeatherForecast.Models.Responses { L10n = category.L10n.Select(x => new CategoryL10nModel(x)).ToList(); } + /// + /// + /// + /// + /// public GetCategoryItemResponseModel(Category category, Locales locale) { Id = category.Id; SiteId = category.SiteId; diff --git a/webapi/WeatherForecast/Models/Responses/GetContentResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetContentResponseModel.cs index c93e5e4..a80a6bc 100644 --- a/webapi/WeatherForecast/Models/Responses/GetContentResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetContentResponseModel.cs @@ -1,24 +1,57 @@ using Core.Abstractions.Models; -using Core.DomainObjects; using Core.DomainObjects.Documents; using WeatherForecast.Models.Pages; -using WeatherForecast.Models.PageSections; namespace WeatherForecast.Models.Responses { + /// + /// + /// public class GetContentResponseModel : ResponseModelBase { + + /// + /// + /// public string SiteName { get; set; } + + /// + /// + /// public string SiteUrl { get; set; } + /// + /// + /// public HeaderModel Header { get; set; } + /// + /// + /// public LocalizationModel Localization { get; set; } + /// + /// + /// public List Routes { get; set; } + + /// + /// + /// public List AdminRoutes { get; set; } + + /// + /// + /// public List ServiceRoutes { get; set; } + /// + /// + /// public List TopMenu { get; set; } + + /// + /// + /// public List SideMenu { get; set; } /// @@ -36,16 +69,40 @@ namespace WeatherForecast.Models.Responses { /// public ShopItemPageModel ShopItem { get; set; } + /// + /// + /// public ShopCartPageModel ShopCart { get; set; } + + /// + /// + /// public ShopCheckoutPageModel ShopCheckout { get; set; } - + /// + /// + /// public BlogCatalogPageModel BlogCatalog { get; set; } + + /// + /// + /// public BlogItemPageModel BlogItem { get; set; } + /// + /// + /// public SignInPageModel SignIn { get; set; } + + /// + /// + /// public SignUpPageModel SignUp { get; set; } + /// + /// + /// + /// public GetContentResponseModel(Content domainObject) { SiteName = domainObject.SiteName; diff --git a/webapi/WeatherForecast/Models/Responses/GetShopCartItemResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetShopCartItemResponseModel.cs index f4cf83d..3c44e23 100644 --- a/webapi/WeatherForecast/Models/Responses/GetShopCartItemResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetShopCartItemResponseModel.cs @@ -3,20 +3,73 @@ using Core.DomainObjects.Documents; using Core.Enumerations; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetShopCartItemResponseModel : ResponseModelBase { + + /// + /// + /// public string Slug { get; set; } + + /// + /// + /// public string Sku { 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 decimal Price { get; set; } + + /// + /// + /// public decimal? NewPrice { get; set; } + + /// + /// + /// public uint? Quantity { get; set; } + /// + /// + /// public GetShopCartItemResponseModel() { } + /// + /// + /// + /// + /// + /// public GetShopCartItemResponseModel(ShopItem shopItem, ShopCartItem shopCartItem, Locales locale) { Sku = shopItem.Sku; diff --git a/webapi/WeatherForecast/Models/Responses/GetShopItemResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetShopItemResponseModel.cs index 61ee1c8..d22c778 100644 --- a/webapi/WeatherForecast/Models/Responses/GetShopItemResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetShopItemResponseModel.cs @@ -5,14 +5,42 @@ using Core.Enumerations; using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models { + + /// + /// + /// public class GetShopItemResponseModel : PostItemResponseModelBase { + /// + /// + /// public string Sku { get; set; } + + /// + /// + /// public decimal? Rating { get; set; } + + /// + /// + /// public decimal Price { get; set; } + + /// + /// + /// public decimal? NewPrice { get; set; } + + /// + /// + /// public uint? Quantity { get; set; } + /// + /// + /// + /// + /// public GetShopItemResponseModel(ShopItem shopCatalogItem, List categories) : base(shopCatalogItem, categories) { Sku = shopCatalogItem.Sku; Rating = shopCatalogItem.Rating; @@ -21,6 +49,12 @@ namespace WeatherForecast.Models { Quantity = shopCatalogItem.Quantity; } + /// + /// + /// + /// + /// + /// public GetShopItemResponseModel(ShopItem shopCatalogItem, List categories, Locales locale) : base(shopCatalogItem, categories, locale) { Sku = shopCatalogItem.Sku; Rating = shopCatalogItem.Rating; diff --git a/webapi/WeatherForecast/Models/Responses/GetShopItemsResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetShopItemsResponseModel.cs index ec66802..8a31e71 100644 --- a/webapi/WeatherForecast/Models/Responses/GetShopItemsResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetShopItemsResponseModel.cs @@ -2,7 +2,18 @@ using Core.Models; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetShopItemsResponseModel : PaginationModelBase { + + /// + /// + /// + /// + /// + /// public GetShopItemsResponseModel(int currentPage, int totalPages, List items) : base(currentPage, totalPages, items) { } } diff --git a/webapi/WeatherForecast/Models/Responses/GetWeatherForecastResponseModel.cs b/webapi/WeatherForecast/Models/Responses/GetWeatherForecastResponseModel.cs index bd5b082..3c0154e 100644 --- a/webapi/WeatherForecast/Models/Responses/GetWeatherForecastResponseModel.cs +++ b/webapi/WeatherForecast/Models/Responses/GetWeatherForecastResponseModel.cs @@ -1,13 +1,30 @@ using Core.Abstractions.Models; namespace WeatherForecast.Models.Responses { + + /// + /// + /// public class GetWeatherForecastResponseModel : ResponseModelBase { + + /// + /// + /// public DateTime Date { get; set; } + /// + /// + /// public int TemperatureC { get; set; } + /// + /// + /// public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + /// + /// + /// public string? Summary { get; set; } } } diff --git a/webapi/WeatherForecast/Models/ReviewerModel.cs b/webapi/WeatherForecast/Models/ReviewerModel.cs index 9cdebd3..8ab9337 100644 --- a/webapi/WeatherForecast/Models/ReviewerModel.cs +++ b/webapi/WeatherForecast/Models/ReviewerModel.cs @@ -2,10 +2,26 @@ using WeatherForecast.Models.Abstractions; namespace WeatherForecast.Models { + + /// + /// + /// public class ReviewerModel : PersonModelBase { + + /// + /// + /// public string FullName { get; set; } + + /// + /// + /// public string Position { get; set; } + /// + /// + /// + /// public ReviewerModel(Reviewer reviewer) : base(reviewer) { FullName = reviewer.FullName; Position = reviewer.Position; diff --git a/webapi/WeatherForecast/Models/RouteModel.cs b/webapi/WeatherForecast/Models/RouteModel.cs index 4c4c614..4a5ebd0 100644 --- a/webapi/WeatherForecast/Models/RouteModel.cs +++ b/webapi/WeatherForecast/Models/RouteModel.cs @@ -1,9 +1,29 @@ namespace WeatherForecast.Models { + + /// + /// + /// public class RouteModel { + + /// + /// + /// public string Target { get; set; } + + /// + /// + /// public string? Component { get; set; } + + /// + /// + /// public List? ChildRoutes { get; set; } + /// + /// + /// + /// public RouteModel(Core.DomainObjects.Route route) { Target = route.Target; Component = route.Component; diff --git a/webapi/WeatherForecast/Models/TestimonialModel.cs b/webapi/WeatherForecast/Models/TestimonialModel.cs index 130dd2c..3a36e34 100644 --- a/webapi/WeatherForecast/Models/TestimonialModel.cs +++ b/webapi/WeatherForecast/Models/TestimonialModel.cs @@ -1,10 +1,26 @@ using Core.DomainObjects; namespace WeatherForecast.Models { + + /// + /// + /// public class TestimonialModel { + + /// + /// + /// public string Text { get; set; } + + /// + /// + /// public ReviewerModel Reviewer { get; set; } + /// + /// + /// + /// public TestimonialModel(Testimonial testimonial) { Text = testimonial.Text; Reviewer = new ReviewerModel(testimonial.Reviewer); diff --git a/webapi/WeatherForecast/Program.cs b/webapi/WeatherForecast/Program.cs index 93f7582..f3e6bf3 100644 --- a/webapi/WeatherForecast/Program.cs +++ b/webapi/WeatherForecast/Program.cs @@ -1,11 +1,25 @@ using Serilog; namespace WeatherForecast { + + /// + /// + /// public class Program { + + /// + /// + /// + /// public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } + /// + /// + /// + /// + /// public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSerilog((hostContext, services, configuration) => { diff --git a/webapi/WeatherForecast/Services/BlogItemService.cs b/webapi/WeatherForecast/Services/BlogItemService.cs index 8bbca90..154de73 100644 --- a/webapi/WeatherForecast/Services/BlogItemService.cs +++ b/webapi/WeatherForecast/Services/BlogItemService.cs @@ -7,19 +7,66 @@ using WeatherForecast.Models.Responses; namespace WeatherForecast.Services { + /// + /// + /// public interface IBlogItemService { + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Post(Guid siteId, PostBlogItemRequestModel requestModel); - (GetBlogItemResponseModel, IDomainResult) Get(Guid siteId, Guid blogId); - (GetBlogItemResponseModel, IDomainResult) GetSlug(Guid siteId, string slug); + + /// + /// + /// + /// + /// + /// + (GetBlogItemResponseModel?, IDomainResult) Get(Guid siteId, Guid blogId); + + /// + /// + /// + /// + /// + /// + (GetBlogItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug); + + /// + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Update(Guid siteId, Guid blogId, PutBlogItemRequestModel requestData); + + /// + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId, Guid blogId); } + /// + /// + /// public class BlogItemService : IBlogItemService { private readonly ILogger _logger; private readonly IBlogCatalogDataProvider _blogCatalogDataProvider; private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// + /// public BlogItemService( ILogger logger, IBlogCatalogDataProvider blogCatalogDataProvider, @@ -30,10 +77,23 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Post(Guid siteId, PostBlogItemRequestModel requestModel) { throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// public (GetBlogItemResponseModel?, IDomainResult) Get(Guid siteId, Guid blogId) { var (item, result) = _blogCatalogDataProvider.Get(siteId, blogId); @@ -52,6 +112,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(new GetBlogItemResponseModel(item, categories)); } + /// + /// + /// + /// + /// + /// public (GetBlogItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug) { var (item, result) = _blogCatalogDataProvider.GetBySlug(siteId, slug); @@ -72,10 +138,25 @@ namespace WeatherForecast.Services { return IDomainResult.Success(new GetBlogItemResponseModel(item, categories, locale)); } + /// + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Update(Guid siteId, Guid blogId, PutBlogItemRequestModel requestData) { throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId, Guid blogId) { throw new NotImplementedException(); } diff --git a/webapi/WeatherForecast/Services/BlogItemsService.cs b/webapi/WeatherForecast/Services/BlogItemsService.cs index 169953f..171e23e 100644 --- a/webapi/WeatherForecast/Services/BlogItemsService.cs +++ b/webapi/WeatherForecast/Services/BlogItemsService.cs @@ -1,4 +1,5 @@ -using Core.DomainObjects; +using Core.Abstractions; +using Core.DomainObjects; using Core.Enumerations; using DataProviders; using DomainResults.Common; @@ -6,17 +7,46 @@ 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); + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + (GetBlogItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? locale, string? searchText); + + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId); } + /// + /// + /// public class BlogItemsService : IBlogItemsService { private readonly ILogger _logger; private readonly IBlogCatalogDataProvider _blogCatalogDataProvider; private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// + /// public BlogItemsService( ILogger logger, IBlogCatalogDataProvider blogCatalogDataProvider, @@ -27,7 +57,17 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } - public (GetBlogItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText) { + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public (GetBlogItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? locale, string? searchText) { var (items, result) = _blogCatalogDataProvider.GetAll(siteId, currentPage > 0 ? ((currentPage - 1) * itemsPerPage) : 0, itemsPerPage); if (!result.IsSuccess || items == null) return (null, result); @@ -42,7 +82,11 @@ namespace WeatherForecast.Services { categories.Add(cat); } - blogItems.Add(new GetBlogItemResponseModel(item, categories, locale)); + + if(locale != null) + blogItems.Add(new GetBlogItemResponseModel(item, categories, Enumeration.FromDisplayName(locale) ?? Locales.Us)); + else + blogItems.Add(new GetBlogItemResponseModel(item, categories)); } return blogItems.Count > 0 @@ -50,6 +94,11 @@ namespace WeatherForecast.Services { : IDomainResult.NotFound(); } + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId) => _blogCatalogDataProvider.DeleteAll(siteId); } } diff --git a/webapi/WeatherForecast/Services/CategoryItemService.cs b/webapi/WeatherForecast/Services/CategoryItemService.cs index eb3629f..9bb3cd0 100644 --- a/webapi/WeatherForecast/Services/CategoryItemService.cs +++ b/webapi/WeatherForecast/Services/CategoryItemService.cs @@ -5,19 +5,67 @@ using WeatherForecast.Models.Requests; using WeatherForecast.Models.Responses; namespace WeatherForecast.Services { + + /// + /// + /// public interface ICategoryItemService { + + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Post(Guid siteId, PostCategoryItemRequestModel requestModel); + + /// + /// + /// + /// + /// + /// (GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, Guid categoryId); + + /// + /// + /// + /// + /// + /// (GetCategoryItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug); + + /// + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData); + + /// + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId, Guid categoryId); } + /// + /// + /// public class CategoryItemService : ICategoryItemService { - ILogger _logger; - ICategoryDataProvider _categoryDataProvider; + private readonly ILogger _logger; + private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// public CategoryItemService( ILogger logger, ICategoryDataProvider categoryDataProvider @@ -26,6 +74,12 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Post(Guid siteId, PostCategoryItemRequestModel requestModel) { var (_, getResult) = _categoryDataProvider.GetBySlugs(siteId, requestModel.L10n.Select(x => x.Slug).ToList()); if (getResult.IsSuccess) @@ -43,6 +97,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(id); } + /// + /// + /// + /// + /// + /// public (GetCategoryItemResponseModel?, IDomainResult) Get(Guid siteId, Guid categoryId) { var (item, result) = _categoryDataProvider.Get(siteId, categoryId); if (!result.IsSuccess || item == null) @@ -51,6 +111,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(new GetCategoryItemResponseModel(item)); } + /// + /// + /// + /// + /// + /// public (GetCategoryItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug) { var (item, result) = _categoryDataProvider.GetBySlug(siteId, slug); if (!result.IsSuccess || item == null) @@ -61,6 +127,13 @@ namespace WeatherForecast.Services { return IDomainResult.Success(new GetCategoryItemResponseModel(item, locale)); } + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Update(Guid siteId, Guid categoryId, PutCategoryItemRequestModel requestData) { var (item, result) = _categoryDataProvider.Get(siteId, categoryId); if (!result.IsSuccess || item == null) @@ -80,6 +153,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(item.Id); } + /// + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId, Guid categoryId) { var (item, getResult) = _categoryDataProvider.Get(siteId, categoryId); if (!getResult.IsSuccess || item == null) diff --git a/webapi/WeatherForecast/Services/CategoryItemsService.cs b/webapi/WeatherForecast/Services/CategoryItemsService.cs index a153eb1..c0fe192 100644 --- a/webapi/WeatherForecast/Services/CategoryItemsService.cs +++ b/webapi/WeatherForecast/Services/CategoryItemsService.cs @@ -6,16 +6,40 @@ using WeatherForecast.Models.Responses; namespace WeatherForecast.Services { + /// + /// + /// public interface ICategoryItemsService { + + /// + /// + /// + /// + /// + /// (List?, IDomainResult) Get(Guid siteId, string? locale); + + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId); } + /// + /// + /// public class CategoryItemsService : ICategoryItemsService { private readonly ILogger _logger; private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// public CategoryItemsService( ILogger logger, ICategoryDataProvider categoryDataProvider @@ -24,6 +48,12 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } + /// + /// + /// + /// + /// + /// public (List?, IDomainResult) Get(Guid siteId, string? locale) { var (items, result) = _categoryDataProvider.GetAll(siteId); if (!result.IsSuccess || items == null) @@ -36,6 +66,11 @@ namespace WeatherForecast.Services { return IDomainResult.Success(items.Select(x => new GetCategoryItemResponseModel(x)).ToList()); } + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId) => _categoryDataProvider.DeleteAll(siteId); } } diff --git a/webapi/WeatherForecast/Services/ContentService.cs b/webapi/WeatherForecast/Services/ContentService.cs index 1387770..f134ff1 100644 --- a/webapi/WeatherForecast/Services/ContentService.cs +++ b/webapi/WeatherForecast/Services/ContentService.cs @@ -5,15 +5,33 @@ using WeatherForecast.Models.Responses; namespace WeatherForecast.Services { + /// + /// + /// public interface IContentService { + + /// + /// + /// + /// + /// + /// (GetContentResponseModel?, IDomainResult) GetContent(Guid siteId, string locale); } + /// + /// + /// public class ContentService : IContentService { private readonly ILogger _logger; private readonly IContentDataProvider _contentDataProvider; + /// + /// + /// + /// + /// public ContentService( ILogger logger, IContentDataProvider contentDataprovider @@ -22,6 +40,12 @@ namespace WeatherForecast.Services { _contentDataProvider = contentDataprovider; } + /// + /// + /// + /// + /// + /// public (GetContentResponseModel?, IDomainResult) GetContent(Guid siteId, string locale) { var (content, result) = _contentDataProvider.Get(siteId, locale); @@ -31,6 +55,4 @@ namespace WeatherForecast.Services { return IDomainResult.Success(new GetContentResponseModel(content)); } } - - } diff --git a/webapi/WeatherForecast/Services/ShopCartItemService.cs b/webapi/WeatherForecast/Services/ShopCartItemService.cs index 2fa759c..383fa85 100644 --- a/webapi/WeatherForecast/Services/ShopCartItemService.cs +++ b/webapi/WeatherForecast/Services/ShopCartItemService.cs @@ -9,19 +9,66 @@ using WeatherForecast.Models.Responses; 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, Locales locale); + + /// + /// + /// + /// + /// + /// + /// + /// + (GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku, string locale = "en-US"); + + /// + /// + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Update(Guid siteId, Guid userId, string sku, PutShopCartItemRequestModel requestData); + + /// + /// + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId, Guid userId, string sku); } + /// + /// + /// public class ShopCartItemService : IShopCartItemService { - ILogger _logger; - IShopCatalogDataProvider _shopCatalogDataProvider; - IShopCartDataProvider _shopCartDataProvider; + private readonly ILogger _logger; + private readonly IShopCatalogDataProvider _shopCatalogDataProvider; + private readonly IShopCartDataProvider _shopCartDataProvider; + /// + /// + /// + /// + /// + /// public ShopCartItemService( ILogger logger, IShopCatalogDataProvider shopCatalogDataProvider, @@ -32,6 +79,14 @@ namespace WeatherForecast.Services { _shopCartDataProvider = shopCartDataprovider; } + /// + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Post(Guid siteId, Guid userId, string sku, PostShopCartItemRequestModel requestModel) { var (_, getResult) = _shopCartDataProvider.Get(siteId, userId, sku); if (getResult.IsSuccess) @@ -51,7 +106,15 @@ namespace WeatherForecast.Services { return IDomainResult.Success(id); } - public (GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku, Locales locale) { + /// + /// + /// + /// + /// + /// + /// + /// + public (GetShopCartItemResponseModel?, IDomainResult) Get(Guid siteId, Guid userId, string sku, string locale = "en-US") { var (cartItem, getCartItemResult) = _shopCartDataProvider.Get(siteId, userId, sku); if (!getCartItemResult.IsSuccess || cartItem == null) @@ -61,9 +124,17 @@ namespace WeatherForecast.Services { if (!result.IsSuccess || item == null) return (null, result); - return IDomainResult.Success(new GetShopCartItemResponseModel(item, cartItem, locale)); + return IDomainResult.Success(new GetShopCartItemResponseModel(item, cartItem, Enumeration.FromDisplayName(locale))); } + /// + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Update(Guid siteId, Guid userId, string sku, PutShopCartItemRequestModel requestData) { var (item, getResult) = _shopCartDataProvider.Get(siteId, userId, sku); if (!getResult.IsSuccess || item == null) @@ -86,6 +157,13 @@ namespace WeatherForecast.Services { return IDomainResult.Success(item.Id); } + /// + /// + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId, Guid userId, string sku) { var (item, getResult) = _shopCartDataProvider.Get(siteId, userId, sku); if (!getResult.IsSuccess || item == null) diff --git a/webapi/WeatherForecast/Services/ShopCartItemsService.cs b/webapi/WeatherForecast/Services/ShopCartItemsService.cs index 9b7323c..eb8240a 100644 --- a/webapi/WeatherForecast/Services/ShopCartItemsService.cs +++ b/webapi/WeatherForecast/Services/ShopCartItemsService.cs @@ -5,20 +5,48 @@ using WeatherForecast.Models.Responses; using DataProviders; using Core.Enumerations; +using Core.Abstractions; namespace WeatherForecast.Services { + /// + /// + /// public interface IShopCartItemsService { - (List?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale); + + /// + /// + /// + /// + /// + /// + /// + (List?, IDomainResult) Get(Guid siteId, Guid userId, string locale = "en-US"); + + /// + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId, Guid userId); } + /// + /// + /// public class ShopCartItemsService : IShopCartItemsService { - ILogger _logger; - IShopCatalogDataProvider _shopCatalogDataProvider; - IShopCartDataProvider _shopCartDataProvider; + private readonly ILogger _logger; + private readonly IShopCatalogDataProvider _shopCatalogDataProvider; + private readonly IShopCartDataProvider _shopCartDataProvider; + /// + /// + /// + /// + /// + /// public ShopCartItemsService( ILogger logger, IShopCatalogDataProvider shopCatalogDataProvider, @@ -29,7 +57,14 @@ namespace WeatherForecast.Services { _shopCartDataProvider = shopCartDataprovider; } - public (List?, IDomainResult) Get(Guid siteId, Guid userId, Locales locale) { + /// + /// + /// + /// + /// + /// + /// + public (List?, IDomainResult) Get(Guid siteId, Guid userId, string locale = "en-US") { var (cartItems, getCartItemsResult) = _shopCartDataProvider.GetAll(siteId, userId); if (!getCartItemsResult.IsSuccess || cartItems == null) @@ -41,7 +76,7 @@ namespace WeatherForecast.Services { if (!result.IsSuccess || item == null) return (null, result); - items.Add(new GetShopCartItemResponseModel(item, cartItem, locale)); + items.Add(new GetShopCartItemResponseModel(item, cartItem, Enumeration.FromDisplayName(locale))); } return items.Count > 0 @@ -49,6 +84,12 @@ namespace WeatherForecast.Services { : IDomainResult.NotFound?>(); } + /// + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId, Guid userId) => _shopCartDataProvider.DeleteAll(siteId, userId); } } diff --git a/webapi/WeatherForecast/Services/ShopItemService.cs b/webapi/WeatherForecast/Services/ShopItemService.cs index 7e1da27..5cb41a9 100644 --- a/webapi/WeatherForecast/Services/ShopItemService.cs +++ b/webapi/WeatherForecast/Services/ShopItemService.cs @@ -9,21 +9,69 @@ using WeatherForecast.Models.Requests; namespace WeatherForecast.Services { + /// + /// + /// public interface IShopItemService { + + /// + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel); - (GetShopItemResponseModel, IDomainResult) Get(Guid siteId, string sku); - (GetShopItemResponseModel, IDomainResult) GetSlug(Guid siteId, string slug); + /// + /// + /// + /// + /// + /// + (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku); + + /// + /// + /// + /// + /// + /// + (GetShopItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug); + + /// + /// + /// + /// + /// + /// + /// (Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData); + + /// + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId, string sku); } + /// + /// + /// public class ShopItemService : IShopItemService { private readonly ILogger _logger; private readonly IShopCatalogDataProvider _shopCatalogDataProvider; private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// + /// public ShopItemService( ILogger logger, IShopCatalogDataProvider shopCatalogDataProvider, @@ -34,6 +82,13 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Post(Guid siteId, string sku, PostShopItemRequestModel requestModel) { var (_, getResult) = _shopCatalogDataProvider.Get(siteId, sku); if (getResult.IsSuccess) @@ -71,6 +126,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(id); } + /// + /// + /// + /// + /// + /// public (GetShopItemResponseModel?, IDomainResult) Get(Guid siteId, string sku) { var (item, result) = _shopCatalogDataProvider.Get(siteId, sku); @@ -78,18 +139,26 @@ namespace WeatherForecast.Services { return (null, result); var categories = new List(); - foreach (var catId in item.Categories) { - var (category, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); - if (!getCategoryResult.IsSuccess || category == null) - return (null, getCategoryResult); + if (item.Categories != null) { + foreach (var catId in item.Categories) { + var (category, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); + if (!getCategoryResult.IsSuccess || category == null) + return (null, getCategoryResult); - categories.Add(category); + categories.Add(category); + } } return IDomainResult.Success(new GetShopItemResponseModel(item, categories)); } - public (GetShopItemResponseModel, IDomainResult) GetSlug(Guid siteId, string slug) { + /// + /// + /// + /// + /// + /// + public (GetShopItemResponseModel?, IDomainResult) GetSlug(Guid siteId, string slug) { var (item, result) = _shopCatalogDataProvider.GetBySlug(siteId, slug); if (!result.IsSuccess || item == null) @@ -98,17 +167,26 @@ namespace WeatherForecast.Services { var locale = item.L10n.SingleOrDefault(x => x.Slug == slug)?.Locale ?? Locales.Us; var categories = new List(); - foreach (var catId in item.Categories) { - var (category, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); - if (!getCategoryResult.IsSuccess || category == null) - return (null, getCategoryResult); + if (item.Categories != null) { + foreach (var catId in item.Categories) { + var (category, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); + if (!getCategoryResult.IsSuccess || category == null) + return (null, getCategoryResult); - categories.Add(category); + categories.Add(category); + } } return IDomainResult.Success(new GetShopItemResponseModel(item, categories, locale)); } + /// + /// + /// + /// + /// + /// + /// public (Guid?, IDomainResult) Update(Guid siteId, string sku, PutShopItemRequestModel requestData) { var (item, getResult) = _shopCatalogDataProvider.Get(siteId, sku); if (!getResult.IsSuccess || item == null) @@ -131,6 +209,12 @@ namespace WeatherForecast.Services { return IDomainResult.Success(item.Id); } + /// + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId, string sku) { var (item, getResult) = _shopCatalogDataProvider.Get(siteId, sku); if (!getResult.IsSuccess || item == null) diff --git a/webapi/WeatherForecast/Services/ShopItemsService.cs b/webapi/WeatherForecast/Services/ShopItemsService.cs index c900d40..256c9a7 100644 --- a/webapi/WeatherForecast/Services/ShopItemsService.cs +++ b/webapi/WeatherForecast/Services/ShopItemsService.cs @@ -1,4 +1,5 @@ -using Core.DomainObjects; +using Core.Abstractions; +using Core.DomainObjects; using Core.Enumerations; using DataProviders; using DomainResults.Common; @@ -7,16 +8,45 @@ using WeatherForecast.Models.Responses; namespace WeatherForecast.Services { + /// + /// + /// public interface IShopItemsService { - (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText); + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? locale, string? searchText); + + /// + /// + /// + /// + /// IDomainResult Delete(Guid siteId); } + /// + /// + /// public class ShopItemsService : IShopItemsService { private readonly ILogger _logger; private readonly IShopCatalogDataProvider _shopCatalogDataProvider; private readonly ICategoryDataProvider _categoryDataProvider; + /// + /// + /// + /// + /// + /// public ShopItemsService( ILogger logger, IShopCatalogDataProvider shopCatalogDataprovider, @@ -27,7 +57,17 @@ namespace WeatherForecast.Services { _categoryDataProvider = categoryDataProvider; } - public (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, Locales locale, string? searchText) { + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public (GetShopItemsResponseModel?, IDomainResult) Get(Guid siteId, Guid? category, int currentPage, int itemsPerPage, string? locale, string? searchText) { var (items, result) = _shopCatalogDataProvider.GetAll(siteId, currentPage > 0 ? ((currentPage - 1) * itemsPerPage) : 0, itemsPerPage); if (!result.IsSuccess || items == null) @@ -36,15 +76,22 @@ namespace WeatherForecast.Services { var shopItems = new List(); foreach (var item in items) { - var categories = new List(); - foreach (var catId in item.Categories) { - var (cat, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); - if (!getCategoryResult.IsSuccess || cat == null) - return (null, getCategoryResult); - categories.Add(cat); + var categories = new List(); + if (item.Categories != null) { + foreach (var catId in item.Categories) { + var (cat, getCategoryResult) = _categoryDataProvider.Get(siteId, catId); + if (!getCategoryResult.IsSuccess || cat == null) + return (null, getCategoryResult); + + categories.Add(cat); + } } - shopItems.Add(new GetShopItemResponseModel(item, categories, locale)); + + if(locale != null) + shopItems.Add(new GetShopItemResponseModel(item, categories, Enumeration.FromDisplayName(locale) ?? Locales.Us)); + else + shopItems.Add(new GetShopItemResponseModel(item, categories)); } return shopItems.Count > 0 @@ -52,7 +99,11 @@ namespace WeatherForecast.Services { : IDomainResult.NotFound(); } - + /// + /// + /// + /// + /// public IDomainResult Delete(Guid siteId) => _shopCatalogDataProvider.DeleteAll(siteId); } } diff --git a/webapi/WeatherForecast/Startup.cs b/webapi/WeatherForecast/Startup.cs index 6e6ebcc..94590cf 100644 --- a/webapi/WeatherForecast/Startup.cs +++ b/webapi/WeatherForecast/Startup.cs @@ -8,17 +8,28 @@ using DataProviders.Extensions; using System.Text.Json.Serialization; namespace WeatherForecast { + + /// + /// + /// public class Startup { - public IConfiguration _configuration { get; } + private readonly IConfiguration _configuration; - string MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; + private const string MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; + /// + /// + /// + /// public Startup(IConfiguration configuration) { _configuration = configuration; } - // This method gets called by the runtime. Use this method to add services to the container. + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// public void ConfigureServices(IServiceCollection services) { string serverHostName = Environment.MachineName; @@ -38,21 +49,23 @@ namespace WeatherForecast { services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull); - // configure jwt authentication - services.AddAuthentication(options => { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }).AddJwtBearer(options => { - options.RequireHttpsMetadata = false; - options.SaveToken = true; - options.TokenValidationParameters = new TokenValidationParameters { - ValidateIssuerSigningKey = true, - IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(appSettings.Secret)), - ValidateIssuer = false, - ValidateAudience = false - }; - }); - + #region configure jwt authentication + if (appSettings.Secret != null) { + services.AddAuthentication(options => { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }).AddJwtBearer(options => { + options.RequireHttpsMetadata = false; + options.SaveToken = true; + options.TokenValidationParameters = new TokenValidationParameters { + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(appSettings.Secret)), + ValidateIssuer = false, + ValidateAudience = false + }; + }); + } + #endregion // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-3.1#use-httpcontext-from-custom-components services.AddHttpContextAccessor(); @@ -137,9 +150,12 @@ namespace WeatherForecast { #endregion } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { - + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage();