protected override void DeleteAction() { ActionWatcher = new TaskWatcher <SingleResponse <int> >(ServicePlaceHolder.DeleteEmployee(employee)); ActionWatcher.Task.GetAwaiter().OnCompleted(() => { var success = ActionWatcher.Result; var originalEmployeesList = ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").Employees; if (ActionWatcher.Result.Success == 1) { var employeeToRemove = ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").Employees.FirstOrDefault(c => c.EmployeeId == employee.EmployeeId); originalEmployeesList.Remove(employeeToRemove); } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error al eliminar cliente"); } ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").CurrentAction = new EmployeesListViewModel(originalEmployeesList); }); }
protected override void ConfirmAction() { ActionWatcher = new TaskWatcher <SingleResponse <int> >(ServicePlaceHolder.InsertOrEditClient(client)); ActionWatcher.Task.GetAwaiter().OnCompleted(() => { var success = ActionWatcher.Result; var originalClientsList = ViewModelFactory <ClientsPageViewModel> .GetView("ClientsPage").Clients; if (ActionWatcher.Result.Success == 1) { if (IsEdit) { var clientToUpdate = originalClientsList.FirstOrDefault(c => c.ClientId == client.ClientId); if (clientToUpdate != null) { clientToUpdate.ClientName = ClientName; clientToUpdate.ClientAddress = ClientAddress; clientToUpdate.ClientCellPhone = ClientCellPhone; clientToUpdate.ClientPhone = ClientPhone; clientToUpdate.ClientEmail = ClientEmail; } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error al actualizar cliente"); } } else { client.ClientId = ActionWatcher.Result.Data; ViewModelFactory <ClientsPageViewModel> .GetView("ClientsPage").Clients.Add(client); } ViewModelFactory <ClientsPageViewModel> .GetView("ClientsPage").CurrentAction = new ClientsListViewModel(originalClientsList); } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error en edicion/adicion de cliente"); } ViewModelFactory <ClientsPageViewModel> .GetView("ClientsPage").CurrentAction = new ClientsListViewModel(originalClientsList); }); }
protected override void ConfirmAction() { ActionWatcher = new TaskWatcher <SingleResponse <int> >(ServicePlaceHolder.InsertOrEditEmployee(employee)); ActionWatcher.Task.GetAwaiter().OnCompleted(() => { var success = ActionWatcher.Result; var originalEmployeesList = ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").Employees; if (ActionWatcher.Result.Success == 1) { if (IsEdit) { var employeeToUpdate = originalEmployeesList.FirstOrDefault(c => c.EmployeeId == employee.EmployeeId); if (employeeToUpdate != null) { employeeToUpdate.EmployeeName = EmployeeName; employeeToUpdate.EmployeeAddress = EmployeeAddress; employeeToUpdate.EmployeeCellPhone = EmployeeCellPhone; employeeToUpdate.EmployeeHomePhone = EmployeePhone; } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error al actualizar cliente"); } } else { employee.EmployeeId = ActionWatcher.Result.Data; ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").Employees.Add(employee); } ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").CurrentAction = new EmployeesListViewModel(originalEmployeesList); } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error en edicion/adicion de cliente"); } ViewModelFactory <EmployeesAdministrationPageViewModel> .GetView("EmployeesAdministrationPage").CurrentAction = new EmployeesListViewModel(originalEmployeesList); }); }
protected override void ConfirmAction() { ActionWatcher = new TaskWatcher <SingleResponse <int> >(ServicePlaceHolder.InsertOrEditWorkspace(workspace)); ActionWatcher.Task.GetAwaiter().OnCompleted(() => { var success = ActionWatcher.Result; var originalWorkspacesList = ViewModelFactory <WorkspacePageViewModel> .GetView("WorkspacePage").Workspaces; if (ActionWatcher.Result.Success == 1) { if (IsEdit) { var workspaceToUpdate = originalWorkspacesList.FirstOrDefault(c => c.WorkspaceId == workspace.WorkspaceId); if (workspaceToUpdate != null) { workspaceToUpdate.WorkspaceName = WorkspaceName; } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error al actualizar cliente"); } } else { workspace.WorkspaceId = ActionWatcher.Result.Data; ViewModelFactory <WorkspacePageViewModel> .GetView("WorkspacePage").Workspaces.Add(workspace); } ViewModelFactory <WorkspacePageViewModel> .GetView("WorkspacePage").CurrentAction = new WorkspacesListViewModel(originalWorkspacesList); } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error en edicion/adicion de cliente"); } ViewModelFactory <WorkspacePageViewModel> .GetView("WorkspacePage").CurrentAction = new WorkspacesListViewModel(originalWorkspacesList); }); }
protected override void ConfirmAction() { ActionWatcher = new TaskWatcher <SingleResponse <ServiceDiscountActionsResponse> >(ServicePlaceHolder.InsertOrEditService(service)); ActionWatcher.Task.GetAwaiter().OnCompleted(() => { var success = ActionWatcher.Result; var originalServicesList = ViewModelFactory <ServiceAdministrationPageViewModel> .GetView("ServiceAdministratorPage").Services; if (ActionWatcher.Result.Success == 1) { if (IsEdit) { var serviceToUpdate = originalServicesList.FirstOrDefault(c => c.ServiceId == service.ServiceId); if (serviceToUpdate != null) { serviceToUpdate.ServiceName = ServiceName; serviceToUpdate.ServicePrice = ServicePrice; serviceToUpdate.Active = ServiceActive; if (ServiceDiscount > 0) { if (serviceToUpdate.ServiceDiscount == null) { serviceToUpdate.ServiceDiscount = new ServiceDiscounts(); } if (serviceToUpdate.ServiceDiscount.ServiceDiscountId == 0) { serviceToUpdate.ServiceDiscount.ServiceDiscountId = ActionWatcher.Result.Data.ServiceDiscountId; } serviceToUpdate.ServiceDiscount.ServiceDiscount = ServiceDiscount; serviceToUpdate.ServiceDiscount.StartDate = StartDiscountDate; serviceToUpdate.ServiceDiscount.EndDate = EndDiscountDate; serviceToUpdate.ServiceDiscount.Active = ServiceDiscountActive; } } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error al actualizar cliente"); } } else { service.ServiceId = ActionWatcher.Result.Data.ServiceId; service.ServiceDiscount.ServiceDiscountId = ActionWatcher.Result.Data.ServiceDiscountId; ViewModelFactory <ServiceAdministrationPageViewModel> .GetView("ServiceAdministratorPage").Services.Add(service); } ViewModelFactory <ServiceAdministrationPageViewModel> .GetView("ServiceAdministratorPage").CurrentAction = new ServicesListViewModel(originalServicesList); } else { ConsoleManager.Show(); Console.WriteLine("Ooppss! Error en edicion/adicion de cliente"); } ViewModelFactory <ServiceAdministrationPageViewModel> .GetView("ServiceAdministratorPage").CurrentAction = new ServicesListViewModel(originalServicesList); }); }