Skip to content

Commit

Permalink
RentalDto Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Enes Aras committed Aug 22, 2021
1 parent 308ded8 commit 63f2ba9
Show file tree
Hide file tree
Showing 58 changed files with 93 additions and 13 deletions.
Binary file modified .vs/ReCapProject/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/ReCapProject/v16/.suo
Binary file not shown.
3 changes: 3 additions & 0 deletions Business/Abstract/IRentalService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Core.Utilities.Results;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -13,5 +14,7 @@ public interface IRentalService
IResult Update(Rental rental);
IDataResult<List<Rental>> GetAll();
IDataResult<Rental> GetById(int id);
IDataResult<List<RentalDetailDto>> GetRentalDetails();

}
}
3 changes: 1 addition & 2 deletions Business/Concrete/CarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public CarManager(ICarDal carDal)
[SecuredOperation("car.add,admin")]
[ValidationAspect(typeof(CarValidator))]
[CacheRemoveAspect("ICarService.Get")]

public IResult Add(Car car)
{
_carDal.Add(car);
Expand All @@ -43,7 +42,7 @@ public IResult Delete(Car car)
return new SuccessResult(Messages.CarDeleted);
}

[CacheAspect] // key, value
//[CacheAspect] // key, value
public IDataResult<List<Car>> GetAll()
{
return new SuccessDataResult<List<Car>>
Expand Down
7 changes: 7 additions & 0 deletions Business/Concrete/RentalManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Core.Utilities.Results;
using DataAccess.Abstract;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down Expand Up @@ -49,6 +50,12 @@ public IDataResult<Rental> GetById(int id)
(_rentalDal.Get(r => r.Id == id));
}

public IDataResult<List<RentalDetailDto>> GetRentalDetails()
{
return new SuccessDataResult<List<RentalDetailDto>>
(_rentalDal.GetRentalDetails());
}

public IResult Update(Rental rental)
{
try
Expand Down
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.
Binary file modified Business/bin/Debug/netstandard2.0/Entities.dll
Binary file not shown.
Binary file modified Business/bin/Debug/netstandard2.0/Entities.pdb
Binary file not shown.
Binary file not shown.
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.
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 modified ConsoleUI/bin/Debug/netcoreapp3.1/Entities.dll
Binary file not shown.
Binary file modified ConsoleUI/bin/Debug/netcoreapp3.1/Entities.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.
Binary file modified Core/obj/Debug/Core.csproj.AssemblyReference.cache
Binary file not shown.
3 changes: 2 additions & 1 deletion DataAccess/Abstract/IRentalDal.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Core.DataAccess;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
using System.Text;

namespace DataAccess.Abstract
{
public interface IRentalDal : IEntityRepository<Rental>
{
List<RentalDetailDto> GetRentalDetails();
}
}
2 changes: 2 additions & 0 deletions DataAccess/Concrete/EntityFramework/EfCarDal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ on c.ColorId equals co.ColorId
BrandName = b.BrandName,
ColorName = co.ColorName,
DailyPrice = c.DailyPrice,
ModelYear = c.ModelYear,
Description = c.Description
};
return result.ToList();
}
Expand Down
30 changes: 29 additions & 1 deletion DataAccess/Concrete/EntityFramework/EfRentalDal.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
using Core.DataAccess.EntityFramework;
using DataAccess.Abstract;
using Entities.Concrete;
using Entities.DTOs;
using System;
using System.Collections.Generic;
using System.Text;

using System.Linq;
namespace DataAccess.Concrete.EntityFramework
{
public class EfRentalDal : EfEntityRepositoryBase<Rental, ReCapContext>, IRentalDal
{
// equals -> eşit ise
public List<RentalDetailDto> GetRentalDetails()
{
using (ReCapContext context = new ReCapContext())
{
var result = from r in context.Rentals
join cr in context.Cars
on r.CarId equals cr.CarId
join cs in context.Customers
on r.CustomerId equals cs.CustomerId
join br in context.Brands
on cr.BrandId equals br.BrandId
join u in context.Users
on cs.UserId equals u.Id

select new RentalDetailDto
{
RentalId = r.Id,
BrandName = br.BrandName,
CustomerName = u.FirstName + " " + u.LastName,
RentDate = r.RentDate,
ReturnDate = r.ReturnDate,

};
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/bin/Debug/netstandard2.0/Entities.dll
Binary file not shown.
Binary file modified DataAccess/bin/Debug/netstandard2.0/Entities.pdb
Binary file not shown.
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.
2 changes: 2 additions & 0 deletions Entities/DTOs/CarDetailDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public class CarDetailDto:IDto
public string BrandName { get; set; }
public string ColorName { get; set; }
public decimal DailyPrice { get; set; }
public int ModelYear { get; set; }
public string Description { get; set; }
}
}
17 changes: 17 additions & 0 deletions Entities/DTOs/RentalDetailDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Core.Entities;
using System;
using System.Collections.Generic;
using System.Text;

namespace Entities.DTOs
{
public class RentalDetailDto:IDto
{
public int RentalId { get; set; }
public string BrandName { get; set; }
public string CustomerName { get; set; }
public DateTime RentDate { get; set; }
public DateTime ReturnDate { get; set; }

}
}
Binary file modified Entities/bin/Debug/netstandard2.0/Entities.dll
Binary file not shown.
Binary file modified Entities/bin/Debug/netstandard2.0/Entities.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72f47d91b768cc3dd29cf8406463336c36526fe7
9f6e973c25150bfb9f9dcd80fe110efe6ca62ca2
Binary file modified Entities/obj/Debug/netstandard2.0/Entities.dll
Binary file not shown.
Binary file modified Entities/obj/Debug/netstandard2.0/Entities.pdb
Binary file not shown.
22 changes: 14 additions & 8 deletions WebAPI/Controllers/CarsController.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
using Business.Abstract;
using Business.Concrete;
using DataAccess.Concrete.EntityFramework;
using Entities.Concrete;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;

namespace WebAPI.Controllers
{
[Route("api/[controller]")]
[ApiController] // attribute
public class CarsController : ControllerBase
{
//Ioc Container -- Inversion of Control
//IoC Container -- Inversion of Control
ICarService _carService;

public CarsController(ICarService carService)
Expand All @@ -26,6 +20,7 @@ public CarsController(ICarService carService)
[HttpGet("getall")]
public IActionResult GetAll()
{
Thread.Sleep(1000);

var result = _carService.GetAll();
if (result.Success)
Expand Down Expand Up @@ -76,5 +71,16 @@ public IActionResult Update(Car car)
}
return BadRequest(result.Message);
}

[HttpGet("getcardetailsbydto")]
public IActionResult GetDetailsByDto()
{
var result = _carService.GetCarDetails();
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
}
}
11 changes: 11 additions & 0 deletions WebAPI/Controllers/RentalsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,16 @@ public IActionResult GetById(int id)
}
return BadRequest(result.Message);
}

[HttpGet("getrentaldetails")]
public IActionResult GetRentalDetails()
{
var result = _rentalService.GetRentalDetails();
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
}
}
4 changes: 4 additions & 0 deletions WebAPI/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public void ConfigureServices(IServiceCollection services)
//services.AddSingleton<IBrandService, BrandManager>();
//services.AddSingleton<IBrandDal, EfBrandDal>();

services.AddCors();

var tokenOptions = Configuration.GetSection("TokenOptions").Get<TokenOptions>();

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
Expand Down Expand Up @@ -74,6 +76,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseDeveloperExceptionPage();
}

app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader());

app.UseHttpsRedirection();

app.UseRouting();
Expand Down
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/Business.dll
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/Business.pdb
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/DataAccess.dll
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/DataAccess.pdb
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/Entities.dll
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/Entities.pdb
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/WebAPI.dll
Binary file not shown.
Binary file modified WebAPI/bin/Debug/netcoreapp3.1/WebAPI.pdb
Binary file not shown.
Binary file not shown.
Binary file modified WebAPI/obj/Debug/netcoreapp3.1/WebAPI.dll
Binary file not shown.
Binary file modified WebAPI/obj/Debug/netcoreapp3.1/WebAPI.pdb
Binary file not shown.

0 comments on commit 63f2ba9

Please sign in to comment.