Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nikita Kums
csharp_2018fall_daytime
Commits
9ba9d827
Commit
9ba9d827
authored
Sep 28, 2018
by
Nikita Kums
Browse files
1
parent
6ecb8f36
Pipeline
#118
failed with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ConsoleApp/Dbinitializer.cs
0 → 100644
View file @
9ba9d827
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
ConsoleApp/Program.cs
View file @
9ba9d827
...
@@ -9,23 +9,47 @@ namespace ConsoleApp
...
@@ -9,23 +9,47 @@ namespace ConsoleApp
{
{
static
void
Main
(
string
[]
args
)
static
void
Main
(
string
[]
args
)
{
{
Console
.
WriteLine
(
"Hello World!"
);
var
dbContext
=
new
DbContext
();
var
dbContext
=
new
DbContext
();
dbContext
.
ContactTypes
.
Add
(
new
ContactType
(
"Discord"
));
dbContext
.
initialize
();
dbContext
.
Persons
.
Add
(
new
Person
(
"Kati"
,
"REE"
));
dbContext
.
Contacts
.
Add
(
//PrintPerson(dbContext.Persons.First(p => p.FirstName == "Kati" && p.LastName == "REE"));
new
Contact
(
"KatiR"
,
/*var contactType = new ContactType("Discord");
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 person = new Person("Kati", "REE");
var person1 = new Contact("KatiR", person, contactType);
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
)
static
void
PrintPerson
(
Person
person
)
...
...
MenuSystem/Menu.cs
0 → 100644
View file @
9ba9d827
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
MenuSystem/MenuItem.cs
0 → 100644
View file @
9ba9d827
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
MenuSystem/MenuSystem.csproj
0 → 100644
View file @
9ba9d827
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
Prax_2018fall_daytime.sln
View file @
9ba9d827
...
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csp
...
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csp
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{46891E68-E56B-49CA-9BAF-11B46B5AAB31}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{46891E68-E56B-49CA-9BAF-11B46B5AAB31}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MenuSystem", "MenuSystem\MenuSystem.csproj", "{CACEA9A7-0E31-476A-B220-B3D75EFE119C}"
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Any CPU = Debug|Any CPU
...
@@ -24,5 +26,9 @@ Global
...
@@ -24,5 +26,9 @@ Global
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{46891E68-E56B-49CA-9BAF-11B46B5AAB31}.Release|Any CPU.Build.0 = 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
EndGlobalSection
EndGlobal
EndGlobal
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment