public ActionResult DeleteMultipleConfirm(DeleteMultipleVM model) { // The user clicked on the button without having selected any articles if (model.ItemsToBeDeleted == null) { return(RedirectToAction("Index")); } // Reconstruction of the model DeleteMultipleVM deleteVM = new DeleteMultipleVM(); deleteVM.Initilize(sir.Items); if (model.ItemsToBeDeleted != null) { deleteVM.ItemsToBeDeleted = model.ItemsToBeDeleted; } // Reconstruction of the list of articles needed to be deleted StaticItemList.Items = new List <StockItem>(); foreach (int articleNumber in model.ItemsToBeDeleted) { StaticItemList.Items.Add(sir.ItemByArticleNumber(articleNumber)); } // Displays the confirmation of delation return(View(deleteVM)); }
public ActionResult DeleteMultiple() { if (StaticItemList.Items == null) { StaticItemList.Items = new List <StockItem>(); } // Recreation of the model DeleteMultipleVM deleteVM = new DeleteMultipleVM(); deleteVM.Initilize(sir.Items); deleteVM.ItemsToBeDeleted = (StaticItemList.Items.Select(i => i.ArticleNumber)).ToArray(); // Displays the list of articles return(View(deleteVM)); }