forked from ahmet-cetinkaya/ReCapProject
-
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.
- Loading branch information
1 parent
8211e3d
commit cdb7ad6
Showing
14 changed files
with
322 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Entities.Concrete; | ||
|
||
namespace Business.Abstract | ||
{ | ||
public interface ICarService | ||
{ | ||
Car GetById(int id); | ||
|
||
List<Car> GetAll(); | ||
|
||
void Add(Car car); | ||
|
||
void Update(Car car); | ||
|
||
void Delete(Car car); | ||
} | ||
} |
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DataAccess\DataAccess.csproj" /> | ||
<ProjectReference Include="..\Entities\Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Business.Abstract; | ||
using DataAccess.Abstract; | ||
using Entities.Concrete; | ||
|
||
namespace Business.Concrete | ||
{ | ||
public class CarManager : ICarService | ||
{ | ||
private ICarDal _carDal; | ||
|
||
public CarManager(ICarDal carDal) | ||
{ | ||
_carDal = carDal; | ||
} | ||
|
||
public Car GetById(int id) | ||
{ | ||
// Debug and Conditions | ||
|
||
return _carDal.GetById(id); | ||
} | ||
|
||
public List<Car> GetAll() | ||
{ | ||
// Debug and Conditions | ||
|
||
return _carDal.GetAll(); | ||
} | ||
|
||
public void Add(Car car) | ||
{ | ||
// Debug and Conditions | ||
|
||
_carDal.Add(car); | ||
} | ||
|
||
public void Update(Car car) | ||
{ | ||
// Debug and Conditions | ||
|
||
_carDal.Update(car); | ||
} | ||
|
||
public void Delete(Car car) | ||
{ | ||
// Debug and Conditions | ||
|
||
_carDal.Delete(car); | ||
} | ||
} | ||
} |
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Business\Business.csproj" /> | ||
<ProjectReference Include="..\DataAccess\DataAccess.csproj" /> | ||
<ProjectReference Include="..\Entities\Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,31 @@ | ||
using System; | ||
using Business.Concrete; | ||
using Business.Concrete.InMemory; | ||
using Entities.Concrete; | ||
|
||
namespace ConsoleUI | ||
{ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
CarManager carManager = new CarManager(new InMemoryCarDal()); | ||
|
||
carManager.GetAll().ForEach(p => Console.WriteLine(p.DailyPrice)); | ||
|
||
Console.WriteLine(carManager.GetById(1).DailyPrice); | ||
|
||
Car newCar = new Car | ||
{ Id = 6, BrandId = 1, ColorId = 2, ModelYear = 2019, DailyPrice = 500, Description = "f" }; | ||
|
||
carManager.Add(newCar); | ||
Console.WriteLine(carManager.GetById(6).DailyPrice); | ||
|
||
newCar.DailyPrice = 300; | ||
carManager.Update(newCar); | ||
Console.WriteLine(carManager.GetById(6).DailyPrice); | ||
|
||
carManager.Delete(newCar); | ||
} | ||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Entities.Concrete; | ||
|
||
namespace DataAccess.Abstract | ||
{ | ||
public interface ICarDal | ||
{ | ||
Car GetById(int id); | ||
|
||
List<Car> GetAll(); | ||
|
||
void Add(Car product); | ||
|
||
void Update(Car product); | ||
|
||
void Delete(Car product); | ||
} | ||
} |
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,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using DataAccess.Abstract; | ||
using Entities.Concrete; | ||
|
||
namespace Business.Concrete.InMemory | ||
{ | ||
public class InMemoryCarDal : ICarDal | ||
{ | ||
private List<Car> _cars; | ||
|
||
public InMemoryCarDal() | ||
{ | ||
_cars = new List<Car> | ||
{ | ||
new Car{Id = 1, BrandId = 1, ColorId = 1, DailyPrice = 120, ModelYear = 2010, Description = "a"}, | ||
new Car{Id = 2, BrandId = 1, ColorId = 4, DailyPrice = 550, ModelYear = 2012, Description = "b"}, | ||
new Car{Id = 3, BrandId = 2, ColorId = 5, DailyPrice = 750, ModelYear = 2015, Description = "c"}, | ||
new Car{Id = 4, BrandId = 2, ColorId = 2, DailyPrice = 350, ModelYear = 2005, Description = "d"}, | ||
new Car{Id = 5, BrandId = 3, ColorId = 1, DailyPrice = 1000, ModelYear = 2020, Description = "e"}, | ||
}; | ||
} | ||
|
||
public Car GetById(int Id) | ||
{ | ||
return _cars.SingleOrDefault(c => c.Id == Id); | ||
} | ||
|
||
public List<Car> GetAll() | ||
{ | ||
return _cars; | ||
} | ||
|
||
public void Add(Car Car) | ||
{ | ||
_cars.Add(Car); | ||
} | ||
|
||
public void Update(Car Car) | ||
{ | ||
Car CarToUpdate = _cars.SingleOrDefault(c => c.Id == Car.Id); | ||
CarToUpdate.BrandId = Car.BrandId; | ||
CarToUpdate.ColorId = Car.ColorId; | ||
CarToUpdate.ModelYear = Car.ModelYear; | ||
CarToUpdate.DailyPrice = CarToUpdate.DailyPrice; | ||
CarToUpdate.Description = CarToUpdate.Description; | ||
} | ||
|
||
public void Delete(Car Car) | ||
{ | ||
Car CarToDelete = _cars.SingleOrDefault(c => c.Id == Car.Id); | ||
_cars.Remove(CarToDelete); | ||
} | ||
} | ||
} |
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Entities\Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Entities.Abstract | ||
{ | ||
public interface IEntity | ||
{ | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Entities.Abstract; | ||
|
||
namespace Entities.Concrete | ||
{ | ||
public class Brand : IEntity | ||
{ | ||
public int Id { get; set; } | ||
public string name { 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,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Entities.Abstract; | ||
|
||
namespace Entities.Concrete | ||
{ | ||
public class Car : IEntity | ||
{ | ||
public int Id { get; set; } | ||
public int BrandId { get; set; } | ||
public int ColorId { get; set; } | ||
public short ModelYear { get; set; } | ||
public decimal DailyPrice { get; set; } | ||
public string Description { 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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Entities.Abstract; | ||
|
||
namespace Entities.Concrete | ||
{ | ||
public class Color : IEntity | ||
{ | ||
public int Id { get; set; } | ||
public string name { 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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</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,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30804.86 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{339C27A1-479E-4B72-AED8-AD7EF514D5FC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{A02933E3-7C1C-4651-9EAE-98E7822EB1C0}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Business", "Business\Business.csproj", "{C1321EA3-0919-4D3D-B80B-C943F791FEBB}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{89FC3102-DE3F-4A9C-8804-6926A4D44C47}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{339C27A1-479E-4B72-AED8-AD7EF514D5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{339C27A1-479E-4B72-AED8-AD7EF514D5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{339C27A1-479E-4B72-AED8-AD7EF514D5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{339C27A1-479E-4B72-AED8-AD7EF514D5FC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A02933E3-7C1C-4651-9EAE-98E7822EB1C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A02933E3-7C1C-4651-9EAE-98E7822EB1C0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A02933E3-7C1C-4651-9EAE-98E7822EB1C0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A02933E3-7C1C-4651-9EAE-98E7822EB1C0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C1321EA3-0919-4D3D-B80B-C943F791FEBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C1321EA3-0919-4D3D-B80B-C943F791FEBB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C1321EA3-0919-4D3D-B80B-C943F791FEBB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C1321EA3-0919-4D3D-B80B-C943F791FEBB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{89FC3102-DE3F-4A9C-8804-6926A4D44C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{89FC3102-DE3F-4A9C-8804-6926A4D44C47}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{89FC3102-DE3F-4A9C-8804-6926A4D44C47}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{89FC3102-DE3F-4A9C-8804-6926A4D44C47}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2ABB2908-51FF-4969-881A-9983E947FAFD} | ||
EndGlobalSection | ||
EndGlobal |