public async Task <IActionResult> Edit(string id, category category)
        {
            if (id != category.cat_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!categoryExists(category.cat_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["ad_id"] = new SelectList(_context.admintables, "ad_id", "ad_id", category.ad_id);
            //ViewData["em_id"] = new SelectList(_context.employees, "em_id", "em_id", category.em_id);
            //ViewData["t_id"] = new SelectList(_context.types, "t_id", "t_id", category.t_id);
            category.BrandSelectList = Brandselect.brandSelectList(_context);
            category.TypeSelectList  = Typeselect.TypeSelectList(_context);
            category.EmSelectList    = Emselect.emSelectList(_context);
            return(View(category));
        }
        // GET: Category/Create
        public IActionResult Create()
        {
            category ct = new category();

            //ViewData["ad_id"] = new SelectList(_context.admintables, "ad_id", "ad_id");
            //ViewData["em_id"] = new SelectList(_context.employees, "em_id", "em_id");
            //ViewData["t_id"] = new SelectList(_context.types, "t_id", "t_id");
            ct.EmSelectList    = Emselect.emSelectList(_context);
            ct.TypeSelectList  = Typeselect.TypeSelectList(_context);
            ct.BrandSelectList = Brandselect.brandSelectList(_context);
            return(View(ct));
        }
        public async Task <IActionResult> Create(category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["ad_id"] = new SelectList(_context.admintables, "ad_id", "ad_id", category.ad_id);
            //ViewData["em_id"] = new SelectList(_context.employees, "em_id", "em_id", category.em_id);
            //ViewData["t_id"] = new SelectList(_context.types, "t_id", "t_id", category.t_id);
            category.EmSelectList    = Emselect.emSelectList(_context);
            category.TypeSelectList  = Typeselect.TypeSelectList(_context);
            category.BrandSelectList = Brandselect.brandSelectList(_context);
            return(View(category));
        }
        // GET: Category/Edit/5
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var category = await _context.categories.FindAsync(id);

            category.TypeSelectList  = Typeselect.TypeSelectList(_context);
            category.EmSelectList    = Emselect.emSelectList(_context);
            category.BrandSelectList = Brandselect.brandSelectList(_context);
            if (category == null)
            {
                return(NotFound());
            }

            //ViewData["ad_id"] = new SelectList(_context.admintables, "ad_id", "ad_id", category.ad_id);
            //ViewData["em_id"] = new SelectList(_context.employees, "em_id", "em_id", category.em_id);
            //ViewData["t_id"] = new SelectList(_context.types, "t_id", "t_id", category.t_id);
            return(View(category));
        }