Ejemplo n.º 1
0
        public async Task <IResultModel> Query(DictionaryQueryModel model)
        {
            var result = new QueryResultModel <DictionaryEntity>
            {
                Rows  = await _dictionaryRepository.Query(model),
                Total = model.TotalCount
            };

            return(ResultModel.Success(result));
        }
Ejemplo n.º 2
0
        public async Task <IList <DictionaryEntity> > Query(DictionaryQueryModel model)
        {
            var conditions = await _filter.GetConditions <DictionaryEntity, DictionaryQueryModel>(model);

            var query = _dbContext.Db.Queryable <DictionaryEntity>()
                        .LeftJoin <DictionaryGroupEntity>((x, y) => x.GroupCode == y.Code && y.IsDel == false)
                        .Select((x, y) => new DictionaryEntity()
            {
                Id        = x.Id.SelectAll(),
                GroupName = y.Name
            })
                        .MergeTable()
                        .Where(conditions)
                        .OrderBy(model.OrderFileds);

            RefAsync <int> totalCount = 0;
            var            data       = await query.ToPageListAsync(model.PageIndex, model.PageSize, totalCount);

            model.TotalCount = totalCount;

            return(data);
        }
Ejemplo n.º 3
0
 public Task <IResultModel> Query([FromQuery] DictionaryQueryModel model)
 {
     return(_service.Query(model));
 }
Ejemplo n.º 4
0
        public WordViewModel(DictionaryQueryModel Querymodel, params object[] args)
        {
            var model = Querymodel.Result;

            IsLoadingVisibility = Visibility.Collapsed;
            switch (Querymodel.ResultStatus)
            {
            case ResultStatus.Succuss:
                Word = model.Word;
                foreach (var item in model.Pronounciations)
                {
                    if (item.PhoneticSymbol != string.Empty || item.SoundUri != string.Empty)
                    {
                        Pronunciations.Add(new PronounciationViewModel(item));
                    }
                }
                if (model.InflectionWords.Count > 0)
                {
                    foreach (var item in model.InflectionWords)
                    {
                        if (item.Words.Count != 0)
                        {
                            InflectionWords.Add(new InflectionWordViewModel(item));
                        }
                    }
                }
                else
                {
                    InflectionWordsVisibility = Visibility.Collapsed;
                }
                if (model.Definitions.Count > 0)
                {
                    foreach (var item in model.Definitions)
                    {
                        Definitions.Add(new DefinitionViewModel(item));
                    }
                }
                else
                {
                    DefinitionsVisibility = Visibility.Collapsed;
                }
                if (model.SampleSentences.Count > 0)
                {
                    foreach (var item in model.SampleSentences)
                    {
                        SampleSentences.Add(new SampleSentenceViewModel(item));
                    }
                }
                else
                {
                    SampleSentencesVisibility = Visibility.Collapsed;
                }
                break;

            case ResultStatus.WordCantFind:
                FailedVisibility = Visibility.Visible;
                NoticeText       = "找不到单词";
                break;

            case ResultStatus.FailedWithUnknownReason:
                FailedVisibility = Visibility.Visible;
                NoticeText       = "未知错误";
                break;

            case ResultStatus.InputSentence:
                FailedVisibility = Visibility.Visible;
                NoticeText       = "您输入的可能是句子,目前仅支持翻译单词或短词组";
                break;

            case ResultStatus.WrongLanguage:
                FailedVisibility = Visibility.Visible;
                NoticeText       = string.Format("您输入的语言可能是 {0}, 请切换词典", LanguageHelper.GetLanguageName((Language)args[0]));
                break;
            }
        }