Esempio n. 1
0
        public async Task <IActionResult> LabelTranslationRevisions(Guid id)
        {
            var labelTranslationUid = id;

            if (labelTranslationUid.IsEmptyGuid())
            {
                return(RedirectToHome());
            }

            var model = new LabelTranslationRevisionReadListModel();

            if (labelTranslationUid.IsNotEmptyGuid())
            {
                var request  = new LabelTranslationReadRequest(CurrentUser.Id, labelTranslationUid);
                var response = await _labelService.GetTranslation(request);

                if (response.Status.IsNotSuccess)
                {
                    return(NotFound());
                }

                model.LabelTranslationUid  = labelTranslationUid;
                model.LabelTranslationName = response.Item.Name;
                model.SetInputModelValues();
            }

            return(View(model));
        }
Esempio n. 2
0
        public async Task <LabelTranslationReadListResponse> GetTranslation(LabelTranslationReadRequest request)
        {
            var response = new LabelTranslationReadListResponse();

            var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId);

            var labelTranslation = await _labelTranslationRepository.Select(x => x.Uid == request.LabelTranslationUid);

            if (labelTranslation.IsNotExist())
            {
                response.SetInvalid();
                response.ErrorMessages.Add("label_translation_not_found");
                return(response);
            }

            if (labelTranslation.OrganizationId != currentUser.OrganizationId)
            {
                response.SetFailed();
                return(response);
            }

            var language = await _languageRepository.SelectById(labelTranslation.LanguageId);

            if (language.IsNotExist())
            {
                response.SetFailed();
                return(response);
            }

            response.Item   = _labelTranslationFactory.CreateDtoFromEntity(labelTranslation, language);
            response.Status = ResponseStatus.Success;
            return(response);
        }
Esempio n. 3
0
        public async Task <IActionResult> LabelTranslationEdit(Guid id)
        {
            var labelTranslationUid = id;

            if (labelTranslationUid.IsEmptyGuid())
            {
                return(RedirectToAccessDenied());
            }

            var request  = new LabelTranslationReadRequest(CurrentUser.Id, labelTranslationUid);
            var response = await _labelService.GetTranslation(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = LabelMapper.MapLabelTranslationEditModel(response.Item);

            return(View(model));
        }
        public static LabelTranslationReadRequest GetLabelTranslationReadRequest()
        {
            var request = new LabelTranslationReadRequest(CurrentUserId, UidOne);

            return(request);
        }