Ejemplo n.º 1
0
        public ActionResult Translate(TranslateDto model)
        {
            this._logger.Info("HomeController/Translate");
            this._abortTaskService.Translate(model);

            return(RedirectToAction("Index", "Home", new { }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostTranslation(string app, [FromBody] TranslateDto request)
        {
            var result = await translator.TranslateAsync(request.Text, request.TargetLanguage, request.SourceLanguage, HttpContext.RequestAborted);

            var response = TranslationDto.FromDomain(result);

            return(Ok(response));
        }
Ejemplo n.º 3
0
        public void Translate(TranslateDto model)
        {
            //AbortTask task = this._validateTranslateDomianService.Validate(model.FromId, model.ToId, model.TaskId);
            //task.Translate(model.FromId, model.ToId);
            AbortTask task = this._abortTaskRepository.Find(model.TaskId);

            if (task == null)
            {
                throw new Exception("指定的任务不存在!");
            }
            Account from = this._accountRepository.Find(model.FromId);
            Account to   = this._accountRepository.Find(model.ToId);

            task.Translate(from, to);
            // 这个实体中一定要有主键
            this._abortTaskRepository.Update(task, t => t.From, t => t.To);

            this._unitOfWork.Commit();
        }