Add Radiobutton in CustomerView for Query-Selection-Method

This commit is contained in:
Francesco 2020-07-30 14:00:50 +02:00
parent 3c0e23284f
commit 13d3654303
4 changed files with 148 additions and 13 deletions

View File

@ -84,6 +84,7 @@
<Compile Include="Model\Node.cs" />
<Compile Include="Model\SeverityComboBoxItem.cs" />
<Compile Include="Repository\CustomerRepository.cs" />
<Compile Include="Repository\CustomerRepositoryEF.cs" />
<Compile Include="Repository\IRepositoryBase.cs" />
<Compile Include="Repository\LocationRepository.cs" />
<Compile Include="Repository\LoggingRepository.cs" />

View File

@ -0,0 +1,60 @@
using LoggingClient.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LoggingClient.Repository
{
public class CustomerRepositoryEF : RepositoryBase<Customer>
{
public CustomerRepositoryEF(string connectionString) : base(connectionString)
{
Customers = new List<Customer>();
}
public List<Customer> Customers { get; set; }
public override string TableName => throw new NotImplementedException();
public override string ColumnsForSelect => throw new NotImplementedException();
public override string ColumnsForAdd => throw new NotImplementedException();
public override string PrimaryKeyFromTable => throw new NotImplementedException();
public override void Add(Customer entity)
{
throw new NotImplementedException();
}
public override void CallStoredProcedure(Customer entity)
{
throw new NotImplementedException();
}
public override void Delete(Customer entity)
{
throw new NotImplementedException();
}
public override List<Customer> GetAll(string whereCondition, Dictionary<string, object> parameterValues)
{
throw new NotImplementedException();
}
public override List<Customer> GetAll()
{
throw new NotImplementedException();
}
public override Customer GetSingle<P>(P pkValue)
{
throw new NotImplementedException();
}
public override void Update(Customer entity)
{
throw new NotImplementedException();
}
}
}

View File

@ -34,6 +34,29 @@ namespace LoggingClient.ViewModel
private List<Customer> _customers;
public Customer NewCustomerEntry { get; set; }
private bool _EfIsChecked;
private bool _LinqIsChecked;
public bool EfIsChecked
{
get { return _EfIsChecked; }
set
{
_EfIsChecked = value;
OnPropertyChanged(nameof(EfIsChecked));
}
}
public bool LinqIsChecked
{
get { return _LinqIsChecked; }
set
{
_LinqIsChecked = value;
OnPropertyChanged(nameof(LinqIsChecked));
}
}
public CustomerViewModel()
{
TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
@ -120,18 +143,52 @@ namespace LoggingClient.ViewModel
}
private void LoadData()
{
if (_EfIsChecked)
{
try
{
var customerModelRepository = new CustomerRepository(TxtConnectionString);
var customerModelRepository = new CustomerRepositoryEF(TxtConnectionString);
this.Customers = customerModelRepository.GetAll().ToList();
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree"));
}
catch (Exception ex)
{
MessageBox.Show("Error occurred: " + ex.Message);
}
}
if (_LinqIsChecked)
{
//TODO
}
else
{
try
{
var customerModelRepository = new CustomerRepository(TxtConnectionString);
this.Customers = customerModelRepository.GetAll().ToList();
}
catch (Exception ex)
{
MessageBox.Show("Error occurred: " + ex.Message);
}
}
}
private void AddData()
{
if (_EfIsChecked)
{
try
{
var customerModelRepository = new CustomerRepositoryEF(TxtConnectionString);
customerModelRepository.Add(this.NewCustomerEntry);
this.Customers = customerModelRepository.GetAll().ToList();
}
catch (Exception ex)
{
MessageBox.Show("Error occurred: " + ex.Message);
}
}
if (_LinqIsChecked)
{
try
{
@ -144,6 +201,20 @@ namespace LoggingClient.ViewModel
MessageBox.Show("Error occurred: " + ex.Message);
}
}
else
{
try
{
var customerModelRepository = new CustomerRepository(TxtConnectionString);
customerModelRepository.Add(this.NewCustomerEntry);
this.Customers = customerModelRepository.GetAll().ToList();
}
catch (Exception ex)
{
MessageBox.Show("Error occurred: " + ex.Message);
}
}
}
private void DeleteData()
{
try

View File

@ -150,6 +150,9 @@
<Label Content="Phone" HorizontalAlignment="Left" Margin="110,346,0,0" VerticalAlignment="Top" Width="95"/>
<Label Content="Email" HorizontalAlignment="Left" Margin="210,346,0,0" VerticalAlignment="Top" Width="95"/>
<Label Content="Password" HorizontalAlignment="Left" Margin="310,347,0,0" VerticalAlignment="Top" Width="95"/>
<Label Content="Select Strategy for SQL" HorizontalAlignment="Left" Margin="508,290,0,0" VerticalAlignment="Top" Width="175"/>
<RadioButton Content="EF" IsChecked="{Binding EfIsChecked}" HorizontalAlignment="Left" Margin="508,341,0,0" VerticalAlignment="Top"/>
<RadioButton Content="LINQ" IsChecked="{Binding LinqIsChecked}" HorizontalAlignment="Left" Margin="508,321,0,0" VerticalAlignment="Top"/>
</Grid>
</Grid>
</UserControl>