diff --git a/.vs/ReCapProject/v16/.suo b/.vs/ReCapProject/v16/.suo index 470c621..22bb5f5 100644 Binary files a/.vs/ReCapProject/v16/.suo and b/.vs/ReCapProject/v16/.suo differ diff --git a/Business/Abstract/IBrandService.cs b/Business/Abstract/IBrandService.cs index 86f88fd..8376008 100644 --- a/Business/Abstract/IBrandService.cs +++ b/Business/Abstract/IBrandService.cs @@ -1,4 +1,5 @@ -using Entities.Concrete; +using Core.Utilities.Results; +using Entities.Concrete; using System; using System.Collections.Generic; using System.Text; @@ -7,9 +8,10 @@ namespace Business.Abstract { public interface IBrandService { - List GetAll(); - void Add(Brand brand); - void Update(Brand brand); - void Delete(Brand brand); + IDataResult> GetAll(); + IDataResult GetById(int id); + IResult Add(Brand brand); + IResult Delete(Brand brand); + IResult Update(Brand brand); } } diff --git a/Business/Abstract/ICarService.cs b/Business/Abstract/ICarService.cs index 3a36cef..69bd1f6 100644 --- a/Business/Abstract/ICarService.cs +++ b/Business/Abstract/ICarService.cs @@ -1,4 +1,5 @@ -using Entities.Concrete; +using Core.Utilities.Results; +using Entities.Concrete; using Entities.DTOs; using System; using System.Collections.Generic; @@ -8,12 +9,13 @@ namespace Business.Abstract { public interface ICarService { - List GetAll(); - List GetCarsByBrandId(int id); - List GetCarsByColorId(int id); - List GetCarDetails(); - void Add(Car car); - void Update(Car car); - void Delete(Car car); + IDataResult> GetAll(); + IDataResult GetById(int id); + IDataResult> GetCarsByBrandId(int id); + IDataResult> GetCarsByColorId(int id); + IDataResult> GetCarDetails(); + IResult Add(Car car); + IResult Delete(Car car); + IResult Update(Car car); } } diff --git a/Business/Abstract/IColorService.cs b/Business/Abstract/IColorService.cs index 4c25fab..f78aaaa 100644 --- a/Business/Abstract/IColorService.cs +++ b/Business/Abstract/IColorService.cs @@ -1,4 +1,5 @@ -using Entities.Concrete; +using Core.Utilities.Results; +using Entities.Concrete; using System; using System.Collections.Generic; using System.Text; @@ -7,10 +8,10 @@ namespace Business.Abstract { public interface IColorService { - List GetAll(); - Color GetById(int id); - void Add(Color color); - void Update(Color color); - void Delete(Color color); + IDataResult> GetAll(); + IDataResult GetById(int id); + IResult Add(Color color); + IResult Delete(Color color); + IResult Update(Color color); } } diff --git a/Business/Concrete/BrandManager.cs b/Business/Concrete/BrandManager.cs index 70be51a..57af57c 100644 --- a/Business/Concrete/BrandManager.cs +++ b/Business/Concrete/BrandManager.cs @@ -1,4 +1,6 @@ using Business.Abstract; +using Business.Constans; +using Core.Utilities.Results; using DataAccess.Abstract; using Entities.Concrete; using System; @@ -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> GetAll() + { + return new SuccessDataResult> + (_brandDal.GetAll(),Messages.BrandListed); } - public List GetAll() + public IDataResult GetById(int id) { - return _brandDal.GetAll(); + return new SuccessDataResult + (_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); } } } diff --git a/Business/Concrete/CarManager.cs b/Business/Concrete/CarManager.cs index 8bd68d8..97abba6 100644 --- a/Business/Concrete/CarManager.cs +++ b/Business/Concrete/CarManager.cs @@ -1,4 +1,6 @@ using Business.Abstract; +using Business.Constans; +using Core.Utilities.Results; using DataAccess.Abstract; using Entities.Concrete; using Entities.DTOs; @@ -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> GetAll() { - _carDal.Update(car); + return new SuccessDataResult> + (_carDal.GetAll(),Messages.CarsListed); } - public List GetAll() + + public IDataResult GetById(int id) { - return _carDal.GetAll(); + return new SuccessDataResult + (_carDal.Get(c => c.Id == id)); } - public List GetCarsByBrandId(int id) + + public IDataResult> GetCarDetails() { - return _carDal.GetAll(c => c.BrandId == id); + return new SuccessDataResult> + (_carDal.GetCarDetails()); } - public List GetCarsByColorId(int id) + + public IDataResult> GetCarsByBrandId(int id) { - return _carDal.GetAll(c => c.ColorId == id); + return new SuccessDataResult> + (_carDal.GetAll(c => c.BrandId == id)); } - public List GetCarDetails() + public IDataResult> GetCarsByColorId(int id) { - return _carDal.GetCarDetails(); + return new SuccessDataResult> + (_carDal.GetAll(c => c.ColorId == id)); + } + + public IResult Update(Car car) + { + _carDal.Update(car); + return new SuccessResult(Messages.CarUpdated); } } } diff --git a/Business/Concrete/ColorManager.cs b/Business/Concrete/ColorManager.cs index 439f1db..fcb57e2 100644 --- a/Business/Concrete/ColorManager.cs +++ b/Business/Concrete/ColorManager.cs @@ -1,4 +1,6 @@ using Business.Abstract; +using Business.Constans; +using Core.Utilities.Results; using DataAccess.Abstract; using Entities.Concrete; using System; @@ -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 GetAll() + public IDataResult> GetAll() { - return _colorDal.GetAll(); + return new SuccessDataResult> + (_colorDal.GetAll(),Messages.ColorListed); } - public Color GetById(int id) + public IDataResult GetById(int id) { - return _colorDal.Get(c => c.ColorId == id); + return new SuccessDataResult + (_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); } } } diff --git a/Business/Constans/Messages.cs b/Business/Constans/Messages.cs new file mode 100644 index 0000000..40fe540 --- /dev/null +++ b/Business/Constans/Messages.cs @@ -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"; + } +} diff --git a/Business/bin/Debug/netstandard2.0/Business.dll b/Business/bin/Debug/netstandard2.0/Business.dll index b4c9d02..5e258fa 100644 Binary files a/Business/bin/Debug/netstandard2.0/Business.dll and b/Business/bin/Debug/netstandard2.0/Business.dll differ diff --git a/Business/bin/Debug/netstandard2.0/Business.pdb b/Business/bin/Debug/netstandard2.0/Business.pdb index f474f06..00d31c8 100644 Binary files a/Business/bin/Debug/netstandard2.0/Business.pdb and b/Business/bin/Debug/netstandard2.0/Business.pdb differ diff --git a/Business/bin/Debug/netstandard2.0/DataAccess.dll b/Business/bin/Debug/netstandard2.0/DataAccess.dll index 4a2d83e..8d3500b 100644 Binary files a/Business/bin/Debug/netstandard2.0/DataAccess.dll and b/Business/bin/Debug/netstandard2.0/DataAccess.dll differ diff --git a/Business/bin/Debug/netstandard2.0/DataAccess.pdb b/Business/bin/Debug/netstandard2.0/DataAccess.pdb index ca16033..6fcb4d1 100644 Binary files a/Business/bin/Debug/netstandard2.0/DataAccess.pdb and b/Business/bin/Debug/netstandard2.0/DataAccess.pdb differ diff --git a/Business/obj/Debug/netstandard2.0/Business.csproj.CoreCompileInputs.cache b/Business/obj/Debug/netstandard2.0/Business.csproj.CoreCompileInputs.cache index a44a6b2..8da66fa 100644 --- a/Business/obj/Debug/netstandard2.0/Business.csproj.CoreCompileInputs.cache +++ b/Business/obj/Debug/netstandard2.0/Business.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -02044cdbb5c862289fe86fb440e7862b0a192851 +656d0b06cad8785ecf985ee2ad32b557b809e9e9 diff --git a/Business/obj/Debug/netstandard2.0/Business.dll b/Business/obj/Debug/netstandard2.0/Business.dll index b4c9d02..5e258fa 100644 Binary files a/Business/obj/Debug/netstandard2.0/Business.dll and b/Business/obj/Debug/netstandard2.0/Business.dll differ diff --git a/Business/obj/Debug/netstandard2.0/Business.pdb b/Business/obj/Debug/netstandard2.0/Business.pdb index f474f06..00d31c8 100644 Binary files a/Business/obj/Debug/netstandard2.0/Business.pdb and b/Business/obj/Debug/netstandard2.0/Business.pdb differ diff --git a/ConsoleUI/Program.cs b/ConsoleUI/Program.cs index ec2847e..e9f9086 100644 --- a/ConsoleUI/Program.cs +++ b/ConsoleUI/Program.cs @@ -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"); + } + */ } } } diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/Business.dll b/ConsoleUI/bin/Debug/netcoreapp3.1/Business.dll index b4c9d02..5e258fa 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/Business.dll and b/ConsoleUI/bin/Debug/netcoreapp3.1/Business.dll differ diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/Business.pdb b/ConsoleUI/bin/Debug/netcoreapp3.1/Business.pdb index f474f06..00d31c8 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/Business.pdb and b/ConsoleUI/bin/Debug/netcoreapp3.1/Business.pdb differ diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.dll b/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.dll index 398afde..d05c747 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.dll and b/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.dll differ diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.pdb b/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.pdb index f7f8091..d56ab31 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.pdb and b/ConsoleUI/bin/Debug/netcoreapp3.1/ConsoleUI.pdb differ diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.dll b/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.dll index 4a2d83e..8d3500b 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.dll and b/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.dll differ diff --git a/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.pdb b/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.pdb index ca16033..6fcb4d1 100644 Binary files a/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.pdb and b/ConsoleUI/bin/Debug/netcoreapp3.1/DataAccess.pdb differ diff --git a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.csproj.AssemblyReference.cache b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.csproj.AssemblyReference.cache index 300397e..fb64d58 100644 Binary files a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.csproj.AssemblyReference.cache and b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.csproj.AssemblyReference.cache differ diff --git a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.dll b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.dll index 398afde..d05c747 100644 Binary files a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.dll and b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.dll differ diff --git a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.pdb b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.pdb index f7f8091..d56ab31 100644 Binary files a/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.pdb and b/ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.pdb differ diff --git a/DataAccess/Concrete/EntityFramework/EfCarDal.cs b/DataAccess/Concrete/EntityFramework/EfCarDal.cs index e208fa5..40c2265 100644 --- a/DataAccess/Concrete/EntityFramework/EfCarDal.cs +++ b/DataAccess/Concrete/EntityFramework/EfCarDal.cs @@ -33,8 +33,6 @@ on c.ColorId equals co.ColorId }; return result.ToList(); } - - } } } diff --git a/DataAccess/bin/Debug/netstandard2.0/DataAccess.dll b/DataAccess/bin/Debug/netstandard2.0/DataAccess.dll index 4a2d83e..8d3500b 100644 Binary files a/DataAccess/bin/Debug/netstandard2.0/DataAccess.dll and b/DataAccess/bin/Debug/netstandard2.0/DataAccess.dll differ diff --git a/DataAccess/bin/Debug/netstandard2.0/DataAccess.pdb b/DataAccess/bin/Debug/netstandard2.0/DataAccess.pdb index ca16033..6fcb4d1 100644 Binary files a/DataAccess/bin/Debug/netstandard2.0/DataAccess.pdb and b/DataAccess/bin/Debug/netstandard2.0/DataAccess.pdb differ diff --git a/DataAccess/obj/Debug/netstandard2.0/DataAccess.dll b/DataAccess/obj/Debug/netstandard2.0/DataAccess.dll index 4a2d83e..8d3500b 100644 Binary files a/DataAccess/obj/Debug/netstandard2.0/DataAccess.dll and b/DataAccess/obj/Debug/netstandard2.0/DataAccess.dll differ diff --git a/DataAccess/obj/Debug/netstandard2.0/DataAccess.pdb b/DataAccess/obj/Debug/netstandard2.0/DataAccess.pdb index ca16033..6fcb4d1 100644 Binary files a/DataAccess/obj/Debug/netstandard2.0/DataAccess.pdb and b/DataAccess/obj/Debug/netstandard2.0/DataAccess.pdb differ