public Result Create(EmailTemplateCreateAdminDto dto)
        {
            var result = _validatorCreate.ValidateResult(dto);

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

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

            _emailTemplateRepository.Insert(entity);
            _unitOfWork.Commit();

            EmailTemplateCacheManager.ClearCache();

            result.Id = entity.Id;

            return(result.SetSuccess(Messages.RecordSaved));
        }
        public Result Edit(int id, EmailTemplateEditAdminDto dto)
        {
            dto.Id = id;
            var result = _validatorEdit.ValidateResult(dto);

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

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

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

                Mapper.Map <EmailTemplate>(dto, entity);
                _emailTemplateRepository.Update(entity);
                _unitOfWork.Commit();

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

                result.Id = entity.Id;
            }

            EmailTemplateCacheManager.ClearCache();

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