This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Oskarowski/dev-task-1-wk
Task 1 - attempt 1
- Loading branch information
Showing
31 changed files
with
1,136 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLayer", "Library\DataLayer\DataLayer.csproj", "{37F35CAD-0E16-44DE-B1EC-B8806B87AF27}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Library\Tests\Tests.csproj", "{E482E32E-3CA7-46DD-83C9-B094E0AD8BA3}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{B858A003-F5DD-4F95-99D9-5A7560A0B8CF}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogicLayer", "Library\LogicLayer\LogicLayer.csproj", "{34D82E95-A0C6-4C12-8BB0-6836280E2491}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{37F35CAD-0E16-44DE-B1EC-B8806B87AF27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{37F35CAD-0E16-44DE-B1EC-B8806B87AF27}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{37F35CAD-0E16-44DE-B1EC-B8806B87AF27}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{37F35CAD-0E16-44DE-B1EC-B8806B87AF27}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E482E32E-3CA7-46DD-83C9-B094E0AD8BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E482E32E-3CA7-46DD-83C9-B094E0AD8BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E482E32E-3CA7-46DD-83C9-B094E0AD8BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E482E32E-3CA7-46DD-83C9-B094E0AD8BA3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{34D82E95-A0C6-4C12-8BB0-6836280E2491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{34D82E95-A0C6-4C12-8BB0-6836280E2491}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{34D82E95-A0C6-4C12-8BB0-6836280E2491}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{34D82E95-A0C6-4C12-8BB0-6836280E2491}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B8DC2F37-8FC7-433C-BA78-56CAE077B47B} | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{34D82E95-A0C6-4C12-8BB0-6836280E2491} = {B858A003-F5DD-4F95-99D9-5A7560A0B8CF} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IBook : IProduct | ||
{ | ||
string Author { get; set; } | ||
string Publisher { get; set; } | ||
int Pages { get; set; } | ||
DateTime PublicationDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IDataContext | ||
{ | ||
public List<IUser> Users { get; set; } | ||
|
||
public List<IProduct> Products { get; set; } | ||
|
||
public List<IEvent> Events { get; set; } | ||
|
||
public List<IState> States { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IDataFiller | ||
{ | ||
void Fill(IDataContext context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using DataLayer.Implementations; | ||
|
||
namespace DataLayer.API | ||
{ | ||
public interface IDataRepository | ||
{ | ||
static IDataRepository CreateDataRepository(IDataContext dataContext) | ||
{ | ||
return new DataRepository(dataContext); | ||
} | ||
|
||
#region User | ||
void AddUser(IUser user); | ||
IUser GetUser(string guid); | ||
List<IUser> GetAllUsers(); | ||
void RemoveUser(string guid); | ||
bool DoesUserExist(string guid); | ||
void UpdateUser(IUser updateUser); | ||
#endregion | ||
|
||
#region Product | ||
void AddProduct(IProduct product); | ||
IProduct GetProduct(string guid); | ||
List<IProduct> GetAllProducts(); | ||
IProduct GetProductByState(string stateGuid); | ||
bool DoesProductExist(string guid); | ||
|
||
void RemoveProduct(string guid); | ||
#endregion | ||
|
||
#region Event | ||
void AddEvent(IEvent @event); | ||
IEvent GetEvent(string guid); | ||
List<IEvent> GetAllEvents(); | ||
List<IEvent> GetEventsByUser(string userGuid); | ||
List<IEvent> GetEventsByProduct(string productGuid); | ||
List<IEvent> GetEventsByState(string stateGuid); | ||
void RemoveEvent(string guid); | ||
#endregion | ||
|
||
#region State | ||
void AddState(IState state); | ||
IState GetState(string guid); | ||
List<IState> GetAllStates(); | ||
void RemoveState(string guid); | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IEvent | ||
{ | ||
string Guid { get; } | ||
IUser User { get; } | ||
IState State { get; } | ||
DateTime CreatedAt { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IProduct | ||
{ | ||
string Guid { get; } | ||
string Name { get; set; } | ||
double Price { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IState | ||
{ | ||
IProduct Product { get; set; } | ||
int Quantity { get; set; } | ||
DateTime LastUpdatedDate { get; } | ||
string Guid { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace DataLayer.API | ||
{ | ||
public interface IUser | ||
{ | ||
// guid, because is more commonly used in contexts of the Microsoft ecosystem | ||
string Guid { get; } | ||
string FirstName { get; set; } | ||
string LastName { get; set; } | ||
string Email { get; set; } | ||
double Balance { get; set; } | ||
// stick to E.164 standard? | ||
int PhoneNumber { get; set; } | ||
// string Role { get; set; } | ||
Dictionary<string, IProduct> ProductsDic { get; set; } | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...tanceCalculator/DistanceCalculator.csproj → Library/DataLayer/DataLayer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using DataLayer.API; | ||
|
||
namespace DataLayer.Implementations | ||
{ | ||
public class Book : IBook | ||
{ | ||
public Book(string name, double price, string author, string publisher, int pages, DateTime publicationDate) | ||
{ | ||
Guid = System.Guid.NewGuid().ToString(); | ||
Name = name; | ||
Price = price; | ||
Author = author; | ||
Publisher = publisher; | ||
Pages = pages; | ||
PublicationDate = publicationDate; | ||
} | ||
public string Guid { get; } | ||
public string Name { get; set; } | ||
public double Price { get; set; } | ||
public string Author { get; set; } | ||
public string Publisher { get; set; } | ||
public int Pages { get; set; } | ||
public DateTime PublicationDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using DataLayer.API; | ||
|
||
namespace DataLayer.Implementations | ||
{ | ||
public class DataContext : IDataContext | ||
{ | ||
public List<IUser> Users { get; set; } | ||
public List<IProduct> Products { get; set; } | ||
public List<IEvent> Events { get; set; } | ||
public List<IState> States { get; set; } | ||
|
||
public DataContext() | ||
{ | ||
Users = new List<IUser>(); | ||
Products = new List<IProduct>(); | ||
Events = new List<IEvent>(); | ||
States = new List<IState>(); | ||
} | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Library/DataLayer/Implementations/DataFillers/PresetFiller.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using DataLayer.API; | ||
using DataLayer.Implementations.Events; | ||
|
||
namespace DataLayer.Implementations | ||
{ | ||
public class PresetFiller : IDataFiller | ||
{ | ||
public void Fill(IDataContext context) | ||
{ | ||
context.Users.Add(new User("John", "Doe", "johndoe@email", 100, 123456789, null)); | ||
context.Users.Add(new User("Jane", "Doe", "janedoe@email", 200, 111111111, null)); | ||
context.Users.Add(new User("Alice", "Smith", "alicesmith@email", 300, 121212121, null)); | ||
context.Users.Add(new User("Bob", "Smith", "bobsmith@email", 400, 987654321, null)); | ||
context.Users.Add(new User("Charlie", "Brown", "charliebrown@email", 500, 999999999, null)); | ||
|
||
context.Products.Add(new Book("Old Man and the Sea", 10, "Ernest Hemingway", "Charles Sons", 300, new DateTime(1952, 1, 1))); | ||
context.Products.Add(new Book("The Great Gatsby", 20, "F. Scott Fitzgerald", "Charles Sons", 400, new DateTime(1925, 1, 1))); | ||
context.Products.Add(new Book("To Kill a Mockingbird", 30, "Harper Lee", "Charles Sons", 500, new DateTime(1960, 1, 1))); | ||
context.Products.Add(new Book("1984", 40, "George Orwell", "Charles Sons", 600, new DateTime(1949, 1, 1))); | ||
context.Products.Add(new Book("Brave New World", 50, "Aldous Huxley", "Charles Sons", 700, new DateTime(1932, 1, 1))); | ||
|
||
context.States.Add(new State(context.Products[0], 5)); | ||
context.States.Add(new State(context.Products[1], 5)); | ||
context.States.Add(new State(context.Products[2], 5)); | ||
context.States.Add(new State(context.Products[3], 5)); | ||
context.States.Add(new State(context.Products[4], 5)); | ||
|
||
context.Events.Add(new Borrow(context.Users[0], context.States[0])); | ||
context.Events.Add(new Borrow(context.Users[1], context.States[1])); | ||
context.Events.Add(new Borrow(context.Users[3], context.States[3])); | ||
context.Events.Add(new Return(context.Users[0], context.States[0])); | ||
context.Events.Add(new Return(context.Users[1], context.States[1])); | ||
context.Events.Add(new Return(context.Users[3], context.States[3])); | ||
context.Events.Add(new Delivery(context.Users[4], context.States[4], 10)); | ||
} | ||
} | ||
} |
Oops, something went wrong.