示例#1
0
        public IActionResult Delete(NRental rental)
        {
            var result = _iRentalService.Delete(rental);

            if (result.Success == true)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
示例#2
0
 public IResult Add(NRental rental)
 {
     if (rental.ReturnDate == null)
     {
         return(new ErrorResult(Messages.RentalDateInvalid));
     }
     else
     {
         _iRentalDal.Add(rental);
         return(new SuccessResult(Messages.RentalAdded));
     }
 }
示例#3
0
        public IResult isCarAvailable(NRental rental)
        {
            var result = _iRentalDal.GetAll(r => r.CarId == rental.CarId);

            if (result.Any(r => r.RentDate != null && r.ReturnDate == null))
            {
                return(new ErrorResult("Messages.CarIsNotAvailable"));
            }
            else
            {
                return(new SuccessResult());
            }
        }
示例#4
0
        private static void RentalAddTest()
        {
            Console.WriteLine("------------------Araç Kiralama------------------------");
            RentalManager rentalManager = new RentalManager(new EfRentalDAL());
            NRental       rental2       = new NRental();

            rental2.CarId      = 2;
            rental2.CustomerId = 6;


            rental2.ReturnDate = DateTime.Now;


            var rental = rentalManager.Add(rental2);

            Console.WriteLine(rental.Message);
        }
示例#5
0
 public IResult Update(NRental rental)
 {
     _iRentalDal.Update(rental);
     return(new SuccessResult(Messages.RentalUpdated));
 }
示例#6
0
 public IResult Delete(NRental rental)
 {
     _iRentalDal.Delete(rental);
     return(new SuccessResult(Messages.RentalDeleted));
 }