-
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.
Results structure, new tables added and refactoring
- Loading branch information
Yusuf Enes Aras
committed
Aug 3, 2021
1 parent
e0fb931
commit c3cdb21
Showing
72 changed files
with
458 additions
and
45 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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 Core.Utilities.Results; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Abstract | ||
{ | ||
public interface ICustomerService | ||
{ | ||
IResult Add(Customer customer); | ||
IResult Delete(Customer customer); | ||
IResult Update(Customer customer); | ||
IDataResult<List<Customer>> GetAll(); | ||
IDataResult<Customer> GetById(int id); | ||
} | ||
} |
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 Core.Utilities.Results; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Abstract | ||
{ | ||
public interface IRentalService | ||
{ | ||
IResult Add(Rental rental); | ||
IResult Delete(Rental rental); | ||
IResult Update(Rental rental); | ||
IDataResult<List<Rental>> GetAll(); | ||
IDataResult<Rental> GetById(int id); | ||
} | ||
} |
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 Core.Utilities.Results; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Abstract | ||
{ | ||
public interface IUserService | ||
{ | ||
IResult Add(User user); | ||
IResult Delete(User user); | ||
IResult Update(User user); | ||
IDataResult<List<User>> GetAll(); | ||
IDataResult<User> GetById(int id); | ||
} | ||
} |
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,50 @@ | ||
using Business.Abstract; | ||
using Business.Constans; | ||
using Core.Utilities.Results; | ||
using DataAccess.Abstract; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Concrete | ||
{ | ||
public class CustomerManager : ICustomerService | ||
{ | ||
ICustomerDal _customerDal; | ||
public CustomerManager(ICustomerDal customerDal) | ||
{ | ||
_customerDal = customerDal; | ||
} | ||
|
||
public IResult Add(Customer customer) | ||
{ | ||
_customerDal.Add(customer); | ||
return new SuccessResult(Messages.UserAdded); | ||
} | ||
|
||
public IResult Delete(Customer customer) | ||
{ | ||
_customerDal.Delete(customer); | ||
return new SuccessResult(Messages.UserDeleted); | ||
} | ||
|
||
public IDataResult<List<Customer>> GetAll() | ||
{ | ||
return new SuccessDataResult<List<Customer>> | ||
(_customerDal.GetAll(), Messages.UsersListed); | ||
} | ||
|
||
public IDataResult<Customer> GetById(int id) | ||
{ | ||
return new SuccessDataResult<Customer> | ||
(_customerDal.Get(c => c.CustomerId == id)); | ||
} | ||
|
||
public IResult Update(Customer customer) | ||
{ | ||
_customerDal.Update(customer); | ||
return new SuccessResult(Messages.UserUpdated); | ||
} | ||
} | ||
} |
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,76 @@ | ||
using Business.Abstract; | ||
using Business.Constans; | ||
using Core.Utilities.BusinessRules; | ||
using Core.Utilities.Results; | ||
using DataAccess.Abstract; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Concrete | ||
{ | ||
public class RentalManager : IRentalService | ||
{ | ||
IRentalDal _rentalDal; | ||
public RentalManager(IRentalDal rentalDal) | ||
{ | ||
_rentalDal = rentalDal; | ||
} | ||
public IResult Add(Rental rental) | ||
{ | ||
IResult result = BusinessRule.Run( | ||
IsCarBeenDelivered(rental.CarId)); | ||
|
||
if (result != null) | ||
{ | ||
return result; | ||
} | ||
|
||
_rentalDal.Add(rental); | ||
return new SuccessResult(Messages.RentalAdded); | ||
} | ||
|
||
public IResult Delete(Rental rental) | ||
{ | ||
_rentalDal.Delete(rental); | ||
return new SuccessResult(Messages.RentalDeleted); | ||
} | ||
|
||
public IDataResult<List<Rental>> GetAll() | ||
{ | ||
return new SuccessDataResult<List<Rental>> | ||
(_rentalDal.GetAll()); | ||
} | ||
|
||
public IDataResult<Rental> GetById(int id) | ||
{ | ||
return new SuccessDataResult<Rental> | ||
(_rentalDal.Get(r => r.Id == id)); | ||
} | ||
|
||
public IResult Update(Rental rental) | ||
{ | ||
try | ||
{ | ||
_rentalDal.Update(rental); | ||
return new SuccessResult(Messages.RentalUpdated); | ||
} | ||
catch (Exception) | ||
{ | ||
return new ErrorResult(Messages.RentalUpdateError); | ||
} | ||
} | ||
|
||
// private metotlar | ||
private IResult IsCarBeenDelivered(int id) | ||
{ | ||
var result = _rentalDal.Get(r => r.CarId == id && r.ReturnDate == null); | ||
if (result == null) | ||
{ | ||
return new SuccessResult(); | ||
} | ||
return new ErrorResult("Araba teslim edilmemiş. Kiralama iptal."); | ||
} | ||
} | ||
} |
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 Business.Abstract; | ||
using Business.Constans; | ||
using Core.Utilities.Results; | ||
using DataAccess.Abstract; | ||
using Entities.Concrete; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Business.Concrete | ||
{ | ||
public class UserManager : IUserService | ||
{ | ||
IUserDal _userDal; | ||
public UserManager(IUserDal userDal) | ||
{ | ||
_userDal = userDal; | ||
} | ||
public IResult Add(User user) | ||
{ | ||
_userDal.Add(user); | ||
return new SuccessResult(Messages.UserAdded); | ||
} | ||
public IResult Delete(User user) | ||
{ | ||
_userDal.Delete(user); | ||
return new SuccessResult(Messages.UserDeleted); | ||
} | ||
|
||
public IDataResult<List<User>> GetAll() | ||
{ | ||
return new SuccessDataResult<List<User>> | ||
(_userDal.GetAll(), Messages.UsersListed); | ||
} | ||
|
||
public IDataResult<User> GetById(int id) | ||
{ | ||
return new SuccessDataResult<User> | ||
(_userDal.Get(u => u.Id == id)); | ||
} | ||
|
||
public IResult Update(User user) | ||
{ | ||
_userDal.Update(user); | ||
return new SuccessResult(Messages.UserUpdated); | ||
} | ||
} | ||
} |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
Business/obj/Debug/netstandard2.0/Business.csproj.CoreCompileInputs.cache
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 +1 @@ | ||
656d0b06cad8785ecf985ee2ad32b557b809e9e9 | ||
8d537954dfa8152d86087da4e642afbaf065af20 |
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-673 Bytes
(65%)
ConsoleUI/obj/Debug/netcoreapp3.1/ConsoleUI.csproj.AssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Oops, something went wrong.