public void UpdateWorker(WorkerModel worker) { int index = Workers.IndexOf(Workers.FirstOrDefault(w => w.Id == worker.Id)); Workers[index] = worker.Clone(); UpdateDepartments(); UpdateOrders(); }
private void OnSaveExecute() { Busy = true; dataClient = ContainerProvider.GetInstance.Resolve <DataServiceClient>(); if (Worker == null) { Worker = new WorkerDetail() { Description = Description, DetachmentID = LoginInit.user.DetachmentID, FirstName = FirstName, LastName = LastName, PersonalEmail = PersonalEmail, PersonalPhone = PersonalPhone, SapNumber = SapNumber, ServiceEmail = ServiceEmail, ServiceNumber = ServiceNumber, ServicePhone = ServicePhone, Tours = WorkerTours }; dataClient.AddWorkerCompleted += AddWorkerCompleted; dataClient.AddWorkerAsync(Worker); } else { update = true; Worker.Description = Description; Worker.PersonalEmail = PersonalEmail; Worker.PersonalPhone = PersonalPhone; Worker.ServiceEmail = ServiceEmail; Worker.ServicePhone = ServicePhone; Worker.Tours = WorkerTours; var w = SelectedWorker; var index = Workers.IndexOf(SelectedWorker); Workers.Remove(SelectedWorker); w.ServicePhone = ServicePhone; Workers.Insert(index, w); SelectedWorker = w; dataClient.UpdateWorkerCompleted += UpdateWorkerCompleted; dataClient.UpdateWorkerAsync(Worker); } }