public async Task <IActionResult> DeleteMeal(int id) { if (!ModelState.IsValid) { return(BadRequest()); } var userId = userService.GetCurrentUserId(HttpContext); var findMealsResponse = await mealService.GetUserMeals(userId).ConfigureAwait(false); if (!findMealsResponse.IsSuccess) { return(BadRequest(findMealsResponse.Message)); } var meal = findMealsResponse.MealsFound.Where(m => m.ID == id).SingleOrDefault(); if (meal == null) { return(BadRequest("Meal doesn't exist")); } var response = await mealService.Delete(meal).ConfigureAwait(false); if (!response.IsSuccess) { return(BadRequest(response.Message)); } return(NoContent()); }
public IActionResult Delete(int id) { var result = mealManager.Delete(id); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Delete(int id) { var meal = _mealService.GetById(id); if (System.IO.File.Exists(Server.MapPath(meal.Image))) { System.IO.File.Delete(Server.MapPath(meal.Image)); } _mealService.Delete(meal); return(RedirectToAction("Index")); }
public IActionResult Delete([FromBody] Meal model) { _mealService.Delete(model); return(Ok()); }
public IActionResult Delete([FromRoute] int id) { _mealService.Delete(id); return(Ok()); }