コード例 #1
0
        public async Task <IActionResult> OrganizationChangeActivation(Guid id)
        {
            var organizationUid = id;

            if (organizationUid.IsEmptyGuid())
            {
                return(Forbid());
            }

            var request  = new OrganizationChangeActivationRequest(CurrentUser.Id, organizationUid);
            var response = await _adminService.OrganizationChangeActivation(request);

            if (response.Status.IsNotSuccess)
            {
                return(Json(new CommonResult {
                    IsOk = false, Messages = response.ErrorMessages
                }));
            }

            return(Json(new CommonResult {
                IsOk = true
            }));
        }
コード例 #2
0
ファイル: AdminService.cs プロジェクト: vandriiv/translation
        public async Task <OrganizationChangeActivationResponse> OrganizationChangeActivation(OrganizationChangeActivationRequest request)
        {
            var response = new OrganizationChangeActivationResponse();

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

            if (!currentUser.IsSuperAdmin)
            {
                response.SetInvalid();
                return(response);
            }

            var organization = await _organizationRepository.Select(x => x.Uid == request.OrganizationUid);

            if (organization.IsNotExist())
            {
                response.SetInvalidBecauseNotFound("organization");
                return(response);
            }

            organization.IsActive = !organization.IsActive;
            var result = await _organizationRepository.Update(request.CurrentUserId, organization);

            if (result)
            {
                _cacheManager.UpsertOrganizationCache(organization, _organizationFactory.MapCurrentOrganization(organization));

                response.Status = ResponseStatus.Success;
                return(response);
            }

            response.SetFailed();
            return(response);
        }
コード例 #3
0
        public static OrganizationChangeActivationRequest GetOrganizationChangeActivationRequest()
        {
            var request = new OrganizationChangeActivationRequest(CurrentUserId, UidOne);

            return(request);
        }