コード例 #1
0
        public async Task <IActionResult> DeleteVideo(int id)
        {
            var model = await GenericGetDataClass <VideoModel> .GetAllData($"api/video/{id}");

            var response = await GenericGetDataClass <VideoModel> .DeleteData($"api/deletevideo/{id}");

            if (response)
            {
                var webRootPath = _hostingEnvironment.WebRootPath;

                // Получаем путь из модели и удаляем первый символ (/)
                var replacedPath = model.Path.Substring(1);
                var path         = Path.Combine(webRootPath, replacedPath);

                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }

                TempData["SM"] = "Видео успешно удалено!";
                return(RedirectToAction(nameof(ShowAllVideo)));
            }
            else
            {
                //TODO: вывод ошибок
                return(RedirectToAction(nameof(ShowAllVideo)));
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddVideo()
        {
            var categories = await GenericGetDataClass <List <CategoryModel> > .GetAllData("api/categories");

            ViewData["CategoryList"] = categories.ToList();
            return(View());
        }
コード例 #3
0
        public async Task <IActionResult> EditCategory(int id)
        {
            var category = await GenericGetDataClass <CategoryModel> .GetAllData($"api/category/{id}");

            return(View(category));
        }
コード例 #4
0
        public async Task <IActionResult> EditUser(int id)
        {
            var user = await GenericGetDataClass <EmployeeModel> .GetAllData($"api/user/{id}");

            return(View(user));
        }
コード例 #5
0
        public async Task <IActionResult> ShowAllCategories()
        {
            var categories = await GenericGetDataClass <List <CategoryModel> > .GetAllData("api/categories");

            return(View(categories));
        }
コード例 #6
0
        public async Task <IActionResult> ShowAllUsers()
        {
            var users = await GenericGetDataClass <IEnumerable <EmployeeModel> > .GetAllData("api/users");

            return(View(users));
        }
コード例 #7
0
        public async Task <IActionResult> EditVideo(int id)
        {
            var video = await GenericGetDataClass <VideoModel> .GetAllData($"api/video/{id}");

            return(View(video));
        }
コード例 #8
0
        public async Task <IActionResult> ShowAllVideo()
        {
            var videos = await GenericGetDataClass <List <VideoModel> > .GetAllData("api/videos");

            return(View(videos));
        }