Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using SimplCommerce.Module.Catalog.Models;
using SimplCommerce.Module.Catalog.Services;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using SimplCommerce.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;

namespace SimplCommerce.Module.Catalog.Controllers
{
[Area("Catalog")]
public class FeedController : Controller
{
private readonly IRepository<Product> _productRepository;

public FeedController(IRepository<Product> productRepository)
{
_productRepository = productRepository;
}

public IActionResult Index()
{
var products = _productRepository.Query().Include(p => p.ThumbnailImage).ToList();
return View(products);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@

@model List<SimplCommerce.Module.Catalog.Models.Product>

@using System.Text.RegularExpressions

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>All Products</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
margin-top: 30px;
color: #333;
}
.product-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
padding: 40px 20px;
}
.product-card {
background-color: #fff;
border: 1px solid #e0e0e0;
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
width: 250px;
text-align: center;
padding: 20px;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}
.product-card img {
width: 100%;
height: 180px;
object-fit: cover;
border-radius: 8px;
margin-bottom: 10px;
}
.product-card h3 {
font-size: 1.2rem;
margin-bottom: 10px;
color: #333;
}
.product-card p {
font-size: 0.9rem;
color: #555;
height: 50px;
overflow: hidden;
}
.product-card strong {
display: block;
margin-top: 10px;
color: #d32f2f;
font-size: 1rem;
}
</style>
</head>
<body>
<h1>All Products</h1>

<div class="product-container">
@foreach (var product in Model)
{
<div style="border: 1px solid #ddd; padding: 16px; margin-bottom: 12px;">
<img src="/user-content/@product.ThumbnailImage?.FileName" alt="@product.Name" style="max-width: 150px;" />

<h3>@product.Name</h3>
<p>@Html.Raw(Regex.Replace(product.Description, "<.*?>", string.Empty))</p>
<strong>Price:@product.Price.ToString("F2")</strong>
</div>
}
</div>
</body>
</html>













@* most importanty *@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary code

@* @model List<SimplCommerce.Module.Catalog.Models.Product>
@using System.Text.RegularExpressions
@{
ViewData["Title"] = "Feed";
}
<h1>Product Feed</h1>
@foreach (var product in Model)
{
<div style="border: 1px solid #ddd; padding: 16px; margin-bottom: 12px;">
<img src="/user-content/@product.ThumbnailImage?.FileName" alt="@product.Name" style="max-width: 150px;" />
<h3>@product.Name</h3>
<p>@Html.Raw(Regex.Replace(product.Description, "<.*?>", string.Empty))</p>
<strong>Price: ₹@product.Price.ToString("F2")</strong>
</div>
}
*@




@* @model IEnumerable<SimplCommerce.Module.Catalog.Models.Product>
<h2>Product Feed</h2>
@* @foreach (var product in Model)
{
<div class="card mb-3 p-3">
<h4>@product.Name</h4>
@if (!string.IsNullOrEmpty(product.ThumbnailImage))
{
<img src="@Url.Content(product.ThumbnailImage)" alt="@product.Name" class="img-fluid mb-2" />
}
else
{
<p><em>No Image Available</em></p>
}
<p>@Html.Raw(product.ShortDescription)</p>
<strong>Price: @product.Price.ToString("C")</strong>
</div>
}
*@


@* @foreach (var product in Model)
{
<div class="card mb-3 p-3">
<h4>@product.Name</h4>
<img src="@(Url.Content("~/user-content/") + product.ThumbnailImage)" alt="@product.Name" class="img-fluid mb-2" />
<p>@Html.Raw(product.ShortDescription)</p>
<strong>Price: @product.Price.ToString("C")</strong>
</div>
} *@


@* @foreach (var product in Model)
{
<div class="card mb-3 p-3">
<h4>@product.Name</h4>
<img src="@product.ThumbnailImage" alt="@product.Name" class="img-fluid mb-2" />
<p>@product.ShortDescription</p>
<strong>Price: @product.Price.ToString("C")</strong>
</div>
} *@
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -29,6 +30,40 @@ public IActionResult TestError()
throw new Exception("Test behavior in case of error");
}

/// <summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

///
///
///

//[HttpGet("/feed")]
//public IActionResult Feed()
//{
// var products = _productRepository.Query()
// .Where(p => p.IsPublished && !p.IsDeleted)
// .OrderByDescending(p => p.CreatedOn)
// .Select(p => new ProductFeedViewModel
// {
// Id = p.Id,
// Name = p.Name,
// ThumbnailImage = p.ThumbnailImage,
// ShortDescription = p.ShortDescription,
// Price = p.Price
// }).ToList();

// return View(products);
//}









/// </summary>
/// <returns></returns>

[HttpGet("/")]
public IActionResult Index()
{
Expand Down
Loading