private void AddBasicInfoCard(string username, GetOrganizationResponse response) { DisplayCard card = new DisplayCard(); StackPanel content = new StackPanel(); card.CardTitle = "About"; content.Margin = new Thickness(16, 0, 16, 16); TextBlock info = new TextBlock(); info.Text = response.Description; info.TextWrapping = TextWrapping.WrapWholeWords; content.Children.Add(info); card.PlaceHolder = content; AboutPanel.Children.Add(card); card = new DisplayCard(); content = new StackPanel(); card.CardTitle = "Contact"; content.Margin = new Thickness(16, 0, 16, 16); TextBlock contactInfo = new TextBlock(); contactInfo.Text = "Phone: " + response.Phone + "\n"; contactInfo.Text += "Email: " + userName + "\n"; contactInfo.Text += "Website: " + response.Website; content.Children.Add(contactInfo); card.PlaceHolder = content; AboutPanel.Children.Add(card); }
public async Task <GetOrganizationResponse> GetOrganization([FromBody] GetOrganizationRequest request) { var response = new GetOrganizationResponse(); try { if (string.IsNullOrWhiteSpace(request.SearchTerm)) { throw new ArgumentException($"{nameof(request)} is null."); } response = await _companiesHouseApi.GetCompaniesApiCompanyList(request.SearchTerm); if (response.ListOfCompanies == null) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; } } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(response); } return(response); }
public OrganizationInfo GetOrganization( ) { GetOrganizationResponse response = CallWebService < IOrgUnitManagementServicev1_0, GetOrganizationRequest, GetOrganizationResponse>( m_service1_0, new GetOrganizationRequest(), (s, q) => s.GetOrganization(q)); return(response.Org); }
public async Task <GetOrganizationResponse> GetCompaniesApiCompanyList(string request) { HttpResponseMessage responseBody = null; var response = new GetOrganizationResponse(); var requestUri = $"{_companiesHouseUrl}{request}"; responseBody = await _client.GetAsync(requestUri); responseBody.EnsureSuccessStatusCode(); var raw = await responseBody.Content.ReadAsStringAsync(); response = JsonConvert.DeserializeObject <GetOrganizationResponse>(raw); return(response); }
public async Task <dto.GetOrganizationResponse> GetAgency(dto.GetOrganizationRequestData requestData) { var signature = !string.IsNullOrEmpty(await _sessionBag.Signature()) ? await _sessionBag.Signature() : await _userSessionService.GetAnonymousSharedSignature(); GetOrganizationResponse response = await _agentClient.GetOrganizationAsync(new GetOrganizationRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, GetOrganizationReqData = new GetOrganizationRequestData { OrganizationCode = requestData.OrganizationCode.ToUpper() } }); return(new dto.GetOrganizationResponse { Organization = Mapper.Map <dto.Organization>(response.Organization) }); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); userName = e.Parameter.ToString(); if (userName == DatabaseHelper.CurrentUser) { // Remove follow button FollowBtn.Visibility = Visibility.Collapsed; UnfollowBtn.Visibility = Visibility.Collapsed; } else { // Remove setting button SettingBtn.Visibility = Visibility.Collapsed; if (await DatabaseHelper.Client.IsFollowingAsync(DatabaseHelper.CurrentUser, userName)) { FollowBtn.Visibility = Visibility.Collapsed; } else { UnfollowBtn.Visibility = Visibility.Collapsed; } } userType = await DatabaseHelper.Client.UserTypeAsync(userName); //Get User following and follwers await followingListViewModel.getFollowingList(userName); await followerListViewModel.getFollowerList(userName); if (userType == 1) { GetIndividualRequest a = new GetIndividualRequest(userName); GetIndividualResponse r = await DatabaseHelper.Client.GetIndividualAsync(a); Firstname.Text = r.FirstName; AdditionalInfo.Text = userName; AddBasicInfoCard(userName, r); // Set profile picture StorageFile file; BitmapImage bmp; if (r.ProfilePic != null) { file = await StorageFile.GetFileFromPathAsync(r.ProfilePic); bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); AvatarBrush.ImageSource = bmp; } // Set cover picture if (r.CoverPic != null) { file = await StorageFile.GetFileFromPathAsync(r.CoverPic); bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); CoverImage.Source = bmp; } } else if (userType == 2) { GetOrganizationRequest a = new GetOrganizationRequest(userName); GetOrganizationResponse r = await DatabaseHelper.Client.GetOrganizationAsync(a); Firstname.Text = r.Name; AdditionalInfo.Text = r.Type; AddBasicInfoCard(userName, r); // Set profile picture StorageFile file; BitmapImage bmp; if (r.ProfilePic != null) { file = await StorageFile.GetFileFromPathAsync(r.ProfilePic); bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); AvatarBrush.ImageSource = bmp; } // Set cover picture if (r.CoverPic != null) { file = await StorageFile.GetFileFromPathAsync(r.CoverPic); bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); CoverImage.Source = bmp; } } }
public async Task <dto.CommitAgencyResponse> AddAgency(dto.CommitAgencyRequest commitAgencyRequest) { if (!string.IsNullOrEmpty(await _sessionBag.AgentName())) { throw new dto.ResponseErrorException(dto.Enumerations.ResponseErrorCode.AlreadyLoggedIn, string.Format("Unable to create agency, Logged in as {0}", await _sessionBag.AgentName())); } var signature = !string.IsNullOrEmpty(await _sessionBag.Signature()) ? await _sessionBag.Signature() : await _userSessionService.GetAnonymousSharedSignature(); // check if organization already exists GetOrganizationResponse getResponse = null; try { getResponse = await _agentClient.GetOrganizationAsync(new GetOrganizationRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, GetOrganizationReqData = new GetOrganizationRequestData { OrganizationCode = commitAgencyRequest.Organization.OrganizationCode.ToUpper() } }); } catch { } if (getResponse != null && getResponse.Organization != null) { throw new dto.ResponseErrorException(dto.Enumerations.ResponseErrorCode.AgencyAlreadyExists, string.Format("Agency {0} already exists: {1}.", getResponse.Organization.OrganizationCode, getResponse.Organization.OrganizationName)); } // check if agent already exists (by login name) dto.FindAgentsResponse findAgentResponse = null; try { findAgentResponse = await _agentService.FindAgent(new dto.FindAgentRequestData { AgentName = new dto.SearchString { SearchType = dto.Enumerations.SearchType.ExactMatch, Value = commitAgencyRequest.CommitAgentRequestData.Agent.LoginName.ToLower() }, DomainCode = _newskiesSettings.AgentDomain }); } catch { } if (findAgentResponse != null && findAgentResponse.FindAgentResponseData != null && findAgentResponse.FindAgentResponseData.FindAgentList != null && findAgentResponse.FindAgentResponseData.FindAgentList.Length != 0) { throw new dto.ResponseErrorException(dto.Enumerations.ResponseErrorCode.AgentAlreadyExists, string.Format("Agent login name'{0}' already exists. ", commitAgencyRequest.CommitAgentRequestData.Agent.LoginName.ToLower())); } // create organization var commitOrganizationResp = await _agentClient.CommitOrganizationAsync(new CommitOrganizationRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, Organization = Mapper.Map <Organization>(commitAgencyRequest.Organization) }); // create master agent var mappedAgentRequest = Mapper.Map <CommitAgentRequestData>(commitAgencyRequest.CommitAgentRequestData); mappedAgentRequest.Agent.AgentIdentifier.OrganizationCode = commitOrganizationResp.Organization.OrganizationCode; mappedAgentRequest.Agent.AuthenticationType = AuthenticationType.Password; var commitAgentResponse = await _agentClient.CommitAgentAsync(new CommitAgentRequest { ContractVersion = _navApiContractVer, MessageContractVersion = _navMsgContractVer, Signature = signature, EnableExceptionStackTrace = false, CommitAgentReqData = mappedAgentRequest }); return(new dto.CommitAgencyResponse { Organization = Mapper.Map <dto.Organization>(commitOrganizationResp.Organization), CommitAgentResponseData = Mapper.Map <dto.CommitAgentResponseData>(commitAgentResponse.CommitAgentResData) }); }
/// <summary> /// Processes a get request for an organization. /// </summary> /// <param name="context">the http context.</param> /// <param name="accountId">the logged in user.</param> /// <param name="name">the name of the organization.</param> private void ProcessGetOrganization(HttpContext context, EmailAddress accountId, DomainLabel name) { OrganizationInfo orgInfo = this.store.GetOrganization(name); if (orgInfo == null) { context.Response.StatusCode = (int)System.Net.HttpStatusCode.NotFound; return; } GetOrganizationResponse response = new GetOrganizationResponse { Name = orgInfo.Name.ToString(), FriendlyName = orgInfo.FriendlyName, CreatedBy = orgInfo.CreatedBy.ToString(), CreatedTime = orgInfo.CreatedTime, LastModifiedBy = orgInfo.LastModifiedBy.ToString(), LastModifiedTime = orgInfo.LastModifiedTime }; context.Response.ContentType = "application/json"; GetOrganizationResponseSerializer.WriteObject(context.Response.OutputStream, response); context.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; }