public async void OnSave() { if (Id == 0) { if (!string.IsNullOrEmpty(Name)) { var addedTechnician = new LocalTechnician() { Id = 0, Name = Name }; addedTechnician.Id = await DatabaseHandler.Instance.AddTechnician(addedTechnician); LocalCache.Instance.Technicians.Add(addedTechnician); Id = addedTechnician.Id; } else { MessageBox.Show("Adaugati Nume pentru a putea salva!"); } } else { if (IsEdit) { var technicianToEdit = LocalCache.Instance.Technicians.FirstOrDefault(item => item.Id == Id); technicianToEdit.Name = Name; DatabaseHandler.Instance.AddTechnician(technicianToEdit); } } IsEdit = false; Parent.MaterialTileListViewModel.WasChanged = false; }
private async void OnSave() { LocalTechnician technician = new LocalTechnician() { Id = Parent.Id, Name = Parent.Name, Materials = new List <LocalMaterial>() }; foreach (var materialTileViewModel in Materials) { technician.Materials.Add(materialTileViewModel.OnSave()); } if (Parent.Technician != null) { Parent.Technician.Materials = technician.Materials; } var updatedTehnician = LocalCache.Instance.Technicians.FirstOrDefault(item => item.Id == technician.Id); LocalCache.Instance.Technicians.Remove(updatedTehnician); LocalCache.Instance.Technicians.Add(technician); //todo:add technician // DatabaseHandler.Instance.AddTechnicianAndMaterials(technician); await DatabaseHandler.Instance.DeleteMaterials(deletedMaterials); await DatabaseHandler.Instance.DeleteMaterialTypes(deletedMaterialTypes); deletedMaterials = new List <int>(); deletedMaterialTypes = new List <int>(); WasChanged = false; }
public static Technician ToTechnician(this LocalTechnician from) { return(new Technician { Id = from.Id, Name = from.Name }); }
public static LocalTechnician ToLocalTechnician(this Technician from) { var technician = new LocalTechnician { Id = from.Id, Name = from.Name }; return(technician); }
private void InitData() { SelectedArea = null; Revenue = null; SelectedWorkType = new LocalWorkType(); SelectedWork = new LocalWork(); SelectedMaterialType = new SettingsType(); SelectedMaterial = new LocalMaterial(); StartingHour = EndTIme; SelectedPatient = new LocalPatient(); Observation = ""; SelectedLocation = new SettingsItem(); SelectedTechnician = new LocalTechnician(); Durata = ""; IsInEditMode = false; WasPayedByDental = false; SelectedPercentage = null; MaterialCost = null; }
private async void OnSave() { if (!string.IsNullOrEmpty(Name)) { var addedTechnician = new LocalTechnician() { Name = Name }; addedTechnician.Id = await DatabaseHandler.Instance.AddTechnician(addedTechnician); LocalCache.Instance.Technicians.Add(addedTechnician); Parent.TechniciansObjectList.Add(new TechnicianTileViewModel(Parent) { Id = addedTechnician.Id, Name = Name }); Parent.AddTileVisibility = Visibility.Collapsed; Parent.AddButtonVisibility = Visibility.Visible; } else { MessageBox.Show("Adaugati Nume pentru a putea salva!"); } }