Пример #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var team = await db.Teams.FindAsync(id);

            //  Captura la ruta del archivo
            var imagePath = Server.MapPath(Url.Content(team.ImagePath));

            db.Teams.Remove(team);
            response = await DbHelper.SaveChangeDB(db);

            if (response.IsSuccess)
            {
                //  Elimina el archivo
                if (FilesHelper.ExistFile(imagePath))
                {
                    var response = FilesHelper.DeleteFile(imagePath);
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError(string.Empty, response.Message);
            }
            return(View(team));
        }
Пример #2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var user = await db.Users.FindAsync(id);

            //  CHEJ - Captura la ruta de la imagen
            var imagePath = Server.MapPath(Url.Content(user.ImagePath));

            db.Users.Remove(user);
            response = await DbHelper.SaveChangeDB(db);

            if (response.IsSuccess)
            {
                //  CHEJ - Elimina el archivo fisico
                if (FilesHelper.ExistFile(imagePath))
                {
                    response = FilesHelper.DeleteFile(imagePath);
                }
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError(string.Empty, response.Message);
            return(View(user));
        }