public async Task <IActionResult> Edit(int id, [Bind("Id,Type,Naam,Prijs,Merk,Kleur,Aantal,Afbeelding,Aantal_gekocht,CategorieId,Maat")] Schoen schoen)
        {
            if (id != schoen.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(schoen);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SchoenExists(schoen.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategorieId"] = new SelectList(_context.Categories, "Id", "Id", schoen.CategorieId);
            return(View(schoen));
        }
        public async Task <IActionResult> Create([Bind("Id,Type,Naam,Prijs,Merk,Kleur,Aantal,Afbeelding,Aantal_gekocht,CategorieId,Maat")] Schoen schoen)
        {
            if (ModelState.IsValid)
            {
                _context.Add(schoen);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategorieId"] = new SelectList(_context.Categories, "Id", "Id", schoen.CategorieId);
            return(View(schoen));
        }
        public async Task <IActionResult> PostSchoen(List <IFormFile> files)
        {
            long   size  = files.Sum(f => f.Length);
            string error = "";

            // full path to file in temp location
            var filePath = Path.GetTempFileName();

            foreach (var formFile in files)
            {
                if (formFile.Length > 0)
                {
                    if (formFile.FileName.EndsWith(".csv"))
                    {
                        using (var stream = new FileStream(filePath, FileMode.Create))
                        {
                            await formFile.CopyToAsync(stream);
                        }
                        var sr = new StreamReader(formFile.OpenReadStream());
                        try
                        {
                            while (!sr.EndOfStream)
                            {
                                var line   = sr.ReadLine();
                                var data   = line.Split(new[] { ',' });
                                var schoen = new Schoen()
                                {
                                    Type           = data[0],
                                    Naam           = data[1],
                                    Prijs          = /* Veranderen naar Float?*/ int.Parse(data[2]),
                                    Merk           = data[3],
                                    Kleur          = data[4],
                                    Aantal         = int.Parse(data[5]),
                                    Afbeelding     = data[6],
                                    Aantal_gekocht = int.Parse(data[7]),
                                    Maat           = int.Parse(data[8]),
                                    CategorieId    = 1
                                };

                                _context.Schoenen.Add(schoen);
                            }
                        }

                        catch (FormatException ex)
                        {
                            System.Console.WriteLine(ex.Message);
                            System.Console.WriteLine("CATCHED ERRRRRRROR-------------------------------------");
                            error = "ERROR";
                        }
                        catch (IndexOutOfRangeException e)
                        {
                            System.Console.WriteLine(e.Message);
                            System.Console.WriteLine("ERRRRRRRRRRRRRRRRORRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
                            error = "ERROR";
                        }

                        _context.SaveChanges();
                    }
                    else
                    {
                        return(RedirectToAction("Error"));
                    }
                }
            }

            if (error == "ERROR")
            {
                return(RedirectToAction("Error"));
            }
            // process uploaded files
            // Don't rely on or trust the FileName property without validation.
            return(RedirectToAction("Succes"));
        }