Пример #1
0
        public async Task <ActionResult> DeleteSubCategory(Guid id, SubCategoryDetailsViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(SubCategories), new { id = request.CategoryId }));
            }
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(SubCategories), new { id = request.CategoryId }));
            }
            try
            {
                var result = await _subCategoryService.Delete(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(RedirectToAction(nameof(SubCategories), new { id = request.CategoryId }));
                }
                Alert($"Sub Category Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(SubCategories), new { id = request.CategoryId }));
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(SubCategories), new { id = request.CategoryId }));
            }
        }
 public async Task <IActionResult> Delete(int id)
 {
     if (await _subCategoryService.Delete(id))
     {
         return(NoContent());
     }
     throw new Exception("Error deleting the subCategory");
 }
Пример #3
0
        public IActionResult Delete(string id)
        {
            var entity = _manager.GetByPrimaryKey(id);

            if (entity == null)
            {
                return(NoResult());
            }
            _manager.Delete(entity);
            return(ResponseJson(entity));
        }
 public ActionResult DeleteSubCategory(int subcategoryId)
 {
     try
     {
         _subCategoryService.Delete(subcategoryId);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Пример #5
0
        public async Task <ActionResult> Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            var result = await _service.Delete(id);

            if (!result)
            {
                return(BadRequest());
            }
            return(Ok(new { Success = result }));
        }
        public async Task <IActionResult> Delete(Guid id, SubCategoryDto model)
        {
            var errorReturnModel = model;

            if (ModelState.IsValid & id == model.Id)
            {
                var deleteService = await _subCategoryService.Delete(id);

                if (deleteService.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, deleteService.ErrorMessage);
            }

            return(View(errorReturnModel));
        }
Пример #7
0
 public IActionResult Delete(Guid id)
 {
     _service.Delete(id);
     return(NoContent());
 }
Пример #8
0
        public async Task <IActionResult> Delete(Guid id)
        {
            await _service.Delete(id);

            return(NoContent());
        }
Пример #9
0
 public async Task Delete(int categoryId, int id)
 {
     await service.Delete(categoryId, id);
 }
 // DELETE: api/SubCategories/5
 public void Delete(int id)
 {
     _subCategoryService.Delete(id);
 }