Views for PC
This commit is contained in:
parent
82be9eab7d
commit
27fc34b712
@ -7,6 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -3,35 +3,33 @@ using ComputerStoreContracts.BindingModels;
|
|||||||
using ComputerStoreContracts.ViewModels;
|
using ComputerStoreContracts.ViewModels;
|
||||||
using ComputerStoreDataModels.Models;
|
using ComputerStoreDataModels.Models;
|
||||||
using ComputerStoreEmployeeApp.Models;
|
using ComputerStoreEmployeeApp.Models;
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
|
|
||||||
|
|
||||||
namespace ComputerStoreEmployeeApp.Controllers
|
namespace ComputerStoreEmployeeApp.Controllers
|
||||||
{
|
{
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger)
|
public HomeController(ILogger<HomeController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
if(APIClient.Employee == null) { return Redirect("Home/Enter"); }
|
if (APIClient.Employee == null) { return Redirect("Home/Enter"); }
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IActionResult ComponentMenu()
|
public IActionResult ComponentMenu()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult ComponentAdd()
|
public IActionResult ComponentAdd()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
@ -47,7 +45,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
throw new Exception("Enter component's name and price.");
|
throw new Exception("Enter component's name and price.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Task.Run(() => APIClient.PostRequest("api/main/insertcomponent", new ComponentBindingModel
|
if (!Task.Run(() => APIClient.PostRequest("api/main/insertcomponent", new ComponentBindingModel
|
||||||
{
|
{
|
||||||
Name = componentname,
|
Name = componentname,
|
||||||
Price = componentprice
|
Price = componentprice
|
||||||
@ -80,9 +78,9 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
if (string.IsNullOrEmpty(componentname) && !componentprice.HasValue)
|
if (string.IsNullOrEmpty(componentname) && !componentprice.HasValue)
|
||||||
{
|
{
|
||||||
throw new Exception("Enter at least one field.");
|
throw new Exception("Enter at least one field.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(componentname))
|
if (string.IsNullOrEmpty(componentname))
|
||||||
{
|
{
|
||||||
Task.Run(() => APIClient.PatchRequest("api/main/updatecomponent", new ComponentBindingModel
|
Task.Run(() => APIClient.PatchRequest("api/main/updatecomponent", new ComponentBindingModel
|
||||||
{
|
{
|
||||||
@ -108,7 +106,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
Price = componentprice.Value
|
Price = componentprice.Value
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -131,7 +129,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
public IActionResult ComponentDelete(int component)
|
public IActionResult ComponentDelete(int component)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task.Run(() => APIClient.DeleteRequest<string>($"api/main/deletecomponent/{component}"));
|
Task.Run(() => APIClient.DeleteRequest<string>($"api/main/deletecomponent/{component}"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -145,8 +143,8 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ComponentCheck()
|
public IActionResult ComponentCheck()
|
||||||
{
|
{
|
||||||
return View( APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result);
|
return View(APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -158,7 +156,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ProductAdd()
|
public IActionResult ProductAdd()
|
||||||
{
|
{
|
||||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
return View(APIClient.productComponents);
|
return View(APIClient.productComponents);
|
||||||
}
|
}
|
||||||
@ -200,31 +198,31 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public double ProductComponents(int id, int componentquantity)
|
public double ProductComponents(int id, int componentquantity)
|
||||||
{
|
{
|
||||||
var component = APIClient.GetRequest<ComponentViewModel>($"api/main/getcomponent?id={id}").Result;
|
var component = APIClient.GetRequest<ComponentViewModel>($"api/main/getcomponent?id={id}").Result;
|
||||||
if(APIClient.productComponents.ContainsKey(component.ID))
|
if (APIClient.productComponents.ContainsKey(component.ID))
|
||||||
{
|
{
|
||||||
APIClient.productComponents[component.ID] = (component, componentquantity);
|
APIClient.productComponents[component.ID] = (component, componentquantity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
||||||
}
|
}
|
||||||
return APIClient.productComponents.Sum(x => x.Value.Component.Price * x.Value.Quantity);
|
return APIClient.productComponents.Sum(x => x.Value.Component.Price * x.Value.Quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("/Home/ProductUpdate/{id}")]
|
[HttpGet("/Home/ProductUpdate/{id}")]
|
||||||
public IActionResult ProductUpdate(int? id,bool selectChange = false)
|
public IActionResult ProductUpdate(int? id, bool selectChange = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
var list = APIClient.GetRequest<List<ProductViewModel>>("api/main/getproductslist").Result;
|
var list = APIClient.GetRequest<List<ProductViewModel>>("api/main/getproductslist").Result;
|
||||||
ViewBag.Products = list;
|
ViewBag.Products = list;
|
||||||
|
|
||||||
if (!id.HasValue)
|
if (!id.HasValue)
|
||||||
{
|
{
|
||||||
var product = list.First();
|
var product = list.First();
|
||||||
APIClient.productComponents = product.ProductComponents;
|
APIClient.productComponents = product.ProductComponents;
|
||||||
ViewBag.Price = product.Price;
|
ViewBag.Price = product.Price;
|
||||||
@ -235,7 +233,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
ViewBag.ID = id;
|
ViewBag.ID = id;
|
||||||
|
|
||||||
if (selectChange)
|
if (selectChange)
|
||||||
{
|
{
|
||||||
var specproduct = list.First(x => x.ID == id);
|
var specproduct = list.First(x => x.ID == id);
|
||||||
APIClient.productComponents = specproduct.ProductComponents;
|
APIClient.productComponents = specproduct.ProductComponents;
|
||||||
ViewBag.Price = specproduct.Price;
|
ViewBag.Price = specproduct.Price;
|
||||||
@ -248,7 +246,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult ProductUpdate(int id, double productprice,string? productname)
|
public IActionResult ProductUpdate(int id, double productprice, string? productname)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -259,7 +257,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
Price = productprice,
|
Price = productprice,
|
||||||
EmployeeID = APIClient.Employee.ID,
|
EmployeeID = APIClient.Employee.ID,
|
||||||
ProductComponents = APIClient.productComponents.Where(component => component.Value.Quantity != 0).ToDictionary(x => x.Key, x => (x.Value.Component as IComponentModel, x.Value.Quantity))
|
ProductComponents = APIClient.productComponents.Where(component => component.Value.Quantity != 0).ToDictionary(x => x.Key, x => (x.Value.Component as IComponentModel, x.Value.Quantity))
|
||||||
|
|
||||||
})).Result)
|
})).Result)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Something went wrong.");
|
throw new InvalidOperationException("Something went wrong.");
|
||||||
@ -277,7 +275,7 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
|
|
||||||
return Redirect("ProductMenu");
|
return Redirect("ProductMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ProductDelete()
|
public IActionResult ProductDelete()
|
||||||
@ -308,6 +306,198 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
return View(APIClient.GetRequest<List<ProductViewModel>>("api/main/getproductslist").Result);
|
return View(APIClient.GetRequest<List<ProductViewModel>>("api/main/getproductslist").Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult PCMenu()
|
||||||
|
{
|
||||||
|
APIClient.pcComponents = new Dictionary<int, (IComponentModel Component, int Quantity)>();
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult PCAdd(int? request)
|
||||||
|
{
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
|
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/main/getrequestlist?id={null}").Result;
|
||||||
|
ViewBag.PCComponents = APIClient.pcComponents;
|
||||||
|
if(request == null)
|
||||||
|
{
|
||||||
|
ViewBag.ID = ViewBag.Requests[0].ID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewBag.ID = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(Requests(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RequestComponentViewModel> Requests(int? id)
|
||||||
|
{
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
var wholelist = APIClient.GetRequest<List<RequestComponentViewModel>>($"api/main/getrequestcomponentlist?id={null}").Result;
|
||||||
|
|
||||||
|
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/main/getrequestlist?id={null}").Result;
|
||||||
|
|
||||||
|
var componentsList = wholelist.Where(x => x.RequestID == ViewBag.Requests[0].ID).Select(x => new RequestComponentViewModel { ComponentName = x.ComponentName, ComponentCount = x.ComponentCount }).ToList();
|
||||||
|
|
||||||
|
return componentsList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var speclist = APIClient.GetRequest<List<RequestComponentViewModel>>($"api/main/getrequestcomponentlist?id={id}").Result;
|
||||||
|
|
||||||
|
var specificcomponentList = speclist.Where(x => x.RequestID == id).Select(x => new RequestComponentViewModel { ComponentName = x.ComponentName, ComponentCount = x.ComponentCount }).ToList();
|
||||||
|
return specificcomponentList;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult PCAdd(string pcname, double pcprice, int request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pcname) || string.IsNullOrEmpty(pcprice.ToString()))
|
||||||
|
{
|
||||||
|
throw new Exception("Enter pc's name or pc doesn't have any components.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APIClient.PostRequest("api/main/insertpc",new PCBindingModel
|
||||||
|
{
|
||||||
|
Name = pcname,
|
||||||
|
Price = pcprice,
|
||||||
|
EmployeeID = APIClient.Employee.ID,
|
||||||
|
RequestID = request,
|
||||||
|
PCComponents = APIClient.pcComponents
|
||||||
|
}).Result)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("PC with such name already exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
APIClient.pcComponents.Clear();
|
||||||
|
ViewBag.Message = new string(ex.Message.ToString());
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
|
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/main/getrequestlist?id={null}").Result;
|
||||||
|
ViewBag.PCComponents = APIClient.pcComponents;
|
||||||
|
return View(Requests(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.pcComponents.Clear();
|
||||||
|
return Redirect("PCMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public double PCComponents(int id, int componentquantity)
|
||||||
|
{
|
||||||
|
var component = APIClient.GetRequest<ComponentViewModel>($"api/main/getcomponent?id={id}").Result;
|
||||||
|
if (APIClient.pcComponents.ContainsKey(component.ID))
|
||||||
|
{
|
||||||
|
APIClient.pcComponents[component.ID] = (component, componentquantity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
APIClient.pcComponents.Add(component.ID, (component, componentquantity));
|
||||||
|
}
|
||||||
|
return APIClient.pcComponents.Sum(x => x.Value.Component.Price * x.Value.Quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("/Home/PCUpdate/{id}")]
|
||||||
|
public IActionResult PCUpdate(int? id, bool selectChange = false)
|
||||||
|
{
|
||||||
|
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
|
var list = APIClient.GetRequest<List<PCViewModel>>("api/main/getpcslist").Result;
|
||||||
|
ViewBag.PCs = list;
|
||||||
|
|
||||||
|
if (!id.HasValue)
|
||||||
|
{
|
||||||
|
var pc = list.First();
|
||||||
|
APIClient.pcComponents = pc.PCComponents;
|
||||||
|
ViewBag.Price = pc.Price;
|
||||||
|
return View(APIClient.pcComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ViewBag.ID = id;
|
||||||
|
|
||||||
|
if (selectChange)
|
||||||
|
{
|
||||||
|
var specpc = list.First(x => x.ID == id);
|
||||||
|
APIClient.pcComponents = specpc.PCComponents;
|
||||||
|
ViewBag.Price = specpc.Price;
|
||||||
|
return View(specpc.PCComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewBag.Price = APIClient.pcComponents.Sum(x => x.Value.Component.Price * x.Value.Quantity);
|
||||||
|
|
||||||
|
return View(APIClient.pcComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult PCUpdate(int id, double pcprice, string? pcname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Task.Run(() => APIClient.PatchRequest("api/main/updatepc", new PCBindingModel
|
||||||
|
{
|
||||||
|
ID = id,
|
||||||
|
Name = pcname,
|
||||||
|
Price = pcprice,
|
||||||
|
EmployeeID = APIClient.Employee.ID,
|
||||||
|
PCComponents = APIClient.pcComponents.Where(component => component.Value.Quantity != 0).ToDictionary(x => x.Key, x => (x.Value.Component as IComponentModel, x.Value.Quantity))
|
||||||
|
|
||||||
|
})).Result)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Something went wrong.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
APIClient.pcComponents.Clear();
|
||||||
|
ViewBag.Message = new string(ex.Message.ToString());
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
|
return View(APIClient.pcComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.pcComponents.Clear();
|
||||||
|
|
||||||
|
return Redirect("PCMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult PCDelete()
|
||||||
|
{
|
||||||
|
ViewBag.PCs = APIClient.GetRequest<List<PCViewModel>>("api/main/getpcslist").Result;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult PCDelete(int pc)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Task.Run(() => APIClient.DeleteRequest<string>($"api/main/deletepc/{pc}"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ViewBag.Message = new string(ex.Message.ToString());
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Redirect("PCMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult PCCheck()
|
||||||
|
{
|
||||||
|
return View(APIClient.GetRequest<List<PCViewModel>>("api/main/getpcslist").Result);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Register()
|
public IActionResult Register()
|
||||||
{
|
{
|
||||||
|
130
ComputerStoreEmployeeApp/Views/Home/PCAdd.cshtml
Normal file
130
ComputerStoreEmployeeApp/Views/Home/PCAdd.cshtml
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
@using ComputerStoreDataModels.Models
|
||||||
|
@using ComputerStoreContracts.ViewModels
|
||||||
|
@model List<RequestComponentViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Add a PC";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Add a PC</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||||
|
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<h1>Component:</h1>
|
||||||
|
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
||||||
|
<div class="componentquantity" style="text-align: left; font-size: 15px;">Quantity:</div>
|
||||||
|
<input type="text" id="componentquantity" name="componentquantity" />
|
||||||
|
<input type="button" id="componentbtn" value="ADD" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Count
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ((IComponentModel,int) item in ViewBag.PCComponents.Values)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Item1.Name)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Item2)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB3" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<h1>PC:</h1>
|
||||||
|
<div class="pcname" style="text-align: left; font-size: 15px;">Name:</div>
|
||||||
|
<input type="text" id="pcname" name="pcname" />
|
||||||
|
<div class="pcprice" style="text-align: left; font-size: 15px;">Price:</div>
|
||||||
|
<input type="text" id="pcprice" name="pcprice" readonly />
|
||||||
|
<input type="submit" id="pcbtn" value="ADD" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="partialView" id="partialView">
|
||||||
|
<select id="request" name="request" class="form-control" asp-items="@(new SelectList(@ViewBag.Requests,"ID","ID"))"></select>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Component
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Count
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@if (Model != null)
|
||||||
|
{
|
||||||
|
foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ComponentName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ComponentCount)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
|
{
|
||||||
|
<script>alert("@ViewBag.Message");</script>
|
||||||
|
}
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
window.onsubmit = function () {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
|
window.onload = function () {
|
||||||
|
$('#pcprice').val(localStorage.getItem("price"));
|
||||||
|
$('#request').val(@ViewBag.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#request').on('change', function () {
|
||||||
|
|
||||||
|
window.location.href = '/Home/PCAdd?request=' + $('#request').val();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#componentbtn').on("click", function () {
|
||||||
|
var count = $('#componentquantity').val();
|
||||||
|
var id = $('#component').val();
|
||||||
|
|
||||||
|
$.when(ajax1(id, count)).done(function (a1) {
|
||||||
|
localStorage.setItem("price", $('#pcprice').val());
|
||||||
|
window.location.href = '/Home/PCAdd?request=' + $('#request').val();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
function ajax1(id, count) {
|
||||||
|
|
||||||
|
return $.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/Home/PCComponents",
|
||||||
|
data: { id: id, componentquantity: count },
|
||||||
|
success: function (result) {
|
||||||
|
$('#pcprice').val(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
56
ComputerStoreEmployeeApp/Views/Home/PCCheck.cshtml
Normal file
56
ComputerStoreEmployeeApp/Views/Home/PCCheck.cshtml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
@using ComputerStoreContracts.ViewModels
|
||||||
|
@model List<PCViewModel>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Storage";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Storage</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Price
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Employee username
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Components
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Name)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Price)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.EmployeeUsername)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<table>
|
||||||
|
@foreach (var component in item.PCComponents)
|
||||||
|
{
|
||||||
|
<tr><td>@component.Value.Component.Name</td></tr>
|
||||||
|
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
18
ComputerStoreEmployeeApp/Views/Home/PCDelete.cshtml
Normal file
18
ComputerStoreEmployeeApp/Views/Home/PCDelete.cshtml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Delete a product";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Delete a product</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||||
|
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.PCs,"ID","Name"))"></select>
|
||||||
|
<input type="submit" id="productbtn" value="DELETE" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
|
{
|
||||||
|
<script>alert("@ViewBag.Message");</script>
|
||||||
|
}
|
||||||
|
</form>
|
32
ComputerStoreEmployeeApp/Views/Home/PCMenu.cshtml
Normal file
32
ComputerStoreEmployeeApp/Views/Home/PCMenu.cshtml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "PCs";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
|
||||||
|
<div class="flex-container" style="flex-direction: row; justify-content: center; display: flex; height: 100vh;">
|
||||||
|
<div class="flex-containerA1" style="flex-direction: column; align-items: center; display: flex; gap: 35px">
|
||||||
|
<h1>What do you want to do with pcs?</h1>
|
||||||
|
<div class="flex-containerB1" style="display: flex; align-items: center; margin-top: 120px;">
|
||||||
|
<form method="get" asp-controller="Home" asp-action="PCAdd">
|
||||||
|
<input type="submit" id="pcadd" value="ADD" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB2" style="display: flex; align-items: center;">
|
||||||
|
<form method="get" asp-controller="Home" asp-action="PCUpdate" asp-route-id="null">
|
||||||
|
<input type="submit" id="pcupdate" value="UPDATE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB3" style="display: flex; align-items: center;">
|
||||||
|
<form method="get" asp-controller="Home" asp-action="PCDelete">
|
||||||
|
<input type="submit" id="pcdel" value="DELETE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB3" style="display: flex; align-items: center;">
|
||||||
|
<form method="get" asp-controller="Home" asp-action="PCCheck">
|
||||||
|
<input type="submit" id="pccheck" value="STORAGE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
18
ComputerStoreEmployeeApp/Views/Home/PCRequest.cshtml
Normal file
18
ComputerStoreEmployeeApp/Views/Home/PCRequest.cshtml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Choose a request";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Choose a request</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||||
|
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.PCs,"ID","Name"))"></select>
|
||||||
|
<input type="submit" id="productbtn" value="DELETE" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
|
{
|
||||||
|
<script>alert("@ViewBag.Message");</script>
|
||||||
|
}
|
||||||
|
</form>
|
96
ComputerStoreEmployeeApp/Views/Home/PCUpdate.cshtml
Normal file
96
ComputerStoreEmployeeApp/Views/Home/PCUpdate.cshtml
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
@using ComputerStoreDataModels.Models;
|
||||||
|
@model Dictionary<int,(IComponentModel,int)>
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Update a PC";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Update a PC</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||||
|
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<h1>Component:</h1>
|
||||||
|
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
||||||
|
<div class="componentquantity" style="text-align: left; font-size: 15px;">Quantity:</div>
|
||||||
|
<input type="text" id="componentquantity" name="componentquantity" />
|
||||||
|
<input type="button" id="componentbtn" value="MODIFY" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th>
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Count
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Value.Item1.Name)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Value.Item2)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="flex-containerB3" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
|
<h1>PC:</h1>
|
||||||
|
<select id="pc" name="pc" class="form-control" asp-items="@(new SelectList(@ViewBag.PCs,"ID","Name"))"></select>
|
||||||
|
<div class="pcname" style="text-align: left; font-size: 15px;">Name:</div>
|
||||||
|
<input type="text" id="pcname" name="pcname" />
|
||||||
|
<div class="pcprice" style="text-align: left; font-size: 15px;">Price:</div>
|
||||||
|
<input type="text" id="pcprice" name="pcprice" readonly />
|
||||||
|
<input type="submit" id="pcbtn" value="UPDATE" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
|
{
|
||||||
|
<script>alert("@ViewBag.Message");</script>
|
||||||
|
}
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
|
||||||
|
$('#pc').val(@ViewBag.ID);
|
||||||
|
$('#pcprice').val(@ViewBag.Price);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#pc').on('change', function () {
|
||||||
|
var pcid = $('#pc').val();
|
||||||
|
window.location.href = '/Home/PCUpdate/' + pcid + '?selectChange=' + true;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#componentbtn').on("click", function () {
|
||||||
|
var count = $('#componentquantity').val();
|
||||||
|
var id = $('#component').val();
|
||||||
|
|
||||||
|
$.when(ajax1(id, count)).done(function (a1) {
|
||||||
|
localStorage.setItem("price", $('#pcprice').val());
|
||||||
|
var pcid = $('#pc').val();
|
||||||
|
window.location.href = '/Home/PCUpdate/' + pcid
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
function ajax1(id, count) {
|
||||||
|
|
||||||
|
return $.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/Home/PCComponents",
|
||||||
|
data: { id: id, componentquantity: count },
|
||||||
|
success: function (result) {
|
||||||
|
$('#pcprice').val(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
@ -13,7 +13,7 @@
|
|||||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
||||||
<div class="componentquantity" style="text-align: left; font-size: 15px;">Quantity:</div>
|
<div class="componentquantity" style="text-align: left; font-size: 15px;">Quantity:</div>
|
||||||
<input type="text" id="componentquantity" name="componentquantity" />
|
<input type="text" id="componentquantity" name="componentquantity" />
|
||||||
<input type="button" id="componentbtn" value="ADD" class="btn btn-primary" />
|
<input type="button" id="componentbtn" value="MODIFY" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<input type="text" id="productname" name="productname" />
|
<input type="text" id="productname" name="productname" />
|
||||||
<div class="productprice" style="text-align: left; font-size: 15px;">Price:</div>
|
<div class="productprice" style="text-align: left; font-size: 15px;">Price:</div>
|
||||||
<input type="text" id="productprice" name="productprice" readonly />
|
<input type="text" id="productprice" name="productprice" readonly />
|
||||||
<input type="submit" id="productbtn" value="ADD" class="btn btn-primary" />
|
<input type="submit" id="productbtn" value="UPDATE" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
|
32
ComputerStoreEmployeeApp/Views/Shared/Requests.cshtml
Normal file
32
ComputerStoreEmployeeApp/Views/Shared/Requests.cshtml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@using ComputerStoreContracts.ViewModels
|
||||||
|
@model List<RequestComponentViewModel>
|
||||||
|
|
||||||
|
<select id="request" name="request" class="form-control" asp-items="@(new SelectList(@ViewBag.Requests,"ID","ID"))"></select>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Component
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Count
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@if(Model != null)
|
||||||
|
{
|
||||||
|
foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ComponentName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ComponentCount)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
@ -33,7 +33,7 @@
|
|||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ProductMenu">Products</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ProductMenu">Products</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PCsMenu">PCs</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PCMenu">PCs</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Request">Requests</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Request">Requests</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user