0% found this document useful (0 votes)
10 views10 pages

App's Fair

App's Fair is an online software marketplace built using ASP.NET Core and JSP, allowing developers to list, manage, and sell software products. The platform features a user-friendly interface for product listing, adding new software, and editing or deleting existing products, all while utilizing a MySQL database for data management. The project aims to provide a scalable structure for digital software sales, with potential for future enhancements like user authentication and payment integration.

Uploaded by

ahmedrafid750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

App's Fair

App's Fair is an online software marketplace built using ASP.NET Core and JSP, allowing developers to list, manage, and sell software products. The platform features a user-friendly interface for product listing, adding new software, and editing or deleting existing products, all while utilizing a MySQL database for data management. The project aims to provide a scalable structure for digital software sales, with potential for future enhancements like user authentication and payment integration.

Uploaded by

ahmedrafid750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Title: Development and Deployment of an Online Software Marketplace Using ASP.NET.

Objective: The aim of this project is to build a dynamic website to sell software products online,
utilizing ASP.NET and JSP technologies. The platform will allow developers or sellers to upload,
manage, and showcase their software products, while users will have the ability to browse and
purchase these products.
The key objectives are:
1. Design a user-friendly frontend with HTML for managing software listings.
2. Implement server-side processing with ASP.NET (for Windows) and JSP (for Java-based
servers).
3. Employ a relational database (like SQL Server or MySQL) to maintain records such as
product names, versions, prices, descriptions, and stock status.
4. Offer a structured platform for adding, viewing, and buying software products
efficiently.

System architecture:

1. User → Accesses the Website (via URL).


2. Request → Routed to the Controller.
3. Controller → Retrieves Data from the Database (Model).
4. Model → Sends data back to the Controller.
5. Controller → Forwards data to the View.
6. View → Displays the HTML content to the user.
Fig-1: Control System
Code:

Fig-2: Visual
App’s Fair Codebase:

Controllers/HomeController.cs:
using Microsoft.AspNetCore.Mvc;
using AppsFair.Models;
using AppsFair.Data;
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace AppsFair.Controllers
{
public class HomeController : Controller
{
private readonly AppsFairContext _ctx;

public HomeController(AppsFairContext context)


{
_ctx = context;
}

// Display all products


[HttpGet]
public IActionResult Index()
{
var items = _ctx.Products.ToList();
return View(items);
}

// Show form to create product


[HttpGet]
public IActionResult AddProduct()
{
return View();
}
[HttpPost]
public async Task<IActionResult> AddProduct(string name, string description, decimal price, IFormFile photo)
{
string imagePath = null;

if (photo != null && photo.Length > 0)


{
var fileName = Path.GetFileName(photo.FileName);
var folderPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/uploads");

if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);

var fullPath = Path.Combine(folderPath, fileName);

using (var stream = new FileStream(fullPath, FileMode.Create))


{
await photo.CopyToAsync(stream);
}

imagePath = "/uploads/" + fileName;


}

var item = new Product


{
Name = name,
Description = description,
Price = price,
PhotoPath = imagePath
};

_ctx.Products.Add(item);
await _ctx.SaveChangesAsync();

return RedirectToAction("Index");
}

// View specific product


public IActionResult Details(int id)
{
var item = _ctx.Products.FirstOrDefault(p => p.Id == id);
if (item == null) return NotFound();

return View(item);
}

// Delete selected product


public async Task<IActionResult> Delete(int id)
{
var product = await _ctx.Products.FindAsync(id);
if (product != null)
{
_ctx.Products.Remove(product);
await _ctx.SaveChangesAsync();
}

return RedirectToAction("Index");
}

// Load edit form


[HttpGet]
public IActionResult Edit(int id)
{
var product = _ctx.Products.Find(id);
if (product == null) return NotFound();

return View(product);
}

// Submit edited data


[HttpPost]
public async Task<IActionResult> Edit(int id, string name, string description, decimal price)
{
var product = await _ctx.Products.FindAsync(id);
if (product != null)
{
product.Name = name;
product.Description = description;
product.Price = price;

await _ctx.SaveChangesAsync();
}

return RedirectToAction("Index");
}
}
}
Data/App’s FairContext.cs:
using System.ComponentModel.DataAnnotations.Schema;

namespace AppsFair.Models
{
public class Product
{
public int Id { get; set; }

public string? PhotoPath { get; set; }

public string? Name { get; set; }

[Column(TypeName = "decimal(18,2)")] // Keeps 2 decimal precision


public decimal Price { get; set; }

public string? Description { get; set; }


}
}

Models/Product.cs:
using System.ComponentModel.DataAnnotations.Schema; // For [Column] attribute
namespace AppBazar.Models
{
public class Product
{
public int Id { get; set; }
public string? PhotoPath { get; set; }
public string? Name { get; set; }

[Column(TypeName = "decimal(18,2)")] // This ensures 2 decimal places in database


public decimal Price { get; set; }

public string? Description { get; set; }


}
}

Views/Home/AddProduct.cshtml:
@{
ViewData["Title"] = "Add Product";
}

<h2>Add Software</h2>

<form asp-action="AddProduct" enctype="multipart/form-data" method="post">


<input type="text" name="Name" placeholder="Software Title" required /><br />
<input type="number" name="Price" placeholder="Cost" step="0.01" required /><br />
<textarea name="Description" placeholder="Details"></textarea><br />
<input type="file" name="Photo" required /><br />
<button type="submit">Save</button>
</form>
Views/Home/Details.cshtml:
@model AppsFair.Models.Product

@{
ViewData["Title"] = "Details";
}

<div style="max-width: 900px; margin: 30px auto; padding: 30px; border:1px solid #ccc; border-radius:15px; box-
shadow: 0 4px 20px rgba(0,0,0,0.15); background:white; display:flex; flex-wrap:wrap; gap:30px; align-items:center;">

<div style="flex:1; min-width:300px;">


<img src="@Model.PhotoPath" alt="@Model.Name" style="width:100%; border-radius:15px; box-shadow:0 2px
8px rgba(0,0,0,0.1);" />
</div>

<div style="flex:1; min-width:300px;">


<h1 style="margin-bottom:10px;">@Model.Name</h1>
<p style="font-size:20px; font-weight:bold; color:#28a745;">💲[email protected]("0.00")</p>
<p style="margin:20px 0; font-size:16px; line-height:1.6;">@Model.Description</p>

<div style="margin-top:30px;">
<button style="padding:10px 20px; background:#007bff; color:white; border:none; border-radius:5px;"> 🛒 Add
to Cart</button>
<button style="padding:10px 20px; background:#28a745; color:white; border:none; border-radius:5px; margin-
left:10px;">⚡ Buy Now</button>
</div>

<div style="margin-top:30px;">
<a asp-action="Index" style="text-decoration:none; color:#333;">⬅️Back</a>
</div>
</div>
</div>

Views/Home/Edit.cshtml:
@model AppsFair.Models.Product

<h2>Update Product</h2>

<form asp-action="Edit" method="post">


<input type="hidden" name="Id" value="@Model.Id" />
<input type="text" name="Name" value="@Model.Name" /><br />
<input type="number" name="Price" value="@Model.Price" step="0.01" /><br />
<textarea name="Description">@Model.Description</textarea><br />
<button type="submit">Update</button>
</form>
views/home/index.cshtml:
@model List<AppsFair.Models.Product>
@{
ViewData["Title"] = "Available Software";
}

<h2> App's Fair - Software Listings</h2>

<div style="margin-bottom: 20px;">


<a asp-action="AddProduct"
style="padding:10px 20px; background:#28a745; color:white; text-decoration:none; border-radius:5px;">
➕ Add New Software
</a>
</div>

<div style="display: flex; flex-wrap: wrap; gap: 20px;">


@foreach (var p in Model)
{
<div
style="position:relative; border:1px solid #ccc; padding:20px; width:300px; border-radius:15px; box-shadow:0
2px 8px rgba(0,0,0,0.15); background:white;">

<!-- Menu -->


<div style="position:absolute; top:10px; right:10px;">
<button onclick="toggleMenu(@p.Id)" style="border:none; background:none; font-size:20px;">⋮</button>
<div id="[email protected]"
style="display:none; background:#eee; padding:5px; border-radius:5px; position:absolute; top:25px;
right:0;">
<a asp-action="Edit" asp-route-id="@p.Id">✏️Edit</a><br />
<a asp-action="Delete" asp-route-id="@p.Id" style="color:red;"> Remove</a>
</div>
</div>

<a asp-action="Details" asp-route-id="@p.Id" style="text-decoration:none; color:inherit;">


<img src="@p.PhotoPath" alt="@p.Name" width="100%" style="border-radius:10px;" />
<h3 style="margin-top:10px;">@p.Name</h3>
<p style="font-weight:bold;">Price: [email protected]("0.00")</p>
</a>

<button style="margin-top:10px;">🛒 Add to Cart</button>


<button style="margin-top:10px;">⚡ Buy Now</button>
</div>
}
</div>

<script>
function toggleMenu(id) {
const menu = document.getElementById("menu-" + id);
menu.style.display = (menu.style.display === "block") ? "none" : "block";
}

document.addEventListener("click", function (e) {


if (!e.target.closest("button")) {
document.querySelectorAll("[id^='menu-']").forEach(menu => menu.style.display = "none");
}
});
</script>
Views/Shared/_Layout.cshtml:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewData["Title"] - App's Fair</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<header style="padding:15px; background:#343a40; color:white;">
<div style="max-width:1200px; margin:auto;">
<h1 style="margin:0;"><a asp-controller="Home" asp-action="Index" style="color:white; text-
decoration:none;">App's Fair</a></h1>
</div>
</header>

<main role="main" class="container" style="padding:20px; max-width:1200px; margin:auto;">


@RenderBody()
</main>

<footer style="padding:15px; background:#f8f9fa; text-align:center; margin-top:30px;">


&copy; 2025 - App's Fair. All rights reserved.
</footer>

@RenderSection("Scripts", required: false)


</body>
</html>

App’s_Fair.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>AppsFair</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0" />
</ItemGroup>

</Project>
Program.cs:

using AppsFair.Data;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Enable Razor Pages and MVC controllers


builder.Services.AddControllersWithViews();

// Register the database context


builder.Services.AddDbContext<AppsFairContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("AppsFairConnection")));

var app = builder.Build();

// Enable error page during development


if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// Production error handling
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}

// Configure HTTP pipeline


app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.UseAuthorization();

// Default route configuration


app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

appsettings.json:

{
"ConnectionStrings": {
"AppsFairConnection": "Server=(localdb)\\
mssqllocaldb;Database=AppsFairDb;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Output:

Summary:

App's Fair is a web-based platform designed for software engineers to list, manage, and sell
software products. Built using ASP.NET Core and JSP, the application integrates a MySQL database
for storing product details such as name, description, price and photo.
Key Features:
1. Product Listing Page: Displays all software products dynamically from the database.
2. Add Product Form: Allows users to upload new software products with images.
3. Edit/Delete Products: Enables modifications or removal of existing entries.
4. Product Details Page: Showcases detailed information about each product.
5. Responsive Frontend: Developed using HTML and styled for modern presentation.
6. Visual Branding: The platform was renamed from App's Fair, ensuring a unique identity
across code, comments and UI.
This project provides a complete, functional structure for managing and showcasing digital software
sales, making it easy to scale with further enhancements like user authentication or payment
integration.

You might also like