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; namespace WeatherForecast.Controllers; /// /// /// [ApiController] [AllowAnonymous] [Route("api/[controller]")] public class ContentController : ControllerBase { private readonly ILogger _logger; /// /// /// /// public ContentController( ILogger logger ) { _logger = logger; } /// /// /// /// [HttpGet] public IActionResult Get([FromQuery] string? locale = "en-US") { var routes = new List { new RouteModel ("/", "Home"), new RouteModel ("/home", "Home") }; var shopRoute = new RouteModel("/shop", new List { new RouteModel ("", "ShopCatalog"), new RouteModel (":page", "ShopCatalog"), new RouteModel (":page", new List { new RouteModel (":slug", "ShopItem") }) }); var blogRoute = new RouteModel("/blog", new List { new RouteModel ("", "BlogCatalog"), new RouteModel (":page", "BlogCatalog"), new RouteModel (":page", new List { new RouteModel (":slug", "BlogItem") }) }); routes.Add(shopRoute); routes.Add(blogRoute); var demoRoutes = new List { new RouteModel ("/counter", "Counter"), new RouteModel ("/fetch-data", new List { new RouteModel ("", "FetchData"), new RouteModel (":startDateIndex", "FetchData") }) }; routes = routes.Concat(demoRoutes).ToList(); var adminRoutes = new List { new RouteModel ("/admin", "AdminHome") }; var serviceRoutes = new List { new RouteModel ("/signin", "Signin"), new RouteModel ("/signup", "Signup"), new RouteModel ("*", "Error") }; 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") }; 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" }, 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 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 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", Routes = routes, AdminRoutes = adminRoutes, ServiceRoutes = serviceRoutes, TopMenu = topMenu, SideMenu = sideMenu, HomePage = homePage, ShopCatalog = shopCatalogPage, ShopItem = shopItem, BlogCatalog = blogCatalogPage, Blogitem = blogItem }); } }