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 })); }
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); }
public static OrganizationChangeActivationRequest GetOrganizationChangeActivationRequest() { var request = new OrganizationChangeActivationRequest(CurrentUserId, UidOne); return(request); }