236 lines
8.3 KiB
C#
236 lines
8.3 KiB
C#
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;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[ApiController]
|
|
[AllowAnonymous]
|
|
[Route("api/[controller]")]
|
|
public class ContentController : ControllerBase {
|
|
|
|
private readonly ILogger<ContentController> _logger;
|
|
private readonly IContentService _contentService;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="logger"></param>
|
|
public ContentController(
|
|
ILogger<ContentController> logger,
|
|
IContentService contentService
|
|
) {
|
|
_logger = logger;
|
|
_contentService = contentService;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("{siteId}")]
|
|
public IActionResult Get([FromRoute] Guid siteId, [FromQuery] string? locale = "en-US") {
|
|
|
|
var result = _contentService.GetContent(siteId, locale);
|
|
return result.ToActionResult();
|
|
|
|
//var routes = new List<RouteModel> {
|
|
// new RouteModel ("/", "Home"),
|
|
// new RouteModel ("/home", "Home")
|
|
//};
|
|
|
|
//var shopRoute = new RouteModel("/shop",
|
|
// new List<RouteModel> {
|
|
// new RouteModel ("", "ShopCatalog"),
|
|
// new RouteModel (":page", "ShopCatalog"),
|
|
// new RouteModel (":page", new List<RouteModel> {
|
|
// new RouteModel (":slug", "ShopItem")
|
|
// })
|
|
//});
|
|
|
|
//var blogRoute = new RouteModel("/blog",
|
|
// new List<RouteModel> {
|
|
// new RouteModel ("", "BlogCatalog"),
|
|
// new RouteModel (":page", "BlogCatalog"),
|
|
// new RouteModel (":page", new List<RouteModel> {
|
|
// new RouteModel (":slug", "BlogItem")
|
|
// })
|
|
//});
|
|
|
|
//routes.Add(shopRoute);
|
|
//routes.Add(blogRoute);
|
|
|
|
//var demoRoutes = new List<RouteModel> {
|
|
// new RouteModel ("/counter", "Counter"),
|
|
// new RouteModel ("/fetch-data", new List<RouteModel> {
|
|
// new RouteModel ("", "FetchData"),
|
|
// new RouteModel (":startDateIndex", "FetchData")
|
|
// })
|
|
// };
|
|
|
|
//routes = routes.Concat(demoRoutes).ToList();
|
|
|
|
//var adminRoutes = new List<RouteModel> {
|
|
// new RouteModel ("/admin", "AdminHome")
|
|
//};
|
|
|
|
//var serviceRoutes = new List<RouteModel> {
|
|
// new RouteModel ("/signin", "Signin"),
|
|
// new RouteModel ("/signup", "Signup"),
|
|
// new RouteModel ("*", "Error")
|
|
//};
|
|
|
|
//var topMenu = new List<MenuItemModel> {
|
|
// new MenuItemModel ("Home", "/"),
|
|
// new MenuItemModel ("Shop", "/shop"),
|
|
// new MenuItemModel ("Blog", "/blog"),
|
|
// new MenuItemModel ("Signin", "/signin"),
|
|
// new MenuItemModel ("Signout", "/signout")
|
|
//};
|
|
|
|
//var sideMenu = new List<MenuItemModel> {
|
|
// new MenuItemModel ("alert-triangle", "Home", "/admin"),
|
|
// new MenuItemModel ("activity", "Page", new List<MenuItemModel> {
|
|
// 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 = @"
|
|
// <p>Welcome to your new single-page application, built with:</p>
|
|
// <ul>
|
|
// <li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li>
|
|
// <li><a href='https://facebook.github.io/react/'>React</a> and <a href='https://redux.js.org/'>Redux</a> for client-side code</li>
|
|
// <li><a href='https://getbootstrap.com/'>Bootstrap</a>, <a href='https://reactstrap.github.io/?path=/story/home-installation--page'>Reactstrap</a> and <a href=\""https://feathericons.com/\"">Feather icons</a> for layout and styling</li>
|
|
// </ul>",
|
|
// 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<FeatureModel> {
|
|
// new FeatureModel {
|
|
// Icon = "navigation",
|
|
// Title = "Client-side navigation",
|
|
// Text = "For example, click <em>Counter</em> then <em>Back</em> to return here."
|
|
// },
|
|
// new FeatureModel {
|
|
// Icon = "server",
|
|
// Title = "Development server integration",
|
|
// Text = "In development mode, the development server from <code>create-react-app</code> 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 <code>dotnet publish</code> configuration produces minified, efficiently bundled JavaScript files."
|
|
// }
|
|
// }
|
|
// },
|
|
// TestimonialsSection = new TestimonialsSectionModel {
|
|
// Items = new List<TestimonialModel> {
|
|
// new TestimonialModel {
|
|
// Text = "The <code>ClientApp</code> subdirectory is a standard React application based on the <code>create-react-app</code> template. If you open a command prompt in that directory, you can run <code>yarn</code> commands such as <code>yarn test</code> or <code>yarn install</code>.",
|
|
// 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
|
|
//});
|
|
}
|
|
}
|