Exemplo n.º 1
0
 public void Add(Car car)
 {
     if (!(car.Description.Length < 2 && car.DailyPrice <= 0))
     {
         _carDal.Add(car);
     }
     else
     {
         Console.WriteLine("Bilgileri kontrol ediniz");
     }
 }
Exemplo n.º 2
0
        public IResult Insert(Car car)
        {
            // FluentValidation yapıldı > ValidationRules.FluentValidation.CarValidator

            //if (car.Name.Length > 2 && car.DailyPrice > 0)
            //{
            //    _carDAL.Add(car);
            //    return new SuccessResult(Messages.CarAdded);
            //}
            //else
            //{
            //    return new ErrorResult(Messages.CarNotAdded);
            //}

            // > Tool yaz > CrossCuttingConcerns.Validation içine evrenselleştir
            //var context = new ValidationContext<Car>(car);
            //CarValidator carValidator = new CarValidator();
            //var result = carValidator.Validate(context);
            //if (!result.IsValid)
            //{
            //    throw new ValidationException(result.Errors);
            //}

            //  [ValidationAspect(typeof(Car))]eklendi. buna gerek yok artık.
            // ValidationTool.Validate(new CarValidator(), car);

            _carDAL.Add(car);
            return(new SuccessResult(Messages.CarAdded));
        }
Exemplo n.º 3
0
 public IResult Add(Car car)
 {
     if (car.Description.Length < 2 && car.DailyPrice < 0)
     {
         return(new ErrorResult(Messages.NameInvalid));
     }
     _icarDal.Add(car);
     return(new SuccessResult(Messages.Added));
 }
Exemplo n.º 4
0
        public IResult AddCar(NCar car)
        {
            // ValidationTool.Validate(new CarValidator(), car);

            //business codes

            _iCarDal.Add(car);
            return(new SuccessResult(Messages.CarAdded));

            // return new ErrorResult(Messages.CarNameInvalid);
        }
Exemplo n.º 5
0
        public IResult Add(Car car)
        {
            IResult result = BusinessRules.Run(CheckSameBrandCount(car.BrandId), CheckSameCarNameAndSameBrandId(car), CheckBrandCount(car.BrandId));

            if (result != null)
            {
                return(result);
            }
            _carDAL.Add(car);
            return(new SuccessResult(Messages.CarAdded));
        }
Exemplo n.º 6
0
 public IResult Add(Car car)
 {
     if (car.CarName.Length >= 2)
     {
         if (car.DailyPrice > 0)
         {
             _carDAL.Add(car);
             //Console.WriteLine("Successfully added.");
             return(new SuccessResult(Messages.CarAdded));
         }
         else
         {
             //Console.WriteLine("Car daily price must be greater than 0.");
             return(new ErrorResult(Messages.CarDailyPriceInvalid));
         }
     }
     else
     {
         //Console.WriteLine("Car name must be at least 2 characters.");
         return(new ErrorResult(Messages.CarNameInvalid));
     }
 }
Exemplo n.º 7
0
 public IResult Add(Car car)
 {
     _carDAL.Add(car);
     return(new SuccessResult());
 }
Exemplo n.º 8
0
 public IResult Add(Car car)
 {
     _Icardal.Add(car);
     return(new SuccessResult());
 }
Exemplo n.º 9
0
 public IResult Add(Car car)
 {
     //business code
     _carDAL.Add(car);
     return(new SuccessResult(Messages.CarAdded));
 }
Exemplo n.º 10
0
 public Car AddCar(Car car)
 {
     return(_carDal.Add(car));
 }
Exemplo n.º 11
0
 public IResult Add(Car car)
 {
     _carDAL.Add(car);
     return(new SuccessResult(Messages.Added));
 }
Exemplo n.º 12
0
 public IDataResult <Car> Add(Car car)
 {
     _carDal.Add(car);
     return(new SuccessDataResult <Car>(Messages.CarAdded));
 }