public async Task <Contoso.Apps.Insurance.Data.DTOs.PolicyHolder> GetPolicyHolder(int id) { Cursor.Current = Cursors.WaitCursor; var policyHolder = new Contoso.Apps.Insurance.Data.DTOs.PolicyHolder(); using (var client = GetPolicyManagementServiceClient()) { try { if (id > 0) { PolicyHolder policy = client.GetPolicyHolder(id); policyHolder = new Contoso.Apps.Insurance.Data.DTOs.PolicyHolder() { }; } } 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(policyHolder); }
public async Task <int> SavePolicyHolder(Contoso.Apps.Insurance.Data.DTOs.PolicyHolder policyHolder) { Cursor.Current = Cursors.WaitCursor; var id = 0; using (var client = GetPolicyManagementServiceClient()) { try { id = client.SavePolicyHolder(new PolicyHolder { Id = policyHolder.Id, PersonId = policyHolder.Id, Active = policyHolder.Active, Deductible = policyHolder.Deductible, EffectiveDate = policyHolder.EffectiveDate, EndDate = policyHolder.EndDate, ExpirationDate = policyHolder.ExpirationDate, FilePath = policyHolder.FilePath, OutOfPocketMax = policyHolder.OutOfPocketMax, PolicyAmount = policyHolder.PolicyAmount, PolicyId = policyHolder.PolicyId, PolicyNumber = policyHolder.PolicyNumber, StartDate = policyHolder.StartDate, Username = policyHolder.Username }); } 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); }