public DataProviderUnitTests()
 {
     testLandLord = new LandlordDTO()
     {
         Forename = "James",
         Surname  = "Bond",
         Email    = "*****@*****.**",
         Phone    = "0#123#456#789#",
     };
 }
        private void ButtonCreateLandlord_Click(object sender, RoutedEventArgs e)
        {
            var landLord = new LandlordDTO();
            var window   = new CRULandLordWindow(landLord, CRUMode.Create);

            window.Title             = "Create Landlord";
            window.CRUButton.Content = "Create";
            var result = window.ShowDialog();

            if (result.HasValue && result.Value)
            {
                dataProvider.CreateLandLord(landLord);
                RefreshLandlords();
            }
        }
        private void ButtonUpdateLandlord_Click(object sender, RoutedEventArgs e)
        {
            if (LandlordsDataGrid.SelectedItem is LandlordDTO selectedLandlord)
            {
                var copy   = new LandlordDTO(selectedLandlord);
                var window = new CRULandLordWindow(copy, CRUMode.Update);

                var result = window.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    dataProvider.UpdateLandLord(copy);
                    RefreshLandlords();
                }
            }
        }
예제 #4
0
        public CRULandLordWindow(LandlordDTO landlord, CRUMode cruMode)
        {
            InitializeComponent();
            this.Landlord = landlord;

            if (cruMode == CRUMode.Create)
            {
                this.Title             = "Create Landlord";
                this.CRUButton.Content = "Create";
            }
            else
            {
                this.Title             = "Update Landlord";
                this.CRUButton.Content = "Update";
            }
        }