Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }