private void addSiteButton_Click(object sender, RoutedEventArgs e) { Site site = new Site(); site.ID_Site = _databaseUtilities.GetMaxIDSite() + 1; site.ID_Province = ((Province)startProvinceComboBox.SelectedItem).ID_Province; site.Province_Name = ((Province)startProvinceComboBox.SelectedItem).Province_Name; site.Site_Name = siteNameTextBox.Text; if (site.Site_Name.Length == 0) { return; } site.Standard_Site_Name = _appUtilities.getStandardName(site.Site_Name, 25); site.Site_Address = siteAddressTextBox.Text; if (site.Site_Address.Length == 0) { return; } site.Standard_Site_Address = _appUtilities.getStandardName(site.Site_Address, 28); if (_srcAvatarSite == "") { return; } site.Site_Description = siteDescriptionTextBox.Text; if (site.Site_Description.Length == 0) { return; } site.Standard_Site_Description = _appUtilities.getStandardName(site.Site_Description, 50); site.Site_Link_Avt = _appUtilities.getTypeOfImage(_srcAvatarSite); //Add _databaseUtilities.AddNewSite(site.ID_Site, site.ID_Province, site.Site_Name, site.Site_Description, site.Site_Link_Avt, site.Site_Address); _appUtilities.createSitesDirectory(); _appUtilities.copyImageToIDirectory(site.ID_Site, _srcAvatarSite, "", true); site.Site_Link_Avt = $"Images/Sites/{site.ID_Site}.{site.Site_Link_Avt}"; _sites.Add(site); notiMessageSnackbar.MessageQueue.Enqueue($"Đã thêm thành công địa danh \"{site.Site_Name}\"", "OK", () => { }); //Reset Input siteNameTextBox.Text = ""; siteAddressTextBox.Text = ""; siteDescriptionTextBox.Text = ""; sitesListView.ItemsSource = null; sitesListView.ItemsSource = _sites; avatarImage.Visibility = Visibility.Collapsed; addSiteAvatarButton.Visibility = Visibility.Visible; startProvinceComboBox.SelectedIndex = 0; }