diff --git a/.DS_Store b/.DS_Store index 726d579..3a7d47a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/; b/; new file mode 100644 index 0000000..3af5379 --- /dev/null +++ b/; @@ -0,0 +1,45 @@ + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# On branch main +# Your branch is up to date with 'origin/main'. +# +# Changes to be committed: +# modified: .DS_Store +# modified: Controllers/CategoriesController.cs +# deleted: Models/CategoryRepositoruy.cs +# modified: Program.cs +# modified: Views/Categories/Index.cshtml +# modified: Views/Shared/_Layout.cshtml +# modified: bin/Debug/net8.0/demoMvcCore.dll +# modified: bin/Debug/net8.0/demoMvcCore.pdb +# modified: demoMvcCore.csproj +# modified: obj/Debug/net8.0/demoMvcCore.AssemblyInfo.cs +# modified: obj/Debug/net8.0/demoMvcCore.AssemblyInfoInputs.cache +# modified: obj/Debug/net8.0/demoMvcCore.GeneratedMSBuildEditorConfig.editorconfig +# modified: obj/Debug/net8.0/demoMvcCore.csproj.CoreCompileInputs.cache +# modified: obj/Debug/net8.0/demoMvcCore.csproj.FileListAbsolute.txt +# modified: obj/Debug/net8.0/demoMvcCore.dll +# modified: obj/Debug/net8.0/demoMvcCore.pdb +# modified: obj/Debug/net8.0/ref/demoMvcCore.dll +# modified: obj/Debug/net8.0/refint/demoMvcCore.dll +# modified: wwwroot/css/site.css +# +# Untracked files: +# Controllers/ProductsController.cs +# Controllers/SalesController.cs +# Controllers/TransactionsController.cs +# Models/CategoryRepository.cs +# Models/Product.cs +# Models/ProductRepository.cs +# Models/Transaction.cs +# Models/TransactionsRepository.cs +# ViewComponents/ +# ViewModels/ +# Views/Products/ +# Views/Sales/ +# Views/Shared/Components/ +# Views/Transactions/ +# obj/Debug/net8.0/demoMvcCore.sourcelink.json +# diff --git a/Controllers/CategoriesController.cs b/Controllers/CategoriesController.cs index 7ae4f6c..4913056 100644 --- a/Controllers/CategoriesController.cs +++ b/Controllers/CategoriesController.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using demoMvcCore.Models; +using demoMvcCore.Models; using Microsoft.AspNetCore.Mvc; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -38,13 +34,14 @@ public IActionResult Edit(Category category) CategoryRepository.UpdateCategory(category.CategoryId, category); return RedirectToAction(nameof(Index)); } + ViewBag.OnClick = "edit"; return View(category); } public IActionResult Add() { - //ViewData["OnClick"] = "add"; + ViewBag.OnClick = "add"; return View(); } @@ -58,11 +55,11 @@ public IActionResult Add(Category category) return RedirectToAction(nameof(Index)); } - + ViewBag.OnClick = "add"; return View(category); } - [HttpGet] + public IActionResult Delete(int categoryId) { CategoryRepository.DeleteCategory(categoryId); diff --git a/Controllers/ProductsController.cs b/Controllers/ProductsController.cs new file mode 100644 index 0000000..8b06307 --- /dev/null +++ b/Controllers/ProductsController.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Xml.Linq; +using demoMvcCore.Models; +using demoMvcCore.ViewModels; +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace demoMvcCore.Controllers +{ + public class ProductsController : Controller + { + // GET: // + public IActionResult Index() + { + var products = ProductsRepository.GetProducts(loadCategory:true); + return View(products); + + } + + public IActionResult Add() + { + ViewBag.Action = "add"; + var productViewModels = new ProductsViewModel + { + Categories = CategoryRepository.GetCategories(), + //Product + }; + return View(productViewModels); + + + } + + [HttpPost] + public IActionResult Add(ProductsViewModel productsViewModel) + { + if (ModelState.IsValid) + { + ProductsRepository.AddProduct(productsViewModel.Product); + return RedirectToAction(nameof(Index)); + } + ViewBag.Action = "edit"; + productsViewModel.Categories = CategoryRepository.GetCategories(); + return View(productsViewModel); + } + + + + + public IActionResult Edit(int id) + { + ViewBag.Action = "edit"; + var productView = new ProductsViewModel + { + Product = ProductsRepository.GetProductById(id) ?? new Product(), + Categories = CategoryRepository.GetCategories() + }; + return View(productView); + } + + [HttpPost] + + public IActionResult Edit(ProductsViewModel productsViewModel) + { + if (ModelState.IsValid) + { + ProductsRepository.UpdateProduct(productsViewModel.Product.ProductId, productsViewModel.Product); + + return RedirectToAction(nameof(Index)); + } + ViewBag.Action = "edit"; + productsViewModel.Categories = CategoryRepository.GetCategories(); + return View(productsViewModel); + } + + + public IActionResult Delete(int id) + { + ProductsRepository.DeleteProduct(id); + return RedirectToAction(nameof(Index)); + } + + public IActionResult ProductsByCategoryPartial(int categoryId) + { + var products = ProductsRepository.GetProductsByCategoryId(categoryId); + return PartialView("_Product",products); + + } + + + + + + } +} + diff --git a/Controllers/SalesController.cs b/Controllers/SalesController.cs new file mode 100644 index 0000000..94c421c --- /dev/null +++ b/Controllers/SalesController.cs @@ -0,0 +1,58 @@ +using demoMvcCore.Models; +using demoMvcCore.ViewModels; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace demoMvcCore.Controllers +{ + public class SalesController : Controller + { + // GET: // + public IActionResult Index() + { + var salesVm = new SalesViewModel + { + Categories = CategoryRepository.GetCategories() + }; + return View(salesVm); + } + + + public IActionResult SellProductPartial(int productId) + { + var product = ProductsRepository.GetProductById(productId); + + return PartialView("_SellProduct", product); + + + } + + public IActionResult Sell(SalesViewModel salesViewModel) + { + if(ModelState.IsValid) + { + var prod = ProductsRepository.GetProductById(salesViewModel.SelectedProductId); + if(prod !=null) + { + TransactionsRepository.Add("Cashier1" + , salesViewModel.SelectedProductId, + prod.Name, + prod.Price.HasValue ? prod.Price.Value : 0, + prod.Quantity.HasValue ? prod.Quantity.Value : 0, + salesViewModel.QuantityToSell); + + prod.Quantity -= salesViewModel.QuantityToSell; + ProductsRepository.UpdateProduct(salesViewModel.SelectedProductId, prod); + + + } + } + var product = ProductsRepository.GetProductById(salesViewModel.SelectedProductId); + salesViewModel.SelectedCategoryId = (product?.CategoryId is null) ? 0 : product.CategoryId.Value; + salesViewModel.Categories = CategoryRepository.GetCategories(); + return View("Index", salesViewModel); + } + } +} + diff --git a/Controllers/TransactionsController.cs b/Controllers/TransactionsController.cs new file mode 100644 index 0000000..07e3d65 --- /dev/null +++ b/Controllers/TransactionsController.cs @@ -0,0 +1,36 @@ +using demoMvcCore.Models; +using demoMvcCore.ViewModels; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace demoMvcCore.Controllers +{ + public class TransactionsController : Controller + { + // GET: // + public IActionResult Index() + { + TransactionsViewModel transactionsVM = new(); + + return View(transactionsVM); + } + + + + public IActionResult Search(TransactionsViewModel transactionsViewModel) + { + + //search + + var transactions = TransactionsRepository.Search(transactionsViewModel.CashierName ?? string.Empty, transactionsViewModel.StartDate, transactionsViewModel.EndDate); + transactionsViewModel.Transactions = transactions; + + return View("Index", transactionsViewModel); + + + } + } +} + + \ No newline at end of file diff --git a/Models/CategoryRepositoruy.cs b/Models/CategoryRepository.cs similarity index 75% rename from Models/CategoryRepositoruy.cs rename to Models/CategoryRepository.cs index 00c9dea..da38f62 100644 --- a/Models/CategoryRepositoruy.cs +++ b/Models/CategoryRepository.cs @@ -13,10 +13,20 @@ public CategoryRepository() public static void AddCategory(Category category) { - var maxId = _categories.Max(x => x.CategoryId); - category.CategoryId = maxId + 1; - _categories.Add(category); - } + if (_categories is not null && _categories.Count > 0) + { + var maxId = _categories.Max(x => x.CategoryId); + category.CategoryId = maxId + 1; + + } + else + { + var maxId = 1; + category.CategoryId = maxId; + } + _categories ??= new List(); + _categories.Add(category); + } public static Category? GetCategoryById(int categoryId) => _categories.FirstOrDefault(x => x.CategoryId == categoryId); diff --git a/Models/Product.cs b/Models/Product.cs new file mode 100644 index 0000000..f9d3d71 --- /dev/null +++ b/Models/Product.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; + +namespace demoMvcCore.Models +{ + + public class Product + { + public int ProductId { get; set; } + + [Required] + [Display(Name = "Category")] + public int? CategoryId { get; set; } + + [Required] + public string Name { get; set; } = string.Empty; + + [Required] + public int? Quantity { get; set; } + + [Required] + [Range(0, int.MaxValue)] + public double? Price { get; set; } + public Category? Category { get; set; } + + + } + } + diff --git a/Models/ProductRepository.cs b/Models/ProductRepository.cs new file mode 100644 index 0000000..de56709 --- /dev/null +++ b/Models/ProductRepository.cs @@ -0,0 +1,105 @@ +namespace demoMvcCore.Models +{ + public class ProductsRepository + { + private static List _products = new List() + { + new Product { ProductId = 1, CategoryId = 1, Name = "Iced Tea", Quantity = 100, Price = 1.99 }, + new Product { ProductId = 2, CategoryId = 1, Name = "Canada Dry", Quantity = 200, Price = 1.99 }, + new Product { ProductId = 3, CategoryId = 2, Name = "Whole Wheat Bread", Quantity = 300, Price = 1.50 }, + new Product { ProductId = 4, CategoryId = 2, Name = "White Bread", Quantity = 300, Price = 1.50 } + }; + + public static void AddProduct(Product product) + { + if (_products is not null && _products.Count() > 0) + { + var maxId = _products.Max(x => x.ProductId); + product.ProductId = maxId + 1; + + } + else + { + var maxId = 1; + product.ProductId = maxId; + } + _products ??= new List(); + _products.Add(product); + } + + public static List GetProducts(bool loadCategory = false) + { + if (!loadCategory) + { + return _products; + } + else + { + if (_products != null && _products.Count > 0) + { + _products.ForEach(x => + { + if (x.CategoryId.HasValue) + x.Category = CategoryRepository.GetCategoryById(x.CategoryId.Value); + }); + } + } + return _products; + } + + public static Product? GetProductById(int productId, bool loadCategory = false) + { + var product = _products.FirstOrDefault(x => x.ProductId == productId); + if (product != null) + { + var prod = new Product + { + ProductId = product.ProductId, + Name = product.Name, + Quantity = product.Quantity, + Price = product.Price, + CategoryId = product.CategoryId + }; + + if (loadCategory && product.CategoryId.HasValue) + { + prod.Category = CategoryRepository.GetCategoryById(prod.CategoryId.Value); + } + + return prod; + } + + return null; + } + + public static void UpdateProduct(int productId, Product product) + { + if (productId != product.ProductId) return; + + var productToUpdate = _products.FirstOrDefault(x => x.ProductId == productId); + if (productToUpdate != null) + { + productToUpdate.Name = product.Name; + productToUpdate.Quantity = product.Quantity; + productToUpdate.Price = product.Price; + productToUpdate.CategoryId = product.CategoryId; + } + } + + public static void DeleteProduct(int productId) + { + var product = _products.FirstOrDefault(x => x.ProductId == productId); + if (product != null) + { + _products.Remove(product); + } + } + + public static List GetProductsByCategoryId(int categoryId) + { + return _products.Where(x => x.CategoryId == categoryId).ToList() ?? new List(); + } + } +} + + diff --git a/Models/Transaction.cs b/Models/Transaction.cs new file mode 100644 index 0000000..7f020e5 --- /dev/null +++ b/Models/Transaction.cs @@ -0,0 +1,15 @@ +namespace demoMvcCore.Models +{ + public class Transaction + { + public int TransactionId { get; set; } + public DateTime TimeStamp { get; set; } + public int ProductId { get; set; } + public string ProductName { get; set; } = ""; + public double Price { get; set; } + public int BeforeQty { get; set; } + public int SoldQty { get; set; } + public string CashierName { get; set; } = ""; + } +} + diff --git a/Models/TransactionsRepository.cs b/Models/TransactionsRepository.cs new file mode 100644 index 0000000..b820cd8 --- /dev/null +++ b/Models/TransactionsRepository.cs @@ -0,0 +1,117 @@ +namespace demoMvcCore.Models +{ + public static class TransactionsRepository + { + private static List transactions = new List(); + + + + public static IEnumerable GetByDayAndCashier(string cashierName, DateTime date) + + { + + if (string.IsNullOrWhiteSpace(cashierName)) + + { + + return transactions.Where(x => x.TimeStamp.Date == date.Date); + + } + + else + + { + + return transactions.Where(x => + + x.CashierName.ToLower().Contains(cashierName.ToLower()) && + + x.TimeStamp.Date == date.Date); + + } + + } + + + + public static IEnumerable Search(string cashierName, DateTime startDate, DateTime endDate) + + { + + if (string.IsNullOrWhiteSpace(cashierName)) + + { + + return transactions.Where(x => x.TimeStamp >= startDate.Date && x.TimeStamp <= endDate.Date.AddDays(1).Date); + + } + + else + + { + + return transactions.Where(x => + + x.CashierName.ToLower().Contains(cashierName.ToLower()) && + + x.TimeStamp >= startDate.Date && x.TimeStamp <= endDate.Date.AddDays(1).Date); + + } + + } + + + + public static void Add(string cashierName, int productId, string productName, double price, int beforeQty, int soldQty) + + { + + var transaction = new Transaction + + { + + ProductId = productId, + + ProductName = productName, + + TimeStamp = DateTime.Now, + + Price = price, + + BeforeQty = beforeQty, + + SoldQty = soldQty, + + CashierName = cashierName + + }; + + + + if (transactions != null && transactions.Count > 0) + + { + + var maxId = transactions.Max(x => x.TransactionId); + + transaction.TransactionId = maxId + 1; + + } + + else + + { + + transaction.TransactionId = 1; + + } + + + + transactions?.Add(transaction); + + } + + } +} + diff --git a/Program.cs b/Program.cs index 9fbb57d..7d9b922 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,13 @@ var builder = WebApplication.CreateBuilder(args); + // Add services to the container. builder.Services.AddControllersWithViews(); - +builder.Services.AddCors(options => +options.AddDefaultPolicy(policy => +{ + policy.WithOrigins("*").WithMethods("GET", "POST").WithHeaders("Content-Type"); +})); var app = builder.Build(); // Configure the HTTP request pipeline. @@ -16,13 +21,14 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); +app.UseCors(); app.UseRouting(); app.UseAuthorization(); - app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); +; app.Run(); diff --git a/ViewComponents/TransactionViewComponent.cs b/ViewComponents/TransactionViewComponent.cs new file mode 100644 index 0000000..4b3cb0a --- /dev/null +++ b/ViewComponents/TransactionViewComponent.cs @@ -0,0 +1,20 @@ +using demoMvcCore.Models; +using Microsoft.AspNetCore.Mvc; + +namespace demoMvcCore.ViewComponents +{ + + public class TransactionViewComponent:ViewComponent + { + + + public IViewComponentResult Invoke(string userName) + { + var transactions = TransactionsRepository.GetByDayAndCashier(userName, DateTime.Now); + + return View(transactions); + } + + } +} + diff --git a/ViewModels/ProductsViewModel.cs b/ViewModels/ProductsViewModel.cs new file mode 100644 index 0000000..089ddff --- /dev/null +++ b/ViewModels/ProductsViewModel.cs @@ -0,0 +1,18 @@ + +using demoMvcCore.Models; + +namespace demoMvcCore.ViewModels +{ + public class ProductsViewModel + { + public ProductsViewModel() + { + + + } + + public IEnumerable Categories { get; set; } = new List(); + public Product Product { get; set; } = new(); + } +} + diff --git a/ViewModels/SalesViewModel.cs b/ViewModels/SalesViewModel.cs new file mode 100644 index 0000000..9396817 --- /dev/null +++ b/ViewModels/SalesViewModel.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using demoMvcCore.Models; +using demoMvcCore.ViewModels.Validations; + +namespace demoMvcCore.ViewModels +{ + public class SalesViewModel + { + public int SelectedCategoryId { get; set; } + public IEnumerable Categories { get; set; } = new List(); + public int SelectedProductId { get; set; } + + + [Display(Name = "Quantity")] + [Range(1,int.MaxValue)] + public int QuantityToSell { get; set; } + + } +} + diff --git a/ViewModels/TransactionsViewModel.cs b/ViewModels/TransactionsViewModel.cs new file mode 100644 index 0000000..516e911 --- /dev/null +++ b/ViewModels/TransactionsViewModel.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations; +using demoMvcCore.Models; + +namespace demoMvcCore.ViewModels +{ + public class TransactionsViewModel + { + [Display(Name = "Cashier Name")] + public string? CashierName { get; set; } + + [Display(Name ="Start Date")] + public DateTime StartDate { get; set; } = DateTime.Now; + + [Display(Name = "End Date")] + public DateTime EndDate { get; set; } = DateTime.Now; + + + public IEnumerable Transactions = new List(); + + + + + + + } +} + diff --git a/ViewModels/Validations/EnsureProperQuantity.cs b/ViewModels/Validations/EnsureProperQuantity.cs new file mode 100644 index 0000000..0bf8b57 --- /dev/null +++ b/ViewModels/Validations/EnsureProperQuantity.cs @@ -0,0 +1,37 @@ +using System; +using System.ComponentModel.DataAnnotations; +using demoMvcCore.Models; + +namespace demoMvcCore.ViewModels.Validations +{ + public class EnsureProperQuantity : ValidationAttribute + { + + protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) + { + var salesVM = validationContext.ObjectInstance as SalesViewModel; + if (salesVM != null) + { + if (salesVM.QuantityToSell <= 0) + { + return new ValidationResult("should be > 0"); + } + else + { + var product = ProductsRepository.GetProductById(salesVM.SelectedProductId); + if (product != null) + { + if (product.Quantity < salesVM.QuantityToSell) + return new ValidationResult($"{product.Name} only has {product.Quantity} left"); + } + else + { + return new ValidationResult("Product doesnt exist"); + } + } + + } + return ValidationResult.Success; + } + } +} diff --git a/Views/Categories/Index.cshtml b/Views/Categories/Index.cshtml index 2a08bd7..4539d87 100644 --- a/Views/Categories/Index.cshtml +++ b/Views/Categories/Index.cshtml @@ -8,37 +8,38 @@ @addTagHelper *,Microsoft.AspNetCore.Mvc.TagHelpers @if (Model is not null && Model.Count() > 0) { - - - - - - - - - - -@foreach (var category in Model) - { - - - - - - - } - -
Name Description
@category.Name@category.DescriptionEditDelete
+ + + + + + + + + + + @foreach (var category in Model) + { + + + + + + + } + +
Name Description
@category.Name@category.DescriptionEditDelete
+ +
-
-Add } - @section Scripts +Add +@section Scripts { - -} \ No newline at end of file + + +} + diff --git a/Views/Products/Add.cshtml b/Views/Products/Add.cshtml new file mode 100644 index 0000000..9b25074 --- /dev/null +++ b/Views/Products/Add.cshtml @@ -0,0 +1,9 @@ +@using demoMvcCore.ViewModels +@model ProductsViewModel + +@section title +{ +

Add product

+} + + \ No newline at end of file diff --git a/Views/Products/Edit.cshtml b/Views/Products/Edit.cshtml new file mode 100644 index 0000000..69d6f84 --- /dev/null +++ b/Views/Products/Edit.cshtml @@ -0,0 +1,25 @@ +@using demoMvcCore.ViewModels +@model ProductsViewModel + +@section title +{ +@if (Model is not null) + { +

Edit product: @Model.Product.Name

+ } + } + +@if (Model != null) + { + + + + } + + + + + + + + diff --git a/Views/Products/Index.cshtml b/Views/Products/Index.cshtml new file mode 100644 index 0000000..1fbd0e6 --- /dev/null +++ b/Views/Products/Index.cshtml @@ -0,0 +1,46 @@ +@model List + +@section title +{ +

Products

+} + +@if (Model is not null && Model.Count() > 0) +{ + + + + + + + + + + + + @foreach (var product in Model) + { + + + + + + + + + } + +
Category NameProduct NamePriceQuantity
@product.Category?.Name@product.Name$ @product.Price?.ToString()@product.QuantityEditDelete
+ +} + +
+Add + +@section Scripts +{ + + +} \ No newline at end of file diff --git a/Views/Products/_Product.cshtml b/Views/Products/_Product.cshtml new file mode 100644 index 0000000..a61a6bc --- /dev/null +++ b/Views/Products/_Product.cshtml @@ -0,0 +1,25 @@ +@model IEnumerable + +@if (Model is not null && Model.Count() > 0) + { + + + + + + + + + + @foreach (var product in Model) +{ + + + + +} + +
Product NameQuantity
@product.Name @product.Quantity
+ } + + diff --git a/Views/Products/_Products.cshtml b/Views/Products/_Products.cshtml new file mode 100644 index 0000000..fa912ae --- /dev/null +++ b/Views/Products/_Products.cshtml @@ -0,0 +1,77 @@ +@using demoMvcCore.ViewModels +@model ProductsViewModel +@{ + string action = ViewBag.Action ?? string.Empty; +} +
+ + @if (action?.ToLower() == "edit") + { + + } +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/Views/Sales/Index.cshtml b/Views/Sales/Index.cshtml new file mode 100644 index 0000000..7506cb4 --- /dev/null +++ b/Views/Sales/Index.cshtml @@ -0,0 +1,130 @@ +@using demoMvcCore.ViewModels +@model SalesViewModel + @section title + { +
+ +

Cashier's Console

+
+
+ + @* Display Cashier's Name Here' *@ + +
+ +
+
+ + + + + } + + +
+ +
+
+
+ @*Category Selection*@ + + + + +
+ +
+ @*Products List*@ + + +
+
+
+ + + @*Products Details*@ +
+
+ @*Sales form*@ + +
+ +
+ + +
+
+
+ +
+
+
+
+
+ @*List of Transactions*@ + + @await Component.InvokeAsync("Transaction","Cashier1") +
+
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/Views/Sales/_SellProduct.cshtml b/Views/Sales/_SellProduct.cshtml new file mode 100644 index 0000000..60ffec3 --- /dev/null +++ b/Views/Sales/_SellProduct.cshtml @@ -0,0 +1,14 @@ +@using System.Globalization +@model Product + +
+ + +
+
+ + +
+ + + diff --git a/Views/Shared/Components/Transaction/Default.cshtml b/Views/Shared/Components/Transaction/Default.cshtml new file mode 100644 index 0000000..b851ad5 --- /dev/null +++ b/Views/Shared/Components/Transaction/Default.cshtml @@ -0,0 +1,29 @@ +@model IEnumerable + + + + + + + + + + + + + + + @foreach (var tran in Model) + { + + + + + + + + + + } + +
Cashier NameProduct NameDate TimeQty BeforeQty SoldQty AfterSold Amt
@tran.CashierName@tran.ProductName@tran.TimeStamp.ToString("MM/dd hh:mm")@tran.BeforeQty@tran.SoldQty@(tran.BeforeQty - tran.SoldQty)@(string.Format("{0:c}", tran.SoldQty * tran.Price))
\ No newline at end of file diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml index 16546bc..680ce54 100644 --- a/Views/Shared/_Layout.cshtml +++ b/Views/Shared/_Layout.cshtml @@ -6,8 +6,10 @@ @ViewData["Title"] - Supermarket Management - + + +
@@ -26,6 +28,15 @@ + + + diff --git a/Views/Transactions/Index.cshtml b/Views/Transactions/Index.cshtml new file mode 100644 index 0000000..fdda6d6 --- /dev/null +++ b/Views/Transactions/Index.cshtml @@ -0,0 +1,106 @@ +@using demoMvcCore.ViewModels; +@using System.Globalization; +@model TransactionsViewModel + + +@section title { +

Transactions Report

+} + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +@if (Model.Transactions is not null) +{ + + + + + + + + + + + + + + + + @foreach (var tran in Model.Transactions) + { + + + + + + + + + + + } + + + + + + + + +
Date TimeCashier NameProduct NameQty BeforeQty SoldQty AfterPriceSold Amt
@tran.TimeStamp.ToString("yyyy-MM-dd hh:mm")@tran.CashierName@tran.ProductName@tran.BeforeQty@tran.SoldQty@(tran.BeforeQty - tran.SoldQty)@(string.Format(new CultureInfo("en-US"),"{0:c}", tran.Price))@(string.Format(new CultureInfo("en-US"), "{0:c}", tran.SoldQty * tran.Price))
  + Grand Total: + + + @(string.Format(new CultureInfo("en-US"),"{0:c}", Model.Transactions.Sum(x => x.Price * x.SoldQty))) + +
+ + +} +
+ +@section Scripts +{ + + + +} + diff --git a/bin/Debug/net8.0/demoMvcCore.dll b/bin/Debug/net8.0/demoMvcCore.dll index 4a78829..ac64139 100644 Binary files a/bin/Debug/net8.0/demoMvcCore.dll and b/bin/Debug/net8.0/demoMvcCore.dll differ diff --git a/bin/Debug/net8.0/demoMvcCore.pdb b/bin/Debug/net8.0/demoMvcCore.pdb index 9bd939e..151bb99 100644 Binary files a/bin/Debug/net8.0/demoMvcCore.pdb and b/bin/Debug/net8.0/demoMvcCore.pdb differ diff --git a/demoMvcCore.csproj b/demoMvcCore.csproj index 5ca3265..1750c26 100644 --- a/demoMvcCore.csproj +++ b/demoMvcCore.csproj @@ -11,12 +11,29 @@ + + + + + + + + + + + + + + + + + diff --git a/obj/Debug/net8.0/demoMvcCore.AssemblyInfo.cs b/obj/Debug/net8.0/demoMvcCore.AssemblyInfo.cs index 1dfcbc2..90ff62d 100644 --- a/obj/Debug/net8.0/demoMvcCore.AssemblyInfo.cs +++ b/obj/Debug/net8.0/demoMvcCore.AssemblyInfo.cs @@ -13,7 +13,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("demoMvcCore")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+86e59537d17bd14d175fe174596e603b0e67fa24")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9f42a68aaa510028e7163ce6690f1e6433d054d4")] [assembly: System.Reflection.AssemblyProductAttribute("demoMvcCore")] [assembly: System.Reflection.AssemblyTitleAttribute("demoMvcCore")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net8.0/demoMvcCore.AssemblyInfoInputs.cache b/obj/Debug/net8.0/demoMvcCore.AssemblyInfoInputs.cache index 1bd5292..7a46cf0 100644 --- a/obj/Debug/net8.0/demoMvcCore.AssemblyInfoInputs.cache +++ b/obj/Debug/net8.0/demoMvcCore.AssemblyInfoInputs.cache @@ -1 +1 @@ -f3f75f70092c22decad48230ee2cd3671f357cfceec8d78d3e33127577b52421 +0f60b351215867e180cd79f3fcc810b50eb9308479b6cd51c079a240f1c1eea0 diff --git a/obj/Debug/net8.0/demoMvcCore.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net8.0/demoMvcCore.GeneratedMSBuildEditorConfig.editorconfig index dd1eeda..07ca636 100644 --- a/obj/Debug/net8.0/demoMvcCore.GeneratedMSBuildEditorConfig.editorconfig +++ b/obj/Debug/net8.0/demoMvcCore.GeneratedMSBuildEditorConfig.editorconfig @@ -38,6 +38,38 @@ build_metadata.AdditionalFiles.CssScope = build_metadata.AdditionalFiles.TargetPath = Vmlld3MvSG9tZS9JbmRleC5jc2h0bWw= build_metadata.AdditionalFiles.CssScope = +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Products/Add.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvUHJvZHVjdHMvQWRkLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Products/Edit.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvUHJvZHVjdHMvRWRpdC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Products/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvUHJvZHVjdHMvSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Products/_Product.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvUHJvZHVjdHMvX1Byb2R1Y3QuY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Products/_Products.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvUHJvZHVjdHMvX1Byb2R1Y3RzLmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Sales/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvU2FsZXMvSW5kZXguY3NodG1s +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Sales/_SellProduct.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvU2FsZXMvX1NlbGxQcm9kdWN0LmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Shared/Components/Transaction/Default.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvU2hhcmVkL0NvbXBvbmVudHMvVHJhbnNhY3Rpb24vRGVmYXVsdC5jc2h0bWw= +build_metadata.AdditionalFiles.CssScope = + [/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Shared/Error.cshtml] build_metadata.AdditionalFiles.TargetPath = Vmlld3MvU2hhcmVkL0Vycm9yLmNzaHRtbA== build_metadata.AdditionalFiles.CssScope = @@ -46,6 +78,10 @@ build_metadata.AdditionalFiles.CssScope = build_metadata.AdditionalFiles.TargetPath = Vmlld3MvU2hhcmVkL19WYWxpZGF0aW9uU2NyaXB0c1BhcnRpYWwuY3NodG1s build_metadata.AdditionalFiles.CssScope = +[/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/Transactions/Index.cshtml] +build_metadata.AdditionalFiles.TargetPath = Vmlld3MvVHJhbnNhY3Rpb25zL0luZGV4LmNzaHRtbA== +build_metadata.AdditionalFiles.CssScope = + [/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/Views/_ViewImports.cshtml] build_metadata.AdditionalFiles.TargetPath = Vmlld3MvX1ZpZXdJbXBvcnRzLmNzaHRtbA== build_metadata.AdditionalFiles.CssScope = diff --git a/obj/Debug/net8.0/demoMvcCore.csproj.CoreCompileInputs.cache b/obj/Debug/net8.0/demoMvcCore.csproj.CoreCompileInputs.cache index e99137c..4e204e3 100644 --- a/obj/Debug/net8.0/demoMvcCore.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net8.0/demoMvcCore.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -0cc43b18c822f2bcc26c25e898904d480d4bc409fe6708e83c324d34ae719746 +39a5223c19ed90571b4257a7b7780512bd2cca71bbe680873ccccb667aea9e20 diff --git a/obj/Debug/net8.0/demoMvcCore.csproj.FileListAbsolute.txt b/obj/Debug/net8.0/demoMvcCore.csproj.FileListAbsolute.txt index 45f4632..4a48840 100644 --- a/obj/Debug/net8.0/demoMvcCore.csproj.FileListAbsolute.txt +++ b/obj/Debug/net8.0/demoMvcCore.csproj.FileListAbsolute.txt @@ -28,3 +28,4 @@ /Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/obj/Debug/net8.0/demoMvcCore.pdb /Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/obj/Debug/net8.0/demoMvcCore.genruntimeconfig.cache /Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/obj/Debug/net8.0/ref/demoMvcCore.dll +/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/obj/Debug/net8.0/demoMvcCore.sourcelink.json diff --git a/obj/Debug/net8.0/demoMvcCore.dll b/obj/Debug/net8.0/demoMvcCore.dll index 4a78829..ac64139 100644 Binary files a/obj/Debug/net8.0/demoMvcCore.dll and b/obj/Debug/net8.0/demoMvcCore.dll differ diff --git a/obj/Debug/net8.0/demoMvcCore.pdb b/obj/Debug/net8.0/demoMvcCore.pdb index 9bd939e..151bb99 100644 Binary files a/obj/Debug/net8.0/demoMvcCore.pdb and b/obj/Debug/net8.0/demoMvcCore.pdb differ diff --git a/obj/Debug/net8.0/demoMvcCore.sourcelink.json b/obj/Debug/net8.0/demoMvcCore.sourcelink.json new file mode 100644 index 0000000..f86b0b6 --- /dev/null +++ b/obj/Debug/net8.0/demoMvcCore.sourcelink.json @@ -0,0 +1 @@ +{"documents":{"/Users/raghavrastogi/Projects/demoMvcCore/demoMvcCore/*":"https://raw.githubusercontent.com/raghav2404/PhoenixSupermarket/9f42a68aaa510028e7163ce6690f1e6433d054d4/*"}} \ No newline at end of file diff --git a/obj/Debug/net8.0/ref/demoMvcCore.dll b/obj/Debug/net8.0/ref/demoMvcCore.dll index ec60dde..8bbab97 100644 Binary files a/obj/Debug/net8.0/ref/demoMvcCore.dll and b/obj/Debug/net8.0/ref/demoMvcCore.dll differ diff --git a/obj/Debug/net8.0/refint/demoMvcCore.dll b/obj/Debug/net8.0/refint/demoMvcCore.dll index ec60dde..8bbab97 100644 Binary files a/obj/Debug/net8.0/refint/demoMvcCore.dll and b/obj/Debug/net8.0/refint/demoMvcCore.dll differ diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css index 8ad7251..f76bb8e 100644 --- a/wwwroot/css/site.css +++ b/wwwroot/css/site.css @@ -20,3 +20,24 @@ html { body { margin-bottom: 60px; } + +tr.highlight > td { + background-color: yellow; +} + + +@media print { + body * { + visibility: hidden; + } + + #printarea, #printarea * { + visibility: visible; + } + + #printarea { + position: absolute; + left: 0; + top: 0; + } +} \ No newline at end of file