Ejemplo n.º 1
0
        public async Task <int> SaveDependent(Contoso.Apps.Insurance.Data.DTOs.Dependent dependent)
        {
            Cursor.Current = Cursors.WaitCursor;
            var id = 0;

            using (var client = GetPolicyManagementServiceClient())
            {
                try
                {
                    id = client.SaveDependent(new PolicyManagementServiceReference.Dependent()
                    {
                        Active         = dependent.Active,
                        PersonId       = dependent.PersonId,
                        PolicyHolderId = dependent.PolicyHolderId
                    });
                }
                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);
        }
Ejemplo n.º 2
0
        public async Task <Contoso.Apps.Insurance.Data.DTOs.Dependent> GetDependent(int id)
        {
            Cursor.Current = Cursors.WaitCursor;
            var dependent = new Contoso.Apps.Insurance.Data.DTOs.Dependent();

            using (var client = GetPolicyManagementServiceClient())
            {
                try
                {
                    if (id > 0)
                    {
                        var result = client.GetDependent(id);
                        dependent.PolicyHolderId = result.PolicyHolderId;
                        dependent.Active         = result.Active;
                        dependent.PersonId       = result.PersonId;
                        dependent.Id             = result.Id;
                    }
                }
                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(dependent);
        }