public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } try { var result = await _categoryServices.DeleteAsync(id); if (!result) { return(BadRequest()); } } catch (NullReferenceException) { return(NotFound()); } catch (Exception) { return(BadRequest()); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> DeleteAsync(int id) { var result = await _categoryServices.DeleteAsync(id); if (!result.Success) { return(BadRequest(result.Message)); } var categoryResource = _mapper.Map <Category, CategoryResource>(result.Category); return(Ok(categoryResource)); }
public async Task <IActionResult> Delete(int?id) { if (id == null) { Log.Warning("Id Category Equal Null"); return(BadRequest()); } var category = await _categoryServices.DeleteAsync(id.Value); if (category) { TempData["Success"] = _categoryLocalizer.GetLocalizedHtmlString("msg_DeleteSuccess").ToString(); return(RedirectToAction("Index")); } TempData["Error"] = _categoryLocalizer.GetLocalizedHtmlString("msg_DeleteError").ToString(); Log.Error("Delete Category Error"); return(RedirectToAction("Index")); }
public async Task <IActionResult> DeleteConfirmed(int id) { await _categoryServices.DeleteAsync(id); return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult> Delete(int id) { await _category.DeleteAsync(id); return(RedirectToAction("Index")); }