public IActionResult EditList(EditSuppliesModel data) { using var context = new SuppliesContext(); var supplies = context.Supplies; if (supplies != null) { foreach (var item in supplies) { if (data.NeededSupplies.Contains(item.Name)) { item.OutOf = true; } else { item.OutOf = false; } } } context.SaveChanges(); var suppliesModel = new SuppliesModel { Supplies = supplies.Select(s => s).Where(s => s.OutOf == true).ToList() }; return(View("Index", suppliesModel)); }
public IActionResult Index() { using var context = new SuppliesContext(); var data = new SuppliesModel { Supplies = context.Supplies.Select(s => s).Where(s => s.OutOf == true).ToList() }; return(View(data)); }
public IActionResult EditList() { using var context = new SuppliesContext(); var supplies = context.Supplies.ToList(); var data = new EditSuppliesModel { AllSupplies = GetSupplies(supplies), NeededSupplies = GetNeededSupplies(supplies) }; return(View(data)); }