[HttpGet] public IActionResult Index() { ViewData["table1"] = _repository.GetAll("table1").ToList(); ViewData["table2"] = _repository.GetAll("table2").ToList(); return View("Index"); } [HttpPost] public IActionResult Remove(string fromTable, List<Items> items) { try { var itemsToDelete = items.Where(x => x.Checked).ToList(); _repository.Remove(itemsToDelete, fromTable); } return RedirectToAction("Index"); }
@{ const string changeQueueTable = "table1"; const string changeQueueErrorsTable = "table2"; var table1 = (List<Items>)ViewData["table1"]; var table2 = (List<Items>)ViewData["table2"]; var error = (string)ViewData["error"]; } @if (error != null) { <div class="alert alert-danger mt-3" role="alert">@error</div> } <div class="row" style="margin-top: 10px;"> <div class="col-md-6" style="border-right: 1px solid #dee2e6"> @if (changeQueue != null) { var id = 0; <h3>Change queue table</h3> <form asp-controller="ErrorConsumer" asp-action="" method="post"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th></th> <th>Object Id</th> <th>Object type</th> </tr> </thead> <tbody> @if (table1.Count > 0) { @for (var i = 0; i < table1.Count; i++) { <input type="hidden" name="@("items[" + i + "].ObjectId")" value="@table1[i].ObjectId"/> <input type="hidden" name="@("items[" + i + "].ObjectType")" value="@table1[i].ObjectType"/> <tr> <td>@(++id)</td> <td> <input name="@("items[" + i + "].Checked")" type="checkbox" value="true" @(table1[i].Checked ? "checked" : " ")/> </td> <td>@table1[i].ObjectId</td> <td>@table1[i].ObjectType</td> </tr> } } else { <tr> <td colspan="8" style="text-align: center;">No items found</td> </tr> } </tbody> </table> <div class="row justify-content-end" style="margin-top: 20px;"> <div class="col-md-2"> <input type="hidden" name="fromTable" value="@changeQueueTable"/> <input type="hidden" name="toTable" value="@changeQueueErrorsTable"/> <div style="float: right"> <button style="width: 84px; margin-right: -30px; @(table1.Count == 0 ? "display:none" : "display:block")" class="btn btn-primary" asp-action="Move" title="Move" type="submit">Move</button> </div> </div> <div class="col-md-2"> <div style="margin-left: -10px; float: right"> <button class="btn btn-secondary" style="@(table1.Count == 0 ? "display:none" : "display:block")" asp-action="Remove" title="Remove " type="submit">Remove</button> </div> </div> </div> </form> } </div> </div>
IActionResult Remove(string fromTable, List<ChangeQueueItem> items)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)