Views for PC
This commit is contained in:
parent
82be9eab7d
commit
27fc34b712
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -3,11 +3,9 @@ using ComputerStoreContracts.BindingModels;
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using ComputerStoreDataModels.Models;
|
||||
using ComputerStoreEmployeeApp.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
|
||||
|
||||
namespace ComputerStoreEmployeeApp.Controllers
|
||||
{
|
||||
@ -308,6 +306,198 @@ namespace ComputerStoreEmployeeApp.Controllers
|
||||
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]
|
||||
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>
|
||||
<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" />
|
||||
<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">
|
||||
@ -51,7 +51,7 @@
|
||||
<input type="text" id="productname" name="productname" />
|
||||
<div class="productprice" style="text-align: left; font-size: 15px;">Price:</div>
|
||||
<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>
|
||||
@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>
|
||||
</li>
|
||||
<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 class="nav-item">
|
||||
<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