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;
|
||||
|
||||
namespace ComputerStoreEmployeeApp.Controllers
|
||||
@ -26,19 +28,22 @@ namespace ComputerStoreEmployeeApp.Controllers
|
||||
}
|
||||
|
||||
[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]
|
||||
public IActionResult SaveWord(List<ReportConsignmentsViewModel> consignments)
|
||||
public IActionResult SaveWord()
|
||||
{
|
||||
|
||||
|
||||
return View("ReportMenu");
|
||||
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,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.document",
|
||||
"ReportConsignments.doc");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -60,13 +65,21 @@ namespace ComputerStoreEmployeeApp.Controllers
|
||||
else
|
||||
{
|
||||
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<form method="post">
|
||||
@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;">
|
||||
<h1>Component:</h1>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
||||
@ -49,6 +49,7 @@
|
||||
</div>
|
||||
<input type="button" id="findbtn" value="FIND" class="btn btn-primary" />
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
@if(ViewBag.Consignments != null)
|
||||
@ -91,15 +92,13 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<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;" />
|
||||
</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;" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<input type="submit" id="findbtn" value="FIND" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||
@ -117,6 +116,12 @@
|
||||
})
|
||||
});
|
||||
|
||||
$('#findbtn').on("click", function () {
|
||||
|
||||
window.location.href = '/Report/ConsignmentsReportResult'
|
||||
|
||||
});
|
||||
|
||||
function ajax1(id, count) {
|
||||
|
||||
return $.ajax({
|
||||
|
Loading…
x
Reference in New Issue
Block a user