public IResult DeleteByCarId(CarDetailDto carDetailDto) { Car deleteToCar = _carDal.Get(c => c.Id == carDetailDto.Id); _carDal.Delete(deleteToCar); return(new SuccessResult(Messages.CarDeleted)); }
public RentalDetailDto GetRentalByBrandModel(string brandModel) { using (CarProjectContext context = new CarProjectContext()) { var result = from r in context.Rentals join c in context.Customers on r.CustomerId equals c.CustomerId join u in context.Users on c.UserId equals u.UsersId join car in context.Cars on r.CarId equals car.Id select new RentalDetailDto { CarId = r.CarId, CustomerId = c.CustomerId, CustomerName = u.FirstName + ' ' + u.LastName, RentalsId = r.RentalsId, RentDate = r.RentDate, ReturnDate = r.ReturnDate }; EfCarDal efCar = new EfCarDal(); CarDetailDto carDetails = efCar.GetCarDetail().Find(item => item.BrandName == brandModel); return((RentalDetailDto)result.Where(item => item.CarId == carDetails.ColorId)); } }
public IDataResult <CarDetailDto> GetCarDetailById(int id) { CarDetailDto carDetailDto = _carDal.GetCarDetailById(c => c.Id == id); carDetailDto.CarImages = _carImagesService.GetAllByCarId(id).Data; return(new SuccessDataResult <CarDetailDto>(carDetailDto)); }
public IDataResult <List <RentalDetailDto> > GetByCustomer(int ID) { var getAll = _rentalDal.GetAll(c => c.CustomerID == ID); List <RentalDetailDto> rentalDetailDto = new List <RentalDetailDto>(); foreach (var g in getAll) { CarDetailDto car = _carService.GetDetail(g.CarID).Data; rentalDetailDto.Add(new RentalDetailDto() { BrandID = car.BrandID, BrandName = car.BrandName, CarImages = car.CarImages, CarName = car.CarName, CarID = car.ID, ColorID = car.ColorID, ModelYear = car.ModelYear, CustomerID = g.CustomerID, ColorName = car.ColorName, RentDate = g.RentDate, ReturnDate = g.ReturnDate, DailyPrice = car.DailyPrice, Description = car.Description }); } return(new SuccessDataResult <List <RentalDetailDto> >(rentalDetailDto)); }
public WindowRental(CarDetailDto car) { InitializeComponent(); _car = car; _customerService = new CustomerManager(new EfCustomerDal()); _rentalService = new RentalManager(new EfRentalDal()); }
private List <CarDetailDto> MainImageAssignerForCarDetailDtos(List <CarDetailDto> dtoListToCheck) { var carDetailDtoList = new List <CarDetailDto>(); foreach (var carDetailDto in dtoListToCheck) { var mainImage = _carImageService.GetCarMainImageByCarId(carDetailDto.CarId); CarDetailDto carDetail = new CarDetailDto { CarId = carDetailDto.CarId, BrandId = carDetailDto.BrandId, ColorId = carDetailDto.ColorId, CarName = carDetailDto.CarName, BrandName = carDetailDto.BrandName, ColorName = carDetailDto.ColorName, DailyPrice = carDetailDto.DailyPrice, Description = carDetailDto.Description, ModelYear = carDetailDto.ModelYear, MinFindeksValue = carDetailDto.MinFindeksValue, MainImage = mainImage.Data }; carDetailDtoList.Add(carDetail); } return(carDetailDtoList); }
private static void Print(CarDetailDto carDetailTo) { Console.WriteLine(hyphen); Console.WriteLine($"Car Description : {carDetailTo.CarDescription}"); Console.WriteLine($"Brand: {carDetailTo.BrandName}"); Console.WriteLine($"Color: {carDetailTo.CarDescription}"); Console.WriteLine($"DailyPrice: {carDetailTo.DailyPrice}"); }
public IDataResult <CarDetailDto> GetCarDetailById(int Id) { CarDetailDto car = _carDal.GetCarDetail(Id); if (car == null) { return(new ErrorDataResult <CarDetailDto>(Messages.CarNotFound)); } return(new SuccessDataResult <CarDetailDto>(car)); }
public IActionResult DeleteByCarId(CarDetailDto carDetailDto) { var result = _carService.DeleteByCarId(carDetailDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
private static void ReadCarsDetail(CarDetailDto carDetail) { if (carDetail != null) { Console.WriteLine($"Car Id : {carDetail.CarId} \n" + $"Car Brand Name : {carDetail.BrandName} \n" + $"Car Color Name : {carDetail.ColorName} \n" + $"Car Name : {carDetail.CarName} \n" + $"Car Daily Price : {carDetail.DailyPrice} \n"); } else { Console.WriteLine("Araç Bulunamadı"); } }
public CarDetailDto GetCarDetail(Expression <Func <CarDetailDto, bool> > filter) { using (CarContext context = new CarContext()) { IQueryable <CarDetailDto> matchingCars = from c in context.Cars join color in context.Colors on c.ColorId equals color.Id join brand in context.Brands on c.BrandId equals brand.Id join image in context.CarImages on c.Id equals image.CarId select new CarDetailDto { CarId = c.Id, BrandId = brand.Id, ColorId = color.Id, BrandName = brand.Name, ColorName = color.Name, ModelYear = c.ModelYear, CarName = c.Description, DailyPrice = c.DailyPrice }; CarDetailDto car = matchingCars.FirstOrDefault(filter); if (car == null) { car = GetCarDetails().FirstOrDefault(filter.Compile()); } else { car.ImageList = context.CarImages.ToList().Where(img => img.CarId == car.CarId).Select(img => img.ImagePath).ToList(); } var allRentalsOfCurrentCar = context.Rentals.Where(r => r.CarId == car.CarId).ToList(); if (allRentalsOfCurrentCar.Count > 0) { car.IsRentedNow = true; } foreach (Rental rental in allRentalsOfCurrentCar) { if (rental.ReturnDate == DateTime.MinValue || rental.ReturnDate > DateTime.Now) { car.IsRentedNow = true; } } return(car); } }
private static void RentalManagerTest() { CarDetailDto carDetailDto = new CarDetailDto(); RentalManager rentalManager = new RentalManager(new EfRentalDal()); rentalManager.Add(new Rental { CarId = 2, CustomerId = 1, RentDate = new DateTime(2020, 06, 23) }); //rentalManager.Add(new Rental { CarId = 3, CustomerId = 3, RentDate = new DateTime(2021, 11, 26) }); var result = rentalManager.GetAll(); if (result.Success) { foreach (var rental in result.Data) { Console.WriteLine($@"{rental.CustomerId}'idli müşterimiz {rental.CarId}'idli arabayı {rental.RentDate} tarihinde kiralamıştır "); if (rental.ReturnDate != null) { Console.WriteLine($@"{rental.ReturnDate} tarihinde teslim etmiştir."); } } } Console.WriteLine("--Update--"); rentalManager.Update(new Rental { RentalId = 4, CarId = 2, CustomerId = 1, RentDate = new DateTime(2020, 06, 23), ReturnDate = new DateTime(2020, 07, 01) }); var result2 = rentalManager.GetAll(); if (result2.Success) { foreach (var rental in result2.Data) { Console.WriteLine($@"{rental.CustomerId}'idli müşterimiz {rental.CarId}'idli arabayı {rental.RentDate} tarihinde kiralamıştır "); if (rental.ReturnDate != null) { Console.WriteLine($@"{rental.ReturnDate} tarihinde teslim etmiştir."); } } } }
public List <CarDetailDto> GetCarDetails() { using (RentaCarContext context = new RentaCarContext()) { List <CarDetailDto> liste = new List <CarDetailDto>(); CarDetailDto sonuc = new CarDetailDto(); var result = from car in context.Car join brand in context.Brands on car.BrandID equals brand.BrandID join color in context.Colors on car.ColorID equals color.ColorId join image in context.CarImage on car.CarID equals image.CarID join carInfo in context.CarInfoDetail on car.CarID equals carInfo.CarID select new CarDetailDto { CarID = car.CarID, BrandName = brand.BrandName, ColorName = color.ColorName, CarName = car.CarName, ModelYear = car.ModelYear, DailyPrice = car.DailyPrice, Description = car.Description, CarImage = image.CarImage, Manifacturer = carInfo.Manifacturer, Production = carInfo.Production, Assembly = carInfo.Assembly, Designer = carInfo.Designer, Class = carInfo.Class, BodyStyle = carInfo.BodyStyle, Engine = carInfo.Engine, PowerOut = carInfo.PowerOut, Transmission = carInfo.Transmission }; foreach (var item in result) { liste.Add(item); } return(liste); } }
public List <CarDetailDto> GetCarDetails() { using (CarsDatabaseContext context = new CarsDatabaseContext()) { CarDetailDto carDto = new CarDetailDto(); var result = from ca in context.Cars join co in context.Colors on ca.ColorId equals co.Id join br in context.Brands on ca.BrandId equals br.Id select new CarDetailDto { Id = ca.Id, BrandName = br.Name, ColorName = co.Name, ModelYear = ca.ModelYear, DailyPrice = ca.DailyPrice }; return(result.ToList()); } }
public CarDetailDto GetWithDetails(int ID) { CarDetailDto detailedCar; var car = GetCarDetails(ID); using (CarContext context = new CarContext()) { var result = from i in context.CarImages join b in context.Brands on car.BrandID equals b.ID join c in context.Colors on car.ColorID equals c.ID where car.ID == i.CarID select new CarImage { CarID = car.ID, Date = i.Date, ID = i.ID, ImagePath = i.ImagePath }; detailedCar = new CarDetailDto() { BrandName = car.BrandName, ColorName = car.ColorName, CarName = car.CarName, BrandID = car.BrandID, ColorID = car.ColorID, DailyPrice = car.DailyPrice, CarImages = result.ToList(), ID = car.ID, Description = car.Description, ModelYear = car.ModelYear }; return(detailedCar); } }
public IDataResult <List <CarDetailDto> > CarDtoImageList(List <CarDetailDto> carDetailList) { carDetailDtos.Clear(); foreach (var item in carDetailList) { carDetail = item; var resultImage = _carImageDal.GetAll(p => p.CarId == item.CarId); if (resultImage.Count != 0) { foreach (var item2 in resultImage) { carDetail.ImagePath = item2.ImagePath; break; } } else { carDetail.ImagePath = "/Images/default.jpg"; } carDetailDtos.Add(carDetail); } return(new SuccessDataResult <List <CarDetailDto> >(carDetailDtos)); }
public void Add(CarDetailDto car) { throw new NotImplementedException(); }
public IActionResult GetCarDetails(CarDetailDto carDetailDto) { var result2 = _carService.GetCarDetails(); return(Ok(result2)); }
public WindowRentalDetails(CarDetailDto car) { InitializeComponent(); _rentalService = new RentalManager(new EfRentalDal()); _car = car; }