From c48f9ed9804db2105ada24f7478fa85f51c33a4f Mon Sep 17 00:00:00 2001 From: Maksym Sadovnychyy Date: Sun, 7 Aug 2022 19:48:03 +0200 Subject: [PATCH] (feat): mapping content collection --- .../DomainObjects/AddressSectionBase.cs | 21 ++ .../DomainObjects/PostItemBase.cs | 2 +- .../{Entities => DomainObjects}/Address.cs | 2 +- webapi/Core/DomainObjects/BlogItem.cs | 14 - .../{Entities => DomainObjects}/Contact.cs | 2 +- .../Core/DomainObjects/Documents/BlogItem.cs | 5 +- .../Core/DomainObjects/Documents/Content.cs | 10 +- webapi/Core/DomainObjects/Documents/User.cs | 2 +- webapi/Core/DomainObjects/FormItem.cs | 2 + webapi/Core/DomainObjects/Header.cs | 6 +- webapi/Core/DomainObjects/Localization.cs | 12 +- .../PageSections/BillingAddressSection.cs | 14 + .../PageSections/FeaturedBlogSection.cs | 2 +- .../PageSections/PaymentSection.cs | 20 ++ .../PageSections/ProductsSection.cs | 25 ++ .../PageSections/RelatedProductsSection.cs | 3 + .../PageSections/SettingsSection.cs | 17 + .../PageSections/ShippingAddressSection.cs | 14 + .../PageSections/ShopItemsSection.cs | 17 + .../PageSections/SummarySection.cs | 21 ++ .../DomainObjects/Pages/BlogCatalogPage.cs | 4 +- .../Core/DomainObjects/Pages/BlogItemPage.cs | 2 + webapi/Core/DomainObjects/Pages/HomePage.cs | 1 + .../Core/DomainObjects/Pages/ShopCartPage.cs | 16 + .../DomainObjects/Pages/ShopCatalogPage.cs | 5 + .../DomainObjects/Pages/ShopCheckoutPage.cs | 31 ++ .../Core/DomainObjects/Pages/ShopItemPage.cs | 1 + webapi/Core/DomainObjects/Pages/SignUpPage.cs | 32 ++ webapi/Core/DomainObjects/Pages/SingInPage.cs | 28 ++ webapi/Core/Enumerations/ReservedWords.cs | 24 ++ .../Abstractions/DataProviderBase.cs | 2 +- webapi/DataProviders/ContentDataProvider.cs | 4 +- webapi/DataProviders/Mappings.cs | 293 ++++++++++++++- .../Controllers/ContentController.cs | 336 +++++++++--------- .../Services/ContentService.cs | 32 +- webapi/WeatherForecast/Startup.cs | 6 + webapi/WeatherForecast/WeatherForecast.csproj | 2 + webapi/WeatherForecast/appsettings.json | 7 +- 38 files changed, 833 insertions(+), 204 deletions(-) create mode 100644 webapi/Core/Abstractions/DomainObjects/AddressSectionBase.cs rename webapi/Core/{Entities => DomainObjects}/Address.cs (90%) delete mode 100644 webapi/Core/DomainObjects/BlogItem.cs rename webapi/Core/{Entities => DomainObjects}/Contact.cs (88%) create mode 100644 webapi/Core/DomainObjects/PageSections/BillingAddressSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/PaymentSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/ProductsSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/SettingsSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/ShippingAddressSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/ShopItemsSection.cs create mode 100644 webapi/Core/DomainObjects/PageSections/SummarySection.cs create mode 100644 webapi/Core/DomainObjects/Pages/ShopCartPage.cs create mode 100644 webapi/Core/DomainObjects/Pages/ShopCheckoutPage.cs create mode 100644 webapi/Core/DomainObjects/Pages/SignUpPage.cs create mode 100644 webapi/Core/DomainObjects/Pages/SingInPage.cs create mode 100644 webapi/Core/Enumerations/ReservedWords.cs diff --git a/webapi/Core/Abstractions/DomainObjects/AddressSectionBase.cs b/webapi/Core/Abstractions/DomainObjects/AddressSectionBase.cs new file mode 100644 index 0000000..aee1eef --- /dev/null +++ b/webapi/Core/Abstractions/DomainObjects/AddressSectionBase.cs @@ -0,0 +1,21 @@ +using Core.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.Abstractions.DomainObjects { + public abstract class AddressSectionBase : PageSectionBase { + public FormItem FirstName { get; set; } + public FormItem LastName { get; set; } + + public FormItem Address { get; set; } + public FormItem Address2 { get; set; } + public FormItem Country { get; set; } + public FormItem State { get; set; } + + public FormItem City { get; set; } + public FormItem Zip { get; set; } + } +} diff --git a/webapi/Core/Abstractions/DomainObjects/PostItemBase.cs b/webapi/Core/Abstractions/DomainObjects/PostItemBase.cs index c0799f3..3e8692f 100644 --- a/webapi/Core/Abstractions/DomainObjects/PostItemBase.cs +++ b/webapi/Core/Abstractions/DomainObjects/PostItemBase.cs @@ -1,4 +1,4 @@ -using Core.Entities; +using Core.DomainObjects; using System; using System.Collections.Generic; using System.Linq; diff --git a/webapi/Core/Entities/Address.cs b/webapi/Core/DomainObjects/Address.cs similarity index 90% rename from webapi/Core/Entities/Address.cs rename to webapi/Core/DomainObjects/Address.cs index ec00d24..fb53e6f 100644 --- a/webapi/Core/Entities/Address.cs +++ b/webapi/Core/DomainObjects/Address.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Core.Entities { +namespace Core.DomainObjects { public class Address { public string Street { get; set; } public string City { get; set; } diff --git a/webapi/Core/DomainObjects/BlogItem.cs b/webapi/Core/DomainObjects/BlogItem.cs deleted file mode 100644 index 40158d1..0000000 --- a/webapi/Core/DomainObjects/BlogItem.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Core.Abstractions.DomainObjects; - -namespace Core.DomainObjects { - public class BlogItem : DomainObjectBase { - - public int? ReadTime { get; set; } - - public int? Likes { get; set; } - - public override int GetHashCode() { - throw new NotImplementedException(); - } - } -} diff --git a/webapi/Core/Entities/Contact.cs b/webapi/Core/DomainObjects/Contact.cs similarity index 88% rename from webapi/Core/Entities/Contact.cs rename to webapi/Core/DomainObjects/Contact.cs index 50676d7..dbfdc66 100644 --- a/webapi/Core/Entities/Contact.cs +++ b/webapi/Core/DomainObjects/Contact.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Core.Entities { +namespace Core.DomainObjects { public class Contact { public string Value { get; set; } public bool IsConfirmed { get; set; } diff --git a/webapi/Core/DomainObjects/Documents/BlogItem.cs b/webapi/Core/DomainObjects/Documents/BlogItem.cs index 765f25f..f73b383 100644 --- a/webapi/Core/DomainObjects/Documents/BlogItem.cs +++ b/webapi/Core/DomainObjects/Documents/BlogItem.cs @@ -3,8 +3,9 @@ namespace Core.DomainObjects.Documents { public class BlogItem : PostItemBase { - public int Likes { get; set; } - public int ReadingTime { get; set; } + public int? ReadTime { get; set; } + + public int? Likes { get; set; } public override int GetHashCode() { throw new NotImplementedException(); diff --git a/webapi/Core/DomainObjects/Documents/Content.cs b/webapi/Core/DomainObjects/Documents/Content.cs index 97f3eee..f62f0f7 100644 --- a/webapi/Core/DomainObjects/Documents/Content.cs +++ b/webapi/Core/DomainObjects/Documents/Content.cs @@ -5,6 +5,8 @@ namespace Core.DomainObjects.Documents { public class Content : DomainObjectDocumentBase { + public Guid SiteId { get; set; } + public string SiteName { get; set; } public string SiteUrl { get; set; } @@ -23,9 +25,15 @@ namespace Core.DomainObjects.Documents { public ShopCatalogPage ShopCatalog { get; set; } public ShopItemPage ShopItem { get; set; } + public ShopCartPage ShopCart { get; set; } + public ShopCheckoutPage ShopCheckout { get; set; } + public BlogCatalogPage BlogCatalog { get; set; } - public BlogItemPage Blogitem { get; set; } + public BlogItemPage BlogItem { get; set; } + + public SignInPage SignIn { get; set; } + public SignUpPage SignUp { get; set; } public override int GetHashCode() { throw new NotImplementedException(); diff --git a/webapi/Core/DomainObjects/Documents/User.cs b/webapi/Core/DomainObjects/Documents/User.cs index d8ef908..7d020da 100644 --- a/webapi/Core/DomainObjects/Documents/User.cs +++ b/webapi/Core/DomainObjects/Documents/User.cs @@ -1,6 +1,6 @@ using Core.Abstractions; using Core.Abstractions.DomainObjects; -using Core.Entities; +using Core.DomainObjects; using System; using System.Collections.Generic; using System.Linq; diff --git a/webapi/Core/DomainObjects/FormItem.cs b/webapi/Core/DomainObjects/FormItem.cs index f175ae1..5381fed 100644 --- a/webapi/Core/DomainObjects/FormItem.cs +++ b/webapi/Core/DomainObjects/FormItem.cs @@ -8,6 +8,8 @@ using System.Threading.Tasks; namespace Core.DomainObjects { public class FormItem : DomainObjectBase { public string? Title { get; set; } + + public string? Optional { get; set; } public string? PlaceHolder { get; set; } public override int GetHashCode() { diff --git a/webapi/Core/DomainObjects/Header.cs b/webapi/Core/DomainObjects/Header.cs index f5444e7..3620161 100644 --- a/webapi/Core/DomainObjects/Header.cs +++ b/webapi/Core/DomainObjects/Header.cs @@ -3,11 +3,11 @@ namespace Core.DomainObjects { public class Header : DomainObjectBase
{ - public string Title { get; set; } + public string? Title { get; set; } - public Dictionary HeaderLink { get; set; } + public Dictionary? Meta { get; set; } - public Dictionary Meta { get; set; } + public Dictionary? Link { get; set; } public override int GetHashCode() { throw new NotImplementedException(); diff --git a/webapi/Core/DomainObjects/Localization.cs b/webapi/Core/DomainObjects/Localization.cs index dd6c3f4..067b15d 100644 --- a/webapi/Core/DomainObjects/Localization.cs +++ b/webapi/Core/DomainObjects/Localization.cs @@ -8,17 +8,17 @@ using System.Threading.Tasks; namespace Core.DomainObjects { public class Localization : DomainObjectBase { - public string TimeZone { get; set; } + public string? TimeZone { get; set; } - public string Locale { get; set; } + public string? Locale { get; set; } - public string DateFormat { get; set; } + public string? DateFormat { get; set; } - public string TimeFormat { get; set; } + public string? TimeFormat { get; set; } - public string Currency { get; set; } + public string? Currency { get; set; } - public string CurrencySymobol { get; set; } + public string? CurrencySymbol { get; set; } public override int GetHashCode() { throw new NotImplementedException(); diff --git a/webapi/Core/DomainObjects/PageSections/BillingAddressSection.cs b/webapi/Core/DomainObjects/PageSections/BillingAddressSection.cs new file mode 100644 index 0000000..270c14b --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/BillingAddressSection.cs @@ -0,0 +1,14 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class BillingAddressSection : AddressSectionBase { + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/FeaturedBlogSection.cs b/webapi/Core/DomainObjects/PageSections/FeaturedBlogSection.cs index ac92c79..e9159e8 100644 --- a/webapi/Core/DomainObjects/PageSections/FeaturedBlogSection.cs +++ b/webapi/Core/DomainObjects/PageSections/FeaturedBlogSection.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; namespace Core.DomainObjects.PageSections { - public class FeaturedBlogSection : PageSectionBase { + public class FeaturedBlogsSection : PageSectionBase { public string ReadTime { get; set; } public override int GetHashCode() { diff --git a/webapi/Core/DomainObjects/PageSections/PaymentSection.cs b/webapi/Core/DomainObjects/PageSections/PaymentSection.cs new file mode 100644 index 0000000..8f72b66 --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/PaymentSection.cs @@ -0,0 +1,20 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class PaymentSection : PageSectionBase { + + public FormItem NameOnCard { get; set; } + public FormItem CardNumber { get; set; } + + public FormItem Expiration { get; set; } + public FormItem Cvv { get; set; } + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/ProductsSection.cs b/webapi/Core/DomainObjects/PageSections/ProductsSection.cs new file mode 100644 index 0000000..e0685aa --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/ProductsSection.cs @@ -0,0 +1,25 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class ProductsSection : PageSectionBase { + public string Product { get; set; } + public string Price { get; set; } + + public string Quantity { get; set; } + + public string Subtotal { get; set; } + + public Link ContinueShopping { get; set; } + + public FormItem Submit { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/RelatedProductsSection.cs b/webapi/Core/DomainObjects/PageSections/RelatedProductsSection.cs index f2318ad..f342305 100644 --- a/webapi/Core/DomainObjects/PageSections/RelatedProductsSection.cs +++ b/webapi/Core/DomainObjects/PageSections/RelatedProductsSection.cs @@ -7,6 +7,9 @@ using System.Threading.Tasks; namespace Core.DomainObjects.PageSections { public class RelatedProductsSection : PageSectionBase { + + public string AddToCart { get; set; } + public override int GetHashCode() { throw new NotImplementedException(); } diff --git a/webapi/Core/DomainObjects/PageSections/SettingsSection.cs b/webapi/Core/DomainObjects/PageSections/SettingsSection.cs new file mode 100644 index 0000000..af56e22 --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/SettingsSection.cs @@ -0,0 +1,17 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class SettingsSection : PageSectionBase { + + public string ShippingAddressSameAsBillingAddress { get; set; } + public string SaveThisInformation { get; set; } + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/ShippingAddressSection.cs b/webapi/Core/DomainObjects/PageSections/ShippingAddressSection.cs new file mode 100644 index 0000000..cd5bce9 --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/ShippingAddressSection.cs @@ -0,0 +1,14 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class ShippingAddressSection : AddressSectionBase { + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/ShopItemsSection.cs b/webapi/Core/DomainObjects/PageSections/ShopItemsSection.cs new file mode 100644 index 0000000..5a30677 --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/ShopItemsSection.cs @@ -0,0 +1,17 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class ShopItemsSection : PageSectionBase { + + public string AddToCart { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/PageSections/SummarySection.cs b/webapi/Core/DomainObjects/PageSections/SummarySection.cs new file mode 100644 index 0000000..fc3f05c --- /dev/null +++ b/webapi/Core/DomainObjects/PageSections/SummarySection.cs @@ -0,0 +1,21 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.PageSections { + public class SummarySection : PageSectionBase { + + public string Total { get; set; } + + public FormItem PromoCode { get; set; } + + public FormItem Submit { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/Pages/BlogCatalogPage.cs b/webapi/Core/DomainObjects/Pages/BlogCatalogPage.cs index 2ad7f0b..a87dde4 100644 --- a/webapi/Core/DomainObjects/Pages/BlogCatalogPage.cs +++ b/webapi/Core/DomainObjects/Pages/BlogCatalogPage.cs @@ -4,8 +4,10 @@ using Core.DomainObjects.PageSections; namespace Core.DomainObjects.Pages { public class BlogCatalogPage : PageBase { + public Header Header { get; set; } + public TitleSection TitleSection { get; set; } - public FeaturedBlogSection FeaturedBlogSection { get; set; } + public FeaturedBlogsSection FeaturedBlogSection { get; set; } public override int GetHashCode() { throw new NotImplementedException(); diff --git a/webapi/Core/DomainObjects/Pages/BlogItemPage.cs b/webapi/Core/DomainObjects/Pages/BlogItemPage.cs index 08e437a..c57f501 100644 --- a/webapi/Core/DomainObjects/Pages/BlogItemPage.cs +++ b/webapi/Core/DomainObjects/Pages/BlogItemPage.cs @@ -3,6 +3,8 @@ using Core.DomainObjects.PageSections; namespace Core.DomainObjects.Pages { public class BlogItemPage : PageBase { + + public Header Header { get; set; } public BlogTitleSection TitleSection { get; set; } public CommentsSection CommentsSection { get; set; } diff --git a/webapi/Core/DomainObjects/Pages/HomePage.cs b/webapi/Core/DomainObjects/Pages/HomePage.cs index 926e4f0..18af212 100644 --- a/webapi/Core/DomainObjects/Pages/HomePage.cs +++ b/webapi/Core/DomainObjects/Pages/HomePage.cs @@ -4,6 +4,7 @@ using Core.DomainObjects.PageSections; namespace Core.DomainObjects.Pages { public class HomePage : PageBase { + public Header Header { get; set; } public TitleSection TitleSection { get; set; } public FeaturesSection FeaturesSection { get; set; } public TestimonialsSection TestimonialsSection { get; set; } diff --git a/webapi/Core/DomainObjects/Pages/ShopCartPage.cs b/webapi/Core/DomainObjects/Pages/ShopCartPage.cs new file mode 100644 index 0000000..4441fa8 --- /dev/null +++ b/webapi/Core/DomainObjects/Pages/ShopCartPage.cs @@ -0,0 +1,16 @@ +using Core.Abstractions.DomainObjects; +using Core.DomainObjects.PageSections; + +namespace Core.DomainObjects.Pages { + public class ShopCartPage : PageBase { + public Header Header { get; set; } + + public TitleSection TitleSection { get; set; } + + public ProductsSection ProductsSection { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/Pages/ShopCatalogPage.cs b/webapi/Core/DomainObjects/Pages/ShopCatalogPage.cs index b516824..f142aec 100644 --- a/webapi/Core/DomainObjects/Pages/ShopCatalogPage.cs +++ b/webapi/Core/DomainObjects/Pages/ShopCatalogPage.cs @@ -3,8 +3,13 @@ using Core.DomainObjects.PageSections; namespace Core.DomainObjects.Pages { public class ShopCatalogPage : PageBase { + + public Header Header { get; set; } + public TitleSection TitleSection { get; set; } + public ShopItemsSection ShopItemsSection { get; set; } + public override int GetHashCode() { throw new NotImplementedException(); } diff --git a/webapi/Core/DomainObjects/Pages/ShopCheckoutPage.cs b/webapi/Core/DomainObjects/Pages/ShopCheckoutPage.cs new file mode 100644 index 0000000..3bceb11 --- /dev/null +++ b/webapi/Core/DomainObjects/Pages/ShopCheckoutPage.cs @@ -0,0 +1,31 @@ +using Core.Abstractions.DomainObjects; +using Core.DomainObjects.PageSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.Pages { + public class ShopCheckoutPage : PageBase { + + public Header Header { get; set; } + public TitleSection TitleSection { get; set; } + + public BillingAddressSection BillingAddressSection { get; set; } + + public ShippingAddressSection ShippingAddressSection { get; set; } + + public SettingsSection SettingsSection { get; set; } + + public SummarySection SummarySection { get; set; } + + public PaymentSection PaymentSection { get; set; } + + public FormItem Submit { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/Pages/ShopItemPage.cs b/webapi/Core/DomainObjects/Pages/ShopItemPage.cs index 36da1b7..d9cc3ed 100644 --- a/webapi/Core/DomainObjects/Pages/ShopItemPage.cs +++ b/webapi/Core/DomainObjects/Pages/ShopItemPage.cs @@ -4,6 +4,7 @@ using Core.DomainObjects.PageSections; namespace Core.DomainObjects.Pages { public class ShopItemPage : PageBase { + public Header Header { get; set; } public ProductSection ProductSection { get; set; } public RelatedProductsSection RelatedProductsSection { get; set; } diff --git a/webapi/Core/DomainObjects/Pages/SignUpPage.cs b/webapi/Core/DomainObjects/Pages/SignUpPage.cs new file mode 100644 index 0000000..d205fe4 --- /dev/null +++ b/webapi/Core/DomainObjects/Pages/SignUpPage.cs @@ -0,0 +1,32 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.Pages { + public class SignUpPage : PageBase { + + public Header Header { get; set; } + + public string Title { get; set; } + + public FormItem Username { get; set; } + + public FormItem Email { get; set; } + + public FormItem ReEmail { get; set; } + public FormItem Password { get; set; } + + public FormItem RePassword { get; set; } + + public string AcceptTermsAndConditions { get; set; } + + public FormItem Submit { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/DomainObjects/Pages/SingInPage.cs b/webapi/Core/DomainObjects/Pages/SingInPage.cs new file mode 100644 index 0000000..860b863 --- /dev/null +++ b/webapi/Core/DomainObjects/Pages/SingInPage.cs @@ -0,0 +1,28 @@ +using Core.Abstractions.DomainObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DomainObjects.Pages { + public class SignInPage : PageBase { + + public Header Header { get; set; } + + public string Title { get; set; } + + public FormItem Email { get; set; } + public FormItem Password { get; set; } + + public string DontHaveAnAccount { get; set; } + + public Link SignUpLink { get; set; } + + public FormItem Submit { get; set; } + + public override int GetHashCode() { + throw new NotImplementedException(); + } + } +} diff --git a/webapi/Core/Enumerations/ReservedWords.cs b/webapi/Core/Enumerations/ReservedWords.cs new file mode 100644 index 0000000..b68f50a --- /dev/null +++ b/webapi/Core/Enumerations/ReservedWords.cs @@ -0,0 +1,24 @@ +using Core.Abstractions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.Enumerations { + public class ReservedWords : Enumeration { + public static ReservedWords SiteName = new ReservedWords(0, "{siteName}" ); + public static ReservedWords SiteUrl = new ReservedWords(0, "{siteUrl}"); + public static ReservedWords Quantity = new ReservedWords(0, "{quantity}"); + public static ReservedWords ProductTitle = new ReservedWords(0, "{productTitle}"); + public static ReservedWords Currency = new ReservedWords(0, "{currency}"); + public static ReservedWords Date = new ReservedWords(0, "{date}"); + public static ReservedWords ReadTime = new ReservedWords(0, "{readTime}"); + public static ReservedWords BlogTitle = new ReservedWords(0, "{blogTitle}"); + public static ReservedWords NickName = new ReservedWords(0, "{nickName}"); + + private ReservedWords(int id, string name) : base(id, name) { + + } + } +} diff --git a/webapi/DataProviders/Abstractions/DataProviderBase.cs b/webapi/DataProviders/Abstractions/DataProviderBase.cs index 67c73f9..8dc4b8c 100644 --- a/webapi/DataProviders/Abstractions/DataProviderBase.cs +++ b/webapi/DataProviders/Abstractions/DataProviderBase.cs @@ -202,7 +202,7 @@ namespace DataProviders.Abstractions { .Find(predicate).ToList(); } - return result != null + return result != null && result.Count > 0 ? IDomainResult.Success(result) : IDomainResult.NotFound?>(); } diff --git a/webapi/DataProviders/ContentDataProvider.cs b/webapi/DataProviders/ContentDataProvider.cs index 78cd1cd..05fda00 100644 --- a/webapi/DataProviders/ContentDataProvider.cs +++ b/webapi/DataProviders/ContentDataProvider.cs @@ -19,7 +19,7 @@ namespace DataProviders { public class ContentDataProvider : DataProviderBase, IContentDataProvider { - private const string _collectionName = "contents"; + private const string _collectionName = "content"; public ContentDataProvider( ILogger> logger, IMongoClient client, @@ -30,7 +30,7 @@ namespace DataProviders { public (Content?, IDomainResult) Get(Guid id) { var (list, result) = GetWithPredicate(x => x.Id == id, _collectionName); - if (!result.IsSuccess || list == null) + if (!result.IsSuccess || list == null || list.Count == 0) return (null, result); return (list.First(), result); diff --git a/webapi/DataProviders/Mappings.cs b/webapi/DataProviders/Mappings.cs index e6bd386..4266e25 100644 --- a/webapi/DataProviders/Mappings.cs +++ b/webapi/DataProviders/Mappings.cs @@ -3,7 +3,10 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Conventions; using MongoDB.Bson.Serialization.Serializers; -using DataProviders; +using Core.DomainObjects; +using Core.DomainObjects.Pages; +using Core.DomainObjects.PageSections; +using Core.DomainObjects.Documents; namespace DataProviders { public class Mappings { @@ -18,7 +21,295 @@ namespace DataProviders { // https://kevsoft.net/2020/06/25/storing-guids-as-strings-in-mongodb-with-csharp.html BsonSerializer.RegisterSerializer(new GuidSerializer(BsonType.String)); + #region Primitives + if (!BsonClassMap.IsClassMapRegistered(typeof(Address))) { + BsonClassMap.RegisterClassMap
(cm => { + cm.AutoMap(); + }); + } + if (!BsonClassMap.IsClassMapRegistered(typeof(Author))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Category))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Comment))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Contact))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Feature))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(FormItem))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + + if (!BsonClassMap.IsClassMapRegistered(typeof(Header))) { + BsonClassMap.RegisterClassMap
(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Image))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Link))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Localization))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(MenuItem))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Reviewer))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + + cm.SetIsRootClass(true); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Route))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(Testimonial))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion + + #region PageSections + if (!BsonClassMap.IsClassMapRegistered(typeof(BillingAddressSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(BlogTitleSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(CallToActionSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(CommentsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(FeaturedBlogsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(FeaturedBlogsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(FeaturesSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(PaymentSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ProductSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ProductsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(RelatedProductsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(SettingsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShippingAddressSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopItemsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(SummarySection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(TestimonialsSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(TitleSection))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion + + #region Pages + if (!BsonClassMap.IsClassMapRegistered(typeof(BlogCatalogPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(BlogItemPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(HomePage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopCartPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopCatalogPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopCheckoutPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopItemPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(SignInPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + + if (!BsonClassMap.IsClassMapRegistered(typeof(SignUpPage))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion + + #region BlogItem + if (!BsonClassMap.IsClassMapRegistered(typeof(BlogItem))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion + + #region Content + if (!BsonClassMap.IsClassMapRegistered(typeof(Content))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + + //cm.GetMemberMap(c => c.Event) + // .SetSerializer(new EnumerationSerializer()); + }); + } + #endregion + + #region ShopItem + if (!BsonClassMap.IsClassMapRegistered(typeof(ShopItem))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion + + #region User + if (!BsonClassMap.IsClassMapRegistered(typeof(User))) { + BsonClassMap.RegisterClassMap(cm => { + cm.AutoMap(); + }); + } + #endregion } } } diff --git a/webapi/WeatherForecast/Controllers/ContentController.cs b/webapi/WeatherForecast/Controllers/ContentController.cs index cea6122..57b18ce 100644 --- a/webapi/WeatherForecast/Controllers/ContentController.cs +++ b/webapi/WeatherForecast/Controllers/ContentController.cs @@ -1,10 +1,12 @@ -using Microsoft.AspNetCore.Authorization; +using DomainResults.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 WeatherForecast.Services; namespace WeatherForecast.Controllers; @@ -17,88 +19,94 @@ namespace WeatherForecast.Controllers; public class ContentController : ControllerBase { private readonly ILogger _logger; + private readonly IContentService _contentService; /// /// /// /// public ContentController( - ILogger logger + ILogger logger, + IContentService contentService ) { _logger = logger; + _contentService = contentService; } /// /// /// /// - [HttpGet] - public IActionResult Get([FromQuery] string? locale = "en-US") { + [HttpGet("{siteId}")] + public IActionResult Get([FromRoute] Guid siteId, [FromQuery] string? locale = "en-US") { - var routes = new List { - new RouteModel ("/", "Home"), - new RouteModel ("/home", "Home") - }; + var result = _contentService.GetContent(siteId, locale); + return result.ToActionResult(); - var shopRoute = new RouteModel("/shop", - new List { - new RouteModel ("", "ShopCatalog"), - new RouteModel (":page", "ShopCatalog"), - new RouteModel (":page", new List { - new RouteModel (":slug", "ShopItem") - }) - }); + //var routes = new List { + // new RouteModel ("/", "Home"), + // new RouteModel ("/home", "Home") + //}; - var blogRoute = new RouteModel("/blog", - new List { - new RouteModel ("", "BlogCatalog"), - new RouteModel (":page", "BlogCatalog"), - new RouteModel (":page", new List { - new RouteModel (":slug", "BlogItem") - }) - }); + //var shopRoute = new RouteModel("/shop", + // new List { + // new RouteModel ("", "ShopCatalog"), + // new RouteModel (":page", "ShopCatalog"), + // new RouteModel (":page", new List { + // new RouteModel (":slug", "ShopItem") + // }) + //}); - routes.Add(shopRoute); - routes.Add(blogRoute); + //var blogRoute = new RouteModel("/blog", + // new List { + // new RouteModel ("", "BlogCatalog"), + // new RouteModel (":page", "BlogCatalog"), + // new RouteModel (":page", new List { + // new RouteModel (":slug", "BlogItem") + // }) + //}); - var demoRoutes = new List { - new RouteModel ("/counter", "Counter"), - new RouteModel ("/fetch-data", new List { - new RouteModel ("", "FetchData"), - new RouteModel (":startDateIndex", "FetchData") - }) - }; + //routes.Add(shopRoute); + //routes.Add(blogRoute); - routes = routes.Concat(demoRoutes).ToList(); + //var demoRoutes = new List { + // new RouteModel ("/counter", "Counter"), + // new RouteModel ("/fetch-data", new List { + // new RouteModel ("", "FetchData"), + // new RouteModel (":startDateIndex", "FetchData") + // }) + // }; - var adminRoutes = new List { - new RouteModel ("/admin", "AdminHome") - }; + //routes = routes.Concat(demoRoutes).ToList(); - var serviceRoutes = new List { - new RouteModel ("/signin", "Signin"), - new RouteModel ("/signup", "Signup"), - new RouteModel ("*", "Error") - }; + //var adminRoutes = new List { + // new RouteModel ("/admin", "AdminHome") + //}; - var topMenu = new List { - new MenuItemModel ("Home", "/"), - new MenuItemModel ("Shop", "/shop"), - new MenuItemModel ("Blog", "/blog"), - new MenuItemModel ("Signin", "/signin"), - new MenuItemModel ("Signout", "/signout") - }; + //var serviceRoutes = new List { + // new RouteModel ("/signin", "Signin"), + // new RouteModel ("/signup", "Signup"), + // new RouteModel ("*", "Error") + //}; - var sideMenu = new List { - new MenuItemModel ("alert-triangle", "Home", "/admin"), - new MenuItemModel ("activity", "Page", new List { - new MenuItemModel ("activity", "Page-1", "Page-1"), - new MenuItemModel ("activity", "Page-2", "Page-2"), - new MenuItemModel ("activity", "Page-3", "Page-3") - }), - new MenuItemModel ("Counter", "/counter"), - new MenuItemModel ("Fetch data", "/fetch-data") - }; + //var topMenu = new List { + // new MenuItemModel ("Home", "/"), + // new MenuItemModel ("Shop", "/shop"), + // new MenuItemModel ("Blog", "/blog"), + // new MenuItemModel ("Signin", "/signin"), + // new MenuItemModel ("Signout", "/signout") + //}; + + //var sideMenu = new List { + // new MenuItemModel ("alert-triangle", "Home", "/admin"), + // new MenuItemModel ("activity", "Page", new List { + // new MenuItemModel ("activity", "Page-1", "Page-1"), + // new MenuItemModel ("activity", "Page-2", "Page-2"), + // new MenuItemModel ("activity", "Page-3", "Page-3") + // }), + // new MenuItemModel ("Counter", "/counter"), + // new MenuItemModel ("Fetch data", "/fetch-data") + //}; @@ -106,122 +114,122 @@ public class ContentController : ControllerBase { - var homePage = new HomePageModel { - TitleSection = new TitleSectionModel { - Title = "Hello, World! by C#", - Text = @" -

Welcome to your new single-page application, built with:

- ", - Image = new ImageModel { Src = "https://dummyimage.com/600x400/343a40/6c757d", Alt = "..." }, - PrimaryLink = new MenuItemModel("Get Started", "#features"), - SecondaryLink = new MenuItemModel("Learn More", "#!") - }, + //var homePage = new HomePageModel { + // TitleSection = new TitleSectionModel { + // Title = "Hello, World! by C#", + // Text = @" + //

Welcome to your new single-page application, built with:

+ // ", + // Image = new ImageModel { Src = "https://dummyimage.com/600x400/343a40/6c757d", Alt = "..." }, + // PrimaryLink = new MenuItemModel("Get Started", "#features"), + // SecondaryLink = new MenuItemModel("Learn More", "#!") + // }, - FeaturesSection = new FeaturesSectionModel { - Title = "To help you get started, we have also set up:", - Items = new List { - new FeatureModel { - Icon = "navigation", - Title = "Client-side navigation", - Text = "For example, click Counter then Back to return here." - }, - new FeatureModel { - Icon = "server", - Title = "Development server integration", - Text = "In development mode, the development server from create-react-app runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file." - }, - new FeatureModel { - Icon = "terminal", - Title = "Efficient production builds", - Text = "In production mode, development-time features are disabled, and your dotnet publish configuration produces minified, efficiently bundled JavaScript files." - } - } - }, - TestimonialsSection = new TestimonialsSectionModel { - Items = new List { - new TestimonialModel { - Text = "The ClientApp subdirectory is a standard React application based on the create-react-app template. If you open a command prompt in that directory, you can run yarn commands such as yarn test or yarn install.", - Reviewer = new ReviewerModel { - Id = Guid.NewGuid(), - Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." }, - FullName = "Admin", - Position = "CEO, MAKS-IT" - } - } - } - }, - FeaturedBlogsSection = new FeaturedBologsSectionModel { - Title = "From our blog" - }, + // FeaturesSection = new FeaturesSectionModel { + // Title = "To help you get started, we have also set up:", + // Items = new List { + // new FeatureModel { + // Icon = "navigation", + // Title = "Client-side navigation", + // Text = "For example, click Counter then Back to return here." + // }, + // new FeatureModel { + // Icon = "server", + // Title = "Development server integration", + // Text = "In development mode, the development server from create-react-app runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file." + // }, + // new FeatureModel { + // Icon = "terminal", + // Title = "Efficient production builds", + // Text = "In production mode, development-time features are disabled, and your dotnet publish configuration produces minified, efficiently bundled JavaScript files." + // } + // } + // }, + // TestimonialsSection = new TestimonialsSectionModel { + // Items = new List { + // new TestimonialModel { + // Text = "The ClientApp subdirectory is a standard React application based on the create-react-app template. If you open a command prompt in that directory, you can run yarn commands such as yarn test or yarn install.", + // Reviewer = new ReviewerModel { + // Id = Guid.NewGuid(), + // Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." }, + // FullName = "Admin", + // Position = "CEO, MAKS-IT" + // } + // } + // } + // }, + // FeaturedBlogsSection = new FeaturedBologsSectionModel { + // Title = "From our blog" + // }, - CallToActionSection = new CallToActionSectionModel { - Title = "New products, delivered to you.", - Text = "Sign up for our newsletter for the latest updates.", - PrivacyDisclaimer = "We care about privacy, and will never share your data.", - Email = new FormItemModel { - PlaceHolder = "Email address...", - Title = "Sign up" - } - } - }; + // CallToActionSection = new CallToActionSectionModel { + // Title = "New products, delivered to you.", + // Text = "Sign up for our newsletter for the latest updates.", + // PrivacyDisclaimer = "We care about privacy, and will never share your data.", + // Email = new FormItemModel { + // PlaceHolder = "Email address...", + // Title = "Sign up" + // } + // } + //}; - var shopCatalogPage = new ShopCatalogPageModel { - TitleSection = new TitleSectionModel { - Title = "Shop in style", - Text = "With this shop hompeage template" - } - }; + //var shopCatalogPage = new ShopCatalogPageModel { + // TitleSection = new TitleSectionModel { + // Title = "Shop in style", + // Text = "With this shop hompeage template" + // } + //}; - var shopItem = new ShopItemPageModel { - ProductSection = new ProductSectionModel { - AvailableQuantity = "Available Qty.", - AddToCart = "Add to cart" - }, - RelatedProductsSection = new RelatedProductsSectionModel { - Title = "Related products" - } - }; + //var shopItem = new ShopItemPageModel { + // ProductSection = new ProductSectionModel { + // AvailableQuantity = "Available Qty.", + // AddToCart = "Add to cart" + // }, + // RelatedProductsSection = new RelatedProductsSectionModel { + // Title = "Related products" + // } + //}; - var blogCatalogPage = new BlogCatalogPageModel { - TitleSection = new TitleSectionModel { - Title = "Welcome to Blog Home!", - Text = "A Bootstrap 5 starter layout for your next blog homepage" - }, - FeaturedBlogSection = new FeaturedBlogSectionModel { - ReadTime = "{date} Time to read: {readTime} min" - } - }; + //var blogCatalogPage = new BlogCatalogPageModel { + // TitleSection = new TitleSectionModel { + // Title = "Welcome to Blog Home!", + // Text = "A Bootstrap 5 starter layout for your next blog homepage" + // }, + // FeaturedBlogSection = new FeaturedBlogSectionModel { + // ReadTime = "{date} Time to read: {readTime} min" + // } + //}; - var blogItem = new BlogItemPageModel { - TitleSection = new BlogTitleSectionModel { - PostedOnBy = "Posted on {date} by {nickName}" - }, - CommentsSection = new CommentsSectionModel { - LeaveComment = "Join the discussion and leave a comment!" - } - }; + //var blogItem = new BlogItemPageModel { + // TitleSection = new BlogTitleSectionModel { + // PostedOnBy = "Posted on {date} by {nickName}" + // }, + // CommentsSection = new CommentsSectionModel { + // LeaveComment = "Join the discussion and leave a comment!" + // } + //}; - return Ok(new GetContentResponseModel { - SiteName = "MAKS-IT", + //return Ok(new GetContentResponseModel { + // SiteName = "MAKS-IT", - Routes = routes, - AdminRoutes = adminRoutes, - ServiceRoutes = serviceRoutes, + // Routes = routes, + // AdminRoutes = adminRoutes, + // ServiceRoutes = serviceRoutes, - TopMenu = topMenu, - SideMenu = sideMenu, + // TopMenu = topMenu, + // SideMenu = sideMenu, - HomePage = homePage, + // HomePage = homePage, - ShopCatalog = shopCatalogPage, - ShopItem = shopItem, + // ShopCatalog = shopCatalogPage, + // ShopItem = shopItem, - BlogCatalog = blogCatalogPage, - Blogitem = blogItem - }); + // BlogCatalog = blogCatalogPage, + // Blogitem = blogItem + //}); } } diff --git a/webapi/WeatherForecast/Services/ContentService.cs b/webapi/WeatherForecast/Services/ContentService.cs index 70ff866..54b9867 100644 --- a/webapi/WeatherForecast/Services/ContentService.cs +++ b/webapi/WeatherForecast/Services/ContentService.cs @@ -1,11 +1,37 @@ -namespace WeatherForecast.Services { +using DataProviders; +using DomainResults.Common; +using ExtensionMethods; +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 + ) { + _logger = logger; + _contentDataProvider = contentDataprovider; + } + + public (GetContentResponseModel?, IDomainResult) GetContent(Guid siteId, string? locale) { + var (content, result) = _contentDataProvider.Get("b3f39a82-6a1b-46a4-85cc-04c3b4315511".ToGuid()); + + if (!result.IsSuccess) + return (null, result); + + // map content to GetContentResponseModel + + return IDomainResult.Failed(); + } } diff --git a/webapi/WeatherForecast/Startup.cs b/webapi/WeatherForecast/Startup.cs index 313e783..99ca36c 100644 --- a/webapi/WeatherForecast/Startup.cs +++ b/webapi/WeatherForecast/Startup.cs @@ -3,6 +3,8 @@ using Microsoft.OpenApi.Models; using Microsoft.IdentityModel.Tokens; using Microsoft.AspNetCore.Authentication.JwtBearer; +using WeatherForecast.Services; +using DataProviders.Extensions; namespace WeatherForecast { public class Startup { @@ -55,6 +57,10 @@ namespace WeatherForecast { // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-3.1#use-httpcontext-from-custom-components services.AddHttpContextAccessor(); + services.AddScoped(); + + services.RegisterDataproviders(appSettings); + #region Swagger services.ConfigureSwaggerGen(options => { // your custom configuration goes here diff --git a/webapi/WeatherForecast/WeatherForecast.csproj b/webapi/WeatherForecast/WeatherForecast.csproj index 280e272..fab6f9c 100644 --- a/webapi/WeatherForecast/WeatherForecast.csproj +++ b/webapi/WeatherForecast/WeatherForecast.csproj @@ -13,6 +13,7 @@ + @@ -21,6 +22,7 @@ + diff --git a/webapi/WeatherForecast/appsettings.json b/webapi/WeatherForecast/appsettings.json index 0439d21..87f0720 100644 --- a/webapi/WeatherForecast/appsettings.json +++ b/webapi/WeatherForecast/appsettings.json @@ -7,6 +7,11 @@ }, "AllowedHosts": "*", "Configuration": { - "Secret": "TUlJQ1d3SUJBQUtCZ0djczU2dnIzTWRwa0VYczYvYjIyemxMWlhSaFdrSWtyN0dqUHB4ZkNpQk9FU2Q3L2VxcA==" + "Secret": "TUlJQ1d3SUJBQUtCZ0djczU2dnIzTWRwa0VYczYvYjIyemxMWlhSaFdrSWtyN0dqUHB4ZkNpQk9FU2Q3L2VxcA==", + + "Database": { + "ConnectionString": "mongodb://localhost:27017" + + } } }