public async Task <IActionResult> UpdateCat(CatAddModel model)
        {
            Category category = _context.Categories.Include(x => x.ChildCategories).FirstOrDefault(x => x.CategoryId == Guid.Parse(model.Id));

            category.Name = model.Name;
            List <ChildCategory> Childs = new List <ChildCategory>();

            foreach (var x in model.ChildCategoryId)
            {
                ChildCategory Category = await _context.ChildCategories.FindAsync(Guid.Parse(x));

                Childs.Add(Category);
            }

            category.ChildCategories = Childs;
            _context.Categories.Update(category);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Main", "Admin"));
        }
        public async Task <IActionResult> CreateCategory(CatAddModel model)
        {
            Guid     Id       = new Guid();
            Category category = new Category()
            {
                CategoryId = Id, Name = model.Name
            };
            List <ChildCategory> Childs = new List <ChildCategory>();

            foreach (var x in model.ChildCategoryId)
            {
                ChildCategory Category = await _context.ChildCategories.FindAsync(Guid.Parse(x));

                Category.CategoryId = Id;
                Childs.Add(Category);
            }
            category.ChildCategories = Childs;
            await _context.Categories.AddAsync(category);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Main", "Admin"));
        }