From 6b6ad8ff84f25a6fb306a8df6149933bed363714 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Fri, 17 Apr 2026 08:13:54 -0500 Subject: [PATCH 01/13] init --- .../Sills.GolfShop.eCommerce/Program.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs new file mode 100644 index 00000000..9d3ee9d1 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Services; + +var builder = WebApplication.CreateBuilder(args); + + +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddControllers(); +builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +builder.WebHost.UseUrls("http://localhost:8080"); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); + +} + +app.MapControllers(); + +app.Run(); From 848301faf8bd92b8fd16a09a4f2d4ccf8df17f96 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Fri, 17 Apr 2026 08:14:00 -0500 Subject: [PATCH 02/13] first commit --- Sills.GolfShop.eCommerce/.gitattributes | 63 +++ Sills.GolfShop.eCommerce/.gitignore | 363 ++++++++++++++++++ .../Sills.GolfShop.eCommerce.slnx | 4 + .../Controllers/CategoryController.cs | 82 ++++ .../Controllers/ProductController.cs | 72 ++++ .../Controllers/SalesController.cs | 66 ++++ .../DTO/ProductDTO.cs | 9 + .../Data/GolfShopDbContext.cs | 24 ++ .../Helpers/PaginationParameters.cs | 14 + .../Helpers/SortingParameters.cs | 20 + .../Mapping/ProductMapper.cs | 16 + .../20260403232616_initial.Designer.cs | 152 ++++++++ .../Migrations/20260403232616_initial.cs | 107 ++++++ .../GolfShopDbContextModelSnapshot.cs | 149 +++++++ .../Models/Categories.cs | 11 + .../Models/Product.cs | 14 + .../Models/ProductSales.cs | 13 + .../Sills.GolfShop.eCommerce/Models/Sales.cs | 11 + .../Postman_Collection/PostmanCollection.json | 99 +++++ .../Properties/launchSettings.json | 23 ++ .../Services/ICategoryService.cs | 72 ++++ .../Services/IProductsService.cs | 72 ++++ .../Services/ISalesService.cs | 90 +++++ .../Sills.GolfShop.eCommerce.http | 6 + .../Sills.GolfShop.eCommerceAPI.csproj | 24 ++ .../appsettings.Development.json | 8 + .../Sills.GolfShop.eCommerce/appsettings.json | 13 + .../Controllers/ProductsController.cs | 6 + .../Controllers/SaleController.cs | 5 + .../Menus/MainMenu.cs | 54 +++ .../Models/Category.cs | 24 ++ .../Models/Product.cs | 33 ++ .../Models/ProductSales.cs | 19 + .../Models/Sales.cs | 20 + .../Program.cs | 10 + .../Sills.GolfShop.eCommerceFrontEnd.csproj | 19 + 36 files changed, 1787 insertions(+) create mode 100644 Sills.GolfShop.eCommerce/.gitattributes create mode 100644 Sills.GolfShop.eCommerce/.gitignore create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs create mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj diff --git a/Sills.GolfShop.eCommerce/.gitattributes b/Sills.GolfShop.eCommerce/.gitattributes new file mode 100644 index 00000000..1ff0c423 --- /dev/null +++ b/Sills.GolfShop.eCommerce/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/Sills.GolfShop.eCommerce/.gitignore b/Sills.GolfShop.eCommerce/.gitignore new file mode 100644 index 00000000..9491a2fd --- /dev/null +++ b/Sills.GolfShop.eCommerce/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx new file mode 100644 index 00000000..9d67d4ca --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx @@ -0,0 +1,4 @@ + + + + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs new file mode 100644 index 00000000..33b9d2a7 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs @@ -0,0 +1,82 @@ +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; +using Sills.GolfShop.eCommerceAPI.Helpers; +using Microsoft.EntityFrameworkCore; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class CategoryController(ICategoryService categoryService) : ControllerBase + +{ + private readonly ICategoryService _categoryService = categoryService; + + [HttpGet] + public async Task>> GetAllCategories([FromQuery] PaginationParameters param, [FromQuery] CategoryParameters categoryParams) + { + var query = _categoryService.GetAllCategoriesQuery(); + query = categoryParams.sortBy switch + { + "name_desc" => query.OrderByDescending(p => p.Name), + _ => query.OrderBy(p => p.Name) + }; + + var pagedCategories = await query + .Where(c => c.DeletedAt == null) + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToListAsync(); + + query = categoryParams.sortBy switch + { + "name_desc" => query.OrderByDescending(p => p.Name), + _ => query.OrderBy(p => p.Name) + }; + + return Ok(pagedCategories); + } + + [HttpGet("{id}")] + public ActionResult GetCategoryById(int id) + { + var category = _categoryService.GetCategoryByIdAsync(id); + if (category == null) + { + return NotFound(); + } + return Ok(category); + } + + [HttpPost] + public ActionResult CreateCategory(Categories category) + { + var createdCategory = _categoryService.CreateCategoryAsync(category); + return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory); + } + + [HttpPut("{id}")] + public IActionResult UpdateCategory(int id, Categories category) + { + var existingCategory = _categoryService.GetCategoryByIdAsync(id); + if (existingCategory == null) + { + return NotFound(); + } + _categoryService.UpdateCategoryAsync(id, category); + return NoContent(); + } + [HttpDelete("{id}")] + public IActionResult DeleteCategory(int id) + { + var existingCategory = _categoryService.GetCategoryByIdAsync(id); + if (existingCategory == null) + { + return NotFound(); + } + _categoryService.DeleteCategoryAsync(id); + return NoContent(); + } + +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs new file mode 100644 index 00000000..ca8c6609 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -0,0 +1,72 @@ +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.DTO; +using Sills.GolfShop.eCommerceAPI.Helpers; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] + +public class ProductController(IProductsService productsService) : ControllerBase +{ + private readonly IProductsService _productService = productsService; + + [HttpGet] + public ActionResult> GetAllProducts(PaginationParameters param) + { + var products = _productService.GetAllProductsAsync().Result; + var pagedProducts = products + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToList(); + return Ok(products); + } + + [HttpGet("{id}")] + public async Task> GetProductById(int id) + { + var product = await _productService.GetProductByIdAsync(id); + if (product == null) + { + return NotFound(); + } + return Ok(product); + } + [HttpPost] + public async Task> CreateProduct(Product product) + { + var createdProduct = await _productService.CreateProductAsync(product); + return CreatedAtAction(nameof(GetProductById), new { id = createdProduct.Id }, createdProduct); + } + + [HttpPut("{id}")] + public async Task UpdateProduct(int id, ProductUpdateDto productUpdateDto) + { + var existingProduct = _productService.GetProductByIdAsync(id).Result; + if (existingProduct == null) + { + return NotFound(); + } + existingProduct.Name = productUpdateDto.Name; + existingProduct.Description = productUpdateDto.Description; + existingProduct.QuantityInStock = productUpdateDto.QuantityInStock; + + await _productService.UpdateProductAsync(id, existingProduct); + return NoContent(); + } + + [HttpDelete("{id}")] + public IActionResult DeleteProduct(int id) + { + var existingProduct = _productService.GetProductByIdAsync(id).Result; + if (existingProduct == null) + { + return NotFound(); + } + _productService.DeleteProductAsync(id).Wait(); + + return NoContent(); + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs new file mode 100644 index 00000000..4791679c --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs @@ -0,0 +1,66 @@ +using Sills.GolfShop.eCommerceAPI.Services; +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Helpers; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class SalesController(ISalesService salesService) : ControllerBase +{ + private readonly ISalesService _salesService = salesService; + + [HttpGet] + public ActionResult> GetAllSales(PaginationParameters param) + { + var sales = _salesService.GetAllSalesAsync().Result; + + var pagedSales = sales + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToList(); + + return Ok(sales); + } + [HttpGet("{id}")] + public async Task> GetSaleById(int id) + { + var sale = await _salesService.GetSaleByIdAsync(id); + if (sale == null) + { + return NotFound(); + } + return Ok(sale); + } + [HttpPost] + public async Task> CreateSale(Sales sale) + { + var createdSale = await _salesService.CreateSaleAsync(sale); + return CreatedAtAction(nameof(GetSaleById), new { id = createdSale.Id }, createdSale); + } + [HttpPut("{id}")] + public IActionResult UpdateSale(int id, Sales sale) + { + var existingSale = _salesService.GetSaleByIdAsync(id).Result; + if (existingSale == null) + { + return NotFound(); + } + _salesService.UpdateSaleAsync(id, sale).Wait(); + return NoContent(); + } + + [HttpDelete("{id}")] + public IActionResult DeleteSale(int id) + { + var existingSale = _salesService.GetSaleByIdAsync(id).Result; + if (existingSale == null) + { + return NotFound(); + } + _salesService.DeleteSaleAsync(id).Wait(); + return NoContent(); + } + + } diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs new file mode 100644 index 00000000..e34179a8 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs @@ -0,0 +1,9 @@ +namespace Sills.GolfShop.eCommerceAPI.DTO +{ + public record ProductUpdateDto + { + public string Name { get; init; } + public string Description { get; init; } + public int QuantityInStock { get; init; } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs new file mode 100644 index 00000000..cf0b3458 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Data; + +public class GolfShopDbContext(DbContextOptions options) : DbContext(options) +{ + + public DbSet Products { get; set; } + public DbSet Categories { get; set; } + public DbSet Sales { get; set; } + public DbSet ProductSales { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasKey(ps => new { ps.ProductID, ps.SaleID }); + + modelBuilder.Entity() + .Property(p => p.Price) + .HasColumnType("decimal(18,2)"); + } +} + + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs new file mode 100644 index 00000000..93611620 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs @@ -0,0 +1,14 @@ +namespace Sills.GolfShop.eCommerceAPI.Helpers; + +public class PaginationParameters +{ + public const int MaxPageSize = 50; + public int PageNumber { get; set; } = 1; + + private int _pageSize = 10; + public int PageSize + { + get => _pageSize; + set => _pageSize = (value > MaxPageSize) ? MaxPageSize : value; + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs new file mode 100644 index 00000000..29734935 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs @@ -0,0 +1,20 @@ +namespace Sills.GolfShop.eCommerceAPI.Helpers; + +public class ProductParameters +{ + public string? name { get; set; } + public decimal? minPrice { get; set; } + public decimal? maxPrice { get; set; } + + public string? sortBy { get; set; } = null; +} + +public class CategoryParameters +{ + public string? name { get; set; } + public string? sortBy { get; set; } = null; +} + public class SalesParameters +{ + public string? sortBy { get; set; } = null; +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs new file mode 100644 index 00000000..d871125b --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs @@ -0,0 +1,16 @@ +namespace Sills.GolfShop.eCommerceAPI.Mapping +{ + public static class ProductMapper + { + public static DTO.ProductUpdateDto ToDTO(this Models.Product product) + { + if (product == null) return null; + return new DTO.ProductUpdateDto + { + Name = product.Name, + Description = product.Description, + QuantityInStock = product.QuantityInStock + }; + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs new file mode 100644 index 00000000..da26d3ec --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs @@ -0,0 +1,152 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sills.GolfShop.eCommerceAPI.Data; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + [DbContext(typeof(GolfShopDbContext))] + [Migration("20260403232616_initial")] + partial class initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.Property("ProductID") + .HasColumnType("int"); + + b.Property("SaleID") + .HasColumnType("int"); + + b.HasKey("ProductID", "SaleID"); + + b.HasIndex("SaleID"); + + b.ToTable("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("customerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("shippingAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") + .WithMany("ProductSales") + .HasForeignKey("ProductID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") + .WithMany("ProductSales") + .HasForeignKey("SaleID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Navigation("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Navigation("ProductSales"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs new file mode 100644 index 00000000..26705a90 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs @@ -0,0 +1,107 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + /// + public partial class initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + DeletedAt = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "decimal(18,2)", nullable: false), + QuantityInStock = table.Column(type: "int", nullable: false), + DeletedAt = table.Column(type: "datetime2", nullable: true), + CategoryId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Sales", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customerName = table.Column(type: "nvarchar(max)", nullable: false), + shippingAddress = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sales", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ProductSales", + columns: table => new + { + ProductID = table.Column(type: "int", nullable: false), + SaleID = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductSales", x => new { x.ProductID, x.SaleID }); + table.ForeignKey( + name: "FK_ProductSales_Products_ProductID", + column: x => x.ProductID, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductSales_Sales_SaleID", + column: x => x.SaleID, + principalTable: "Sales", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ProductSales_SaleID", + table: "ProductSales", + column: "SaleID"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.DropTable( + name: "ProductSales"); + + migrationBuilder.DropTable( + name: "Products"); + + migrationBuilder.DropTable( + name: "Sales"); + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs new file mode 100644 index 00000000..7bbf9761 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs @@ -0,0 +1,149 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sills.GolfShop.eCommerceAPI.Data; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + [DbContext(typeof(GolfShopDbContext))] + partial class GolfShopDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.Property("ProductID") + .HasColumnType("int"); + + b.Property("SaleID") + .HasColumnType("int"); + + b.HasKey("ProductID", "SaleID"); + + b.HasIndex("SaleID"); + + b.ToTable("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("customerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("shippingAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") + .WithMany("ProductSales") + .HasForeignKey("ProductID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") + .WithMany("ProductSales") + .HasForeignKey("SaleID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Navigation("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Navigation("ProductSales"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs new file mode 100644 index 00000000..d2073c4c --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs @@ -0,0 +1,11 @@ +namespace Sills.GolfShop.eCommerceAPI.Models +{ + public class Categories + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public DateTime? DeletedAt { get; set; } + + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs new file mode 100644 index 00000000..ac22a653 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs @@ -0,0 +1,14 @@ +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class Product +{ + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public decimal Price { get; set; } + public int QuantityInStock { get; set; } + public DateTime? DeletedAt { get; set; } + + public List ProductSales { get; } = []; + public int CategoryId { get; internal set; } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs new file mode 100644 index 00000000..09f7e23d --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; + +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class ProductSales +{ + public int ProductID { get; set; } + public int SaleID { get; set; } + public Product Product { get; set; } = null!; + public Sales Sale { get; set; } = null!; + + +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs new file mode 100644 index 00000000..afccd6eb --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs @@ -0,0 +1,11 @@ +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class Sales +{ + public int Id { get; set; } + public string customerName { get; set; } + + public string shippingAddress { get; set; } = string.Empty; + + public List ProductSales { get; } = []; +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json new file mode 100644 index 00000000..bf690538 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json @@ -0,0 +1,99 @@ +{ + "info": { + "name": "Sills Golf Shop eCommerce API", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Products", + "item": [ + { + "name": "Get All Products", + "request": { + "method": "GET", + "url": { + "raw": "{{baseUrl}}/api/Product?PageNumber=1&PageSize=10", + "host": [ "{{baseUrl}}" ], + "path": [ "api", "Product" ], + "query": [ + { + "key": "PageNumber", + "value": "1" + }, + { + "key": "PageSize", + "value": "10" + } + ] + } + } + }, + { + "name": "Create Product", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Driver\",\n \"description\": \"Titanium face driver\",\n \"price\": 499.99,\n \"quantityInStock\": 25,\n \"categoryId\": 1\n}" + }, + "url": "{{baseUrl}}/api/Product" + } + } + ] + }, + { + "name": "Categories", + "item": [ + { + "name": "Get All Categories", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/Category?PageNumber=1&PageSize=10&sortBy=name" + } + }, + { + "name": "Create Category", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Clubs\",\n \"description\": \"Drivers, Irons, and Putters\"\n}" + }, + "url": "{{baseUrl}}/api/Category" + } + } + ] + }, + { + "name": "Sales", + "item": [ + { + "name": "Get All Sales", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/Sales?PageNumber=1&PageSize=10" + } + } + ] + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "https://localhost:7000", + "type": "string" + } + ] +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json new file mode 100644 index 00000000..f8d04a84 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5283", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7070;http://localhost:5283", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs new file mode 100644 index 00000000..ed59f8d2 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; + +namespace Sills.GolfShop.eCommerceAPI.Services; + + + public interface ICategoryService + { + IQueryable GetAllCategoriesQuery(); + Task GetCategoryByIdAsync(int id); + Task CreateCategoryAsync(Categories category); + Task UpdateCategoryAsync(int id, Categories category); + Task DeleteCategoryAsync(int id); + } + +public class CategoryService : ICategoryService +{ + private readonly GolfShopDbContext _context; + + public CategoryService(GolfShopDbContext context) + { + _context = context; + } + + public IQueryable GetAllCategoriesQuery() + { + return _context.Categories.Where(c => c.DeletedAt == null); + } + + public async Task GetCategoryByIdAsync(int id) + { + return await _context.Categories + .Where(c => c.DeletedAt == null) + .FirstOrDefaultAsync(c => c.Id == id); + + } + + public async Task CreateCategoryAsync(Categories category) + { + _context.Categories.Add(category); + await _context.SaveChangesAsync(); + return category; + } + + public async Task UpdateCategoryAsync(int id, Categories category) + { + var existingCategory = await _context.Categories.FindAsync(id); + if (existingCategory == null) + { + return; + } + existingCategory.Name = category.Name; + existingCategory.Description = category.Description; + await _context.SaveChangesAsync(); + } + + public async Task DeleteCategoryAsync(int id) + { + var category = await _context.Categories.FindAsync(id); + if (category == null) + { + return; + } + category.DeletedAt = DateTime.UtcNow; + await _context.SaveChangesAsync(); + } + +} + + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs new file mode 100644 index 00000000..fcf17187 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Services; + + +public interface IProductsService +{ + Task> GetAllProductsAsync(); + Task GetProductByIdAsync(int id); + Task CreateProductAsync(Product product); + Task UpdateProductAsync(int id, Product product); + Task DeleteProductAsync(int id); +} +public class ProductsService : IProductsService +{ + private readonly GolfShopDbContext _context; + + public ProductsService(GolfShopDbContext context) + { + _context = context; + } + + public async Task> GetAllProductsAsync() + { + return await _context.Products + .Where(p => p.DeletedAt == null) + .ToListAsync(); + } + + public async Task GetProductByIdAsync(int id) + { + return await _context.Products + .Where(p => p.DeletedAt == null) + .FirstOrDefaultAsync(p => p.Id == id); + } + + public async Task CreateProductAsync(Product product) + { + _context.Products.Add(product); + await _context.SaveChangesAsync(); + return product; + } + + public async Task UpdateProductAsync(int id, Product product) + { + var existingProduct = await _context.Products + .Where(p => p.DeletedAt == null) + .FirstOrDefaultAsync(p => p.Id == id); + if (existingProduct == null) + { + return; + } + existingProduct.Name = product.Name; + existingProduct.Description = product.Description; + existingProduct.Price = product.Price; + existingProduct.CategoryId = product.CategoryId; + await _context.SaveChangesAsync(); + } + + public async Task DeleteProductAsync(int id) + { + var product = await _context.Products.FindAsync(id); + if (product == null) + { + return; + } + product.DeletedAt = DateTime.UtcNow; + await _context.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs new file mode 100644 index 00000000..38038557 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs @@ -0,0 +1,90 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Services; + +public interface ISalesService +{ + Task> GetAllSalesAsync(); + Task GetSaleByIdAsync(int id); + Task CreateSaleAsync(Sales sale); + Task DeleteSaleAsync(int id); + Task UpdateSaleAsync(int id, Sales sale); + + +} +public class SalesService : ISalesService +{ + private readonly GolfShopDbContext _context; + + public SalesService(GolfShopDbContext context) + { + _context = context; + } + + public async Task> GetAllSalesAsync() + { + return await _context.Sales.ToListAsync(); + } + public async Task GetSaleByIdAsync(int id) + { + return await _context.Sales.FindAsync(id); + } + public async Task CreateSaleAsync(Sales sale) + { + _context.Sales.Add(sale); + await _context.SaveChangesAsync(); + return sale; + } + public async Task UpdateSaleAsync(int id, Sales sale) + { + var existingSale = await _context.Sales.FindAsync(id); + if (existingSale == null) + { + return; + } + existingSale.customerName = sale.customerName; + existingSale.shippingAddress = sale.shippingAddress; + await _context.SaveChangesAsync(); + } + public async Task DeleteSaleAsync(int id) + { + var sale = await _context.Sales.FindAsync(id); + if (sale == null) + { + return; + } + _context.Sales.Remove(sale); + await _context.SaveChangesAsync(); + } + public async Task AddProductToSaleAsync(int saleId, int productId) + { + var sale = await _context.Sales.FindAsync(saleId); + var product = await _context.Products.FindAsync(productId); + if (sale == null || product == null) + { + return; + } + var productSale = new ProductSales + { + Sale = sale, + Product = product + }; + _context.ProductSales.Add(productSale); + await _context.SaveChangesAsync(); + } + + public async Task RemoveProductFromSaleAsync(int saleId, int productId) + { + var productSale = await _context.ProductSales + .FirstOrDefaultAsync(ps => ps.SaleID == saleId && ps.ProductID == productId); + if (productSale == null) + { + return; + } + _context.ProductSales.Remove(productSale); + await _context.SaveChangesAsync(); + } + +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http new file mode 100644 index 00000000..20ed7e48 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http @@ -0,0 +1,6 @@ +@Sills.GolfShop.eCommerce_HostAddress = http://localhost:5283 + +GET {{Sills.GolfShop.eCommerce_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj new file mode 100644 index 00000000..99d30c54 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj @@ -0,0 +1,24 @@ + + + + net10.0 + enable + enable + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json new file mode 100644 index 00000000..0a959ac0 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json @@ -0,0 +1,13 @@ +{ + "ConnectionStrings": { + "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB" + }, + + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs new file mode 100644 index 00000000..92caabf9 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs @@ -0,0 +1,6 @@ + +namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; + +internal class ProductsController +{ +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs new file mode 100644 index 00000000..baf7f7d3 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs @@ -0,0 +1,5 @@ +namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; + +internal class SaleController +{ +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs new file mode 100644 index 00000000..8d515946 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs @@ -0,0 +1,54 @@ +using Spectre.Console; + +namespace Sills.GolfShop.eCommerceFrontEnd.Menus; + +internal static class MainMenu +{ + public static void MainDisplay() + { + bool running = true; + + while (running) + { + Console.Clear(); + + AnsiConsole.Write( + new FigletText("Sills Golf Shop") + .LeftJustified() + .Color(Color.Green)); + + var choice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("What would you like to do?") + .AddChoices(new[] { + "View All Products", + "Choose a category", + "Cart", + "Checkout", + "View Order History", + "Exit" + })); + + + switch (choice) + { + case "View All Products": + //ProductMenu.DisplayProducts(); + break; + case "Choose a category": + //CategoryMenu.DisplayCategories(); + break; + case "Cart": + //CartMenu.DisplayCart(); + break; + case "Checkout": + break; + case "View Order History": + break; + case "Exit": + Environment.Exit(0); + break; + } + } + } +} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs new file mode 100644 index 00000000..0f605f45 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +internal class Categories +{ + [JsonProperty("Category")] + public required List CategoriesList { get; set; } +} +public class Category +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Description")] + public string Description { get; set; } + [JsonProperty("DeletedAt")] + public DateTime? DeletedAt { get; set; } +} + //[JsonProperty("Products")] + + // public List Products { get; } = []; + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs new file mode 100644 index 00000000..22a117ab --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs @@ -0,0 +1,33 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +public class Products +{ + [JsonProperty("Product")] + public required List ProductsList { get; set; } +} + +public class Product +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Description")] + public string Description { get; set; } + [JsonProperty("Price")] + public decimal Price { get; set; } + [JsonProperty("QuantityInStock")] + public int QuantityInStock { get; set; } + [JsonProperty("DeletedAt")] + public DateTime? DeletedAt { get; set; } + [JsonProperty("ProductSales")] + public List ProductSales { get; } = []; + + [JsonProperty("CategoryId")] + public int CategoryId { get; internal set; } + + +} + diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs new file mode 100644 index 00000000..7af2e97f --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +public class ProductSales +{ + [JsonProperty("ProductSales")] + public required List ProductSalesList { get; set; } +} + +public class ProductSale +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("ProductId")] + public int ProductId { get; set; } + [JsonProperty("SaleId")] + public int SaleId { get; set; } +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs new file mode 100644 index 00000000..83d1167c --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +internal class Sales +{ + [JsonProperty("Sales")] + public required List SalesList { get; set; } +} +internal class Sale +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("CustomerName")] + public string CustomerName { get; set; } + [JsonProperty("ShippingAddress")] + public string ShippingAddress { get; set; } = string.Empty; + [JsonProperty("ProductSales")] + public List ProductSales { get; } = []; +} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs new file mode 100644 index 00000000..736e542c --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs @@ -0,0 +1,10 @@ +namespace Sills.GolfShop.eCommerceFrontEnd; + +public class Program +{ + public static void Main(string[] args) + { + Menus.MainMenu.MainDisplay(); + } + +} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj new file mode 100644 index 00000000..ea8c6c82 --- /dev/null +++ b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj @@ -0,0 +1,19 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + + + + + From 13c13ecaada8ad7255bdc5dfbd5f2b815e14ab96 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Fri, 17 Apr 2026 08:16:32 -0500 Subject: [PATCH 03/13] rename folder to meed standards --- Sills.GolfShop.eCommerce/.gitattributes | 63 --- Sills.GolfShop.eCommerce/.gitignore | 363 ------------------ .../Sills.GolfShop.eCommerce.slnx | 4 - .../Controllers/CategoryController.cs | 82 ---- .../Controllers/ProductController.cs | 72 ---- .../Controllers/SalesController.cs | 66 ---- .../DTO/ProductDTO.cs | 9 - .../Data/GolfShopDbContext.cs | 24 -- .../Helpers/PaginationParameters.cs | 14 - .../Helpers/SortingParameters.cs | 20 - .../Mapping/ProductMapper.cs | 16 - .../20260403232616_initial.Designer.cs | 152 -------- .../Migrations/20260403232616_initial.cs | 107 ------ .../GolfShopDbContextModelSnapshot.cs | 149 ------- .../Models/Categories.cs | 11 - .../Models/Product.cs | 14 - .../Models/ProductSales.cs | 13 - .../Sills.GolfShop.eCommerce/Models/Sales.cs | 11 - .../Postman_Collection/PostmanCollection.json | 99 ----- .../Sills.GolfShop.eCommerce/Program.cs | 28 -- .../Properties/launchSettings.json | 23 -- .../Services/ICategoryService.cs | 72 ---- .../Services/IProductsService.cs | 72 ---- .../Services/ISalesService.cs | 90 ----- .../Sills.GolfShop.eCommerce.http | 6 - .../Sills.GolfShop.eCommerceAPI.csproj | 24 -- .../appsettings.Development.json | 8 - .../Sills.GolfShop.eCommerce/appsettings.json | 13 - .../Controllers/ProductsController.cs | 6 - .../Controllers/SaleController.cs | 5 - .../Menus/MainMenu.cs | 54 --- .../Models/Category.cs | 24 -- .../Models/Product.cs | 33 -- .../Models/ProductSales.cs | 19 - .../Models/Sales.cs | 20 - .../Program.cs | 10 - .../Sills.GolfShop.eCommerceFrontEnd.csproj | 19 - 37 files changed, 1815 deletions(-) delete mode 100644 Sills.GolfShop.eCommerce/.gitattributes delete mode 100644 Sills.GolfShop.eCommerce/.gitignore delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs delete mode 100644 Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj diff --git a/Sills.GolfShop.eCommerce/.gitattributes b/Sills.GolfShop.eCommerce/.gitattributes deleted file mode 100644 index 1ff0c423..00000000 --- a/Sills.GolfShop.eCommerce/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/Sills.GolfShop.eCommerce/.gitignore b/Sills.GolfShop.eCommerce/.gitignore deleted file mode 100644 index 9491a2fd..00000000 --- a/Sills.GolfShop.eCommerce/.gitignore +++ /dev/null @@ -1,363 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx deleted file mode 100644 index 9d67d4ca..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.slnx +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs deleted file mode 100644 index 33b9d2a7..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Sills.GolfShop.eCommerceAPI.Models; -using Sills.GolfShop.eCommerceAPI.Services; -using Sills.GolfShop.eCommerceAPI.Helpers; -using Microsoft.EntityFrameworkCore; - -namespace Sills.GolfShop.eCommerceAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -public class CategoryController(ICategoryService categoryService) : ControllerBase - -{ - private readonly ICategoryService _categoryService = categoryService; - - [HttpGet] - public async Task>> GetAllCategories([FromQuery] PaginationParameters param, [FromQuery] CategoryParameters categoryParams) - { - var query = _categoryService.GetAllCategoriesQuery(); - query = categoryParams.sortBy switch - { - "name_desc" => query.OrderByDescending(p => p.Name), - _ => query.OrderBy(p => p.Name) - }; - - var pagedCategories = await query - .Where(c => c.DeletedAt == null) - .Skip((param.PageNumber - 1) * param.PageSize) - .Take(param.PageSize) - .ToListAsync(); - - query = categoryParams.sortBy switch - { - "name_desc" => query.OrderByDescending(p => p.Name), - _ => query.OrderBy(p => p.Name) - }; - - return Ok(pagedCategories); - } - - [HttpGet("{id}")] - public ActionResult GetCategoryById(int id) - { - var category = _categoryService.GetCategoryByIdAsync(id); - if (category == null) - { - return NotFound(); - } - return Ok(category); - } - - [HttpPost] - public ActionResult CreateCategory(Categories category) - { - var createdCategory = _categoryService.CreateCategoryAsync(category); - return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory); - } - - [HttpPut("{id}")] - public IActionResult UpdateCategory(int id, Categories category) - { - var existingCategory = _categoryService.GetCategoryByIdAsync(id); - if (existingCategory == null) - { - return NotFound(); - } - _categoryService.UpdateCategoryAsync(id, category); - return NoContent(); - } - [HttpDelete("{id}")] - public IActionResult DeleteCategory(int id) - { - var existingCategory = _categoryService.GetCategoryByIdAsync(id); - if (existingCategory == null) - { - return NotFound(); - } - _categoryService.DeleteCategoryAsync(id); - return NoContent(); - } - -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs deleted file mode 100644 index ca8c6609..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/ProductController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Sills.GolfShop.eCommerceAPI.DTO; -using Sills.GolfShop.eCommerceAPI.Helpers; -using Sills.GolfShop.eCommerceAPI.Models; -using Sills.GolfShop.eCommerceAPI.Services; - -namespace Sills.GolfShop.eCommerceAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] - -public class ProductController(IProductsService productsService) : ControllerBase -{ - private readonly IProductsService _productService = productsService; - - [HttpGet] - public ActionResult> GetAllProducts(PaginationParameters param) - { - var products = _productService.GetAllProductsAsync().Result; - var pagedProducts = products - .Skip((param.PageNumber - 1) * param.PageSize) - .Take(param.PageSize) - .ToList(); - return Ok(products); - } - - [HttpGet("{id}")] - public async Task> GetProductById(int id) - { - var product = await _productService.GetProductByIdAsync(id); - if (product == null) - { - return NotFound(); - } - return Ok(product); - } - [HttpPost] - public async Task> CreateProduct(Product product) - { - var createdProduct = await _productService.CreateProductAsync(product); - return CreatedAtAction(nameof(GetProductById), new { id = createdProduct.Id }, createdProduct); - } - - [HttpPut("{id}")] - public async Task UpdateProduct(int id, ProductUpdateDto productUpdateDto) - { - var existingProduct = _productService.GetProductByIdAsync(id).Result; - if (existingProduct == null) - { - return NotFound(); - } - existingProduct.Name = productUpdateDto.Name; - existingProduct.Description = productUpdateDto.Description; - existingProduct.QuantityInStock = productUpdateDto.QuantityInStock; - - await _productService.UpdateProductAsync(id, existingProduct); - return NoContent(); - } - - [HttpDelete("{id}")] - public IActionResult DeleteProduct(int id) - { - var existingProduct = _productService.GetProductByIdAsync(id).Result; - if (existingProduct == null) - { - return NotFound(); - } - _productService.DeleteProductAsync(id).Wait(); - - return NoContent(); - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs deleted file mode 100644 index 4791679c..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Controllers/SalesController.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Sills.GolfShop.eCommerceAPI.Services; -using Microsoft.AspNetCore.Mvc; -using Sills.GolfShop.eCommerceAPI.Models; -using Sills.GolfShop.eCommerceAPI.Helpers; - -namespace Sills.GolfShop.eCommerceAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -public class SalesController(ISalesService salesService) : ControllerBase -{ - private readonly ISalesService _salesService = salesService; - - [HttpGet] - public ActionResult> GetAllSales(PaginationParameters param) - { - var sales = _salesService.GetAllSalesAsync().Result; - - var pagedSales = sales - .Skip((param.PageNumber - 1) * param.PageSize) - .Take(param.PageSize) - .ToList(); - - return Ok(sales); - } - [HttpGet("{id}")] - public async Task> GetSaleById(int id) - { - var sale = await _salesService.GetSaleByIdAsync(id); - if (sale == null) - { - return NotFound(); - } - return Ok(sale); - } - [HttpPost] - public async Task> CreateSale(Sales sale) - { - var createdSale = await _salesService.CreateSaleAsync(sale); - return CreatedAtAction(nameof(GetSaleById), new { id = createdSale.Id }, createdSale); - } - [HttpPut("{id}")] - public IActionResult UpdateSale(int id, Sales sale) - { - var existingSale = _salesService.GetSaleByIdAsync(id).Result; - if (existingSale == null) - { - return NotFound(); - } - _salesService.UpdateSaleAsync(id, sale).Wait(); - return NoContent(); - } - - [HttpDelete("{id}")] - public IActionResult DeleteSale(int id) - { - var existingSale = _salesService.GetSaleByIdAsync(id).Result; - if (existingSale == null) - { - return NotFound(); - } - _salesService.DeleteSaleAsync(id).Wait(); - return NoContent(); - } - - } diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs deleted file mode 100644 index e34179a8..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.DTO -{ - public record ProductUpdateDto - { - public string Name { get; init; } - public string Description { get; init; } - public int QuantityInStock { get; init; } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs deleted file mode 100644 index cf0b3458..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Sills.GolfShop.eCommerceAPI.Models; - -namespace Sills.GolfShop.eCommerceAPI.Data; - -public class GolfShopDbContext(DbContextOptions options) : DbContext(options) -{ - - public DbSet Products { get; set; } - public DbSet Categories { get; set; } - public DbSet Sales { get; set; } - public DbSet ProductSales { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity() - .HasKey(ps => new { ps.ProductID, ps.SaleID }); - - modelBuilder.Entity() - .Property(p => p.Price) - .HasColumnType("decimal(18,2)"); - } -} - - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs deleted file mode 100644 index 93611620..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Helpers; - -public class PaginationParameters -{ - public const int MaxPageSize = 50; - public int PageNumber { get; set; } = 1; - - private int _pageSize = 10; - public int PageSize - { - get => _pageSize; - set => _pageSize = (value > MaxPageSize) ? MaxPageSize : value; - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs deleted file mode 100644 index 29734935..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Helpers; - -public class ProductParameters -{ - public string? name { get; set; } - public decimal? minPrice { get; set; } - public decimal? maxPrice { get; set; } - - public string? sortBy { get; set; } = null; -} - -public class CategoryParameters -{ - public string? name { get; set; } - public string? sortBy { get; set; } = null; -} - public class SalesParameters -{ - public string? sortBy { get; set; } = null; -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs deleted file mode 100644 index d871125b..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Mapping -{ - public static class ProductMapper - { - public static DTO.ProductUpdateDto ToDTO(this Models.Product product) - { - if (product == null) return null; - return new DTO.ProductUpdateDto - { - Name = product.Name, - Description = product.Description, - QuantityInStock = product.QuantityInStock - }; - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs deleted file mode 100644 index da26d3ec..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs +++ /dev/null @@ -1,152 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sills.GolfShop.eCommerceAPI.Data; - -#nullable disable - -namespace Sills.GolfShop.eCommerceAPI.Migrations -{ - [DbContext(typeof(GolfShopDbContext))] - [Migration("20260403232616_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeletedAt") - .HasColumnType("datetime2"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("int"); - - b.Property("DeletedAt") - .HasColumnType("datetime2"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("QuantityInStock") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => - { - b.Property("ProductID") - .HasColumnType("int"); - - b.Property("SaleID") - .HasColumnType("int"); - - b.HasKey("ProductID", "SaleID"); - - b.HasIndex("SaleID"); - - b.ToTable("ProductSales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("customerName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("shippingAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Sales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => - { - b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") - .WithMany("ProductSales") - .HasForeignKey("ProductID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") - .WithMany("ProductSales") - .HasForeignKey("SaleID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Sale"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => - { - b.Navigation("ProductSales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => - { - b.Navigation("ProductSales"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs deleted file mode 100644 index 26705a90..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Sills.GolfShop.eCommerceAPI.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: false), - DeletedAt = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Products", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "decimal(18,2)", nullable: false), - QuantityInStock = table.Column(type: "int", nullable: false), - DeletedAt = table.Column(type: "datetime2", nullable: true), - CategoryId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Products", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Sales", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - customerName = table.Column(type: "nvarchar(max)", nullable: false), - shippingAddress = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Sales", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ProductSales", - columns: table => new - { - ProductID = table.Column(type: "int", nullable: false), - SaleID = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ProductSales", x => new { x.ProductID, x.SaleID }); - table.ForeignKey( - name: "FK_ProductSales_Products_ProductID", - column: x => x.ProductID, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ProductSales_Sales_SaleID", - column: x => x.SaleID, - principalTable: "Sales", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_ProductSales_SaleID", - table: "ProductSales", - column: "SaleID"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Categories"); - - migrationBuilder.DropTable( - name: "ProductSales"); - - migrationBuilder.DropTable( - name: "Products"); - - migrationBuilder.DropTable( - name: "Sales"); - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs deleted file mode 100644 index 7bbf9761..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Sills.GolfShop.eCommerceAPI.Data; - -#nullable disable - -namespace Sills.GolfShop.eCommerceAPI.Migrations -{ - [DbContext(typeof(GolfShopDbContext))] - partial class GolfShopDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DeletedAt") - .HasColumnType("datetime2"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CategoryId") - .HasColumnType("int"); - - b.Property("DeletedAt") - .HasColumnType("datetime2"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.Property("QuantityInStock") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Products"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => - { - b.Property("ProductID") - .HasColumnType("int"); - - b.Property("SaleID") - .HasColumnType("int"); - - b.HasKey("ProductID", "SaleID"); - - b.HasIndex("SaleID"); - - b.ToTable("ProductSales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("customerName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("shippingAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Sales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => - { - b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") - .WithMany("ProductSales") - .HasForeignKey("ProductID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") - .WithMany("ProductSales") - .HasForeignKey("SaleID") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Product"); - - b.Navigation("Sale"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => - { - b.Navigation("ProductSales"); - }); - - modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => - { - b.Navigation("ProductSales"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs deleted file mode 100644 index d2073c4c..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Categories.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Models -{ - public class Categories - { - public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public DateTime? DeletedAt { get; set; } - - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs deleted file mode 100644 index ac22a653..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Product.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Models; - -public class Product -{ - public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public decimal Price { get; set; } - public int QuantityInStock { get; set; } - public DateTime? DeletedAt { get; set; } - - public List ProductSales { get; } = []; - public int CategoryId { get; internal set; } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs deleted file mode 100644 index 09f7e23d..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/ProductSales.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace Sills.GolfShop.eCommerceAPI.Models; - -public class ProductSales -{ - public int ProductID { get; set; } - public int SaleID { get; set; } - public Product Product { get; set; } = null!; - public Sales Sale { get; set; } = null!; - - -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs deleted file mode 100644 index afccd6eb..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Models/Sales.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.Models; - -public class Sales -{ - public int Id { get; set; } - public string customerName { get; set; } - - public string shippingAddress { get; set; } = string.Empty; - - public List ProductSales { get; } = []; -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json deleted file mode 100644 index bf690538..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "info": { - "name": "Sills Golf Shop eCommerce API", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Products", - "item": [ - { - "name": "Get All Products", - "request": { - "method": "GET", - "url": { - "raw": "{{baseUrl}}/api/Product?PageNumber=1&PageSize=10", - "host": [ "{{baseUrl}}" ], - "path": [ "api", "Product" ], - "query": [ - { - "key": "PageNumber", - "value": "1" - }, - { - "key": "PageSize", - "value": "10" - } - ] - } - } - }, - { - "name": "Create Product", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"name\": \"Driver\",\n \"description\": \"Titanium face driver\",\n \"price\": 499.99,\n \"quantityInStock\": 25,\n \"categoryId\": 1\n}" - }, - "url": "{{baseUrl}}/api/Product" - } - } - ] - }, - { - "name": "Categories", - "item": [ - { - "name": "Get All Categories", - "request": { - "method": "GET", - "url": "{{baseUrl}}/api/Category?PageNumber=1&PageSize=10&sortBy=name" - } - }, - { - "name": "Create Category", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"name\": \"Clubs\",\n \"description\": \"Drivers, Irons, and Putters\"\n}" - }, - "url": "{{baseUrl}}/api/Category" - } - } - ] - }, - { - "name": "Sales", - "item": [ - { - "name": "Get All Sales", - "request": { - "method": "GET", - "url": "{{baseUrl}}/api/Sales?PageNumber=1&PageSize=10" - } - } - ] - } - ], - "variable": [ - { - "key": "baseUrl", - "value": "https://localhost:7000", - "type": "string" - } - ] -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs deleted file mode 100644 index 9d3ee9d1..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Program.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Sills.GolfShop.eCommerceAPI.Data; -using Sills.GolfShop.eCommerceAPI.Services; - -var builder = WebApplication.CreateBuilder(args); - - -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddControllers(); -builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); - -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -builder.WebHost.UseUrls("http://localhost:8080"); - -var app = builder.Build(); - -if (app.Environment.IsDevelopment()) -{ - app.MapOpenApi(); - -} - -app.MapControllers(); - -app.Run(); diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json deleted file mode 100644 index f8d04a84..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Properties/launchSettings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:5283", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:7070;http://localhost:5283", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs deleted file mode 100644 index ed59f8d2..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ICategoryService.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Sills.GolfShop.eCommerceAPI.Data; -using Sills.GolfShop.eCommerceAPI.Models; -using Sills.GolfShop.eCommerceAPI.Services; - -namespace Sills.GolfShop.eCommerceAPI.Services; - - - public interface ICategoryService - { - IQueryable GetAllCategoriesQuery(); - Task GetCategoryByIdAsync(int id); - Task CreateCategoryAsync(Categories category); - Task UpdateCategoryAsync(int id, Categories category); - Task DeleteCategoryAsync(int id); - } - -public class CategoryService : ICategoryService -{ - private readonly GolfShopDbContext _context; - - public CategoryService(GolfShopDbContext context) - { - _context = context; - } - - public IQueryable GetAllCategoriesQuery() - { - return _context.Categories.Where(c => c.DeletedAt == null); - } - - public async Task GetCategoryByIdAsync(int id) - { - return await _context.Categories - .Where(c => c.DeletedAt == null) - .FirstOrDefaultAsync(c => c.Id == id); - - } - - public async Task CreateCategoryAsync(Categories category) - { - _context.Categories.Add(category); - await _context.SaveChangesAsync(); - return category; - } - - public async Task UpdateCategoryAsync(int id, Categories category) - { - var existingCategory = await _context.Categories.FindAsync(id); - if (existingCategory == null) - { - return; - } - existingCategory.Name = category.Name; - existingCategory.Description = category.Description; - await _context.SaveChangesAsync(); - } - - public async Task DeleteCategoryAsync(int id) - { - var category = await _context.Categories.FindAsync(id); - if (category == null) - { - return; - } - category.DeletedAt = DateTime.UtcNow; - await _context.SaveChangesAsync(); - } - -} - - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs deleted file mode 100644 index fcf17187..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/IProductsService.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Sills.GolfShop.eCommerceAPI.Data; -using Sills.GolfShop.eCommerceAPI.Models; - -namespace Sills.GolfShop.eCommerceAPI.Services; - - -public interface IProductsService -{ - Task> GetAllProductsAsync(); - Task GetProductByIdAsync(int id); - Task CreateProductAsync(Product product); - Task UpdateProductAsync(int id, Product product); - Task DeleteProductAsync(int id); -} -public class ProductsService : IProductsService -{ - private readonly GolfShopDbContext _context; - - public ProductsService(GolfShopDbContext context) - { - _context = context; - } - - public async Task> GetAllProductsAsync() - { - return await _context.Products - .Where(p => p.DeletedAt == null) - .ToListAsync(); - } - - public async Task GetProductByIdAsync(int id) - { - return await _context.Products - .Where(p => p.DeletedAt == null) - .FirstOrDefaultAsync(p => p.Id == id); - } - - public async Task CreateProductAsync(Product product) - { - _context.Products.Add(product); - await _context.SaveChangesAsync(); - return product; - } - - public async Task UpdateProductAsync(int id, Product product) - { - var existingProduct = await _context.Products - .Where(p => p.DeletedAt == null) - .FirstOrDefaultAsync(p => p.Id == id); - if (existingProduct == null) - { - return; - } - existingProduct.Name = product.Name; - existingProduct.Description = product.Description; - existingProduct.Price = product.Price; - existingProduct.CategoryId = product.CategoryId; - await _context.SaveChangesAsync(); - } - - public async Task DeleteProductAsync(int id) - { - var product = await _context.Products.FindAsync(id); - if (product == null) - { - return; - } - product.DeletedAt = DateTime.UtcNow; - await _context.SaveChangesAsync(); - } -} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs deleted file mode 100644 index 38038557..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Services/ISalesService.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Sills.GolfShop.eCommerceAPI.Data; -using Sills.GolfShop.eCommerceAPI.Models; - -namespace Sills.GolfShop.eCommerceAPI.Services; - -public interface ISalesService -{ - Task> GetAllSalesAsync(); - Task GetSaleByIdAsync(int id); - Task CreateSaleAsync(Sales sale); - Task DeleteSaleAsync(int id); - Task UpdateSaleAsync(int id, Sales sale); - - -} -public class SalesService : ISalesService -{ - private readonly GolfShopDbContext _context; - - public SalesService(GolfShopDbContext context) - { - _context = context; - } - - public async Task> GetAllSalesAsync() - { - return await _context.Sales.ToListAsync(); - } - public async Task GetSaleByIdAsync(int id) - { - return await _context.Sales.FindAsync(id); - } - public async Task CreateSaleAsync(Sales sale) - { - _context.Sales.Add(sale); - await _context.SaveChangesAsync(); - return sale; - } - public async Task UpdateSaleAsync(int id, Sales sale) - { - var existingSale = await _context.Sales.FindAsync(id); - if (existingSale == null) - { - return; - } - existingSale.customerName = sale.customerName; - existingSale.shippingAddress = sale.shippingAddress; - await _context.SaveChangesAsync(); - } - public async Task DeleteSaleAsync(int id) - { - var sale = await _context.Sales.FindAsync(id); - if (sale == null) - { - return; - } - _context.Sales.Remove(sale); - await _context.SaveChangesAsync(); - } - public async Task AddProductToSaleAsync(int saleId, int productId) - { - var sale = await _context.Sales.FindAsync(saleId); - var product = await _context.Products.FindAsync(productId); - if (sale == null || product == null) - { - return; - } - var productSale = new ProductSales - { - Sale = sale, - Product = product - }; - _context.ProductSales.Add(productSale); - await _context.SaveChangesAsync(); - } - - public async Task RemoveProductFromSaleAsync(int saleId, int productId) - { - var productSale = await _context.ProductSales - .FirstOrDefaultAsync(ps => ps.SaleID == saleId && ps.ProductID == productId); - if (productSale == null) - { - return; - } - _context.ProductSales.Remove(productSale); - await _context.SaveChangesAsync(); - } - -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http deleted file mode 100644 index 20ed7e48..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http +++ /dev/null @@ -1,6 +0,0 @@ -@Sills.GolfShop.eCommerce_HostAddress = http://localhost:5283 - -GET {{Sills.GolfShop.eCommerce_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj deleted file mode 100644 index 99d30c54..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net10.0 - enable - enable - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json deleted file mode 100644 index 0c208ae9..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json deleted file mode 100644 index 0a959ac0..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce/appsettings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB" - }, - - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs deleted file mode 100644 index 92caabf9..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs +++ /dev/null @@ -1,6 +0,0 @@ - -namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; - -internal class ProductsController -{ -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs deleted file mode 100644 index baf7f7d3..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; - -internal class SaleController -{ -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs deleted file mode 100644 index 8d515946..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Spectre.Console; - -namespace Sills.GolfShop.eCommerceFrontEnd.Menus; - -internal static class MainMenu -{ - public static void MainDisplay() - { - bool running = true; - - while (running) - { - Console.Clear(); - - AnsiConsole.Write( - new FigletText("Sills Golf Shop") - .LeftJustified() - .Color(Color.Green)); - - var choice = AnsiConsole.Prompt( - new SelectionPrompt() - .Title("What would you like to do?") - .AddChoices(new[] { - "View All Products", - "Choose a category", - "Cart", - "Checkout", - "View Order History", - "Exit" - })); - - - switch (choice) - { - case "View All Products": - //ProductMenu.DisplayProducts(); - break; - case "Choose a category": - //CategoryMenu.DisplayCategories(); - break; - case "Cart": - //CartMenu.DisplayCart(); - break; - case "Checkout": - break; - case "View Order History": - break; - case "Exit": - Environment.Exit(0); - break; - } - } - } -} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs deleted file mode 100644 index 0f605f45..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Newtonsoft.Json; - -namespace Sills.GolfShop.eCommerceFrontEnd.Models; - -internal class Categories -{ - [JsonProperty("Category")] - public required List CategoriesList { get; set; } -} -public class Category -{ - [JsonProperty("Id")] - public int Id { get; set; } - [JsonProperty("Name")] - public string Name { get; set; } - [JsonProperty("Description")] - public string Description { get; set; } - [JsonProperty("DeletedAt")] - public DateTime? DeletedAt { get; set; } -} - //[JsonProperty("Products")] - - // public List Products { get; } = []; - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs deleted file mode 100644 index 22a117ab..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Newtonsoft.Json; - -namespace Sills.GolfShop.eCommerceFrontEnd.Models; - -public class Products -{ - [JsonProperty("Product")] - public required List ProductsList { get; set; } -} - -public class Product -{ - [JsonProperty("Id")] - public int Id { get; set; } - [JsonProperty("Name")] - public string Name { get; set; } - [JsonProperty("Description")] - public string Description { get; set; } - [JsonProperty("Price")] - public decimal Price { get; set; } - [JsonProperty("QuantityInStock")] - public int QuantityInStock { get; set; } - [JsonProperty("DeletedAt")] - public DateTime? DeletedAt { get; set; } - [JsonProperty("ProductSales")] - public List ProductSales { get; } = []; - - [JsonProperty("CategoryId")] - public int CategoryId { get; internal set; } - - -} - diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs deleted file mode 100644 index 7af2e97f..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Newtonsoft.Json; - -namespace Sills.GolfShop.eCommerceFrontEnd.Models; - -public class ProductSales -{ - [JsonProperty("ProductSales")] - public required List ProductSalesList { get; set; } -} - -public class ProductSale -{ - [JsonProperty("Id")] - public int Id { get; set; } - [JsonProperty("ProductId")] - public int ProductId { get; set; } - [JsonProperty("SaleId")] - public int SaleId { get; set; } -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs deleted file mode 100644 index 83d1167c..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; - -namespace Sills.GolfShop.eCommerceFrontEnd.Models; - -internal class Sales -{ - [JsonProperty("Sales")] - public required List SalesList { get; set; } -} -internal class Sale -{ - [JsonProperty("Id")] - public int Id { get; set; } - [JsonProperty("CustomerName")] - public string CustomerName { get; set; } - [JsonProperty("ShippingAddress")] - public string ShippingAddress { get; set; } = string.Empty; - [JsonProperty("ProductSales")] - public List ProductSales { get; } = []; -} diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs deleted file mode 100644 index 736e542c..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Program.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Sills.GolfShop.eCommerceFrontEnd; - -public class Program -{ - public static void Main(string[] args) - { - Menus.MainMenu.MainDisplay(); - } - -} \ No newline at end of file diff --git a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj b/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj deleted file mode 100644 index ea8c6c82..00000000 --- a/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Exe - net10.0 - enable - enable - - - - - - - - - - - - From 6d3f6c93046555e6715e53cb9503786c585f89f4 Mon Sep 17 00:00:00 2001 From: David Sills Date: Tue, 21 Apr 2026 08:21:55 -0500 Subject: [PATCH 04/13] Pushing all code --- eCommerceApi.dsills735/.gitattributes | 63 +++ eCommerceApi.dsills735/.gitignore | 363 ++++++++++++++++++ .../Sills.GolfShop.eCommerce.slnx | 4 + .../Controllers/CategoryController.cs | 82 ++++ .../Controllers/ProductController.cs | 74 ++++ .../Controllers/SalesController.cs | 66 ++++ .../DTO/ProductDTO.cs | 9 + .../Data/GolfShopDbContext.cs | 24 ++ .../Helpers/PaginationParameters.cs | 14 + .../Helpers/SortingParameters.cs | 20 + .../Mapping/ProductMapper.cs | 16 + .../20260403232616_initial.Designer.cs | 152 ++++++++ .../Migrations/20260403232616_initial.cs | 107 ++++++ .../GolfShopDbContextModelSnapshot.cs | 149 +++++++ .../Models/Categories.cs | 11 + .../Models/Product.cs | 14 + .../Models/ProductSales.cs | 13 + .../Sills.GolfShop.eCommerce/Models/Sales.cs | 11 + .../Postman_Collection/PostmanCollection.json | 99 +++++ .../Sills.GolfShop.eCommerce/Program.cs | 28 ++ .../Properties/launchSettings.json | 23 ++ .../Services/ICategoryService.cs | 72 ++++ .../Services/IProductsService.cs | 72 ++++ .../Services/ISalesService.cs | 90 +++++ .../Sills.GolfShop.eCommerce.http | 6 + .../Sills.GolfShop.eCommerceAPI.csproj | 24 ++ .../appsettings.Development.json | 8 + .../Sills.GolfShop.eCommerce/appsettings.json | 13 + .../Controllers/ProductsController.cs | 34 ++ .../Controllers/SaleController.cs | 5 + .../Helpers/Pagination.cs | 11 + .../Menus/AdministratorMenu.cs | 55 +++ .../Menus/MainMenu.cs | 69 ++++ .../Models/Category.cs | 24 ++ .../Models/Product.cs | 33 ++ .../Models/ProductSales.cs | 19 + .../Models/Sales.cs | 20 + .../Program.cs | 10 + .../Services/ProductService.cs | 68 ++++ .../Sills.GolfShop.eCommerceFrontEnd.csproj | 15 + .../Visualizations/ProductVisualizations.cs | 29 ++ 41 files changed, 2019 insertions(+) create mode 100644 eCommerceApi.dsills735/.gitattributes create mode 100644 eCommerceApi.dsills735/.gitignore create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Helpers/Pagination.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Program.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Services/ProductService.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Visualizations/ProductVisualizations.cs diff --git a/eCommerceApi.dsills735/.gitattributes b/eCommerceApi.dsills735/.gitattributes new file mode 100644 index 00000000..1ff0c423 --- /dev/null +++ b/eCommerceApi.dsills735/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/eCommerceApi.dsills735/.gitignore b/eCommerceApi.dsills735/.gitignore new file mode 100644 index 00000000..9491a2fd --- /dev/null +++ b/eCommerceApi.dsills735/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx new file mode 100644 index 00000000..9d67d4ca --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx @@ -0,0 +1,4 @@ + + + + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs new file mode 100644 index 00000000..33b9d2a7 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs @@ -0,0 +1,82 @@ +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; +using Sills.GolfShop.eCommerceAPI.Helpers; +using Microsoft.EntityFrameworkCore; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class CategoryController(ICategoryService categoryService) : ControllerBase + +{ + private readonly ICategoryService _categoryService = categoryService; + + [HttpGet] + public async Task>> GetAllCategories([FromQuery] PaginationParameters param, [FromQuery] CategoryParameters categoryParams) + { + var query = _categoryService.GetAllCategoriesQuery(); + query = categoryParams.sortBy switch + { + "name_desc" => query.OrderByDescending(p => p.Name), + _ => query.OrderBy(p => p.Name) + }; + + var pagedCategories = await query + .Where(c => c.DeletedAt == null) + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToListAsync(); + + query = categoryParams.sortBy switch + { + "name_desc" => query.OrderByDescending(p => p.Name), + _ => query.OrderBy(p => p.Name) + }; + + return Ok(pagedCategories); + } + + [HttpGet("{id}")] + public ActionResult GetCategoryById(int id) + { + var category = _categoryService.GetCategoryByIdAsync(id); + if (category == null) + { + return NotFound(); + } + return Ok(category); + } + + [HttpPost] + public ActionResult CreateCategory(Categories category) + { + var createdCategory = _categoryService.CreateCategoryAsync(category); + return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory); + } + + [HttpPut("{id}")] + public IActionResult UpdateCategory(int id, Categories category) + { + var existingCategory = _categoryService.GetCategoryByIdAsync(id); + if (existingCategory == null) + { + return NotFound(); + } + _categoryService.UpdateCategoryAsync(id, category); + return NoContent(); + } + [HttpDelete("{id}")] + public IActionResult DeleteCategory(int id) + { + var existingCategory = _categoryService.GetCategoryByIdAsync(id); + if (existingCategory == null) + { + return NotFound(); + } + _categoryService.DeleteCategoryAsync(id); + return NoContent(); + } + +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs new file mode 100644 index 00000000..f725159e --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -0,0 +1,74 @@ +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.DTO; +using Sills.GolfShop.eCommerceAPI.Helpers; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] + +public class ProductController(IProductsService productsService) : ControllerBase +{ + private readonly IProductsService _productService = productsService; + + [HttpGet] + public ActionResult> GetAllProducts([FromQuery]PaginationParameters param) + { + var products = _productService.GetAllProductsAsync().Result; + + var pagedProducts = products + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToList(); + + return Ok(products); + } + + [HttpGet("{id}")] + public async Task> GetProductById(int id) + { + var product = await _productService.GetProductByIdAsync(id); + if (product == null) + { + return NotFound(); + } + return Ok(product); + } + [HttpPost] + public async Task> CreateProduct(Product product) + { + var createdProduct = await _productService.CreateProductAsync(product); + return CreatedAtAction(nameof(GetProductById), new { id = createdProduct.Id }, createdProduct); + } + + [HttpPut("{id}")] + public async Task UpdateProduct(int id, ProductUpdateDto productUpdateDto) + { + var existingProduct = _productService.GetProductByIdAsync(id).Result; + if (existingProduct == null) + { + return NotFound(); + } + existingProduct.Name = productUpdateDto.Name; + existingProduct.Description = productUpdateDto.Description; + existingProduct.QuantityInStock = productUpdateDto.QuantityInStock; + + await _productService.UpdateProductAsync(id, existingProduct); + return NoContent(); + } + + [HttpDelete("{id}")] + public IActionResult DeleteProduct(int id) + { + var existingProduct = _productService.GetProductByIdAsync(id).Result; + if (existingProduct == null) + { + return NotFound(); + } + _productService.DeleteProductAsync(id).Wait(); + + return NoContent(); + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs new file mode 100644 index 00000000..4791679c --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs @@ -0,0 +1,66 @@ +using Sills.GolfShop.eCommerceAPI.Services; +using Microsoft.AspNetCore.Mvc; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Helpers; + +namespace Sills.GolfShop.eCommerceAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class SalesController(ISalesService salesService) : ControllerBase +{ + private readonly ISalesService _salesService = salesService; + + [HttpGet] + public ActionResult> GetAllSales(PaginationParameters param) + { + var sales = _salesService.GetAllSalesAsync().Result; + + var pagedSales = sales + .Skip((param.PageNumber - 1) * param.PageSize) + .Take(param.PageSize) + .ToList(); + + return Ok(sales); + } + [HttpGet("{id}")] + public async Task> GetSaleById(int id) + { + var sale = await _salesService.GetSaleByIdAsync(id); + if (sale == null) + { + return NotFound(); + } + return Ok(sale); + } + [HttpPost] + public async Task> CreateSale(Sales sale) + { + var createdSale = await _salesService.CreateSaleAsync(sale); + return CreatedAtAction(nameof(GetSaleById), new { id = createdSale.Id }, createdSale); + } + [HttpPut("{id}")] + public IActionResult UpdateSale(int id, Sales sale) + { + var existingSale = _salesService.GetSaleByIdAsync(id).Result; + if (existingSale == null) + { + return NotFound(); + } + _salesService.UpdateSaleAsync(id, sale).Wait(); + return NoContent(); + } + + [HttpDelete("{id}")] + public IActionResult DeleteSale(int id) + { + var existingSale = _salesService.GetSaleByIdAsync(id).Result; + if (existingSale == null) + { + return NotFound(); + } + _salesService.DeleteSaleAsync(id).Wait(); + return NoContent(); + } + + } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs new file mode 100644 index 00000000..e34179a8 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs @@ -0,0 +1,9 @@ +namespace Sills.GolfShop.eCommerceAPI.DTO +{ + public record ProductUpdateDto + { + public string Name { get; init; } + public string Description { get; init; } + public int QuantityInStock { get; init; } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs new file mode 100644 index 00000000..cf0b3458 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Data; + +public class GolfShopDbContext(DbContextOptions options) : DbContext(options) +{ + + public DbSet Products { get; set; } + public DbSet Categories { get; set; } + public DbSet Sales { get; set; } + public DbSet ProductSales { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasKey(ps => new { ps.ProductID, ps.SaleID }); + + modelBuilder.Entity() + .Property(p => p.Price) + .HasColumnType("decimal(18,2)"); + } +} + + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs new file mode 100644 index 00000000..93611620 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs @@ -0,0 +1,14 @@ +namespace Sills.GolfShop.eCommerceAPI.Helpers; + +public class PaginationParameters +{ + public const int MaxPageSize = 50; + public int PageNumber { get; set; } = 1; + + private int _pageSize = 10; + public int PageSize + { + get => _pageSize; + set => _pageSize = (value > MaxPageSize) ? MaxPageSize : value; + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs new file mode 100644 index 00000000..29734935 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs @@ -0,0 +1,20 @@ +namespace Sills.GolfShop.eCommerceAPI.Helpers; + +public class ProductParameters +{ + public string? name { get; set; } + public decimal? minPrice { get; set; } + public decimal? maxPrice { get; set; } + + public string? sortBy { get; set; } = null; +} + +public class CategoryParameters +{ + public string? name { get; set; } + public string? sortBy { get; set; } = null; +} + public class SalesParameters +{ + public string? sortBy { get; set; } = null; +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs new file mode 100644 index 00000000..d871125b --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs @@ -0,0 +1,16 @@ +namespace Sills.GolfShop.eCommerceAPI.Mapping +{ + public static class ProductMapper + { + public static DTO.ProductUpdateDto ToDTO(this Models.Product product) + { + if (product == null) return null; + return new DTO.ProductUpdateDto + { + Name = product.Name, + Description = product.Description, + QuantityInStock = product.QuantityInStock + }; + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs new file mode 100644 index 00000000..da26d3ec --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs @@ -0,0 +1,152 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sills.GolfShop.eCommerceAPI.Data; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + [DbContext(typeof(GolfShopDbContext))] + [Migration("20260403232616_initial")] + partial class initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.Property("ProductID") + .HasColumnType("int"); + + b.Property("SaleID") + .HasColumnType("int"); + + b.HasKey("ProductID", "SaleID"); + + b.HasIndex("SaleID"); + + b.ToTable("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("customerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("shippingAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") + .WithMany("ProductSales") + .HasForeignKey("ProductID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") + .WithMany("ProductSales") + .HasForeignKey("SaleID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Navigation("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Navigation("ProductSales"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs new file mode 100644 index 00000000..26705a90 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs @@ -0,0 +1,107 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + /// + public partial class initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + DeletedAt = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "decimal(18,2)", nullable: false), + QuantityInStock = table.Column(type: "int", nullable: false), + DeletedAt = table.Column(type: "datetime2", nullable: true), + CategoryId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Sales", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customerName = table.Column(type: "nvarchar(max)", nullable: false), + shippingAddress = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sales", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ProductSales", + columns: table => new + { + ProductID = table.Column(type: "int", nullable: false), + SaleID = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductSales", x => new { x.ProductID, x.SaleID }); + table.ForeignKey( + name: "FK_ProductSales_Products_ProductID", + column: x => x.ProductID, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductSales_Sales_SaleID", + column: x => x.SaleID, + principalTable: "Sales", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ProductSales_SaleID", + table: "ProductSales", + column: "SaleID"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.DropTable( + name: "ProductSales"); + + migrationBuilder.DropTable( + name: "Products"); + + migrationBuilder.DropTable( + name: "Sales"); + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs new file mode 100644 index 00000000..7bbf9761 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs @@ -0,0 +1,149 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Sills.GolfShop.eCommerceAPI.Data; + +#nullable disable + +namespace Sills.GolfShop.eCommerceAPI.Migrations +{ + [DbContext(typeof(GolfShopDbContext))] + partial class GolfShopDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Categories", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("QuantityInStock") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.Property("ProductID") + .HasColumnType("int"); + + b.Property("SaleID") + .HasColumnType("int"); + + b.HasKey("ProductID", "SaleID"); + + b.HasIndex("SaleID"); + + b.ToTable("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("customerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("shippingAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Sales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.ProductSales", b => + { + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Product", "Product") + .WithMany("ProductSales") + .HasForeignKey("ProductID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Sills.GolfShop.eCommerceAPI.Models.Sales", "Sale") + .WithMany("ProductSales") + .HasForeignKey("SaleID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Sale"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Product", b => + { + b.Navigation("ProductSales"); + }); + + modelBuilder.Entity("Sills.GolfShop.eCommerceAPI.Models.Sales", b => + { + b.Navigation("ProductSales"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs new file mode 100644 index 00000000..d2073c4c --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs @@ -0,0 +1,11 @@ +namespace Sills.GolfShop.eCommerceAPI.Models +{ + public class Categories + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public DateTime? DeletedAt { get; set; } + + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs new file mode 100644 index 00000000..ac22a653 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs @@ -0,0 +1,14 @@ +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class Product +{ + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public decimal Price { get; set; } + public int QuantityInStock { get; set; } + public DateTime? DeletedAt { get; set; } + + public List ProductSales { get; } = []; + public int CategoryId { get; internal set; } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs new file mode 100644 index 00000000..09f7e23d --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; + +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class ProductSales +{ + public int ProductID { get; set; } + public int SaleID { get; set; } + public Product Product { get; set; } = null!; + public Sales Sale { get; set; } = null!; + + +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs new file mode 100644 index 00000000..afccd6eb --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs @@ -0,0 +1,11 @@ +namespace Sills.GolfShop.eCommerceAPI.Models; + +public class Sales +{ + public int Id { get; set; } + public string customerName { get; set; } + + public string shippingAddress { get; set; } = string.Empty; + + public List ProductSales { get; } = []; +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json new file mode 100644 index 00000000..bf690538 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json @@ -0,0 +1,99 @@ +{ + "info": { + "name": "Sills Golf Shop eCommerce API", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Products", + "item": [ + { + "name": "Get All Products", + "request": { + "method": "GET", + "url": { + "raw": "{{baseUrl}}/api/Product?PageNumber=1&PageSize=10", + "host": [ "{{baseUrl}}" ], + "path": [ "api", "Product" ], + "query": [ + { + "key": "PageNumber", + "value": "1" + }, + { + "key": "PageSize", + "value": "10" + } + ] + } + } + }, + { + "name": "Create Product", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Driver\",\n \"description\": \"Titanium face driver\",\n \"price\": 499.99,\n \"quantityInStock\": 25,\n \"categoryId\": 1\n}" + }, + "url": "{{baseUrl}}/api/Product" + } + } + ] + }, + { + "name": "Categories", + "item": [ + { + "name": "Get All Categories", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/Category?PageNumber=1&PageSize=10&sortBy=name" + } + }, + { + "name": "Create Category", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Clubs\",\n \"description\": \"Drivers, Irons, and Putters\"\n}" + }, + "url": "{{baseUrl}}/api/Category" + } + } + ] + }, + { + "name": "Sales", + "item": [ + { + "name": "Get All Sales", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/Sales?PageNumber=1&PageSize=10" + } + } + ] + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "https://localhost:7000", + "type": "string" + } + ] +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs new file mode 100644 index 00000000..9d3ee9d1 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Services; + +var builder = WebApplication.CreateBuilder(args); + + +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddControllers(); +builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +builder.WebHost.UseUrls("http://localhost:8080"); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); + +} + +app.MapControllers(); + +app.Run(); diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json new file mode 100644 index 00000000..f8d04a84 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5283", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7070;http://localhost:5283", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs new file mode 100644 index 00000000..ed59f8d2 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; +using Sills.GolfShop.eCommerceAPI.Services; + +namespace Sills.GolfShop.eCommerceAPI.Services; + + + public interface ICategoryService + { + IQueryable GetAllCategoriesQuery(); + Task GetCategoryByIdAsync(int id); + Task CreateCategoryAsync(Categories category); + Task UpdateCategoryAsync(int id, Categories category); + Task DeleteCategoryAsync(int id); + } + +public class CategoryService : ICategoryService +{ + private readonly GolfShopDbContext _context; + + public CategoryService(GolfShopDbContext context) + { + _context = context; + } + + public IQueryable GetAllCategoriesQuery() + { + return _context.Categories.Where(c => c.DeletedAt == null); + } + + public async Task GetCategoryByIdAsync(int id) + { + return await _context.Categories + .Where(c => c.DeletedAt == null) + .FirstOrDefaultAsync(c => c.Id == id); + + } + + public async Task CreateCategoryAsync(Categories category) + { + _context.Categories.Add(category); + await _context.SaveChangesAsync(); + return category; + } + + public async Task UpdateCategoryAsync(int id, Categories category) + { + var existingCategory = await _context.Categories.FindAsync(id); + if (existingCategory == null) + { + return; + } + existingCategory.Name = category.Name; + existingCategory.Description = category.Description; + await _context.SaveChangesAsync(); + } + + public async Task DeleteCategoryAsync(int id) + { + var category = await _context.Categories.FindAsync(id); + if (category == null) + { + return; + } + category.DeletedAt = DateTime.UtcNow; + await _context.SaveChangesAsync(); + } + +} + + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs new file mode 100644 index 00000000..fcf17187 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Services; + + +public interface IProductsService +{ + Task> GetAllProductsAsync(); + Task GetProductByIdAsync(int id); + Task CreateProductAsync(Product product); + Task UpdateProductAsync(int id, Product product); + Task DeleteProductAsync(int id); +} +public class ProductsService : IProductsService +{ + private readonly GolfShopDbContext _context; + + public ProductsService(GolfShopDbContext context) + { + _context = context; + } + + public async Task> GetAllProductsAsync() + { + return await _context.Products + .Where(p => p.DeletedAt == null) + .ToListAsync(); + } + + public async Task GetProductByIdAsync(int id) + { + return await _context.Products + .Where(p => p.DeletedAt == null) + .FirstOrDefaultAsync(p => p.Id == id); + } + + public async Task CreateProductAsync(Product product) + { + _context.Products.Add(product); + await _context.SaveChangesAsync(); + return product; + } + + public async Task UpdateProductAsync(int id, Product product) + { + var existingProduct = await _context.Products + .Where(p => p.DeletedAt == null) + .FirstOrDefaultAsync(p => p.Id == id); + if (existingProduct == null) + { + return; + } + existingProduct.Name = product.Name; + existingProduct.Description = product.Description; + existingProduct.Price = product.Price; + existingProduct.CategoryId = product.CategoryId; + await _context.SaveChangesAsync(); + } + + public async Task DeleteProductAsync(int id) + { + var product = await _context.Products.FindAsync(id); + if (product == null) + { + return; + } + product.DeletedAt = DateTime.UtcNow; + await _context.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs new file mode 100644 index 00000000..38038557 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs @@ -0,0 +1,90 @@ +using Microsoft.EntityFrameworkCore; +using Sills.GolfShop.eCommerceAPI.Data; +using Sills.GolfShop.eCommerceAPI.Models; + +namespace Sills.GolfShop.eCommerceAPI.Services; + +public interface ISalesService +{ + Task> GetAllSalesAsync(); + Task GetSaleByIdAsync(int id); + Task CreateSaleAsync(Sales sale); + Task DeleteSaleAsync(int id); + Task UpdateSaleAsync(int id, Sales sale); + + +} +public class SalesService : ISalesService +{ + private readonly GolfShopDbContext _context; + + public SalesService(GolfShopDbContext context) + { + _context = context; + } + + public async Task> GetAllSalesAsync() + { + return await _context.Sales.ToListAsync(); + } + public async Task GetSaleByIdAsync(int id) + { + return await _context.Sales.FindAsync(id); + } + public async Task CreateSaleAsync(Sales sale) + { + _context.Sales.Add(sale); + await _context.SaveChangesAsync(); + return sale; + } + public async Task UpdateSaleAsync(int id, Sales sale) + { + var existingSale = await _context.Sales.FindAsync(id); + if (existingSale == null) + { + return; + } + existingSale.customerName = sale.customerName; + existingSale.shippingAddress = sale.shippingAddress; + await _context.SaveChangesAsync(); + } + public async Task DeleteSaleAsync(int id) + { + var sale = await _context.Sales.FindAsync(id); + if (sale == null) + { + return; + } + _context.Sales.Remove(sale); + await _context.SaveChangesAsync(); + } + public async Task AddProductToSaleAsync(int saleId, int productId) + { + var sale = await _context.Sales.FindAsync(saleId); + var product = await _context.Products.FindAsync(productId); + if (sale == null || product == null) + { + return; + } + var productSale = new ProductSales + { + Sale = sale, + Product = product + }; + _context.ProductSales.Add(productSale); + await _context.SaveChangesAsync(); + } + + public async Task RemoveProductFromSaleAsync(int saleId, int productId) + { + var productSale = await _context.ProductSales + .FirstOrDefaultAsync(ps => ps.SaleID == saleId && ps.ProductID == productId); + if (productSale == null) + { + return; + } + _context.ProductSales.Remove(productSale); + await _context.SaveChangesAsync(); + } + +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http new file mode 100644 index 00000000..20ed7e48 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http @@ -0,0 +1,6 @@ +@Sills.GolfShop.eCommerce_HostAddress = http://localhost:5283 + +GET {{Sills.GolfShop.eCommerce_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj new file mode 100644 index 00000000..99d30c54 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj @@ -0,0 +1,24 @@ + + + + net10.0 + enable + enable + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json new file mode 100644 index 00000000..0a959ac0 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json @@ -0,0 +1,13 @@ +{ + "ConnectionStrings": { + "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB" + }, + + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs new file mode 100644 index 00000000..efc2761e --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs @@ -0,0 +1,34 @@ +using Sills.GolfShop.eCommerceFrontEnd.Models; +using Sills.GolfShop.eCommerceFrontEnd.Services; +using Spectre.Console; + +namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; + +internal class ProductsController +{ + internal void AddProduct() + { + Console.Clear(); + + string ProductName = AnsiConsole.Ask("Enter the name of the product:"); + string ProductDescription = AnsiConsole.Ask("Enter the description of the product:"); + decimal ProductPrice = AnsiConsole.Ask("Enter the price of the product:"); + int ProductQuantity = AnsiConsole.Ask("Enter the quantity in stock for the product:"); + //Add category list to assign category to the product?? + + + Product product = new Product + { + Name = ProductName, + Description = ProductDescription, + Price = ProductPrice, + QuantityInStock = ProductQuantity + }; + + //TODO call product service to finalize addition + + await ProductService.AddProduct(product); + + + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs new file mode 100644 index 00000000..baf7f7d3 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/SaleController.cs @@ -0,0 +1,5 @@ +namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; + +internal class SaleController +{ +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Helpers/Pagination.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Helpers/Pagination.cs new file mode 100644 index 00000000..ed978cb1 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Helpers/Pagination.cs @@ -0,0 +1,11 @@ + + +namespace Sills.GolfShop.eCommerceFrontEnd.Helpers; + +internal class Pagination +{ + internal static string GetPaginationQuery(int pageNumber, int pageSize) + { + return $"?pageNumber={pageNumber}&pageSize={pageSize}"; + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs new file mode 100644 index 00000000..c760528c --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs @@ -0,0 +1,55 @@ +using Sills.GolfShop.eCommerceFrontEnd.Controllers; +using Spectre.Console; + +namespace Sills.GolfShop.eCommerceFrontEnd.Menus; + +internal class AdministratorMenu +{ + internal static void AdminMenu() + { + bool running = true; + + while (running) + { + Console.Clear(); + + AnsiConsole.Write( + new FigletText("Admin Menu") + .LeftJustified() + .Color(Color.Green)); + + var choice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("What would you like to do?") + .AddChoices(new[] { + "Add a product", + "Update a product", + "Delete a product", + "Add a category", + "Update a category", + "Delete a category", + "Exit" + })); + + switch (choice) + { + case "Add a product": + ProductsController productsController = new ProductsController(); + productsController.AddProduct(); + break; + + case "Update a product": + //UpdateProductMenu.DisplayUpdateProductMenu(); + break; + + case "Delete a product": + //DeleteProductMenu.DisplayDeleteProductMenu(); + break; + + case "Exit": + running = false; + break; + } + } + } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs new file mode 100644 index 00000000..905c7edf --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/MainMenu.cs @@ -0,0 +1,69 @@ +using Sills.GolfShop.eCommerceFrontEnd.Services; +using Spectre.Console; + +namespace Sills.GolfShop.eCommerceFrontEnd.Menus; + +internal class MainMenu +{ + public static async Task MainDisplayAsync() + { + bool running = true; + + while (running) + { + //Console.Clear(); + + AnsiConsole.Write( + new FigletText("Sills Golf Shop") + .LeftJustified() + .Color(Color.Green)); + + var choice = AnsiConsole.Prompt( + new SelectionPrompt() + .Title("What would you like to do?") + .AddChoices(new[] { + "Search for a product", + "Shop All Products", + "Shop from a category", + "View Cart", + "Checkout", + "View Order History", + "Administration Menu", + "Exit" + })); + + switch (choice) + { + case "Search for a product": + //SearchMenu.DisplaySearch(); + break; + + case "Shop All Products": + Console.Clear(); + ProductService productService = new ProductService(); + await productService.GetAllProductsAsync(); + break; + + case "Shop from a category": + //CategoryMenu.DisplayCategories(); + break; + case "View Cart": + //CartMenu.DisplayCart(); + break; + + case "Checkout": + break; + + case "View Order History": + break; + + case "Administration Menu": + break; + + case "Exit": + Environment.Exit(0); + break; + } + } + } +} \ No newline at end of file diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs new file mode 100644 index 00000000..0f605f45 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Category.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +internal class Categories +{ + [JsonProperty("Category")] + public required List CategoriesList { get; set; } +} +public class Category +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Description")] + public string Description { get; set; } + [JsonProperty("DeletedAt")] + public DateTime? DeletedAt { get; set; } +} + //[JsonProperty("Products")] + + // public List Products { get; } = []; + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs new file mode 100644 index 00000000..22a117ab --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Product.cs @@ -0,0 +1,33 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +public class Products +{ + [JsonProperty("Product")] + public required List ProductsList { get; set; } +} + +public class Product +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Description")] + public string Description { get; set; } + [JsonProperty("Price")] + public decimal Price { get; set; } + [JsonProperty("QuantityInStock")] + public int QuantityInStock { get; set; } + [JsonProperty("DeletedAt")] + public DateTime? DeletedAt { get; set; } + [JsonProperty("ProductSales")] + public List ProductSales { get; } = []; + + [JsonProperty("CategoryId")] + public int CategoryId { get; internal set; } + + +} + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs new file mode 100644 index 00000000..7af2e97f --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/ProductSales.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +public class ProductSales +{ + [JsonProperty("ProductSales")] + public required List ProductSalesList { get; set; } +} + +public class ProductSale +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("ProductId")] + public int ProductId { get; set; } + [JsonProperty("SaleId")] + public int SaleId { get; set; } +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs new file mode 100644 index 00000000..83d1167c --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Models/Sales.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace Sills.GolfShop.eCommerceFrontEnd.Models; + +internal class Sales +{ + [JsonProperty("Sales")] + public required List SalesList { get; set; } +} +internal class Sale +{ + [JsonProperty("Id")] + public int Id { get; set; } + [JsonProperty("CustomerName")] + public string CustomerName { get; set; } + [JsonProperty("ShippingAddress")] + public string ShippingAddress { get; set; } = string.Empty; + [JsonProperty("ProductSales")] + public List ProductSales { get; } = []; +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Program.cs new file mode 100644 index 00000000..fd129fc2 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Program.cs @@ -0,0 +1,10 @@ +namespace Sills.GolfShop.eCommerceFrontEnd; + +public class Program +{ + public static async Task Main(string[] args) + { + await Menus.MainMenu.MainDisplayAsync(); + } + +} \ No newline at end of file diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Services/ProductService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Services/ProductService.cs new file mode 100644 index 00000000..0a72aac0 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Services/ProductService.cs @@ -0,0 +1,68 @@ + +using Newtonsoft.Json; +using Sills.GolfShop.eCommerceFrontEnd.Models; +using Sills.GolfShop.eCommerceFrontEnd.Visualizations; + + +namespace Sills.GolfShop.eCommerceFrontEnd.Services; + +internal class ProductService +{ + private static readonly HttpClient client = new HttpClient(); + + static ProductService() + { + client.BaseAddress = new Uri("http://localhost:8080/"); + client.Timeout = TimeSpan.FromSeconds(30); + } + + + + internal async Task GetAllProductsAsync() + { + //TODO finish once admin area is done. + try + { + var response = await client.GetStringAsync("api/Product?PageNumber=1&PageSize=20"); + + if (response == null) + { + Console.WriteLine("No products found."); + return; + } + var deserializedProducts = JsonConvert.DeserializeObject>(response); + + + if (deserializedProducts != null && deserializedProducts.Count > 0) + { + ProductVisualizations.DisplayProductsTable(deserializedProducts); + } + else + { + Console.WriteLine("No products found."); + + } + } + + catch (HttpRequestException ex) + { + Console.WriteLine($"Error fetching products: {ex.Message}"); + return; + + } + catch(JsonException ex) + { + Console.WriteLine($"Error parsing product data: {ex.Message}"); + return; + } + catch (Exception ex) + { + Console.WriteLine($"Unexpected error: {ex.Message}"); + return; + } + } + internal static async Task AddProduct(Product product) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj new file mode 100644 index 00000000..e79be62b --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Sills.GolfShop.eCommerceFrontEnd.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Visualizations/ProductVisualizations.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Visualizations/ProductVisualizations.cs new file mode 100644 index 00000000..18b11a09 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Visualizations/ProductVisualizations.cs @@ -0,0 +1,29 @@ +using Sills.GolfShop.eCommerceFrontEnd.Models; +using Spectre.Console; +namespace Sills.GolfShop.eCommerceFrontEnd.Visualizations; + +internal class ProductVisualizations +{ + internal static void DisplayProductsTable(List products, bool stay = true) + { + var table = new Table() + .RoundedBorder() + .BorderColor(Color.Green) + .AddColumn("Product Name") + .AddColumn("Description") + .AddColumn("Price"); + + foreach (var product in products) + { + table.AddRow(product.Name, product.Description, product.Price.ToString("C")); + } + AnsiConsole.Write(table); + + if (stay) + { + Console.WriteLine("Press any key to return to the menu"); + Console.ReadKey(); + Console.Clear(); + } + } +} \ No newline at end of file From 099f8060497e8b4a8ec1a4720bbe8a8b959b0da5 Mon Sep 17 00:00:00 2001 From: David Sills Date: Tue, 21 Apr 2026 08:23:51 -0500 Subject: [PATCH 05/13] added Fq and rename Api proj --- .../Controllers/CategoryController.cs | 0 .../Controllers/ProductController.cs | 0 .../Controllers/SalesController.cs | 2 +- .../DTO/ProductDTO.cs | 0 .../Data/GolfShopDbContext.cs | 0 .../Helpers/PaginationParameters.cs | 0 .../Helpers/SortingParameters.cs | 0 .../Mapping/ProductMapper.cs | 0 .../Migrations/20260403232616_initial.Designer.cs | 0 .../Migrations/20260403232616_initial.cs | 0 .../Migrations/GolfShopDbContextModelSnapshot.cs | 0 .../Models/Categories.cs | 0 .../Models/Product.cs | 0 .../Models/ProductSales.cs | 0 .../Models/Sales.cs | 0 .../Postman_Collection/PostmanCollection.json | 0 .../Program.cs | 0 .../Properties/launchSettings.json | 0 .../Services/ICategoryService.cs | 0 .../Services/IProductsService.cs | 0 .../Services/ISalesService.cs | 0 .../Sills.GolfShop.eCommerce.http | 0 .../Sills.GolfShop.eCommerceAPI.csproj | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 25 files changed, 1 insertion(+), 1 deletion(-) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Controllers/CategoryController.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Controllers/ProductController.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Controllers/SalesController.cs (95%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/DTO/ProductDTO.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Data/GolfShopDbContext.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Helpers/PaginationParameters.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Helpers/SortingParameters.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Mapping/ProductMapper.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Migrations/20260403232616_initial.Designer.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Migrations/20260403232616_initial.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Migrations/GolfShopDbContextModelSnapshot.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Models/Categories.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Models/Product.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Models/ProductSales.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Models/Sales.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Postman_Collection/PostmanCollection.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Program.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Properties/launchSettings.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Services/ICategoryService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Services/IProductsService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Services/ISalesService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Sills.GolfShop.eCommerce.http (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/Sills.GolfShop.eCommerceAPI.csproj (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/appsettings.Development.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerce => Sills.GolfShop.eCommerceApi}/appsettings.json (100%) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/CategoryController.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/CategoryController.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/ProductController.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/ProductController.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/SalesController.cs similarity index 95% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/SalesController.cs index 4791679c..e8ea4afc 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/SalesController.cs @@ -12,7 +12,7 @@ public class SalesController(ISalesService salesService) : ControllerBase private readonly ISalesService _salesService = salesService; [HttpGet] - public ActionResult> GetAllSales(PaginationParameters param) + public ActionResult> GetAllSales([FromQuery]PaginationParameters param) { var sales = _salesService.GetAllSalesAsync().Result; diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/DTO/ProductDTO.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/DTO/ProductDTO.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Data/GolfShopDbContext.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Data/GolfShopDbContext.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/PaginationParameters.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/PaginationParameters.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/SortingParameters.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/SortingParameters.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Mapping/ProductMapper.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Mapping/ProductMapper.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.Designer.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.Designer.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/GolfShopDbContextModelSnapshot.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/GolfShopDbContextModelSnapshot.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Categories.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Categories.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Product.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Product.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/ProductSales.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/ProductSales.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Sales.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Sales.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Postman_Collection/PostmanCollection.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Postman_Collection/PostmanCollection.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Program.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Program.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Properties/launchSettings.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Properties/launchSettings.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ICategoryService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ICategoryService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/IProductsService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/IProductsService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ISalesService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ISalesService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerce.http similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerce.http diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerceAPI.csproj similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerceAPI.csproj diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.Development.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.Development.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.json From 81d75e320f7b4538755d727ae3915055d27fe403 Mon Sep 17 00:00:00 2001 From: David Sills Date: Thu, 23 Apr 2026 11:29:39 -0500 Subject: [PATCH 06/13] fix folder names --- .../Controllers/CategoryController.cs | 0 .../Controllers/ProductController.cs | 0 .../Controllers/SalesController.cs | 0 .../DTO/ProductDTO.cs | 0 .../Data/GolfShopDbContext.cs | 0 .../Helpers/PaginationParameters.cs | 0 .../Helpers/SortingParameters.cs | 0 .../Mapping/ProductMapper.cs | 0 .../Migrations/20260403232616_initial.Designer.cs | 0 .../Migrations/20260403232616_initial.cs | 0 .../Migrations/GolfShopDbContextModelSnapshot.cs | 0 .../Models/Categories.cs | 0 .../Models/Product.cs | 0 .../Models/ProductSales.cs | 0 .../Models/Sales.cs | 0 .../Postman_Collection/PostmanCollection.json | 0 .../Program.cs | 0 .../Properties/launchSettings.json | 0 .../Services/ICategoryService.cs | 0 .../Services/IProductsService.cs | 0 .../Services/ISalesService.cs | 0 .../Sills.GolfShop.eCommerce.http | 0 .../Sills.GolfShop.eCommerceAPI.csproj | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 .../Controllers/ProductsController.cs | 9 +-------- 26 files changed, 1 insertion(+), 8 deletions(-) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Controllers/CategoryController.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Controllers/ProductController.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Controllers/SalesController.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/DTO/ProductDTO.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Data/GolfShopDbContext.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Helpers/PaginationParameters.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Helpers/SortingParameters.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Mapping/ProductMapper.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Migrations/20260403232616_initial.Designer.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Migrations/20260403232616_initial.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Migrations/GolfShopDbContextModelSnapshot.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Models/Categories.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Models/Product.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Models/ProductSales.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Models/Sales.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Postman_Collection/PostmanCollection.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Program.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Properties/launchSettings.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Services/ICategoryService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Services/IProductsService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Services/ISalesService.cs (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Sills.GolfShop.eCommerce.http (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/Sills.GolfShop.eCommerceAPI.csproj (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/appsettings.Development.json (100%) rename eCommerceApi.dsills735/{Sills.GolfShop.eCommerceApi => Sills.GolfShop.eCommerce}/appsettings.json (100%) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/CategoryController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/ProductController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/SalesController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Controllers/SalesController.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/DTO/ProductDTO.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/DTO/ProductDTO.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Data/GolfShopDbContext.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Data/GolfShopDbContext.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Data/GolfShopDbContext.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/PaginationParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/PaginationParameters.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/PaginationParameters.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/SortingParameters.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Helpers/SortingParameters.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Helpers/SortingParameters.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Mapping/ProductMapper.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Mapping/ProductMapper.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.Designer.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.Designer.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.Designer.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/20260403232616_initial.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/20260403232616_initial.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/GolfShopDbContextModelSnapshot.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Migrations/GolfShopDbContextModelSnapshot.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Migrations/GolfShopDbContextModelSnapshot.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Categories.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Categories.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Categories.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Product.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Product.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Product.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/ProductSales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/ProductSales.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/ProductSales.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Sales.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Models/Sales.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Models/Sales.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Postman_Collection/PostmanCollection.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Program.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Properties/launchSettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Properties/launchSettings.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ICategoryService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ICategoryService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/IProductsService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/IProductsService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ISalesService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Services/ISalesService.cs rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerce.http b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerce.http rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerceAPI.csproj b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/Sills.GolfShop.eCommerceAPI.csproj rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.Development.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.Development.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.Development.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json similarity index 100% rename from eCommerceApi.dsills735/Sills.GolfShop.eCommerceApi/appsettings.json rename to eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs index efc2761e..657583de 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs @@ -14,8 +14,6 @@ internal void AddProduct() string ProductDescription = AnsiConsole.Ask("Enter the description of the product:"); decimal ProductPrice = AnsiConsole.Ask("Enter the price of the product:"); int ProductQuantity = AnsiConsole.Ask("Enter the quantity in stock for the product:"); - //Add category list to assign category to the product?? - Product product = new Product { @@ -24,11 +22,6 @@ internal void AddProduct() Price = ProductPrice, QuantityInStock = ProductQuantity }; - - //TODO call product service to finalize addition - - await ProductService.AddProduct(product); - - + ProductService.AddProduct(product); } } From 02a355d7d7dcc00fcab1bd25253064043bf176de Mon Sep 17 00:00:00 2001 From: DSills735 Date: Mon, 27 Apr 2026 11:08:35 -0500 Subject: [PATCH 07/13] several changes fixing async ops. Testing pagination fix in Sales area. --- .../Controllers/CategoryController.cs | 26 +++--- .../Controllers/ProductController.cs | 14 ++-- .../Controllers/SalesController.cs | 82 +++++++++---------- .../DTO/ProductDTO.cs | 9 -- .../DTO/ProductUpdateDTO.cs | 3 + .../Mapping/ProductMapper.cs | 23 +++--- .../Postman_Collection/PostmanCollection.json | 2 +- .../Sills.GolfShop.eCommerce/Program.cs | 6 +- .../Properties/launchSettings.json | 4 +- .../Services/ISalesService.cs | 16 +++- .../Sills.GolfShop.eCommerce.http | 6 -- .../Controllers/ProductsController.cs | 4 +- 12 files changed, 92 insertions(+), 103 deletions(-) delete mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs create mode 100644 eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductUpdateDTO.cs diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs index 33b9d2a7..1b2d6465 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs @@ -29,19 +29,13 @@ public async Task>> GetAllCategories([FromQuery] P .Take(param.PageSize) .ToListAsync(); - query = categoryParams.sortBy switch - { - "name_desc" => query.OrderByDescending(p => p.Name), - _ => query.OrderBy(p => p.Name) - }; - return Ok(pagedCategories); } [HttpGet("{id}")] - public ActionResult GetCategoryById(int id) + public async Task> GetCategoryById(int id) { - var category = _categoryService.GetCategoryByIdAsync(id); + var category = await _categoryService.GetCategoryByIdAsync(id); if (category == null) { return NotFound(); @@ -50,32 +44,32 @@ public ActionResult GetCategoryById(int id) } [HttpPost] - public ActionResult CreateCategory(Categories category) + public async Task> CreateCategory(Categories category) { - var createdCategory = _categoryService.CreateCategoryAsync(category); + var createdCategory = await _categoryService.CreateCategoryAsync(category); return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory); } [HttpPut("{id}")] - public IActionResult UpdateCategory(int id, Categories category) + public async Task UpdateCategory(int id, Categories category) { - var existingCategory = _categoryService.GetCategoryByIdAsync(id); + var existingCategory = await _categoryService.GetCategoryByIdAsync(id); if (existingCategory == null) { return NotFound(); } - _categoryService.UpdateCategoryAsync(id, category); + await _categoryService.UpdateCategoryAsync(id, category); return NoContent(); } [HttpDelete("{id}")] - public IActionResult DeleteCategory(int id) + public async Task DeleteCategory(int id) { - var existingCategory = _categoryService.GetCategoryByIdAsync(id); + var existingCategory = await _categoryService.GetCategoryByIdAsync(id); if (existingCategory == null) { return NotFound(); } - _categoryService.DeleteCategoryAsync(id); + await _categoryService.DeleteCategoryAsync(id); return NoContent(); } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs index f725159e..1f202986 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -14,16 +14,16 @@ public class ProductController(IProductsService productsService) : ControllerBas private readonly IProductsService _productService = productsService; [HttpGet] - public ActionResult> GetAllProducts([FromQuery]PaginationParameters param) + public async Task>> GetAllProducts([FromQuery]PaginationParameters param) { - var products = _productService.GetAllProductsAsync().Result; + var products = await _productService.GetAllProductsAsync(); var pagedProducts = products .Skip((param.PageNumber - 1) * param.PageSize) .Take(param.PageSize) .ToList(); - return Ok(products); + return Ok(pagedProducts); } [HttpGet("{id}")] @@ -46,7 +46,7 @@ public async Task> CreateProduct(Product product) [HttpPut("{id}")] public async Task UpdateProduct(int id, ProductUpdateDto productUpdateDto) { - var existingProduct = _productService.GetProductByIdAsync(id).Result; + var existingProduct = await _productService.GetProductByIdAsync(id); if (existingProduct == null) { return NotFound(); @@ -60,14 +60,14 @@ public async Task UpdateProduct(int id, ProductUpdateDto productU } [HttpDelete("{id}")] - public IActionResult DeleteProduct(int id) + public async Task DeleteProduct(int id) { - var existingProduct = _productService.GetProductByIdAsync(id).Result; + var existingProduct = await _productService.GetProductByIdAsync(id); if (existingProduct == null) { return NotFound(); } - _productService.DeleteProductAsync(id).Wait(); + await _productService.DeleteProductAsync(id); return NoContent(); } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs index e8ea4afc..911802c9 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs @@ -12,55 +12,51 @@ public class SalesController(ISalesService salesService) : ControllerBase private readonly ISalesService _salesService = salesService; [HttpGet] - public ActionResult> GetAllSales([FromQuery]PaginationParameters param) + public async Task>> GetAllSales([FromQuery] PaginationParameters param) { - var sales = _salesService.GetAllSalesAsync().Result; + var pagedSales = await _salesService + .GetPagedSalesAsync(param.PageNumber, param.PageSize); - var pagedSales = sales - .Skip((param.PageNumber - 1) * param.PageSize) - .Take(param.PageSize) - .ToList(); - - return Ok(sales); - } - [HttpGet("{id}")] - public async Task> GetSaleById(int id) - { - var sale = await _salesService.GetSaleByIdAsync(id); - if (sale == null) - { - return NotFound(); - } - return Ok(sale); - } - [HttpPost] - public async Task> CreateSale(Sales sale) + return Ok(pagedSales); + } + [HttpGet("{id}")] + public async Task> GetSaleById(int id) + { + var sale = await _salesService.GetSaleByIdAsync(id); + if (sale == null) { - var createdSale = await _salesService.CreateSaleAsync(sale); - return CreatedAtAction(nameof(GetSaleById), new { id = createdSale.Id }, createdSale); + return NotFound(); } - [HttpPut("{id}")] - public IActionResult UpdateSale(int id, Sales sale) + return Ok(sale); + } + [HttpPost] + public async Task> CreateSale(Sales sale) + { + var createdSale = await _salesService.CreateSaleAsync(sale); + return CreatedAtAction(nameof(GetSaleById), new { id = createdSale.Id }, createdSale); + } + [HttpPut("{id}")] + public async Task UpdateSale(int id, Sales sale) + { + var existingSale = await _salesService.GetSaleByIdAsync(id); + if (existingSale == null) { - var existingSale = _salesService.GetSaleByIdAsync(id).Result; - if (existingSale == null) - { - return NotFound(); - } - _salesService.UpdateSaleAsync(id, sale).Wait(); - return NoContent(); + return NotFound(); } - - [HttpDelete("{id}")] - public IActionResult DeleteSale(int id) + await _salesService.UpdateSaleAsync(id, sale); + return NoContent(); + } + + [HttpDelete("{id}")] + public async Task DeleteSale(int id) + { + var existingSale = await _salesService.GetSaleByIdAsync(id); + if (existingSale == null) { - var existingSale = _salesService.GetSaleByIdAsync(id).Result; - if (existingSale == null) - { - return NotFound(); - } - _salesService.DeleteSaleAsync(id).Wait(); - return NoContent(); + return NotFound(); } - + await _salesService.DeleteSaleAsync(id); + return NoContent(); } + +} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs deleted file mode 100644 index e34179a8..00000000 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductDTO.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Sills.GolfShop.eCommerceAPI.DTO -{ - public record ProductUpdateDto - { - public string Name { get; init; } - public string Description { get; init; } - public int QuantityInStock { get; init; } - } -} diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductUpdateDTO.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductUpdateDTO.cs new file mode 100644 index 00000000..667c7d70 --- /dev/null +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/DTO/ProductUpdateDTO.cs @@ -0,0 +1,3 @@ +namespace Sills.GolfShop.eCommerceAPI.DTO; + +public sealed record ProductUpdateDto(string Name, string Description, int QuantityInStock); diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs index d871125b..280037cc 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Mapping/ProductMapper.cs @@ -1,16 +1,15 @@ -namespace Sills.GolfShop.eCommerceAPI.Mapping +namespace Sills.GolfShop.eCommerceAPI.Mapping; + +public static class ProductMapper { - public static class ProductMapper + public static DTO.ProductUpdateDto? ToDTO(this Models.Product product) { - public static DTO.ProductUpdateDto ToDTO(this Models.Product product) - { - if (product == null) return null; - return new DTO.ProductUpdateDto - { - Name = product.Name, - Description = product.Description, - QuantityInStock = product.QuantityInStock - }; - } + if (product == null) return null; + + return new DTO.ProductUpdateDto( + product.Name, + product.Description, + product.QuantityInStock + ); } } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json index bf690538..1687e5e6 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json @@ -92,7 +92,7 @@ "variable": [ { "key": "baseUrl", - "value": "https://localhost:7000", + "value": "https://localhost:8080", "type": "string" } ] diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs index 9d3ee9d1..02eb742a 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.OpenApi; using Sills.GolfShop.eCommerceAPI.Data; using Sills.GolfShop.eCommerceAPI.Services; @@ -13,14 +14,15 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.WebHost.UseUrls("http://localhost:8080"); var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.MapOpenApi(); - + var dbContext = app.Services.GetRequiredService(); + dbContext.Database.EnsureDeleted(); + dbContext.Database.EnsureCreated(); } app.MapControllers(); diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json index f8d04a84..8cb9f9ee 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Properties/launchSettings.json @@ -5,7 +5,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "http://localhost:5283", + "applicationUrl": "http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:7070;http://localhost:5283", + "applicationUrl": "https://localhost:7070;http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs index 38038557..bc2760da 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs @@ -6,13 +6,12 @@ namespace Sills.GolfShop.eCommerceAPI.Services; public interface ISalesService { - Task> GetAllSalesAsync(); + //Task> GetAllSalesAsync(); Task GetSaleByIdAsync(int id); Task CreateSaleAsync(Sales sale); Task DeleteSaleAsync(int id); Task UpdateSaleAsync(int id, Sales sale); - - + Task> GetPagedSalesAsync(int pageNumber, int pageSize); } public class SalesService : ISalesService { @@ -23,10 +22,12 @@ public SalesService(GolfShopDbContext context) _context = context; } + /* public async Task> GetAllSalesAsync() { return await _context.Sales.ToListAsync(); } + */ public async Task GetSaleByIdAsync(int id) { return await _context.Sales.FindAsync(id); @@ -87,4 +88,13 @@ public async Task RemoveProductFromSaleAsync(int saleId, int productId) await _context.SaveChangesAsync(); } + public async Task> GetPagedSalesAsync(int pageNumber, int pageSize) + { + return await _context.Sales + .OrderBy(s => s.Id) + .Skip((pageNumber - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + } + } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http index 20ed7e48..e69de29b 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerce.http @@ -1,6 +0,0 @@ -@Sills.GolfShop.eCommerce_HostAddress = http://localhost:5283 - -GET {{Sills.GolfShop.eCommerce_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs index 657583de..6d710057 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Controllers/ProductsController.cs @@ -6,7 +6,7 @@ namespace Sills.GolfShop.eCommerceFrontEnd.Controllers; internal class ProductsController { - internal void AddProduct() + internal async Task AddProduct() { Console.Clear(); @@ -22,6 +22,6 @@ internal void AddProduct() Price = ProductPrice, QuantityInStock = ProductQuantity }; - ProductService.AddProduct(product); + await ProductService.AddProduct(product); } } From 8ce28616026a2b764249aa56af61eab66708d16e Mon Sep 17 00:00:00 2001 From: David Sills Date: Mon, 4 May 2026 12:37:55 -0500 Subject: [PATCH 08/13] product pagination fixed --- .../Controllers/ProductController.cs | 11 ++++++++++- .../Services/IProductsService.cs | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs index 1f202986..d09ff6e8 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -25,8 +25,17 @@ public async Task>> GetAllProducts([FromQuery]Paginat return Ok(pagedProducts); } + /* + * [HttpGet] + public async Task>> GetAllProductsAsync([FromQuery] PaginationParameters param) + { + var pagedProducts = await _productsService + .GetPagedProductsAsync(param.PageNumber, param.PageSize); - [HttpGet("{id}")] + return Ok(pagedProducts); + } + */ + [HttpGet("{id}")] public async Task> GetProductById(int id) { var product = await _productService.GetProductByIdAsync(id); diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs index fcf17187..ac2cfb84 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs @@ -7,11 +7,12 @@ namespace Sills.GolfShop.eCommerceAPI.Services; public interface IProductsService { - Task> GetAllProductsAsync(); + //Task> GetAllProductsAsync(); Task GetProductByIdAsync(int id); Task CreateProductAsync(Product product); Task UpdateProductAsync(int id, Product product); Task DeleteProductAsync(int id); + Task> GetPagedProductsAsync(int pageNumber, int pageSize); } public class ProductsService : IProductsService { @@ -22,12 +23,12 @@ public ProductsService(GolfShopDbContext context) _context = context; } - public async Task> GetAllProductsAsync() + /*public async Task> GetAllProductsAsync() { return await _context.Products .Where(p => p.DeletedAt == null) .ToListAsync(); - } + }*/ public async Task GetProductByIdAsync(int id) { @@ -69,4 +70,14 @@ public async Task DeleteProductAsync(int id) product.DeletedAt = DateTime.UtcNow; await _context.SaveChangesAsync(); } + + public async Task> GetPagedProductsAsync(int pageNumber, int pageSize) + { + return await _context.Products + .Where(p => p.DeletedAt == null) + .OrderBy(p => p.Id) + .Skip((pageNumber - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + } } \ No newline at end of file From 271c2d3a2ca7c1c3195022c3e1c955e90ab4b038 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Tue, 5 May 2026 10:01:51 -0500 Subject: [PATCH 09/13] all pagination finished, startiing debugging --- .../Controllers/CategoryController.cs | 9 +++------ .../Controllers/ProductController.cs | 12 ++++++------ .../Services/ICategoryService.cs | 10 +++++++++- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs index 1b2d6465..4d95e500 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs @@ -23,13 +23,10 @@ public async Task>> GetAllCategories([FromQuery] P _ => query.OrderBy(p => p.Name) }; - var pagedCategories = await query - .Where(c => c.DeletedAt == null) - .Skip((param.PageNumber - 1) * param.PageSize) - .Take(param.PageSize) - .ToListAsync(); + var pagedCategoriies = await _categoryService + .GetPagedCategoriesAsync(query, param.PageNumber, param.PageSize); - return Ok(pagedCategories); + return Ok(pagedCategories); } [HttpGet("{id}")] diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs index d09ff6e8..f63335c0 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -12,7 +12,7 @@ namespace Sills.GolfShop.eCommerceAPI.Controllers; public class ProductController(IProductsService productsService) : ControllerBase { private readonly IProductsService _productService = productsService; - + /* [HttpGet] public async Task>> GetAllProducts([FromQuery]PaginationParameters param) { @@ -24,17 +24,17 @@ public async Task>> GetAllProducts([FromQuery]Paginat .ToList(); return Ok(pagedProducts); - } - /* - * [HttpGet] + }*/ + + [HttpGet] public async Task>> GetAllProductsAsync([FromQuery] PaginationParameters param) { - var pagedProducts = await _productsService + var pagedProducts = await _productService .GetPagedProductsAsync(param.PageNumber, param.PageSize); return Ok(pagedProducts); } - */ + [HttpGet("{id}")] public async Task> GetProductById(int id) { diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs index ed59f8d2..5d248bdc 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ICategoryService.cs @@ -13,7 +13,8 @@ public interface ICategoryService Task CreateCategoryAsync(Categories category); Task UpdateCategoryAsync(int id, Categories category); Task DeleteCategoryAsync(int id); - } + Task > GetPagedCategoriesAsync(int pageNumber, int pageSize); +} public class CategoryService : ICategoryService { @@ -67,6 +68,13 @@ public async Task DeleteCategoryAsync(int id) await _context.SaveChangesAsync(); } + public async Task> GetPagedCategoriesAsync(int pageNumber, int pageSize) + { + return await _context.Categories + .Skip((pageNumber - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + } } From 13bfcbfb8a0217dea3086d44a27e9d5b72fd2680 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Tue, 5 May 2026 10:20:48 -0500 Subject: [PATCH 10/13] all changes complete --- .../Controllers/CategoryController.cs | 4 +- .../Postman_Collection/PostmanCollection.json | 166 ++++++++++++++++-- .../Sills.GolfShop.eCommerce/Program.cs | 9 +- .../Sills.GolfShop.eCommerce/appsettings.json | 3 +- .../Menus/AdministratorMenu.cs | 4 +- 5 files changed, 166 insertions(+), 20 deletions(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs index 4d95e500..04df079b 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/CategoryController.cs @@ -23,8 +23,8 @@ public async Task>> GetAllCategories([FromQuery] P _ => query.OrderBy(p => p.Name) }; - var pagedCategoriies = await _categoryService - .GetPagedCategoriesAsync(query, param.PageNumber, param.PageSize); + var pagedCategories = await _categoryService + .GetPagedCategoriesAsync(param.PageNumber, param.PageSize); return Ok(pagedCategories); } diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json index 1687e5e6..334cd90a 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json @@ -1,6 +1,6 @@ { "info": { - "name": "Sills Golf Shop eCommerce API", + "name": "Sills Golf Shop eCommerce API (Updated)", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ @@ -8,26 +8,33 @@ "name": "Products", "item": [ { - "name": "Get All Products", + "name": "Get All Products (Paged)", "request": { "method": "GET", "url": { - "raw": "{{baseUrl}}/api/Product?PageNumber=1&PageSize=10", + "raw": "{{baseUrl}}/api/Product?pageNumber=1&pageSize=10", "host": [ "{{baseUrl}}" ], "path": [ "api", "Product" ], "query": [ { - "key": "PageNumber", + "key": "pageNumber", "value": "1" }, { - "key": "PageSize", + "key": "pageSize", "value": "10" } ] } } }, + { + "name": "Get Product by Id", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/Product/1" + } + }, { "name": "Create Product", "request": { @@ -40,10 +47,34 @@ ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"Driver\",\n \"description\": \"Titanium face driver\",\n \"price\": 499.99,\n \"quantityInStock\": 25,\n \"categoryId\": 1\n}" + "raw": "{\n \"name\": \"Driver\",\n \"description\": \"Titanium face driver\",\n \"price\": 499.99,\n \"quantityInStock\": 25,\n \"categoryId\": 1\n}" }, "url": "{{baseUrl}}/api/Product" } + }, + { + "name": "Update Product", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Updated Driver\",\n \"description\": \"Updated description\",\n \"quantityInStock\": 20\n}" + }, + "url": "{{baseUrl}}/api/Product/1" + } + }, + { + "name": "Delete Product", + "request": { + "method": "DELETE", + "url": "{{baseUrl}}/api/Product/1" + } } ] }, @@ -51,10 +82,35 @@ "name": "Categories", "item": [ { - "name": "Get All Categories", + "name": "Get All Categories (Paged + Sort)", + "request": { + "method": "GET", + "url": { + "raw": "{{baseUrl}}/api/Category?pageNumber=1&pageSize=10&sortBy=name", + "host": [ "{{baseUrl}}" ], + "path": [ "api", "Category" ], + "query": [ + { + "key": "pageNumber", + "value": "1" + }, + { + "key": "pageSize", + "value": "10" + }, + { + "key": "sortBy", + "value": "name" + } + ] + } + } + }, + { + "name": "Get Category by Id", "request": { "method": "GET", - "url": "{{baseUrl}}/api/Category?PageNumber=1&PageSize=10&sortBy=name" + "url": "{{baseUrl}}/api/Category/1" } }, { @@ -69,10 +125,34 @@ ], "body": { "mode": "raw", - "raw": "{\n \"name\": \"Clubs\",\n \"description\": \"Drivers, Irons, and Putters\"\n}" + "raw": "{\n \"name\": \"Clubs\",\n \"description\": \"Drivers, Irons, Putters\"\n}" }, "url": "{{baseUrl}}/api/Category" } + }, + { + "name": "Update Category", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Updated Category\",\n \"description\": \"Updated description\"\n}" + }, + "url": "{{baseUrl}}/api/Category/1" + } + }, + { + "name": "Delete Category", + "request": { + "method": "DELETE", + "url": "{{baseUrl}}/api/Category/1" + } } ] }, @@ -80,10 +160,72 @@ "name": "Sales", "item": [ { - "name": "Get All Sales", + "name": "Get All Sales (Paged)", + "request": { + "method": "GET", + "url": { + "raw": "{{baseUrl}}/api/Sales?pageNumber=1&pageSize=10", + "host": [ "{{baseUrl}}" ], + "path": [ "api", "Sales" ], + "query": [ + { + "key": "pageNumber", + "value": "1" + }, + { + "key": "pageSize", + "value": "10" + } + ] + } + } + }, + { + "name": "Get Sale by Id", "request": { "method": "GET", - "url": "{{baseUrl}}/api/Sales?PageNumber=1&PageSize=10" + "url": "{{baseUrl}}/api/Sales/1" + } + }, + { + "name": "Create Sale", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"customerName\": \"John Doe\",\n \"shippingAddress\": \"123 Main St\"\n}" + }, + "url": "{{baseUrl}}/api/Sales" + } + }, + { + "name": "Update Sale", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"customerName\": \"Updated Name\",\n \"shippingAddress\": \"Updated Address\"\n}" + }, + "url": "{{baseUrl}}/api/Sales/1" + } + }, + { + "name": "Delete Sale", + "request": { + "method": "DELETE", + "url": "{{baseUrl}}/api/Sales/1" } } ] @@ -92,7 +234,7 @@ "variable": [ { "key": "baseUrl", - "value": "https://localhost:8080", + "value": "https://localhost:5001", "type": "string" } ] diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs index 02eb742a..797201b0 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Program.cs @@ -20,9 +20,12 @@ if (app.Environment.IsDevelopment()) { app.MapOpenApi(); - var dbContext = app.Services.GetRequiredService(); - dbContext.Database.EnsureDeleted(); - dbContext.Database.EnsureCreated(); + using (var scope = app.Services.CreateScope()) + { + var dbContext = scope.ServiceProvider.GetRequiredService(); + dbContext.Database.EnsureDeleted(); + dbContext.Database.EnsureCreated(); + } } app.MapControllers(); diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json index 0a959ac0..f8d66769 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/appsettings.json @@ -1,7 +1,8 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB" + "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=GolfShopDb;Trusted_Connection=True;MultipleActiveResultSets=true" }, + "Logging": { "LogLevel": { diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs index c760528c..9eeaaeae 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerceFrontEnd/Menus/AdministratorMenu.cs @@ -5,7 +5,7 @@ namespace Sills.GolfShop.eCommerceFrontEnd.Menus; internal class AdministratorMenu { - internal static void AdminMenu() + internal static async Task AdminMenuAsync() { bool running = true; @@ -35,7 +35,7 @@ internal static void AdminMenu() { case "Add a product": ProductsController productsController = new ProductsController(); - productsController.AddProduct(); + await productsController.AddProduct(); break; case "Update a product": From 8d2896111c33c2d01cbafdbbabb3622e779cf643 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Tue, 5 May 2026 10:24:38 -0500 Subject: [PATCH 11/13] removed frontend as it is still incomplete, updated postmanc ollection to proper address. --- eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx | 1 - .../Postman_Collection/PostmanCollection.json | 2 +- .../Sills.GolfShop.eCommerceAPI.csproj | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx index 9d67d4ca..b355a29d 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce.slnx @@ -1,4 +1,3 @@ - diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json index 334cd90a..a92647c7 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Postman_Collection/PostmanCollection.json @@ -234,7 +234,7 @@ "variable": [ { "key": "baseUrl", - "value": "https://localhost:5001", + "value": "https://localhost:8080", "type": "string" } ] diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj index 99d30c54..acf65e91 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Sills.GolfShop.eCommerceAPI.csproj @@ -17,8 +17,4 @@ - - - - From ef2ff09456d08d1bc82d4b255d668dd88e093060 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Tue, 5 May 2026 10:28:24 -0500 Subject: [PATCH 12/13] un commented some HttpGet code in all models --- .../Controllers/ProductController.cs | 4 ++-- .../Sills.GolfShop.eCommerce/Services/IProductsService.cs | 8 ++++---- .../Sills.GolfShop.eCommerce/Services/ISalesService.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs index f63335c0..8dfccb6d 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/ProductController.cs @@ -12,7 +12,7 @@ namespace Sills.GolfShop.eCommerceAPI.Controllers; public class ProductController(IProductsService productsService) : ControllerBase { private readonly IProductsService _productService = productsService; - /* + [HttpGet] public async Task>> GetAllProducts([FromQuery]PaginationParameters param) { @@ -24,7 +24,7 @@ public async Task>> GetAllProducts([FromQuery]Paginat .ToList(); return Ok(pagedProducts); - }*/ + } [HttpGet] public async Task>> GetAllProductsAsync([FromQuery] PaginationParameters param) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs index ac2cfb84..faf530ec 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/IProductsService.cs @@ -7,7 +7,7 @@ namespace Sills.GolfShop.eCommerceAPI.Services; public interface IProductsService { - //Task> GetAllProductsAsync(); + Task> GetAllProductsAsync(); Task GetProductByIdAsync(int id); Task CreateProductAsync(Product product); Task UpdateProductAsync(int id, Product product); @@ -23,12 +23,12 @@ public ProductsService(GolfShopDbContext context) _context = context; } - /*public async Task> GetAllProductsAsync() + public async Task> GetAllProductsAsync() { return await _context.Products .Where(p => p.DeletedAt == null) - .ToListAsync(); - }*/ + .ToListAsync(); + } public async Task GetProductByIdAsync(int id) { diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs index bc2760da..60277644 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Services/ISalesService.cs @@ -6,7 +6,7 @@ namespace Sills.GolfShop.eCommerceAPI.Services; public interface ISalesService { - //Task> GetAllSalesAsync(); + Task> GetAllSalesAsync(); Task GetSaleByIdAsync(int id); Task CreateSaleAsync(Sales sale); Task DeleteSaleAsync(int id); @@ -22,12 +22,12 @@ public SalesService(GolfShopDbContext context) _context = context; } - /* + public async Task> GetAllSalesAsync() { return await _context.Sales.ToListAsync(); } - */ + public async Task GetSaleByIdAsync(int id) { return await _context.Sales.FindAsync(id); From 37e4b20d82adf806a8315fd619bd775b351255e7 Mon Sep 17 00:00:00 2001 From: DSills735 Date: Tue, 5 May 2026 14:16:29 -0500 Subject: [PATCH 13/13] update API to improve pagination --- .../Sills.GolfShop.eCommerce/Controllers/SalesController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs index 911802c9..3c2c4eb9 100644 --- a/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs +++ b/eCommerceApi.dsills735/Sills.GolfShop.eCommerce/Controllers/SalesController.cs @@ -16,7 +16,6 @@ public async Task>> GetAllSales([FromQuery] PaginationP { var pagedSales = await _salesService .GetPagedSalesAsync(param.PageNumber, param.PageSize); - return Ok(pagedSales); } [HttpGet("{id}")]