Exemple #1
0
        public void Delete(int categoryId)
        {
            Categories category = GetById(categoryId);

            _categoryRepository.Delete(category);
            _unitOfWork.Complete();
        }
        public async Task Delete(Guid id)
        {
            var category = await _repository.GetById(id);

            _repository.Delete(category);
            await _repository.SaveChanges();
        }
Exemple #3
0
        //  [Route("DeleteCategory")]
        public async Task <IActionResult> DeleteCategory([FromQuery] int id)
        {
            bool result   = false;
            var  category = CategoriesRepository.Get(id);

            if (category == null)
            {
                // return BadRequest();
                return(NotFound());
            }

            try
            {
                result = await CategoriesRepository.Delete(category);

                if (result == false)
                {
                    return(NotFound());
                }
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
        public HttpResponseMessage Delete(long id)
        {
            _cartRepository.Delete(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
 public IActionResult Delete(int id)
 {
     if (categoriesRepository.Delete(id))
     {
         return(RedirectToAction("Index", "Categories"));
     }
     return(View());
 }
Exemple #6
0
        public IActionResult Delete([FromRoute] int id)
        {
            if (_categoryRepository.Get(id) == null)
            {
                return(NotFound(NotFoundMessage));
            }
            _categoryRepository.Delete(id);

            return(StatusCode(StatusCodes.Status204NoContent));
        }
Exemple #7
0
        public IActionResult Delete(int CategoryId)
        {
            var category = _categoriesRepository.GetCategory(CategoryId);

            if (category == null)
            {
                return(NotFound());
            }
            _categoriesRepository.Delete(CategoryId);
            return(Ok());
        }
Exemple #8
0
        public IResult Delete(string guid)
        {
            if (!Util.IsGuid(guid))
            {
                return(new ValidateResult(null, false, "A identificação fornecida está inválida"));
            }

            var categoriesEntity = _categoriesRepository.Get(guid);

            _categoriesRepository.Delete(categoriesEntity);
            return(new ValidateResult(null, true, "Categoria deletada com sucesso"));
        }
Exemple #9
0
        public IActionResult Delete(int id)
        {
            var dbCat = _categoriesRepository.GetById(id);

            if (dbCat == null)
            {
                return(NotFound());
            }

            _categoriesRepository.Delete(id);
            return(NoContent());
        }
Exemple #10
0
        public void DeleteCategoryById(int id)
        {
            var category = _categoryRepository.GetCategoryById(id);

            //check if category exists in db
            if (category == null)
            {
                throw new ValidationException("This category doesn't exist");
            }

            //delete category
            _categoryRepository.Delete(category);
        }
        public IActionResult DeleteCategory([FromBody] CategoryDto deletedCatgory)
        {
            var categoryToDelete = GetCategory(deletedCatgory.Id);

            if (categoryToDelete == null)
            {
                return(NotFound("Category does not exist in the database"));
            }
            else
            {
                _categoriesRepository.Delete(categoryToDelete);
                return(Ok("Category has been deleted"));
            }
        }
        public ActionResult Delete(int cateId = 0)
        {
            try
            {
                bool status = false;
                if (cateId > 0)
                {
                    status = _repo.Delete(cateId);
                    if (status)
                    {
                        var resp = new
                        {
                            result  = true,
                            message = "Category Deleted Successfully."
                        };
                        return(Json(resp, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        var resp = new
                        {
                            result  = false,
                            message = "Something went wrong will deleting category."
                        };
                        return(Json(resp, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    var resp = new
                    {
                        result  = false,
                        message = "Id must be required."
                    };

                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                var resp = new
                {
                    result  = false,
                    message = ex.Message,
                    AddedId = 0
                };
                return(Json(resp, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #13
0
        public ActionResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            Category category = _categoriesRepository.Get(id);

            if (category == null)
            {
                return(BadRequest());
            }
            _categoriesRepository.Delete(id);
            //Delete(id);
            return(RedirectToAction("Index"));
        }
        public async Task <bool> Delete(int id)
        {
            if (id < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(id), id, "Id cannot be lower than 1.");
            }

            var result = await _categoriesRepository.Delete(id);

            //If result == 1, one entity has been deleted from the database
            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        ///<Summary>
        ///Delete
        ///This method deletes one Categories record from the store
        ///</Summary>
        ///<returns>
        ///void
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public virtual void Delete()
        {
            Doing(this);
            IDAOCategories daoCategories = _iCategoriesRepository.New();

            RegisterDataObject(_iCategoriesRepository, _iCategoriesRepository.BaseData(daoCategories));
            BeginTransaction(_iCategoriesRepository, "deleteBOCategories");
            try
            {
                daoCategories.CategoryID = _categoryID;
                _iCategoriesRepository.Delete(daoCategories);
                CommitTransaction(_iCategoriesRepository);
                Done(this);
            }
            catch (Exception ex)
            {
                Failed(this, ex);
                RollbackTransaction(_iCategoriesRepository, "deleteBOCategories");
                Handle(this, ex);
            }
        }
Exemple #16
0
 public IActionResult Delete(int Id)
 {
     _categoriesRepository.Delete(Id);
     return(RedirectToAction("Index", "Categories"));
 }
Exemple #17
0
 public void Delete(int?id)
 {
     _categoriesRepository.Delete(id);
 }
Exemple #18
0
 public void Delete(Categories category)
 {
     _repCategories.Delete(category);
 }
 public async Task Delete(Guid id)
 {
     await _repository.Delete(id);
 }
 public void Delete(long id)
 {
     _caategoriesRepository.Delete(id);
 }
Exemple #21
0
 public ApiResponseBase Delete(int id)
 {
     _repo.Delete(id);
     return(new ApiResponseBase());
 }
        public async Task <NoContentResult> Delete(Guid id)
        {
            await _categoriesRepository.Delete(id);

            return(NoContent());
        }
 public void Delete(Guid categoryId)
 {
     Logger.Log.Instance.Trace("Удаление категории с id: {0}", categoryId);
     _categoryRepository.Delete(categoryId);
 }
Exemple #24
0
        public virtual ActionResult Delete(DeleteConfirmViewModel model)
        {
            _categoriesRepository.Delete(model.Id);

            return(RedirectToAction(MVC.Admin.Categories.List()));
        }
        public void DeleteCategory(int id)
        {
            _categoriesRepository.Delete(id);

            // log su db dell'operazione
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            await _categoriesRepository.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }