public Result Edit(int id, QuizCategoryEditAdminDto dto)
        {
            dto.Id = id;
            var result = _validatorEdit.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            if (dto.Id > 0)
            {
                var entity = _quizCategoryRepository.AsNoTracking.FirstOrDefault(w => w.Id == dto.Id);

                if (entity == null)
                {
                    return(result.SetError("There are error for update record. Please try again with refresh."));
                }

                Mapper.Map <QuizCategory>(dto, entity);
                _quizCategoryRepository.Update(entity);

                _unitOfWork.Commit();

                result.Id = entity.Id;
            }
            else
            {
                var entity = Mapper.Map <QuizCategory>(dto);
                _quizCategoryRepository.Insert(entity);
                _unitOfWork.Commit();

                result.Id = entity.Id;
            }

            QuizCategoryCacheManager.ClearCache();

            return(result.SetSuccess(Messages.RecordSaved));
        }
        public Result Create(QuizCategoryCreateAdminDto dto)
        {
            var result = _validatorCreate.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            var entity = Mapper.Map <QuizCategory>(dto);

            entity.IsActive = true;
            entity.Slug     = _quizCategoryRepository.GenerateUniqueSlug(entity.Name);
            _quizCategoryRepository.Insert(entity);

            _unitOfWork.Commit();

            QuizCategoryCacheManager.ClearCache();

            result.Id = entity.Id;

            return(result.SetSuccess(Messages.RecordSaved));
        }