/// <summary> /// Осуществляет выборку персоны из бд вместе с дочерними коллекциями (eager loading) асинхронно /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetPersonResponse> GetItemAsync(GetPersonRequest request) { if (request == null) { throw new ArgumentNullException("Person model GetPersonRequest is invalid"); } var resp = new GetPersonResponse(); try { resp.Person = mapper.Map <PersonContract>( await factory.CreateUnitOfWork().Persons.GetItemAsync(request.Id) ); } catch (Exception e) { resp.AddMessage(new Contracts.Message(e.Message)); } return(resp); }
public async Task <GetPersonResponse> GetPerson(GetPersonRequest request) { GetPersonResponse getPersonResponse = new GetPersonResponse(); try { getPersonResponse = (await App.Database.GetPerson(new GetPersonRequest { Username = request.Username })); } catch (Exception e) { await _dialogService.ShowMessage($"The server returned an error: {e.Message}", "Error", "OK", null); } return(getPersonResponse); }
public async Task <GetPersonResponse> GetPersonAsync(string personGroupId, string personId) { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Add(_ocpApimSubscriptionKey, _subscriptionKey); string uri = $"{_uriBase}/persongroups/{personGroupId}/persons/{personId}"; HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); GetPersonResponse result = JsonConvert.DeserializeObject <GetPersonResponse>(content); return(result); } throw CreateHttpException(await response.Content.ReadAsStringAsync()); } }
public void ShowCustomerData(GetPersonResponse r) { Device.BeginInvokeOnMainThread(() => { ClearForm(); customerList = r.PersonAndAddress; customersOC.Clear(); foreach (PersonAndAddressDTO p in customerList) { customersOC.Add(p); } CustomerListView.ItemsSource = customersOC; }); }
private bool MatchingPersonFound(ASAMemberModel member, GetPersonResponse getPersonResponse) { _log.Debug("START MatchingPersonFound"); bool bMatched = false; if (getPersonResponse != null && getPersonResponse.PersonCanonicalList != null && getPersonResponse.PersonCanonicalList.Length > 0 ) { _log.Debug("The getPersonResponse returned is constructed correctly."); foreach (PersonCanonicalType p in getPersonResponse.PersonCanonicalList) { //compare this person's LastName and DOB with those on the member object. if (p.PersonTier2 != null && p.PersonTier2.PersonInfoType != null) { _log.Debug("PersonInfoType was found"); if (member.DOB != null && p.PersonTier2.PersonInfoType.DateOfBirth != null) //can only compare these if they're not null { _log.Debug(string.Format("ODS: First={0}, Last={1}, DOB={2}", !string.IsNullOrEmpty(p.PersonTier2.PersonInfoType.FirstName)?p.PersonTier2.PersonInfoType.FirstName.ToUpper():"", !string.IsNullOrEmpty(p.PersonTier2.PersonInfoType.LastName)?p.PersonTier2.PersonInfoType.LastName.ToUpper():"", p.PersonTier2.PersonInfoType.DateOfBirth.ToString()) ); _log.Debug(string.Format("MRM: First={0}, Last={1}, DOB={2}", !string.IsNullOrEmpty(member.FirstName) ? member.FirstName.ToUpper() : "", !string.IsNullOrEmpty(member.LastName) ? member.LastName.ToUpper() : "", member.DOB.ToString()) ); if (string.Compare(p.PersonTier2.PersonInfoType.LastName.ToUpper(), member.LastName.ToUpper()) == 0 && string.Compare(p.PersonTier2.PersonInfoType.FirstName.ToUpper(), member.FirstName.ToUpper()) == 0 && DateTime.Compare((DateTime)p.PersonTier2.PersonInfoType.DateOfBirth, (DateTime)member.DOB) == 0) //found match { bMatched = true; break; } } } } } _log.Debug("END MatchingPersonFound"); return(bMatched); }
public SelfReportedLoanListModel GetLoans(string ssn, ASAMemberModel member) { _log.Debug("START GetLoans"); SelfReportedLoanListModel srlList = null; if (member != null) //TODO: Mehdi && member.Source != SourceType.SELF_REGISTERED_NO_MATCH) { ////the following hardcoded values are only for when you're being lazy and dont want to find a person to test GetPerson, MatchingPersonFound, and GetLoan //member.FirstName = "Dwayne"; //member.LastName = "Baker"; //member.DOB = new DateTime(1976,1,30); //member.IndividualId = "967A954B-AB09-4713-9B6E-2067B8C3F992"; //ssn = "803450294"; // See if person is in ODS for this SSN GetPersonRequest getPersonRequest = TranslateLoanModel.MapSSNToGetPersonRequest(ssn); GetPersonResponse getPersonResponse = _proxyPerson.GetPerson(getPersonRequest); // if person was retrieved, do they match the FName, LName, and DOB from context? bool personMatchFound = MatchingPersonFound(member, getPersonResponse); if (personMatchFound) { _log.Debug("personMatchFound."); // save this person's SSN from ODS to Avectra bool ssnSaved = SaveSSNToAvectra(member, ssn); if (ssnSaved) { // go get this person's Loans from ODS GetLoanRequest getRequest = TranslateLoanModel.MapSsnToGetRequest(ssn, Config.LoanServiceMaxEntities); GetLoanResponse response = _proxyLoan.GetLoan(getRequest); srlList = TranslateLoanModel.MapGetResponseToModel(response, member.IndividualId); } } else { _log.Debug("NOT personMatchFound."); } } _log.Debug("END GetLoans"); return(srlList); }
public async Task Returns_person_when_person_exist() { var personId = Guid.NewGuid(); var dateCreated = DateTime.UtcNow; _handler .Get(Arg.Is <GetPersonRequest>(request => request.PersonId.Equals(personId))) .Returns(GetPersonResponse.Success(new PersonModel(personId, "any name", dateCreated))); var result = await _controller.Get(personId); var response = result as OkObjectResult; var model = (GetPersonsViewModel)response.Value; model.Id.ShouldBe(personId); model.Name.ShouldBe("any name"); model.DateCreated.ShouldBe(dateCreated); }
private void Button_Click(object sender, RoutedEventArgs e) { //run filter against person table GetPersonRequest request = new GetPersonRequest(); request.FirstName = Name.Text; //request.LastName = LastNameTextBox.Text; request.PhonePrimary = Phone.Text; request.Email = Email.Text; GetPersonResponse response = mainWnd.GetCustomers(request); ObservableCollection <PersonDTO> list1 = new ObservableCollection <PersonDTO>(); foreach (PersonAndAddressDTO p in response.PersonAndAddress) { list1.Add(p.Person); } PersonFilterListView.ItemsSource = list1; }
public GetPersonResponse GetCustomers(GetPersonRequest request) { GetPersonResponse persons = new GetPersonResponse(); string jsonData = String.Empty; try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(((App)App.Current).LAN_Address); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("EO-Header", User + " : " + Pwd); jsonData = JsonConvert.SerializeObject(request); StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage httpResponse = client.PostAsync("api/Login/GetPerson", content).Result; if (httpResponse.IsSuccessStatusCode) { Stream streamData = httpResponse.Content.ReadAsStreamAsync().Result; StreamReader strReader = new StreamReader(streamData); string strData = strReader.ReadToEnd(); strReader.Close(); persons = JsonConvert.DeserializeObject <GetPersonResponse>(strData); } else { MessageBox.Show("There was an error retreiving customers"); } } catch (Exception ex) { Exception ex2 = new Exception("Admin - GetCustomers", ex); ((App)App.Current).LogError(ex2.Message, jsonData); } return(persons); }
public GetPersonResponse GetPerson(GetPersonRequest getRequest) { _log.Debug("InvokePersonManagementService.GetPerson() starting ..."); PersonManagementClient client = null; GetPersonResponse response = null; try { client = new PersonManagementClient(); _log.Debug("client created successfully"); IPersonManagement pm = (IPersonManagement)client; response = pm.GetPerson(getRequest); _log.Debug("response was received from ODS PersonManagement service"); } catch (TimeoutException timeout) { _log.Error("InvokePersonManagementService.GetPerson() Timeout Exception:" + timeout.Message); ProxyHelper.HandleServiceException(client); } catch (CommunicationException comm) { _log.Error("InvokePersonManagementService.GetPerson() Communication Exception:" + comm.Message); ProxyHelper.HandleServiceException(client); } catch (Exception e) { _log.Error("InvokePersonManagementService.GetPerson() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Debug("InvokePersonManagementService.GetPerson() ending ..."); return(response); }
public async Task <IActionResult> GetById(Guid id, CancellationToken cancellationToken) { if (id == Guid.Empty) { return(BadRequest("Invalid Person Id")); } var person = await _peopleCosmosStore.FindAsync(id.ToString(), cancellationToken : cancellationToken); if (person == null) { return(NotFound()); } var response = new GetPersonResponse { Identifier = person.Id, Name = person.Name, }; return(Ok(response)); }
protected void CreateUser_Click(object sender, EventArgs e) { if (checkMail(Email.Text)) { GetPersonRequest rqt = new GetPersonRequest() { Username = Email.Text }; using (Service1Client client = new Service1Client()) { GetPersonResponse rsp = client.GetPerson(rqt); //Check mail is not already used if (rsp.Errored) { //Check password and Hash if (check_password(Password.Text) && Password.Text == ConfirmPassword.Text) { // Add to database Person user = new Person() { Username = Email.Text, Company = Company.Text, FirstName = FirstName.Text, LastName = LastName.Text, IsAdmin = false, Password = Password.Text }; RegisterUserResponse response = client.RegisterUser(new RegisterUserRequest() { User = user }); if (!response.Errored) { ErrorMessage.Text = "Your account has been created"; // clear all the fields Email.Text = ""; Password.Text = ""; ConfirmPassword.Text = ""; Company.Text = ""; FirstName.Text = ""; LastName.Text = ""; } else { ErrorMessage.Text = "Fail to create your account"; } } else { ErrorMessage.Text = "Wrong Password"; } } else { ErrorMessage.Text = "This email adress is already used"; } } } else { ErrorMessage.Text = "Wrong email address format"; } }
public void CanMapPersonDetailsToGetPersonResponse() { Person person = DatabaseGatewayHelper.CreatePersonDatabaseEntity(); person.Id = 123; Address address = DatabaseGatewayHelper.CreateAddressDatabaseEntity(person.Id); //set to display address address.IsDisplayAddress = "Y"; PhoneNumber phoneNumber1 = DatabaseGatewayHelper.CreatePhoneNumberEntity(person.Id); PhoneNumber phoneNumber2 = DatabaseGatewayHelper.CreatePhoneNumberEntity(person.Id); PersonOtherName otherName1 = DatabaseGatewayHelper.CreatePersonOtherNameDatabaseEntity(person.Id); PersonOtherName otherName2 = DatabaseGatewayHelper.CreatePersonOtherNameDatabaseEntity(person.Id); person.Addresses = new List <Address> { address }; person.PhoneNumbers = new List <PhoneNumber> { phoneNumber1, phoneNumber2 }; person.OtherNames = new List <PersonOtherName> { otherName1, otherName2 }; AddressDomain addressDomain = new AddressDomain() { Address = address.AddressLines, Postcode = address.PostCode, Uprn = address.Uprn }; OtherName personOtherName1 = new OtherName() { FirstName = otherName1.FirstName, LastName = otherName1.LastName }; OtherName personOtherName2 = new OtherName() { FirstName = otherName2.FirstName, LastName = otherName2.LastName }; PhoneNumberDomain phoneNumberDomain1 = new PhoneNumberDomain() { Number = phoneNumber1.Number, Type = phoneNumber1.Type }; PhoneNumberDomain phoneNumberDomain2 = new PhoneNumberDomain() { Number = phoneNumber2.Number, Type = phoneNumber2.Type }; var expectedResponse = new GetPersonResponse() { EmailAddress = person.EmailAddress, DateOfBirth = person.DateOfBirth.Value, DateOfDeath = person.DateOfDeath.Value, Address = addressDomain, SexualOrientation = person.SexualOrientation, ContextFlag = person.AgeContext, CreatedBy = person.CreatedBy, Ethnicity = person.Ethnicity, FirstLanguage = person.FirstLanguage, FirstName = person.FirstName, Gender = person.Gender, LastName = person.LastName, NhsNumber = person.NhsNumber.Value, Id = person.Id, PreferredMethodOfContact = person.PreferredMethodOfContact, Religion = person.Religion, Restricted = person.Restricted, Title = person.Title, OtherNames = new List <OtherName>() { personOtherName1, personOtherName2 }, PhoneNumbers = new List <PhoneNumberDomain>() { phoneNumberDomain1, phoneNumberDomain2 } }; var result = ResponseFactory.ToResponse(person); result.Should().BeEquivalentTo(expectedResponse); }
public GetPersonResponse GetPersons(GetPersonRequest request) { try { if (request.PagingModel == null) { request.PagingModel = new PagingBaseRequestModel() { Sorting = new SortingModel { SortBy = "CreateDate" } }; } var phoneQuery = (from t in _db.PersonPhones.AsNoTracking() select t); var personsQuery = (from p in _db.Persons.AsNoTracking() join g in _db.Genders.AsNoTracking() on p.GenderId equals g.Id join c in _db.Citys.AsNoTracking() on p.CityId equals c.Id where (request.Fname == null || p.Fname.Contains(request.Fname)) && (request.Lname == null || p.Lname.Contains(request.Lname)) && (request.PersonalNumber == null || p.PersonalNumber.Contains(request.PersonalNumber)) && (request.BirthDateFrom == null || p.BirthDate >= request.BirthDateFrom) && (request.BirthDateTo == null || p.BirthDate <= request.BirthDateFrom) && (request.GenderId == null || p.GenderId == request.GenderId) && (request.CityId == null || p.CityId == request.CityId) && (request.PhoneNumber == null || phoneQuery.Where(pp => pp.PersonId == p.Id && pp.PhoneNumber.Contains(request.PhoneNumber)).Any()) select new PersonBaseModel { PersonId = p.Id, Fname = p.Fname, Lname = p.Lname, PersonalNumber = p.PersonalNumber, BirthDate = p.BirthDate, GenderId = p.GenderId, Gender = g.GenderName, CityId = p.CityId, City = c.CityName }); var persons = PaginatedList(personsQuery, request.PagingModel); var personIds = persons.Select(t => t.PersonId).ToList(); var personPhones = phoneQuery.Where(t => personIds.Contains(t.PersonId)).ToList(); foreach (var item in persons) { item.PersonalNumber = personPhones.Where(t => t.PersonId == item.PersonId).Select(t => t.PhoneNumber).FirstOrDefault(); } var result = new GetPersonResponse { Persons = persons, TotalCount = personsQuery.Count(), CurrentElementStart = request.PagingModel.Paging.Offset, CurrentElementEnd = request.PagingModel.Paging.Offset + request.PagingModel.Paging.Limit }; return(Success(result)); } catch (Exception ex) { return(Error(new GetPersonResponse(), RsStrings.GetPersonsUnexpectedException)); } }
public async Task <GetPersonResponse> GetCustomers(GetPersonRequest request) { GetPersonResponse response = await PostRequest <GetPersonRequest, GetPersonResponse>("GetPerson", request); return(response); }