Commit 9ba9d827 authored by Nikita Kums's avatar Nikita Kums
Browse files

1

parent 6ecb8f36
Pipeline #118 failed with stages
using System.Linq;
using DAL;
using Domain;
namespace ConsoleApp
{
public static class Dbinitializer
{
public static void initialize(this DbContext dbContext)
{
dbContext.ContactTypes.Add(new ContactType("Discord"));
dbContext.Persons.Add(new Person("test1", "test1"));
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")
));
// Func<parameter0, p1, ..., p16, returnType> -
// give me an method, with p0-pxx parameters (can be none) and return me returnTpe value
/*
* Same as the p => ... lambda expression
*
* db.Context.Persons.First(p => IsPerson(p, "Kati", "REE"))
*
* static void bool IsPerson(Person person, string firstName, string lastName){
* if (person.FirstName == firstName && person.LastName == lastName) return true;
* return false
* }
*
* Same thing, different implementation
*
* db.Context.Persons.First(IsPerson)
*
* static static bool IsPerson(Person person){
* if (person.FirstName == firstName && person.LastName == lastName) return true;
* return false
* }
*/
}
}
}
\ No newline at end of file
......@@ -9,23 +9,47 @@ 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");
dbContext.initialize();
//PrintPerson(dbContext.Persons.First(p => p.FirstName == "Kati" && p.LastName == "REE"));
/*var contactType = new ContactType("Discord");
var person = new Person("Kati", "REE");
var person1 = new Contact("KatiR", person, contactType);
PrintPerson(person);
//PrintPerson(person);*/
var done = false;
do
{
Console.WriteLine("--------Main---------");
Console.WriteLine("P) Person");
Console.WriteLine("C) Contact");
Console.WriteLine("T) ContactType");
Console.WriteLine("---------------------");
Console.WriteLine("Q) Back");
Console.Write("Please choose>");
var input = Console.ReadLine().ToUpper();
switch (input)
{
case "P":
break;
case "C":
break;
case "T":
break;
case "Q":
done = true;
break;
default:
Console.WriteLine("Meh");
break;
}
} while (!done);
}
static void PrintPerson(Person person)
......
using System;
using System.Collections.Generic;
namespace MenuSystem
{
public class Menu
{
public string Title { get; set; }
public List<MenuItem> MenuItems { get; set; } = new List<MenuItem>();
public MenuItem GoBackItem { get; set; } = new MenuItem()
{
Command = "X",
Description = "Go back"
};
public void PrintMenu()
{
Console.WriteLine("--------" + Title + "--------");
foreach (var menuItem in MenuItems)
{
Console.WriteLine(menuItem);
}
Console.WriteLine("----------------");
Console.WriteLine(GoBackItem);
}
}
}
\ No newline at end of file
using System;
namespace MenuSystem
{
public class MenuItem
{
public string Command { get; set; }
public string Description { get; set; }
public override string ToString()
{
return Command + ") " + Description;
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
......@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{46891E68-E56B-49CA-9BAF-11B46B5AAB31}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MenuSystem", "MenuSystem\MenuSystem.csproj", "{CACEA9A7-0E31-476A-B220-B3D75EFE119C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -24,5 +26,9 @@ Global
{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
{CACEA9A7-0E31-476A-B220-B3D75EFE119C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CACEA9A7-0E31-476A-B220-B3D75EFE119C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CACEA9A7-0E31-476A-B220-B3D75EFE119C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CACEA9A7-0E31-476A-B220-B3D75EFE119C}.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