Ejemplo n.º 1
0
 public AdminController(ICategoryRepository categoryRepository, IItemsRepository itemsRepository, ICategoryRepositoryDB categoryRepositoryDB, IItemsRepositoryDB itemsRepositoryDB, IHostingEnvironment env)
 {
     this.categoryRepository   = categoryRepository;
     this.itemsRepository      = itemsRepository;
     this.categoryRepositoryDB = categoryRepositoryDB;
     this.itemsRepositoryDB    = itemsRepositoryDB;
     civm.Categories           = categoryRepository.GetAll().ToList();
     civm.Items        = itemsRepository.GetAll();
     ivm.Categories    = categoryRepository.GetAll().ToList();
     civmDB.Categories = categoryRepositoryDB.GetAll().ToList();
     civmDB.Items      = itemsRepositoryDB.GetAll();
     ivmDB.Categories  = categoryRepositoryDB.GetAll().ToList();
     this.hostingEnv   = env;
 }
        public DropBoxController(ICategoryRepositoryDB categoryRepository, IItemsRepositoryDB itemsRepository, IHostingEnvironment env)
        {
            this.categoryRepository = categoryRepository;
            this.itemsRepository    = itemsRepository;
            //auxCivm.Categories = categoryRepository.GetAll().ToList();
            auxCivm.Categories = categoryRepository.GetAll().ToList();
            auxCivm.Items      = itemsRepository.GetAll().ToList();
            var task = Task.Run((Func <Task>)DropBoxController.Run);

            civm.GroupTags = new List <String>();
            task.Wait();
            if (task.IsCompleted)
            {
                try{
                    foreach (DropBoxCategory c in auxCivm.Categories)
                    {
                        categoryRepository.Save(c);
                    }
                    foreach (DropBoxItems i in auxCivm.Items)
                    {
                        itemsRepository.Save(i);
                    }
                    foreach (DropBoxCategory c in auxCivmRemove.Categories)
                    {
                        categoryRepository.Delete(c);
                    }
                    foreach (DropBoxItems i in auxCivmRemove.Items)
                    {
                        itemsRepository.Delete(i);
                    }
                }catch (Exception e)
                {
                }
                civm.Categories = categoryRepository.GetAll().ToList();
                civm.Items      = itemsRepository.GetAll();
                ivm.Categories  = categoryRepository.GetAll().ToList();
                this.hostingEnv = env;
            }
        }