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)));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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"));
        }
Beispiel #4
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _categoryServices.DeleteAsync(id);

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #5
0
        public async Task <ActionResult> Delete(int id)
        {
            await _category.DeleteAsync(id);

            return(RedirectToAction("Index"));
        }