Beispiel #1
0
        public async Task <LabelTranslationDeleteResponse> DeleteTranslation(LabelTranslationDeleteRequest request)
        {
            var response = new LabelTranslationDeleteResponse();

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

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

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

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

            if (await _organizationRepository.Any(x => x.Id == labelTranslation.OrganizationId && !x.IsActive))
            {
                response.SetInvalid();
                response.ErrorMessages.Add("organization_not_active");
                return(response);
            }

            if (await _projectRepository.Any(x => x.Id == labelTranslation.ProjectId && !x.IsActive))
            {
                response.SetInvalid();
                response.ErrorMessages.Add("project_not_active");
                return(response);
            }

            if (await _labelRepository.Any(x => x.Id == labelTranslation.LabelId && !x.IsActive))
            {
                response.SetInvalid();
                response.ErrorMessages.Add("label");
                return(response);
            }

            var uowResult = await _labelUnitOfWork.DoDeleteTranslationWork(request.CurrentUserId, labelTranslation);

            if (uowResult)
            {
                response.Status = ResponseStatus.Success;
                return(response);
            }

            response.SetFailed();
            return(response);
        }
        public static LabelTranslationDeleteRequest GetLabelTranslationDeleteRequest()
        {
            var request = new LabelTranslationDeleteRequest(CurrentUserId, UidOne, UidOne);

            return(request);
        }