Merge branch 'dev'
This commit is contained in:
commit
653fd35c66
@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29806.167
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoggingClient", "LoggingClient\LoggingClient.csproj", "{2622C2FC-3522-4D6F-B021-F63A243E77F1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoggingClientUnitTest", "LoggingClientUnitTest\LoggingClientUnitTest.csproj", "{6B9F572F-AE97-4A52-89AD-4453BC51E038}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{2622C2FC-3522-4D6F-B021-F63A243E77F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2622C2FC-3522-4D6F-B021-F63A243E77F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2622C2FC-3522-4D6F-B021-F63A243E77F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6B9F572F-AE97-4A52-89AD-4453BC51E038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B9F572F-AE97-4A52-89AD-4453BC51E038}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B9F572F-AE97-4A52-89AD-4453BC51E038}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B9F572F-AE97-4A52-89AD-4453BC51E038}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -16,6 +16,7 @@
|
||||
</userSettings>
|
||||
<connectionStrings>
|
||||
<add name="inventarisierungsloesungEntities" connectionString="metadata=res://*/Model.Inventar.csdl|res://*/Model.Inventar.ssdl|res://*/Model.Inventar.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-8H0TJ4E;initial catalog=inventarisierungsloesung;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
<add name="InventarDB" connectionString="metadata=res://*/DTO.DataAccessLayer.csdl|res://*/DTO.DataAccessLayer.ssdl|res://*/DTO.DataAccessLayer.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-8H0TJ4E;initial catalog=inventarisierungsloesung;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
|
||||
</connectionStrings>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
|
@ -62,6 +62,7 @@
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.Linq" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Drawing.Design" />
|
||||
<Reference Include="System.Management" />
|
||||
@ -89,6 +90,7 @@
|
||||
<Compile Include="Model\Customer.cs">
|
||||
<DependentUpon>Inventar.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\CustomerLinq.cs" />
|
||||
<Compile Include="Model\Inventar.Context.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@ -110,11 +112,16 @@
|
||||
<Compile Include="Model\SeverityComboBoxItem.cs" />
|
||||
<Compile Include="Repository\CustomerRepository.cs" />
|
||||
<Compile Include="Repository\CustomerRepositoryEF.cs" />
|
||||
<Compile Include="Repository\CustomerRepositoryLinq.cs" />
|
||||
<Compile Include="Repository\IRepositoryBase.cs" />
|
||||
<Compile Include="Repository\LocationRepository.cs" />
|
||||
<Compile Include="Repository\LoggingRepository.cs" />
|
||||
<Compile Include="Repository\RepositoryBase.cs" />
|
||||
<Compile Include="Validators\CustomerNumberValidationRule.cs" />
|
||||
<Compile Include="Validators\EmailValidationRule.cs" />
|
||||
<Compile Include="Validators\IntRangeValidationRule.cs" />
|
||||
<Compile Include="Validators\PasswordValidationRule.cs" />
|
||||
<Compile Include="Validators\UrlValidationRule.cs" />
|
||||
<Compile Include="ViewModel\Commands\BaseCommand.cs" />
|
||||
<Compile Include="ViewModel\Commands\RelayCommand.cs" />
|
||||
<Compile Include="Validators\StringRangeValidationRule.cs" />
|
||||
@ -209,5 +216,9 @@
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -9,9 +9,6 @@
|
||||
|
||||
namespace LoggingClient.Model
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Customer
|
||||
{
|
||||
public long customer_id { get; set; }
|
||||
|
42
LoggingClient/LoggingClient/Model/CustomerLinq.cs
Normal file
42
LoggingClient/LoggingClient/Model/CustomerLinq.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Data.Linq.Mapping;
|
||||
|
||||
namespace LoggingClient.Model
|
||||
{
|
||||
[Table(Name = "inventarisierungsloesung.Customer")]
|
||||
public class CustomerLinq
|
||||
{
|
||||
[Column(IsPrimaryKey = true, Name = "CustomerId")]
|
||||
public long customer_id { get; set; }
|
||||
[Column(Name = "FirstName")]
|
||||
public string firstname { get; set; }
|
||||
[Column(Name = "LastName")]
|
||||
public string lastname { get; set; }
|
||||
[Column(Name = "CustomerNumber")]
|
||||
public string customernumber { get; set; }
|
||||
[Column(Name = "KundenKontoFK")]
|
||||
public long kundenkonto_fk { get; set; }
|
||||
[Column(Name = "PhoneNumber")]
|
||||
public string tel { get; set; }
|
||||
[Column(Name = "EMail")]
|
||||
public string email { get; set; }
|
||||
[Column(Name = "URL")]
|
||||
public string url { get; set; }
|
||||
[Column(Name = "Password")]
|
||||
public string password { get; set; }
|
||||
|
||||
public CustomerLinq() { }
|
||||
|
||||
public CustomerLinq(long Id, string FirstName, string LastName, string CustomerNumber, long Customer_fk, string PhoneNumber, string EMail, string URL, string Password)
|
||||
{
|
||||
this.customer_id = Id;
|
||||
this.firstname = FirstName;
|
||||
this.lastname = LastName;
|
||||
this.customernumber = CustomerNumber;
|
||||
this.kundenkonto_fk = Customer_fk;
|
||||
this.tel = PhoneNumber;
|
||||
this.email = EMail;
|
||||
this.url = URL;
|
||||
this.password = Password;
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ namespace LoggingClient.Repository
|
||||
public override string PrimaryKeyFromTable => "customer_id";
|
||||
|
||||
public List<Customer> Customers { get; set; }
|
||||
public Customer _Customers { get; set; }
|
||||
|
||||
public override void Add(Customer entity)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using LoggingClient.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Linq;
|
||||
|
||||
namespace LoggingClient.Repository
|
||||
@ -13,6 +14,8 @@ namespace LoggingClient.Repository
|
||||
}
|
||||
public List<Customer> Customers { get; set; }
|
||||
|
||||
public string TableName => throw new NotImplementedException();
|
||||
|
||||
public void Add(Customer newCustomerEntry)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
@ -33,6 +36,16 @@ namespace LoggingClient.Repository
|
||||
}
|
||||
}
|
||||
|
||||
public long Count(string whereCondition, Dictionary<string, object> parameterValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long Count()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Delete(Customer entity)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
@ -63,7 +76,11 @@ namespace LoggingClient.Repository
|
||||
|
||||
public void Update(Customer entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
context.Customer.AddOrUpdate(entity);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
105
LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs
Normal file
105
LoggingClient/LoggingClient/Repository/CustomerRepositoryLinq.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using LoggingClient.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace LoggingClient.Repository
|
||||
{
|
||||
public class CustomerRepositoryLinq : IRepositoryBase<Customer>
|
||||
{
|
||||
public CustomerRepositoryLinq() { }
|
||||
|
||||
public string TableName => throw new NotImplementedException();
|
||||
|
||||
public void Add(Customer entity)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
var customer = new Customer()
|
||||
{
|
||||
firstname = entity.firstname,
|
||||
lastname = entity.lastname,
|
||||
customernumber = entity.customernumber,
|
||||
kundenkonto_fk = entity.kundenkonto_fk,
|
||||
tel = entity.tel,
|
||||
email = entity.email,
|
||||
url = entity.url,
|
||||
password = entity.password
|
||||
};
|
||||
context.Customer.Add(customer);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void CallStoredProcedure(Customer entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long Count(string whereCondition, Dictionary<string, object> parameterValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long Count()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Delete(Customer entity)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
var x = (from c in context.Customer
|
||||
where (c.customer_id == entity.customer_id)
|
||||
select c).SingleOrDefault();
|
||||
context.Customer.Remove(x);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Customer> GetAll(string whereCondition, Dictionary<string, object> parameterValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<Customer> GetAll()
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
return context.Customer.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public Customer GetSingle<P>(P pkValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Update(Customer entity)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
var x = (from c in context.Customer
|
||||
where (c.customer_id == entity.customer_id)
|
||||
select c).SingleOrDefault();
|
||||
|
||||
x.firstname = entity.firstname;
|
||||
x.lastname = entity.lastname;
|
||||
x.customernumber = entity.customernumber;
|
||||
x.kundenkonto_fk = entity.kundenkonto_fk;
|
||||
x.tel = entity.tel;
|
||||
x.email = entity.email;
|
||||
x.url = entity.url;
|
||||
x.password = entity.password;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
List<Customer> IRepositoryBase<Customer>.GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ namespace LoggingClient.Repository
|
||||
{
|
||||
try
|
||||
{
|
||||
location.AddressId = 2;
|
||||
using (var conn = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
@ -0,0 +1,32 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace LoggingClient.Validators
|
||||
{
|
||||
public class CustomerNumberValidationRule : ValidationRule
|
||||
{
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Regex for Address Number Validation.
|
||||
/// Beginning with CU following a 5 digit number.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="cultureInfo"></param>
|
||||
/// <returns></returns>
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
Regex regex = new Regex(@"^CU[0-9]{5}$");
|
||||
Match match = regex.Match(value.ToString());
|
||||
if (match == Match.Empty)
|
||||
{
|
||||
return new ValidationResult(false, ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace LoggingClient.Validators
|
||||
{
|
||||
public class EmailValidationRule : ValidationRule
|
||||
{
|
||||
public string ErrorMessage { get; set; }
|
||||
/// <summary>
|
||||
/// Checks an Email Address if it's valid or not
|
||||
/// Regex doesn't check if the top + subdomains are valid.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="cultureInfo"></param>
|
||||
/// <returns></returns>
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
Regex regex = new Regex(@"\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z");
|
||||
Match match = regex.Match(value.ToString());
|
||||
if (match == Match.Empty)
|
||||
{
|
||||
return new ValidationResult(false, ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace LoggingClient.Validators
|
||||
{
|
||||
public class IntRangeValidationRule : ValidationRule
|
||||
{
|
||||
public int MinimumLength { get; set; }
|
||||
public int MaximumLength { get; set; }
|
||||
public int MinimumLength { get; set; } = 1;
|
||||
public int MaximumLength { get; set; } = 8;
|
||||
public string ErrorMessage { get; set; }
|
||||
public override ValidationResult Validate(object value,
|
||||
CultureInfo cultureInfo)
|
||||
|
@ -0,0 +1,31 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace LoggingClient.Validators
|
||||
{
|
||||
public class PasswordValidationRule : ValidationRule
|
||||
{
|
||||
public string ErrorMessage { get; set; }
|
||||
/// <summary>
|
||||
/// Regex for password validation
|
||||
/// 8 - 15 characters. At least 1 upper, 1 lowercase, 1 number and 1 special character.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="cultureInfo"></param>
|
||||
/// <returns></returns>
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
Regex regex = new Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,15}$");
|
||||
Match match = regex.Match(value.ToString());
|
||||
if (match == Match.Empty)
|
||||
{
|
||||
return new ValidationResult(false, ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace LoggingClient.Validators
|
||||
{
|
||||
public class StringRangeValidationRule : ValidationRule
|
||||
{
|
||||
public int MinimumLength { get; set; }
|
||||
public int MaximumLength { get; set; }
|
||||
public int MinimumLength { get; set; } = 1;
|
||||
public int MaximumLength { get; set; } = 50;
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
|
32
LoggingClient/LoggingClient/Validators/UrlValidationRule.cs
Normal file
32
LoggingClient/LoggingClient/Validators/UrlValidationRule.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace LoggingClient.Validators
|
||||
{
|
||||
public class UrlValidationRule : ValidationRule
|
||||
{
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Regex for url Validation.
|
||||
/// Doesn't check if the url exists.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="cultureInfo"></param>
|
||||
/// <returns></returns>
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
Regex regex = new Regex(@"^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$");
|
||||
Match match = regex.Match(value.ToString());
|
||||
if (match == Match.Empty)
|
||||
{
|
||||
return new ValidationResult(false, ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public Customer NewCustomerEntry { get; set; }
|
||||
public Customer SelectedItem { get; set; }
|
||||
|
||||
private long _customerId;
|
||||
public long customer_id
|
||||
@ -58,6 +58,8 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
|
||||
private bool _LinqIsChecked;
|
||||
private Customer mySelectedItem;
|
||||
|
||||
public bool LinqIsChecked
|
||||
{
|
||||
get { return _LinqIsChecked; }
|
||||
@ -67,17 +69,26 @@ namespace LoggingClient.ViewModel
|
||||
OnPropertyChanged(nameof(LinqIsChecked));
|
||||
}
|
||||
}
|
||||
public Customer SelectedItem { get; set; }
|
||||
|
||||
|
||||
public CustomerViewModel()
|
||||
{
|
||||
TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
|
||||
|
||||
Customers = new List<Customer>();
|
||||
NewCustomerEntry = new Customer();
|
||||
|
||||
_dupChecker = new DuplicateChecker();
|
||||
}
|
||||
public Customer MySelectedItem { get; set; }
|
||||
public Customer MySelectedItem
|
||||
{
|
||||
get => mySelectedItem;
|
||||
set
|
||||
{
|
||||
mySelectedItem = value;
|
||||
this.OnPropertyChanged("MySelectedItem");
|
||||
|
||||
}
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string TxtConnectionString
|
||||
@ -161,6 +172,8 @@ namespace LoggingClient.ViewModel
|
||||
{
|
||||
var customerModelRepositoryEF = new CustomerRepositoryEF();
|
||||
Customers = customerModelRepositoryEF.GetAll();
|
||||
|
||||
this.MySelectedItem = new Customer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -169,7 +182,15 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
if (_LinqIsChecked)
|
||||
{
|
||||
//TODO
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryLinq = new CustomerRepositoryLinq();
|
||||
Customers = customerModelRepositoryLinq.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (!_EfIsChecked && !_LinqIsChecked)
|
||||
{
|
||||
@ -191,24 +212,47 @@ namespace LoggingClient.ViewModel
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryEF = new CustomerRepositoryEF();
|
||||
customerModelRepositoryEF.Add(NewCustomerEntry);
|
||||
customerModelRepositoryEF.Add(MySelectedItem);
|
||||
Customers = customerModelRepositoryEF.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (MySelectedItem.kundenkonto_fk == 0)
|
||||
{
|
||||
MessageBox.Show("Error occurred: CustAcck ID darf nicht 0 sein");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_LinqIsChecked)
|
||||
{
|
||||
// TODO
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryLinq = new CustomerRepositoryLinq();
|
||||
customerModelRepositoryLinq.Add(MySelectedItem);
|
||||
Customers = customerModelRepositoryLinq.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (MySelectedItem.kundenkonto_fk == 0)
|
||||
{
|
||||
MessageBox.Show("Error occurred: CustAcck ID darf nicht 0 sein");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_EfIsChecked && !_LinqIsChecked)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerModelRepository = new CustomerRepository(TxtConnectionString);
|
||||
customerModelRepository.Add(this.NewCustomerEntry);
|
||||
customerModelRepository.Add(MySelectedItem);
|
||||
this.Customers = customerModelRepository.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -232,12 +276,25 @@ namespace LoggingClient.ViewModel
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (_LinqIsChecked)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryLinq = new CustomerRepositoryLinq();
|
||||
customerModelRepositoryLinq.Delete(MySelectedItem);
|
||||
Customers = customerModelRepositoryLinq.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (!_EfIsChecked && !_LinqIsChecked)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerModelRepository = new CustomerRepository(TxtConnectionString);
|
||||
customerModelRepository.Delete(this.NewCustomerEntry);
|
||||
customerModelRepository.Delete(MySelectedItem);
|
||||
this.Customers = customerModelRepository.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -248,10 +305,39 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
private void UpdateData()
|
||||
{
|
||||
if (_EfIsChecked)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryEF = new CustomerRepositoryEF();
|
||||
customerModelRepositoryEF.Update(MySelectedItem);
|
||||
Customers = customerModelRepositoryEF.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (_LinqIsChecked)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryLinq = new CustomerRepositoryLinq();
|
||||
customerModelRepositoryLinq.Update(MySelectedItem);
|
||||
Customers = customerModelRepositoryLinq.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
if (!_EfIsChecked && !_LinqIsChecked)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var customerModelRepository = new CustomerRepository(TxtConnectionString);
|
||||
customerModelRepository.Update(this.NewCustomerEntry);
|
||||
customerModelRepository.Update(MySelectedItem);
|
||||
this.Customers = customerModelRepository.GetAll().ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -259,6 +345,7 @@ namespace LoggingClient.ViewModel
|
||||
MessageBox.Show("Error occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
|
@ -29,15 +29,13 @@ namespace LoggingClient.ViewModel
|
||||
}
|
||||
}
|
||||
private List<Location> _locations;
|
||||
public Location NewLocationModelEntry { get; set; }
|
||||
public Location SelectedItem { get; set; }
|
||||
public List<Node<Location>> LocationTree { get; set; }
|
||||
|
||||
public LocationViewModel()
|
||||
{
|
||||
TxtConnectionString = "Server=localhost;Database=inventarisierungsloesung;Uid=root;Pwd=MySQLPassword1234!;";
|
||||
Locations = new List<Location>();
|
||||
NewLocationModelEntry = new Location();
|
||||
|
||||
}
|
||||
public Location MySelectedItem { get; set; }
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
@ -126,7 +124,7 @@ namespace LoggingClient.ViewModel
|
||||
try
|
||||
{
|
||||
var locationModelRepository = new LocationRepository(TxtConnectionString);
|
||||
locationModelRepository.Add(this.NewLocationModelEntry);
|
||||
locationModelRepository.Add(SelectedItem);
|
||||
this.Locations = locationModelRepository.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -139,7 +137,7 @@ namespace LoggingClient.ViewModel
|
||||
try
|
||||
{
|
||||
var locationModelRepository = new LocationRepository(TxtConnectionString);
|
||||
locationModelRepository.Delete(this.NewLocationModelEntry);
|
||||
locationModelRepository.Delete(SelectedItem);
|
||||
this.Locations = locationModelRepository.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -152,7 +150,7 @@ namespace LoggingClient.ViewModel
|
||||
try
|
||||
{
|
||||
var locationModelRepository = new LocationRepository(TxtConnectionString);
|
||||
locationModelRepository.Update(this.NewLocationModelEntry);
|
||||
locationModelRepository.Update(SelectedItem);
|
||||
this.Locations = locationModelRepository.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -15,7 +15,7 @@
|
||||
<Grid Height="450" Width="800" Background="#FF89A9B2" >
|
||||
<TextBlock Height="32" HorizontalAlignment="Left" Margin="10,18,0,0" Name="TextBlockHeading" Text="Customers" VerticalAlignment="Top" Width="310" FontSize="20" FontStretch="Normal"/>
|
||||
<Grid HorizontalAlignment="Left" Height="416" VerticalAlignment="Top" Width="773">
|
||||
<DataGrid CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,55,0,131" Name="DataGridLogs" Width="763" ItemsSource="{Binding Path=Customers}" CanUserResizeRows="False">
|
||||
<DataGrid CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,55,0,131" x:Name="DataGridCustomer" Width="763" ItemsSource="{Binding Path=Customers}" CanUserResizeRows="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Path=customer_id}" Header="ID" Width="40" IsReadOnly="True" />
|
||||
<DataGridTextColumn Binding="{Binding Path=firstname}" Header="First Name" Width="70" IsReadOnly="True" />
|
||||
@ -35,7 +35,7 @@
|
||||
<Label Content="Firstname" HorizontalAlignment="Left" Margin="10,290,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="10,321,0,0" TextWrapping="Wrap" Name="EnterFirstName" VerticalAlignment="Top" Width="95">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewCustomerEntry.firstname" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.firstname" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="45"
|
||||
@ -48,7 +48,7 @@
|
||||
<Label Content="Lastname" HorizontalAlignment="Left" Margin="110,290,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="110,321,0,0" TextWrapping="Wrap" Name="EnterLastName" VerticalAlignment="Top" Width="95" >
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewCustomerEntry.lastname" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.lastname" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="45"
|
||||
@ -61,11 +61,10 @@
|
||||
<Label Content="CustomerNr" HorizontalAlignment="Left" Margin="210,290,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="210,321,0,0" TextWrapping="Wrap" Name="EnterCustomerNr" VerticalAlignment="Top" Width="95">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewCustomerEntry.customernumber" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.customernumber" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="45"
|
||||
ErrorMessage="Message must contain at least 1 character up to 45" />
|
||||
<validators:CustomerNumberValidationRule
|
||||
ErrorMessage="CU12345 - Pattern of a valid CustomerNumber" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
@ -73,11 +72,10 @@
|
||||
|
||||
<Label Content="Url" HorizontalAlignment="Left" Margin="310,291,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="310,321,0,0" TextWrapping="Wrap" x:Name="EnterUrl" VerticalAlignment="Top" Width="95">
|
||||
<Binding Path="NewCustomerEntry.url" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.url" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="30"
|
||||
ErrorMessage="Message must contain at least 1 characters up to 30" />
|
||||
<validators:UrlValidationRule
|
||||
ErrorMessage="Invalid URL." />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox>
|
||||
@ -85,7 +83,7 @@
|
||||
<Label Content="CustAcc ID" HorizontalAlignment="Left" Margin="10,346,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="10,372,0,0" TextWrapping="Wrap" Name="EnterCustAccFk" VerticalAlignment="Top" Width="95">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewCustomerEntry.kundenkonto_fk" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.kundenkonto_fk" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="8"/>
|
||||
@ -97,7 +95,7 @@
|
||||
<Label Content="Phone" HorizontalAlignment="Left" Margin="110,346,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="110,372,0,0" TextWrapping="Wrap" Name="EnterPhoneNumber" VerticalAlignment="Top" Width="95">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewCustomerEntry.tel" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.tel" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="20"
|
||||
@ -109,22 +107,20 @@
|
||||
|
||||
<Label Content="Email" HorizontalAlignment="Left" Margin="210,346,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="210,372,0,0" TextWrapping="Wrap" x:Name="EnterEmail" VerticalAlignment="Top" Width="95">
|
||||
<Binding Path="NewCustomerEntry.email" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.email" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="30"
|
||||
ErrorMessage="Message must contain at least 1 characters up to 30" />
|
||||
<validators:EmailValidationRule
|
||||
ErrorMessage="Invalid Email Address" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox>
|
||||
|
||||
<Label Content="Password" HorizontalAlignment="Left" Margin="310,347,0,0" VerticalAlignment="Top" Width="95"/>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="310,372,0,0" TextWrapping="Wrap" x:Name="EnterPassword" VerticalAlignment="Top" Width="95">
|
||||
<Binding Path="NewCustomerEntry.password" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding Path="MySelectedItem.password" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="255"
|
||||
ErrorMessage="Message must contain at least 1 character up to 255" />
|
||||
<validators:PasswordValidationRule
|
||||
ErrorMessage="1 lower, 1 UPPER-case, 1 number, 1 SpecialCaracter, 8-15 caracters" />
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<Grid Height="450" Width="800" Background="#FF89A9B2" >
|
||||
<TextBlock Height="32" HorizontalAlignment="Left" Margin="10,18,0,0" Name="TextBlockHeading" Text="Locations" VerticalAlignment="Top" Width="310" FontSize="20" FontStretch="Normal"/>
|
||||
<Grid HorizontalAlignment="Left" Height="416" VerticalAlignment="Top" Width="773">
|
||||
<DataGrid Validation.ErrorTemplate="{x:Null}" CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,196,0,76" Name="DataGridLocations" Width="763" ItemsSource="{Binding Path=Locations}" CanUserResizeRows="False">
|
||||
<DataGrid Validation.ErrorTemplate="{x:Null}" CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,196,0,76" x:Name="DataGridLocations" Width="763" ItemsSource="{Binding Path=Locations}" CanUserResizeRows="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Path=Id}" Header="id" Width="1*" IsReadOnly="True" />
|
||||
<DataGridTextColumn Binding="{Binding Path=ParentId}" Header="ParentId" Width="1*" IsReadOnly="True" />
|
||||
@ -34,7 +34,7 @@
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
|
||||
<!--<Button Content="Add" Height="25" HorizontalAlignment="Left" Margin="478,366,0,0" Name="BtnAdd" VerticalAlignment="Top" Width="70" Command="{Binding BtnAddDataClick}">
|
||||
<Button Content="Add" Height="25" HorizontalAlignment="Left" Margin="478,366,0,0" Name="BtnAdd" VerticalAlignment="Top" Width="70" Command="{Binding BtnAddDataClick}">
|
||||
<Button.Style>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Style.Triggers>
|
||||
@ -51,22 +51,15 @@
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="Update" Height="25" HorizontalAlignment="Left" Margin="553,366,0,0" Name="BtnUpdateDataClick" VerticalAlignment="Top" Width="70" Command="{Binding BtnUpdateDataClick}" />-->
|
||||
<Button Content="Update" Height="25" HorizontalAlignment="Left" Margin="553,366,0,0" Name="BtnUpdateDataClick" VerticalAlignment="Top" Width="70" Command="{Binding BtnUpdateDataClick}" />
|
||||
<Button Content="Load Data" Height="25" HorizontalAlignment="Left" Margin="628,366,0,0" Name="BtnLoadDataClick" VerticalAlignment="Top" Width="70" Command="{Binding BtnLoadDataClick}" />
|
||||
<!--<Button Content="Delete" Height="25" HorizontalAlignment="Left" Margin="703,366,0,0" Name="BtnDeleteDataClick" VerticalAlignment="Top" Width="70" Command="{Binding BtnDeleteDataClick}"/>-->
|
||||
<Button Content="Delete" Height="25" HorizontalAlignment="Left" Margin="703,366,0,0" Name="BtnDeleteDataClick" VerticalAlignment="Top" Width="70" Command="{Binding BtnDeleteDataClick}"/>
|
||||
|
||||
<TextBox HorizontalAlignment="Left" Height="23" Margin="248,22,0,0" TextWrapping="Wrap" Text="{Binding TxtConnectionString}" Name="TxtConnectionString" VerticalAlignment="Top" Width="525" />
|
||||
<!--<TextBox HorizontalAlignment="Left" Height="25" Margin="10,366,0,0" TextWrapping="Wrap" x:Name="LocationId" VerticalAlignment="Top" Width="80" >
|
||||
<Binding Path="NewLocationModelEntry.AddressId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="95,366,0,0" TextWrapping="Wrap" Name="EnterParentId" VerticalAlignment="Top" Width="80">
|
||||
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="10,366,0,0" TextWrapping="Wrap" Name="EnterParentId" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.ParentId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding ElementName="DataGridLocations" Path="SelectedItem.ParentId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
@ -74,9 +67,17 @@
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="95,366,0,0" TextWrapping="Wrap" x:Name="AddressId" VerticalAlignment="Top" Width="80" >
|
||||
<Binding ElementName="DataGridLocations" Path="SelectedItem.AddressId" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
MinimumLength="1" MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="180,366,0,0" TextWrapping="Wrap" Name="EnterDesignation" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.Designation" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding ElementName="DataGridLocations" Path="SelectedItem.Designation" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:StringRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="45"
|
||||
@ -88,7 +89,7 @@
|
||||
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="265,366,0,0" TextWrapping="Wrap" Name="EnterBuildingNr" VerticalAlignment="Top" Width="80">
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.BuildingNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding ElementName="DataGridLocations" Path="SelectedItem.BuildingNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
@ -98,23 +99,23 @@
|
||||
</TextBox>
|
||||
<TextBox HorizontalAlignment="Left" Height="25" Margin="350,366,0,0" TextWrapping="Wrap" Name="EnterRoomNr" VerticalAlignment="Top" Width="80" >
|
||||
<TextBox.Text>
|
||||
<Binding Path="NewLocationModelEntry.RoomNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding ElementName="DataGridLocations" Path="SelectedItem.RoomNr" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<validators:IntRangeValidationRule
|
||||
validators:MinimumLength="1" validators:MaximumLength="10000"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>-->
|
||||
</TextBox>
|
||||
|
||||
<!--<ComboBox x:Name="SeverityCombobox" DisplayMemberPath="Severity" SelectedValuePath="id" ItemsSource="{Binding SeverityComboBox}" SelectedValue="{Binding Path=Severity , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="240,359,470,66" Width="90" Height="25"/>-->
|
||||
<ComboBox x:Name="SeverityCombobox" DisplayMemberPath="Severity" SelectedValuePath="id" ItemsSource="{Binding SeverityComboBox}" SelectedValue="{Binding Path=Severity , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="240,359,470,66" Width="90" Height="25"/>
|
||||
|
||||
<Label Content="Database Connection" HorizontalAlignment="Left" Margin="118,22,0,0" VerticalAlignment="Top" Height="23" Width="125" Background="{x:Null}" RenderTransformOrigin="0.366,0.725"/>
|
||||
<!--<Label Content="LocationId" HorizontalAlignment="Left" Margin="10,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="ParentId" HorizontalAlignment="Left" Margin="95,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="ParentId" HorizontalAlignment="Left" Margin="10,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="AddressId" HorizontalAlignment="Left" Margin="95,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="Designation" HorizontalAlignment="Left" Margin="180,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="BuildingNr" HorizontalAlignment="Left" Margin="265,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
<Label Content="RoomNr" HorizontalAlignment="Left" Margin="350,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>-->
|
||||
<Label Content="RoomNr" HorizontalAlignment="Left" Margin="350,340,0,0" VerticalAlignment="Top" Width="80" FontSize="12"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6B9F572F-AE97-4A52-89AD-4453BC51E038}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LoggingClientUnitTest</RootNamespace>
|
||||
<AssemblyName>LoggingClientUnitTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="RegEx.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LoggingClient\LoggingClient.csproj">
|
||||
<Project>{2622c2fc-3522-4d6f-b021-f63a243e77f1}</Project>
|
||||
<Name>LoggingClient</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" />
|
||||
</Project>
|
@ -0,0 +1,20 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("LoggingClientUnitTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LoggingClientUnitTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("6b9f572f-ae97-4a52-89ad-4453bc51e038")]
|
||||
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
284
LoggingClient/LoggingClientUnitTest/RegEx.cs
Normal file
284
LoggingClient/LoggingClientUnitTest/RegEx.cs
Normal file
@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using LoggingClient.Validators;
|
||||
|
||||
namespace LoggingClientUnitTest
|
||||
{
|
||||
[TestClass]
|
||||
public class RegEx
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_True()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("CU12345", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_False()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("CU123456", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_lower_False()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("cu12345", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_wrongChar_False()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("ab12345", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_wrongCharUpper_False()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("ZZ12345", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCustomerNumberRegex_onlyDigit_False()
|
||||
{
|
||||
// arrange
|
||||
var customerNumberValidationRule = new CustomerNumberValidationRule();
|
||||
// act
|
||||
var result = customerNumberValidationRule.Validate("0012345", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestEmailRegex_True()
|
||||
{
|
||||
// arrange
|
||||
var emailValidationRule = new EmailValidationRule();
|
||||
// act
|
||||
var result = emailValidationRule.Validate("test.test@test.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
[TestMethod]
|
||||
public void TestEmailRegex_False()
|
||||
{
|
||||
// arrange
|
||||
var emailValidationRule = new EmailValidationRule();
|
||||
// act
|
||||
var result = emailValidationRule.Validate("test.test@.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestEmailRegex_2_False()
|
||||
{
|
||||
// arrange
|
||||
var emailValidationRule = new EmailValidationRule();
|
||||
// act
|
||||
var result = emailValidationRule.Validate("test..test@a.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestEmailRegex_3_False()
|
||||
{
|
||||
// arrange
|
||||
var emailValidationRule = new EmailValidationRule();
|
||||
// act
|
||||
var result = emailValidationRule.Validate("test.test@a_com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestIntRangeValidation_True()
|
||||
{
|
||||
// arrange
|
||||
var intRangeValidationRule = new IntRangeValidationRule();
|
||||
// act
|
||||
var result = intRangeValidationRule.Validate("8", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestIntRangeValidation_False()
|
||||
{
|
||||
// arrange
|
||||
var intRangeValidationRule = new IntRangeValidationRule();
|
||||
// act
|
||||
var result = intRangeValidationRule.Validate("100", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPasswordRegex_True()
|
||||
{
|
||||
// arrange
|
||||
var passwordValidationRule = new PasswordValidationRule();
|
||||
// act
|
||||
var result = passwordValidationRule.Validate("Test1234?", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPasswordRegex_noLenght_False()
|
||||
{
|
||||
// arrange
|
||||
var passwordValidationRule = new PasswordValidationRule();
|
||||
// act
|
||||
var result = passwordValidationRule.Validate("Test12!", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPasswordRegex_nolower_False()
|
||||
{
|
||||
// arrange
|
||||
var passwordValidationRule = new PasswordValidationRule();
|
||||
// act
|
||||
var result = passwordValidationRule.Validate("TWST1234!", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPasswordRegex_noUpper_False()
|
||||
{
|
||||
// arrange
|
||||
var passwordValidationRule = new PasswordValidationRule();
|
||||
// act
|
||||
var result = passwordValidationRule.Validate("test1234!", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPasswordRegex_noSpecials_False()
|
||||
{
|
||||
// arrange
|
||||
var passwordValidationRule = new PasswordValidationRule();
|
||||
// act
|
||||
var result = passwordValidationRule.Validate("test1234", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestStringRangeValidation_True()
|
||||
{
|
||||
// arrange
|
||||
var stringRangeValidationRule = new StringRangeValidationRule();
|
||||
// act
|
||||
var result = stringRangeValidationRule.Validate("Test", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestStringRangeValidation_False()
|
||||
{
|
||||
// arrange
|
||||
var stringRangeValidationRule = new StringRangeValidationRule();
|
||||
// act
|
||||
var result = stringRangeValidationRule.Validate("", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_subdomain_True()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("www.google.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_prefix_True()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("https://google.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_prefix_subdomain_True()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("https://www.google.com", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_prefix_subdomain_endpoint_True()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("https://www.google.com/passwords", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_prefix_subdomain_endpoint_query_True()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("https://www.google.com/passwords?lernen.zbw=rafr1", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsTrue(result.IsValid);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestUrlRegex_False()
|
||||
{
|
||||
// arrange
|
||||
var urlValidationRule = new UrlValidationRule();
|
||||
// act
|
||||
var result = urlValidationRule.Validate("google", CultureInfo.CurrentCulture);
|
||||
// assert
|
||||
Assert.IsFalse(result.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
5
LoggingClient/LoggingClientUnitTest/packages.config
Normal file
5
LoggingClient/LoggingClientUnitTest/packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MSTest.TestAdapter" version="2.1.1" targetFramework="net472" />
|
||||
<package id="MSTest.TestFramework" version="2.1.1" targetFramework="net472" />
|
||||
</packages>
|
23
README.md
23
README.md
@ -69,27 +69,24 @@ Button Erklärung:
|
||||
|
||||
## Generics
|
||||
|
||||
Mit dem Reiter kann Zwischen Location und Logs gewechselt werden.
|
||||
|
||||
Logs gleiche Funktionalität unverändert.
|
||||
|
||||
Location können die vorhandenen Locaiton abgerufen werden und in einer Baumstruktur angezeigt werden.
|
||||
|
||||
Implementationen wie Add, Update und Delete sind vorhanden aber keine UI bereitgelegt da diese noch Fehlerhaft sind.
|
||||
|
||||
TODO: Add, Update, Delete produktiv implementieren.
|
||||
Die Ganze Architektur auf Generics umgeschrieben.
|
||||
|
||||
## LINQ
|
||||
|
||||
|
||||
Implementierung von einem Radiobutton um die Möglichkeit zu haben die DB-Abragen via LINQ to SQL zu tätigen.
|
||||
|
||||
## RegEx
|
||||
|
||||
Die Felder `Email`, `URL`, `Passwort` und `CustomerNumber` folgen die Constraint der Aufgabenstellung.
|
||||
|
||||
Email: Gültige Mailadresse
|
||||
|
||||
URL: Verschiedene Schreibweisen mit, ohne https:// und mit und ohne Querystrings.
|
||||
|
||||
Passwort: 8 - 15 Zeichen, min 1 Gross-, 1 Kleinbuchstabe, 1 Zahl und 1 Sonderzeichen.
|
||||
|
||||
CustomerNumber: Beginnend mit CU und folgt von 5 Zahlen.
|
||||
|
||||
## Inversion of Control
|
||||
|
||||
|
||||
|
||||
## Reflection & Serialization
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user