File saving methods.
This commit is contained in:
parent
54dadbeb7e
commit
5802a5a4dd
@ -1,4 +1,6 @@
|
|||||||
using ComputerStoreContracts.ViewModels;
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.SearchModels;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ComputerStoreEmployeeApp.Controllers
|
namespace ComputerStoreEmployeeApp.Controllers
|
||||||
@ -26,19 +28,22 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult SaveExcel(List<ReportConsignmentsViewModel> consignments)
|
public IActionResult SaveExcel()
|
||||||
{
|
{
|
||||||
|
var model = new ReportComponentsBindingModel { FileName = "ReportConsignments", Components = APIClient.productComponents.Select(x => new ComponentSearchModel { ID = x.Key, Name = x.Value.Component.Name }).ToList() };
|
||||||
|
return File(APIClient.GetRequest<byte[]>($"api/main/savereportconsignmentstoexcel?model={model}").Result,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
"ReportConsignments.xlsx");
|
||||||
|
|
||||||
|
|
||||||
return View("ReportMenu");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult SaveWord(List<ReportConsignmentsViewModel> consignments)
|
public IActionResult SaveWord()
|
||||||
{
|
{
|
||||||
|
var model = new ReportComponentsBindingModel { FileName = "ReportConsignments", Components = APIClient.productComponents.Select(x => new ComponentSearchModel { ID = x.Key, Name = x.Value.Component.Name }).ToList() };
|
||||||
|
return File(APIClient.GetRequest<byte[]>($"api/main/savereportconsignmentstoword?model={model}").Result,
|
||||||
return View("ReportMenu");
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.document",
|
||||||
|
"ReportConsignments.doc");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -61,12 +66,20 @@ namespace ComputerStoreEmployeeApp.Controllers
|
|||||||
{
|
{
|
||||||
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ConsignmentsReportResult()
|
public IActionResult ConsignmentsReportResult()
|
||||||
{
|
{
|
||||||
ViewBag.Consignments = APIClient.GetRequest<List<ReportConsignmentsViewModel>>($"api/main/getreportconsignmentslist").Result;
|
if(APIClient.productComponents.Any())
|
||||||
|
{
|
||||||
|
ViewBag.Consignments = APIClient.GetRequest<List<ReportConsignmentsViewModel>>($"api/main/getreportconsignmentslist?model={APIClient.productComponents.Select(x => new ComponentSearchModel { ID = x.Key, Name = x.Value.Component.Name })}").Result;
|
||||||
|
return View("ConsignmentsReport", APIClient.productComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewBag.Message = "You should enter at least one product";
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||||
return View("ConsignmentsReport", APIClient.productComponents);
|
return View("ConsignmentsReport", APIClient.productComponents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
@if(ViewBag.Components != null)
|
@if(ViewBag.Components != null)
|
||||||
{
|
{
|
||||||
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh; gap: 20px; align-items: center;">
|
||||||
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||||
<h1>Component:</h1>
|
<h1>Component:</h1>
|
||||||
<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>
|
||||||
@ -49,6 +49,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="button" id="findbtn" value="FIND" class="btn btn-primary" />
|
<input type="button" id="findbtn" value="FIND" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@if(ViewBag.Consignments != null)
|
@if(ViewBag.Consignments != null)
|
||||||
@ -91,15 +92,13 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<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;">
|
||||||
<form method="post" asp-controller="Report" asp-action="SaveExcel" asp-route-consignments="@ViewBag.Consignments">
|
<form method="post" asp-controller="Report" asp-action="SaveExcel">
|
||||||
<input type="submit" id="consignmentreport" value="Save excel" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
<input type="submit" id="consignmentreport" value="Save excel" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||||
</form>
|
</form>
|
||||||
<form method="post" asp-controller="Report" asp-action="SaveWord" asp-route-consignments="@ViewBag.Consignments">
|
<form method="post" asp-controller="Report" asp-action="SaveWord">
|
||||||
<input type="submit" id="consignmentreport" value="Save word" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
<input type="submit" id="consignmentreport" value="Save word" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="submit" id="findbtn" value="FIND" class="btn btn-primary" />
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||||
@ -117,6 +116,12 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#findbtn').on("click", function () {
|
||||||
|
|
||||||
|
window.location.href = '/Report/ConsignmentsReportResult'
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
function ajax1(id, count) {
|
function ajax1(id, count) {
|
||||||
|
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user