public async Task <IActionResult> DeleteConfirmed(int id) { var recipe = await _recipeRepository.GetRecipeAsync(id); String wwwroot = @"C:\Users\Seba\Desktop\PSSC_V4\MVC_CookBook_PSSC\MVC_CookBook_PSSC\wwwroot\"; try { System.IO.DirectoryInfo di = new DirectoryInfo(wwwroot + @"\images\" + recipe.strCreatorUsername + @"\" + recipe.strRecipeName); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } Directory.Delete(wwwroot + @"\images\" + recipe.strCreatorUsername + @"\" + recipe.strRecipeName); } catch (Exception exp) { Console.WriteLine(exp.ToString()); } await _recipeRepository.DeleteAsync(recipe); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(string id) { return((await _recipeRepository.DeleteAsync(id)).ToActionResult()); }
/// <inheritdoc /> public async Task DeleteAsync(long id) { await _repo.DeleteAsync(id); await _repo.SaveAsync(); }
public async Task <IActionResult> Delete(int id) { await _recipeRepo.DeleteAsync(HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.Name).Value, id); return(Ok()); }