Exemplo n.º 1
0
 public async Task ResetDataAsync()
 {
     try
     {
         using (var client = new ExpenseServiceClient())
         {
             await client.ResetDataAsync();
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException)
     {
         this._viewService.ShowError("Could not connect to configured service.");
     }
     catch (Exception ex)
     {
         this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
     }
 }
Exemplo n.º 2
0
        public async Task <ExpenseReport[]> GetExpenseReportsForEmployeeAsync(int employeeId)
        {
            try
            {
                using (var client = new ExpenseServiceClient())
                {
                    return(await client.GetExpenseReportsForEmployeeAsync(employeeId));
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                this._viewService.ShowError("Could not connect to configured service.");
            }
            catch (Exception ex)
            {
                this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
            }

            return(new ExpenseReport[0]);
        }
        public async Task<ExpenseReport[]> GetExpenseReportsForEmployeeAsync(int employeeId)
        {
            try
            {
                using (var client = new ExpenseServiceClient())
                {
                    return await client.GetExpenseReportsForEmployeeAsync(employeeId);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                this._viewService.ShowError("Could not connect to configured service.");
            }
            catch (Exception ex)
            {
                this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
            }

            return new ExpenseReport[0];
        }
Exemplo n.º 4
0
        public async Task <int> UpdateExpenseReportAsync(ExpenseReport expenseReport)
        {
            try
            {
                using (var client = new ExpenseServiceClient())
                {
                    return(await client.UpdateExpenseReportAsync(expenseReport));
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                this._viewService.ShowError("Could not connect to configured service.");
            }
            catch (Exception ex)
            {
                this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
            }

            return(0);
        }
Exemplo n.º 5
0
        public async Task <Employee> GetEmployeeAsync(string employeeAlias)
        {
            try
            {
                using (var client = new ExpenseServiceClient())
                {
                    string theAlias = employeeAlias.ToLower();
                    return(await client.GetEmployeeAsync(theAlias));
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                this._viewService.ShowError("Could not connect to configured service.");
            }
            catch (Exception ex)
            {
                this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
            }

            return(new Employee());
        }
        /// <summary>
        /// Returns a list of expenses based on roles.
        /// </summary>
        /// <param name="role">The name of the role.</param>
        /// <returns>An expense list.</returns>
        public List<Expense> LoadExpenses(string role)
        {
            List<Expense> expensesList = null;

            ExpenseServiceClient proxy = new ExpenseServiceClient();

            try
            {
                expensesList = proxy.ListExpensesForApproval(role);
                proxy.Close();
            }
            catch (FaultException<ProcessExecutionFault> ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return expensesList;
        }
        public List<ExpenseLog> LoadExpenseLogs(long expenseID)
        {
            List<ExpenseLog> LogsList = null;
            try
            {
                ExpenseServiceClient proxy = new ExpenseServiceClient();
                LogsList = proxy.ListExpenseLogs(expenseID);
                proxy.Close();
            }
            catch (FaultException<ProcessExecutionFault> ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return LogsList;
        }
        public void ResetDatabase()
        {
            try
            {
                ExpenseServiceClient proxy = new ExpenseServiceClient();

                // Get a list of active expenses.
                List<Expense> expensesList = proxy.ListActiveExpenses();

                if (expensesList.Count > 0)
                {
                    throw new ApplicationException("Cannot reset ExpenseSample database when there are active expenses. Please Cancel all active expenses and then try again.");
                }

                proxy.Purge();
                proxy.Close();
            }
            catch (FaultException<ProcessExecutionFault> ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
        /// <summary>
        /// Loads the expenses.
        /// </summary>
        /// <param name="employeeID">An EmployeeID.</param>
        /// <returns>A List of Expenses.</returns>
        public List<Expense> LoadExpenses(string employeeID)
        {
            List<Expense> expensesList = null;

            try
            {
                ExpenseServiceClient proxy = new ExpenseServiceClient();
                expensesList = proxy.ListExpensesForEmployee(employeeID);
                proxy.Close();
            }
            catch (FaultException<ProcessExecutionFault> ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return expensesList;
        }
Exemplo n.º 10
0
 public void Dispose()
 {
     this.expenseClient = null;
     instance = null;
 }
 public async Task ResetDataAsync()
 {
     try
     {
         using (var client = new ExpenseServiceClient())
         {
             await client.ResetDataAsync();
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException)
     {
         this._viewService.ShowError("Could not connect to configured service.");
     }
     catch (Exception ex)
     {
         this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
     }
 }
        public async Task<int> UpdateExpenseReportAsync(ExpenseReport expenseReport)
        {
            try
            {
                using (var client = new ExpenseServiceClient())
                {
                    return await client.UpdateExpenseReportAsync(expenseReport);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                this._viewService.ShowError("Could not connect to configured service.");
            }
            catch (Exception ex)
            {
                this._viewService.ShowError(String.Format("Error in WCF call: {0}", ex.Message));
            }

            return 0;
        }
Exemplo n.º 13
0
 void IDisposable.Dispose()
 {
     this._expenseClient = null;
     _instance           = null;
 }