Commit 6ecb8f36 authored by Nikita Kums's avatar Nikita Kums
Browse files

1

parent 814a1a99
Pipeline #113 canceled with stages
......@@ -5,4 +5,9 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DAL\DAL.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
</Project>
using System;
using System.Linq;
using DAL;
using Domain;
namespace ConsoleApp
{
......@@ -7,6 +10,31 @@ namespace ConsoleApp
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var dbContext = new DbContext();
dbContext.ContactTypes.Add(new ContactType("Discord"));
dbContext.Persons.Add(new Person("Kati", "REE"));
dbContext.Contacts.Add(
new Contact(
"KatiR",
dbContext.Persons.First(p => p.FirstName == "Kati" && p.LastName == "REE"),
dbContext.ContactTypes.First(c => c.ContactTypeValue == "Discord")
));
var contactType = new ContactType("Discord");
var person = new Person("Kati", "REE");
var person1 = new Contact("KatiR", person, contactType);
PrintPerson(person);
}
static void PrintPerson(Person person)
{
Console.WriteLine(person + " Contact: " + person.Contacts.Count);
foreach (var contact in person.Contacts)
{
Console.WriteLine("\t" + contact.ContactValue + " - " + contact.ContactType);
}
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using Domain;
namespace DAL
{
public class DbContext
{
public List<Person> Persons { get; set; } = new List<Person>();
public List<Contact> Contacts { get; set; } = new List<Contact>();
public List<ContactType> ContactTypes { get; set; } = new List<ContactType>();
}
}
\ No newline at end of file
......@@ -4,10 +4,14 @@ namespace Domain
{
public string ContactValue { get; set; }
public Contact(Person person, ContactType contactType)
public Contact(string contactValue, Person person, ContactType contactType)
{
ContactValue = contactValue;
Person = person;
ContactType = contactType;
person.Contacts.Add(this);
contactType.Contacts.Add(this);
}
public Person Person { get; set; }
......
......@@ -6,7 +6,16 @@ namespace Domain
{
public string ContactTypeValue { get; set; }
public ContactType(string contactTypeValue)
{
ContactTypeValue = contactTypeValue;
}
public List<Contact> Contacts { get; set; } = new List<Contact>();
public override string ToString()
{
return ContactTypeValue;
}
}
}
\ No newline at end of file
......@@ -8,6 +8,17 @@ namespace Domain
public string FirstName { get; set; }
public string LastName { get; set; }
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public List<Contact> Contacts { get; set; } = new List<Contact>();
public override string ToString()
{
return FirstName + " " + LastName;
}
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\Co
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{EC36D18E-BAAD-445E-B60A-3F34642B96E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{46891E68-E56B-49CA-9BAF-11B46B5AAB31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -18,5 +20,9 @@ Global
{EC36D18E-BAAD-445E-B60A-3F34642B96E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC36D18E-BAAD-445E-B60A-3F34642B96E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC36D18E-BAAD-445E-B60A-3F34642B96E2}.Release|Any CPU.Build.0 = Release|Any CPU
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment