Ejemplo n.º 1
0
        public async Task <TranslationDTO> SetStringTranslation(int identifier, TranslationDTO translation)
        {
            var target = await _complexStringRepository.GetAsync(identifier);

            if (target != null)
            {
                var currentTranslation = _mapper.Map <Translation>(translation);
                currentTranslation.Id = Guid.NewGuid();
                currentTranslation.History.Add(new AdditionalTranslation
                {
                    Id               = Guid.NewGuid(),
                    CreatedOn        = DateTime.Now,
                    TranslationValue = translation.TranslationValue,
                    UserId           = translation.UserId
                });
                //currentTranslation.AssignedTranslatorId = translation.AssignedTranslatorId;

                var targetTranslationDublicateIndex = target.Translations.FindIndex(t => t.LanguageId == translation.LanguageId);
                if (targetTranslationDublicateIndex >= 0)
                {
                    target.Translations[targetTranslationDublicateIndex] = currentTranslation;
                }
                else
                {
                    target.Translations.Add(currentTranslation);
                }
                var result = await _complexStringRepository.Update(target);


                var targetProjectId = target.ProjectId;
                await _signalRWorkspaceService.LanguageTranslationCommitted($"{Group.project}{targetProjectId}", translation.LanguageId);

                await _signalRWorkspaceService.ChangedTranslation($"{Group.complexString}{identifier}", identifier);

                return((_mapper.Map <ComplexStringDTO>(result)).Translations.LastOrDefault());
                //var translationNew = (_mapper.Map<ComplexStringDTO>(result)).Translations.LastOrDefault();
                //translationNew.AssignedTranslatorAvatarUrl = translation.AssignedTranslatorAvatarUrl;
                //translationNew.AssignedTranslatorName = translation.AssignedTranslatorName;
                //return translationNew;
            }
            return(null);
        }
Ejemplo n.º 2
0
        public async Task <TranslationDTO> UnConfirmTranslation(int identifier, TranslationDTO translation)
        {
            var target = await _complexStringRepository.GetAsync(identifier);

            if (target != null)
            {
                var translationsList   = _mapper.Map <List <Translation> >(target.Translations);
                var currentTranslation = translationsList.FirstOrDefault(x => x.Id == translation.Id);
                currentTranslation.IsConfirmed = false;

                target.Translations = translationsList;

                var result = await _complexStringRepository.Update(_mapper.Map <ComplexString>(target));

                var targetProjectId = target.ProjectId;

                await _signalRWorkspaceService.ChangedTranslation($"{Group.complexString}{identifier}", identifier);

                return((_mapper.Map <ComplexStringDTO>(result)).Translations.FirstOrDefault(x => x.Id == translation.Id));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public async Task <TranslationDTO> EditStringTranslation(int identifier, TranslationDTO translation)
        {
            var target = await _complexStringRepository.GetAsync(identifier);

            if (target != null)
            {
                var translationsList   = _mapper.Map <List <Translation> >(target.Translations);
                var currentTranslation = translationsList.FirstOrDefault(x => x.Id == translation.Id);
                currentTranslation.History.Add(new AdditionalTranslation
                {
                    Id               = Guid.NewGuid(),
                    CreatedOn        = DateTime.Now,
                    TranslationValue = translation.TranslationValue,
                    UserId           = translation.UserId
                });
                currentTranslation.TranslationValue     = translation.TranslationValue;
                currentTranslation.UserId               = translation.UserId;
                currentTranslation.CreatedOn            = DateTime.Now;
                currentTranslation.AssignedTranslatorId = translation.AssignedTranslatorId;

                target.Translations = translationsList;

                var result = await _complexStringRepository.Update(target);

                var targetProjectId = target.ProjectId;
                await _signalRWorkspaceService.LanguageTranslationCommitted($"{Group.project}{targetProjectId}", translation.LanguageId);

                await _signalRWorkspaceService.ChangedTranslation($"{Group.complexString}{identifier}", identifier);

                //var translationNew = (_mapper.Map<ComplexStringDTO>(result)).Translations.FirstOrDefault(x => x.Id == translation.Id);
                //translationNew.AssignedTranslatorAvatarUrl = translation.AssignedTranslatorAvatarUrl;
                //translationNew.AssignedTranslatorName = translation.AssignedTranslatorName;
                //return translationNew;
                return((_mapper.Map <ComplexStringDTO>(result)).Translations.FirstOrDefault(x => x.Id == translation.Id));
            }
            return(null);
        }