private void LoadPanelsAndFields() { CloseButton.Visibility = Visibility.Visible; string updateType = UpdateType.Trim().ToUpper(); switch (updateType) { case "HOME": { this.Title = "Update Home Information"; LoadHomeInfoFields(); break; } case "PUTONMARKET": { this.Title = "Update Home: Put on the Market"; Case_AddHfsWithAgent(); break; } case "HOMESOLD": { this.Title = "Update Home Sale as SOLD"; Case_HomeSold(); break; } case "OWNER": { this.Title = "Update Owner information"; LoadHomeInfoFields(); break; } case "BUYER": { this.Title = "Update Buyer information"; LoadHomeInfoFields(); break; } case "AGENT": { this.Title = "Update Agent information"; LoadHomeInfoFields(); break; } default: { ShowCloseButtonOnly(); break; } } }
private void SaveChangesButton_Click(object sender, RoutedEventArgs e) { try { int savedCount = 0; string updateType = UpdateType.Trim().ToUpper(); switch (updateType) { case "PUTONMARKET": { savedCount += ((App)Application.Current)._homeSalesCollection.Add(UpdateHomeSale); break; } case "HOMESOLD": { if (BuyerUpdated && HomesaleUpdated) { Person buyerPerson = ((App)Application.Current)._peopleCollection.Get(UpdateBuyer.BuyerID); if (buyerPerson == null) { break; } savedCount += ((App)Application.Current)._peopleCollection.UpdatePerson(buyerPerson); var homesaleToSave = new HomeSale() { SaleID = UpdateHomeSale.SaleID, HomeID = UpdateHomeSale.HomeID, SoldDate = UpdateHomeSale.SoldDate, AgentID = UpdateHomeSale.AgentID, SaleAmount = UpdateHomeSale.SaleAmount, BuyerID = UpdateBuyer.BuyerID, MarketDate = UpdateHomeSale.MarketDate, CompanyID = UpdateHomeSale.CompanyID }; savedCount += ((App)Application.Current)._homeSalesCollection.Update(homesaleToSave); } break; } default: { DisplayStatusMessage("Nothing was saved."); ShowCloseButtonOnly(); break; } } if (savedCount < 1) { DisplayStatusMessage("Home or Home Sale info required for: Agent, Buyer, and Owner changes."); } if (savedCount > 0) { DisplayStatusMessage("Save completed! Click Close to exit."); IsButtonClose = true; } } catch (Exception ex) { DisplayStatusMessage("Unable to save changes."); logger.Data("Home Updater Window Exception Caught!", ex.Message); logger.Flush(); logger.Data("UpdateHome: ", UpdateHome?.ToString()); logger.Flush(); logger.Data("UpdateRealEstateCompany: ", UpdateReco?.ToString()); logger.Flush(); logger.Data("UpdateHomeSale (Market): ", UpdateHomeSale?.ToString()); logger.Flush(); logger.Data("UpdateBuyer: ", $"{ UpdateBuyer?.ToString() }"); logger.Flush(); logger.Data("UpdatedHomeSale (Sold): ", $"{ UpdateHomeSale?.ToString() }"); logger.Flush(); } }