public IDataResult <SubCategory> GetById(int id)
        {
            var result = _subCategoryDal.Get(s => s.SubCategoryId == id);

            if (result == null)
            {
                return(new ErrorDataResult <SubCategory>(Messages.SubCategoryNotFound));
            }
            return(new SuccessDataResult <SubCategory>(result));
        }
示例#2
0
 public IResult DeleteCategory(Category category)
 {
     if (IsEndCategory(category.CategoryId))
     {
         try
         {
             if (!category.IsMainCategory)
             {
                 var subCategory = _subCategoryDal.Get(sc => sc.SubCategoryId == category.CategoryId);
                 _subCategoryDal.Delete(subCategory);
             }
             _categoryDal.Delete(category);
             return(new SuccessResult());
         }
         catch (Exception)
         {
             return(new ErrorResult(Messages.ErrorWhileDeletingEntity));
         }
     }
     return(new ErrorResult(Messages.CategoryCantDeleted));
 }