Skip to content

Commit

Permalink
Core, results added
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Enes Aras committed Aug 1, 2021
1 parent 2531328 commit e0fb931
Show file tree
Hide file tree
Showing 30 changed files with 176 additions and 68 deletions.
Binary file modified .vs/ReCapProject/v16/.suo
Binary file not shown.
12 changes: 7 additions & 5 deletions Business/Abstract/IBrandService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Entities.Concrete;
using Core.Utilities.Results;
using Entities.Concrete;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -7,9 +8,10 @@ namespace Business.Abstract
{
public interface IBrandService
{
List<Brand> GetAll();
void Add(Brand brand);
void Update(Brand brand);
void Delete(Brand brand);
IDataResult<List<Brand>> GetAll();
IDataResult<Brand> GetById(int id);
IResult Add(Brand brand);
IResult Delete(Brand brand);
IResult Update(Brand brand);
}
}
18 changes: 10 additions & 8 deletions Business/Abstract/ICarService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Entities.Concrete;
using Core.Utilities.Results;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
Expand All @@ -8,12 +9,13 @@ namespace Business.Abstract
{
public interface ICarService
{
List<Car> GetAll();
List<Car> GetCarsByBrandId(int id);
List<Car> GetCarsByColorId(int id);
List<CarDetailDto> GetCarDetails();
void Add(Car car);
void Update(Car car);
void Delete(Car car);
IDataResult<List<Car>> GetAll();
IDataResult<Car> GetById(int id);
IDataResult<List<Car>> GetCarsByBrandId(int id);
IDataResult<List<Car>> GetCarsByColorId(int id);
IDataResult<List<CarDetailDto>> GetCarDetails();
IResult Add(Car car);
IResult Delete(Car car);
IResult Update(Car car);
}
}
13 changes: 7 additions & 6 deletions Business/Abstract/IColorService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Entities.Concrete;
using Core.Utilities.Results;
using Entities.Concrete;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -7,10 +8,10 @@ namespace Business.Abstract
{
public interface IColorService
{
List<Color> GetAll();
Color GetById(int id);
void Add(Color color);
void Update(Color color);
void Delete(Color color);
IDataResult<List<Color>> GetAll();
IDataResult<Color> GetById(int id);
IResult Add(Color color);
IResult Delete(Color color);
IResult Update(Color color);
}
}
30 changes: 23 additions & 7 deletions Business/Concrete/BrandManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Business.Abstract;
using Business.Constans;
using Core.Utilities.Results;
using DataAccess.Abstract;
using Entities.Concrete;
using System;
Expand All @@ -16,24 +18,38 @@ public BrandManager(IBrandDal brandDal)
{
_brandDal = brandDal;
}
public void Add(Brand brand)
public IResult Add(Brand brand)
{
_brandDal.Add(brand);
_brandDal.Add(brand);
return new SuccessResult(Messages.BrandAdded);

}

public void Delete(Brand brand)
public IResult Delete(Brand brand)
{
_brandDal.Delete(brand);
return new Result(true, Messages.BrandDeleted);
}

public IDataResult<List<Brand>> GetAll()
{
return new SuccessDataResult<List<Brand>>
(_brandDal.GetAll(),Messages.BrandListed);
}

public List<Brand> GetAll()
public IDataResult<Brand> GetById(int id)
{
return _brandDal.GetAll();
return new SuccessDataResult<Brand>
(_brandDal.Get(b => b.BrandId == id));
}

public void Update(Brand brand)
public IResult Update(Brand brand)
{
if (brand.BrandName == null)
{
return new ErrorResult(Messages.BrandNameNull);
}
_brandDal.Update(brand);
return new Result(true, Messages.BrandUpdated);
}
}
}
58 changes: 43 additions & 15 deletions Business/Concrete/CarManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Business.Abstract;
using Business.Constans;
using Core.Utilities.Results;
using DataAccess.Abstract;
using Entities.Concrete;
using Entities.DTOs;
Expand All @@ -16,41 +18,67 @@ public CarManager(ICarDal carDal)
{
_carDal = carDal;
}
public void Add(Car car)

public IResult Add(Car car)
{
if (car.DailyPrice > 0 && car.CarName.Length >= 2)
if (car.CarName.Length >= 2)
{
_carDal.Add(car);
if (car.DailyPrice > 0)
{
_carDal.Add(car);
return new SuccessResult(Messages.CarAdded);
}
else
{
return new ErrorResult(Messages.CarDailyPrice);
}
}
else
{
Console.WriteLine("Araba adı 2 karakterden büyük ve günlük fiyatı 0'dan büyük olmalıdır.");
return new ErrorResult(Messages.CarNameError);
}
}
public void Delete(Car car)

public IResult Delete(Car car)
{
_carDal.Delete(car);
return new SuccessResult(Messages.CarDeleted);
}
public void Update(Car car)

public IDataResult<List<Car>> GetAll()
{
_carDal.Update(car);
return new SuccessDataResult<List<Car>>
(_carDal.GetAll(),Messages.CarsListed);
}
public List<Car> GetAll()

public IDataResult<Car> GetById(int id)
{
return _carDal.GetAll();
return new SuccessDataResult<Car>
(_carDal.Get(c => c.Id == id));
}
public List<Car> GetCarsByBrandId(int id)

public IDataResult<List<CarDetailDto>> GetCarDetails()
{
return _carDal.GetAll(c => c.BrandId == id);
return new SuccessDataResult<List<CarDetailDto>>
(_carDal.GetCarDetails());
}
public List<Car> GetCarsByColorId(int id)

public IDataResult<List<Car>> GetCarsByBrandId(int id)
{
return _carDal.GetAll(c => c.ColorId == id);
return new SuccessDataResult<List<Car>>
(_carDal.GetAll(c => c.BrandId == id));
}

public List<CarDetailDto> GetCarDetails()
public IDataResult<List<Car>> GetCarsByColorId(int id)
{
return _carDal.GetCarDetails();
return new SuccessDataResult<List<Car>>
(_carDal.GetAll(c => c.ColorId == id));
}

public IResult Update(Car car)
{
_carDal.Update(car);
return new SuccessResult(Messages.CarUpdated);
}
}
}
22 changes: 15 additions & 7 deletions Business/Concrete/ColorManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Business.Abstract;
using Business.Constans;
using Core.Utilities.Results;
using DataAccess.Abstract;
using Entities.Concrete;
using System;
Expand All @@ -14,29 +16,35 @@ public ColorManager(IColorDal colorDal)
{
_colorDal = colorDal;
}
public void Add(Color color)

public IResult Add(Color color)
{
_colorDal.Add(color);
return new Result(true, Messages.ColorAdded);
}

public void Delete(Color color)
public IResult Delete(Color color)
{
_colorDal.Delete(color);
return new Result(true, Messages.ColorDeleted);
}

public List<Color> GetAll()
public IDataResult<List<Color>> GetAll()
{
return _colorDal.GetAll();
return new SuccessDataResult<List<Color>>
(_colorDal.GetAll(),Messages.ColorListed);
}

public Color GetById(int id)
public IDataResult<Color> GetById(int id)
{
return _colorDal.Get(c => c.ColorId == id);
return new SuccessDataResult<Color>
(_colorDal.Get(c => c.ColorId == id));
}

public void Update(Color color)
public IResult Update(Color color)
{
_colorDal.Update(color);
return new Result(true, Messages.ColorUpdated);
}
}
}
44 changes: 44 additions & 0 deletions Business/Constans/Messages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Business.Constans
{
public static class Messages
{
public static string CarAdded = "Araba Eklendi";
public static string CarDeleted = "Araba Silindi";
public static string CarUpdated = "Araba Güncellendi";
public static string AddError = "Ekleme Başarısız Oldu";
public static string CarsListed = "Arabalar listelendi";
public static string CarDetails = "Araba Detayları Listelendi";
public static string CarDailyPrice = "Günlük fiyat 0' dan küçük olamaz";
public static string CarNameError = "Araba ismi minimum 2 karakter olmalıdır.";

public static string BrandAdded = "Marka Eklendi";
public static string BrandDeleted = "Marka Silindi";
public static string BrandUpdated = "Marka Güncellendi";
public static string BrandListed = "Markalar Listelendi";
public static string BrandError = "Marka Eklenemedi";
public static string BrandUpdateError = "Marka Güncellenemedi";
public static string BrandNameNull = "Marka ismi boş olamaz";

public static string ColorAdded = "Renk Eklendi";
public static string ColorDeleted = "Renk Silindi";
public static string ColorUpdated = "Renk Güncellendi";
public static string ColorListed = "Renkler Listelendi";
public static string ColorAddError = "Renk Eklenemedi";

public static string MaintenanceTime = "Sistem Şuan Bakımda.";
public static string Added = "Eklendi";
public static string Deleted = "Silindi";
public static string Updated = "Güncellendi";
public static string Rented = "Kiralandı";
public static string InActiveUse = "Araba Kullanımda";
internal static string ImageLimitOver = "Her Arabanın en fazla 5 Fotoğrafı Olabilir";
internal static string ImageAdded = "Fotoğraf Yüklendi";
internal static string CarImageUpdated = "Fotoğraf Güncellendi";
internal static string CarImageNotFound = "Fotoğraf Bulunamadı";
internal static string CarImageDeleted = "Fotoğraf Silindi";
}
}
Binary file modified Business/bin/Debug/netstandard2.0/Business.dll
Binary file not shown.
Binary file modified Business/bin/Debug/netstandard2.0/Business.pdb
Binary file not shown.
Binary file modified Business/bin/Debug/netstandard2.0/DataAccess.dll
Binary file not shown.
Binary file modified Business/bin/Debug/netstandard2.0/DataAccess.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
02044cdbb5c862289fe86fb440e7862b0a192851
656d0b06cad8785ecf985ee2ad32b557b809e9e9
Binary file modified Business/obj/Debug/netstandard2.0/Business.dll
Binary file not shown.
Binary file modified Business/obj/Debug/netstandard2.0/Business.pdb
Binary file not shown.
43 changes: 26 additions & 17 deletions ConsoleUI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,37 @@ static void Main(string[] args)
//car1.Description = "Kia Rio 1.3 motor";
//carManager.Add(car1);

foreach (var car in carManager.GetCarDetails())
var result = carManager.GetCarDetails();
if (result.Success == true)
{
Console.WriteLine($"Araba Adı: {car.CarName}\n" +
$"Araba Günlük Fiyatı: {car.DailyPrice}\n" +
$"Araba Markası: {car.BrandName}\n" +
$"Araba Rengi: {car.ColorName}");

foreach (var car in result.Data)
{
Console.WriteLine($"Araba Adı: {car.CarName}\n" +
$"Araba Günlük Fiyatı: {car.DailyPrice}\n" +
$"Araba Markası: {car.BrandName}\n" +
$"Araba Rengi: {car.ColorName}");
}
}

/*
* BrandManager brandManager = new BrandManager(new EfBrandDal());
foreach (var brand in brandManager.GetAll())
else
{
Console.WriteLine($"Araba Markası: {brand.BrandName}\n");
Console.WriteLine(result.Message);
}

ColorManager colorManager = new ColorManager(new EfColorDal());
foreach (var color in colorManager.GetAll())
{
Console.WriteLine($"Araba Rengi: {color.ColorName}\n");
}
*/


/*
* BrandManager brandManager = new BrandManager(new EfBrandDal());
foreach (var brand in brandManager.GetAll())
{
Console.WriteLine($"Araba Markası: {brand.BrandName}\n");
}
ColorManager colorManager = new ColorManager(new EfColorDal());
foreach (var color in colorManager.GetAll())
{
Console.WriteLine($"Araba Rengi: {color.ColorName}\n");
}
*/
}
}
}
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/Business.dll
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/Business.pdb
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.dll
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.pdb
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.dll
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.pdb
Binary file not shown.
Binary file not shown.
Binary file modified ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.dll
Binary file not shown.
Binary file modified ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.pdb
Binary file not shown.
2 changes: 0 additions & 2 deletions DataAccess/Concrete/EntityFramework/EfCarDal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ on c.ColorId equals co.ColorId
};
return result.ToList();
}


}
}
}
Binary file modified DataAccess/bin/Debug/netstandard2.0/DataAccess.dll
Binary file not shown.
Binary file modified DataAccess/bin/Debug/netstandard2.0/DataAccess.pdb
Binary file not shown.
Binary file modified DataAccess/obj/Debug/netstandard2.0/DataAccess.dll
Binary file not shown.
Binary file modified DataAccess/obj/Debug/netstandard2.0/DataAccess.pdb
Binary file not shown.

0 comments on commit e0fb931

Please sign in to comment.