public async Task DeleteEmployee(Employee employee) { if (IsBusy) { return; } Exception error = null; try { IsBusy = true; IEmployeeService employeeService = new EmployeeAzureService(); await employeeService.DeleteEmployee(employee); Employees.Remove(employee); } catch (Exception ex) { Debug.WriteLine("Error: " + ex); error = ex; } finally { IsBusy = false; } if (error != null) { await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK"); } }
async Task GetEmployees() { if (IsBusy) { return; } Exception error = null; try { IsBusy = true; IEmployeeService employeeService = new EmployeeAzureService(); var employees = await employeeService.GetEmployees(); Employees.Clear(); foreach (var employee in employees) { Employees.Add(employee); } } catch (Exception ex) { Debug.WriteLine("Error: " + ex); error = ex; } finally { IsBusy = false; } if (error != null) { await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK"); } }
public async Task SaveEmployee() { IEmployeeService service = new EmployeeAzureService(); await service.AddEmployee(Employee); }