public IResult AddOrEdit(Rental entity) { try { if (entity.Id == 0) { bool result = _dal.Any(r => r.CarId == entity.CarId && r.ReturnDate == null); if (!result) { _dal.Add(entity); return(new SuccessResult(Messages.Added)); } return(new ErrorResult(Messages.CarError)); } else { _dal.Update(entity); return(new SuccessResult(Messages.Updated)); } } catch (Exception e) { return(new ErrorResult(Messages.Error + e.Message)); } }
private IResult IsCarAvaliable(int carId) { var result = _rentalDal.Any(x => x.CarId == carId && (x.ReturnDate == null || x.ReturnDate <= DateTime.Now)); if (result) { return(new ErrorResult(Messages.CarIsNotAvaliable)); } return(new SuccessResult()); }
public IResult IsCarAvaliable(int carId) { var result = _rentalDal.Any(r => r.CarId == carId && (r.ReturnDate == null || r.ReturnDate < DateTime.Now)); if (result) { return(new ErrorResult("Araba Kiralanmaya uygun değil")); } return(new SuccessResult()); }
public IResult Add(Rental rental) { var result = _rentalDal.Any(r => r.CarId == rental.CarId && r.ReturnDate == null); if (!result) { _rentalDal.Add(rental); return(new SuccessResult(Messages.Rental.Add())); } return(new ErrorResult(Messages.Error())); }
public IResult Add(RentalDetailDto rentalDto) { var result = _rentalDal.Any(r => r.CarId == rentalDto.CarId && (r.ReturnDate == null || r.ReturnDate >= rentalDto.RentDate)); if (!result) { var rental = _mapper.Map <Rental>(rentalDto); _rentalDal.Add(rental); return(new SuccessResult(Messages.Rental.Add())); } return(new ErrorResult(Messages.Rental.Exists())); }
private IResult CheckRentals(Rental rental) { if (!_dal.Any(r => r.CarId == rental.CarId && (r.ReturnDate == null || r.ReturnDate > DateTime.UtcNow))) { return(new SuccessResult()); } return(new ErrorResult()); }
public IResult Add(Rental rental) { var result = _rentalDal.Any(p => p.CarId == rental.CarId && (p.ReturnDate == null || p.ReturnDate > DateTime.Now)); if (result) { return(new ErrorResult("Araba hala kullanılıyor")); } _rentalDal.Add(rental); return(new SuccessResult("Araba Eklendi")); }