Exemplo n.º 1
0
        public async Task <Contoso.Apps.Insurance.Data.DTOs.Person> GetPerson(int id)
        {
            Cursor.Current = Cursors.WaitCursor;
            var person = new Contoso.Apps.Insurance.Data.DTOs.Person();

            using (var client = GetPolicyManagementServiceClient())
            {
                try
                {
                    var result = client.GetPerson(id);
                    person.Address     = result.Address;
                    person.Address2    = result.Address2;
                    person.City        = result.City;
                    person.DisplayName = result.DisplayName;
                    person.Dob         = result.Dob;
                    person.FName       = result.FName;
                    person.LName       = result.LName;
                    person.Postcode    = result.Postcode;
                    person.Suburb      = result.Suburb;
                    person.Dependents  = result.Dependents.Select(d => new Contoso.Apps.Insurance.Data.DTOs.Dependent
                    {
                        Id             = d.Id,
                        Active         = d.Active,
                        PersonId       = d.PersonId,
                        PolicyHolderId = d.PolicyHolderId
                    }).ToList();
                }
                catch (MessageSecurityException mex)
                {
                    MessageBox.Show("Your username or password was incorrect. Please try again.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"An error occurred while communicating with the server: {ex.Message}");
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

            return(person);
        }
Exemplo n.º 2
0
        public async Task <int> SavePerson(Contoso.Apps.Insurance.Data.DTOs.Person person)
        {
            Cursor.Current = Cursors.WaitCursor;
            var id = 0;

            using (var client = GetPolicyManagementServiceClient())
            {
                try
                {
                    id = client.SavePerson(new Person
                    {
                        Address     = person.Address,
                        Address2    = person.Address2,
                        City        = person.City,
                        DisplayName = person.DisplayName,
                        Dob         = person.Dob,
                        FName       = person.FName,
                        LName       = person.LName,
                        Postcode    = person.Postcode,
                        Suburb      = person.Suburb,
                    });
                }
                catch (MessageSecurityException mex)
                {
                    MessageBox.Show("Your username or password was incorrect. Please try again.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"An error occurred while communicating with the server: {ex.Message}");
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

            return(id);
        }