Added all DataModels, Converters and Menagments

This commit is contained in:
Arkadiusz Jurga 2018-11-15 23:49:14 +01:00
parent eea7c149b0
commit 82d321f771
12 changed files with 249 additions and 0 deletions

View File

@ -0,0 +1,29 @@
using DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Converters
{
class ConvertContactPerson
{
public static ContactPersons ConvertDBContactPersonToContactPerson (ContactPerson dbContactPerson)
{
ContactPersons contactPersons = new ContactPersons
{
Id = dbContactPerson.Id,
IdCustomer = dbContactPerson.IdCustomer,
IdUser = dbContactPerson.IdUser,
Name = dbContactPerson.Name,
Surname = dbContactPerson.Surname,
TelephonNumber = dbContactPerson.TelephonNumber,
Email = dbContactPerson.Email,
Position = dbContactPerson.Position,
IsDeleted = dbContactPerson.IsDeleted
};
return contactPersons;
}
}
}

View File

@ -0,0 +1,25 @@
using DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Converters
{
class ConvertNote
{
public static Notes ConvertDBNoteToNote (Note dbNote)
{
Notes note = new Notes
{
Id = dbNote.Id,
IdCustomer = dbNote.IdCustomer,
IdUser = dbNote.IdUser,
Contents = dbNote.Contents,
IsDeleted = dbNote.IsDeleted
};
return note;
}
}
}

View File

@ -0,0 +1,23 @@
using DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Converters
{
class ConvertTrade
{
public static Trades ConvertDBTradeToTrade(Trade dbTrade)
{
Trades trade = new Trades
{
Id = dbTrade.Id,
Name = dbTrade.Name
};
return trade;
}
}
}

View File

@ -54,9 +54,16 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\ConvertContactPerson.cs" />
<Compile Include="Converters\ConvertCustomer.cs" />
<Compile Include="Converters\ConvertNote.cs" />
<Compile Include="Converters\ConvertRole.cs" />
<Compile Include="Converters\ConvertTrade.cs" />
<Compile Include="Menagments\ContactPersonMenagment.cs" />
<Compile Include="Menagments\CustomerMenagment.cs" />
<Compile Include="Menagments\NoteMenagment.cs" />
<Compile Include="Menagments\RoleMenagment.cs" />
<Compile Include="Menagments\TradeMenagment.cs" />
<Compile Include="Menagments\UserMenagment.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,26 @@
using DataModels;
using DBconnection.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Menagments
{
public class ContactPersonMenagment
{
public List<ContactPersons> GetAllContactPersons()
{
LINQconecctionDataContext baza = new LINQconecctionDataContext();
List<ContactPerson> dbContactPerson = baza.ContactPerson.ToList();
List<ContactPersons> contactPersons = new List<ContactPersons>();
foreach (var dbCP in dbContactPerson)
{
contactPersons.Add(ConvertContactPerson.ConvertDBContactPersonToContactPerson(dbCP));
}
return contactPersons;
}
}
}

View File

@ -0,0 +1,26 @@
using DataModels;
using DBconnection.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Menagments
{
public class CustomerMenagment
{
public List<Customers> GetAllCustomers()
{
LINQconecctionDataContext baza = new LINQconecctionDataContext();
List<Customer> dbCustomers = baza.Customer.ToList();
List<Customers> customers = new List<Customers>();
foreach (var dbCust in dbCustomers)
{
customers.Add(ConvertCustomer.ConvertDBCustomerToCustomer(dbCust));
}
return customers;
}
}
}

View File

@ -0,0 +1,25 @@
using DataModels;
using DBconnection.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Menagments
{
public class NoteMenagment
{
public List<Notes> GetAllNotes()
{
LINQconecctionDataContext baza = new LINQconecctionDataContext();
List<Note> dbNotes = baza.Note.ToList();
List<Notes> notes = new List<Notes>();
foreach (var dbNote in dbNotes)
{
notes.Add(ConvertNote.ConvertDBNoteToNote(dbNote));
}
return notes;
}
}
}

View File

@ -0,0 +1,25 @@
using DataModels;
using DBconnection.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DBconnection.Menagments
{
public class TradeMenagment
{
public List<Trades> GetAllTrades()
{
LINQconecctionDataContext baza = new LINQconecctionDataContext();
List<Trade> dbTrades = baza.Trade.ToList();
List<Trades> trades = new List<Trades>();
foreach (var dbtrade in dbTrades)
{
trades.Add(ConvertTrade.ConvertDBTradeToTrade(dbtrade));
}
return trades;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DataModels
{
public class ContactPersons
{
int id, idCustomer, idUser;
string name, surname, telephonNumber, email, position;
bool isDeleted;
public int Id { get => id; set => id = value; }
public int IdCustomer { get => idCustomer; set => idCustomer = value; }
public int IdUser { get => idUser; set => idUser = value; }
public string Name { get => name; set => name = value; }
public string Surname { get => surname; set => surname = value; }
public string TelephonNumber { get => telephonNumber; set => telephonNumber = value; }
public string Email { get => email; set => email = value; }
public string Position { get => position; set => position = value; }
public bool IsDeleted { get => isDeleted; set => isDeleted = value; }
}
}

View File

@ -40,8 +40,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ContactPersons.cs" />
<Compile Include="Customers.cs" />
<Compile Include="Notes.cs" />
<Compile Include="Role.cs" />
<Compile Include="Trades.cs" />
<Compile Include="User.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

20
DataModels/Notes.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DataModels
{
public class Notes
{
int id, idCustomer, idUser;
string contents;
bool isDeleted;
public int Id { get => id; set => id = value; }
public int IdCustomer { get => idCustomer; set => idCustomer = value; }
public int IdUser { get => idUser; set => idUser = value; }
public string Contents { get => contents; set => contents = value; }
public bool IsDeleted { get => isDeleted; set => isDeleted = value; }
}
}

16
DataModels/Trades.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DataModels
{
public class Trades
{
int id;
string name;
public int Id { get => id; set => id = value; }
public string Name { get => name; set => name = value; }
}
}