Exemplo n.º 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)));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DeleteUser(int id)
        {
            var response = await GenericGetDataClass <EmployeeModel> .DeleteData($"api/deleteuser/{id}");

            if (response)
            {
                TempData["SM"] = "Пользователь успешно удален!";
                return(RedirectToAction(nameof(ShowAllUsers)));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> DeleteCategory(int id)
        {
            var response = await GenericGetDataClass <CategoryModel> .DeleteData($"api/deletecategory/{id}");

            if (response)
            {
                TempData["SM"] = "Категория успешно удалена!";
                return(RedirectToAction(nameof(ShowAllCategories)));
            }
            else
            {
                return(View());
            }
        }