public ClientValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A client with same phone number is already exist");
     RuleFor(x => x.FirstName)
     .NotEmpty().WithMessage("Client's first name must be entered")
     .MinimumLength(2).WithMessage("Client's first name too short")
     .MaximumLength(20).WithMessage("Client's first name too long")
     .Matches(@"^[A-Za-z]*$").WithMessage("Invalid first name entered");
     RuleFor(x => x.MiddleName)
     .NotEmpty().WithMessage("Client's second name must be entered")
     .MinimumLength(2).WithMessage("Client's second name too short")
     .MaximumLength(20).WithMessage("Client's second name too long")
     .Matches(@"^[A-Za-z]*$").WithMessage("Invalid second name entered");
     RuleFor(x => x.LastName)
     .NotEmpty().WithMessage("Client's last name must be entered")
     .MinimumLength(2).WithMessage("Client's last name too short")
     .MaximumLength(20).WithMessage("Client's last name too long")
     .Matches(@"^[A-Za-z]*$").WithMessage("Invalid last name entered");
     RuleFor(x => x.Address)
     .NotEmpty().WithMessage("Client's address must be entered")
     .MinimumLength(10).WithMessage("Client's address too short")
     .MaximumLength(50).WithMessage("Client's address too long");
     RuleFor(x => x.PhoneNumber)
     .NotEmpty().WithMessage("Phone number must be entered")
     .Matches(@"^(\d{9,15})$").WithMessage("Invalid phone number entered");
 }
 public DurationValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A duration with same time is already exist");
     RuleFor(x => x.Time)
     .NotNull().WithMessage("Duration time must be entered")
     .GreaterThan((byte)0).WithMessage("Duration time must be greater than 0");
 }
 public PassDiscountValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("The discount already applied to the pass");
     //RuleFor(x => x.Discount)
     //    .MustAsync(IsExist).WithMessage("Discount with same Id does not exist");
     //RuleFor(x => x.Pass)
     //    .MustAsync(IsExist).WithMessage("Pass with same Id does not exist");
 }
 public ClimateValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A climate with same name is already exist");
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Climate name must be entered")
     .MinimumLength(2).WithMessage("Climate name too short")
     .MaximumLength(20).WithMessage("Climate name too long")
     .Matches(@"^[A-Za-z]*$").WithMessage("Invalid climate name entered");
 }
示例#5
0
 public CountryValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A country with same name is already exist");
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Country name must be entered")
     .MinimumLength(2).WithMessage("Country name too short")
     .MaximumLength(20).WithMessage("Country name too long")
     .Matches("\\D*").WithMessage("Invalid country name entered");
 }
 public DiscountValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A discount with same name is already exist");
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Discount name must be entered")
     .MinimumLength(3).WithMessage("Discount name too short")
     .MaximumLength(20).WithMessage("Discount name too long");
     RuleFor(x => x.Value)
     .NotNull().WithMessage("Discount value must be entered")
     .GreaterThan(0).WithMessage("Discount value must be greater than 0");
 }
示例#7
0
 public PassValidator(TravelCompanyDBContext context) : base(context)
 {
     //RuleFor(x => x.Client)
     //    .MustAsync(IsExist).WithMessage("Client with same Id does not exist");
     //RuleFor(x => x.Tour)
     //    .MustAsync(IsExist).WithMessage("Tour with same Id does not exist");
     RuleFor(x => x.Count)
     .NotNull().WithMessage("Pass tours count must be entered")
     .GreaterThan(0).WithMessage("Pass tours count must be greater than 0");
     RuleFor(x => x.PurchaseDate)
     .NotNull().WithMessage("Pass purchase date must be entered");
 }
示例#8
0
 public HotelValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A hotel with same name is already exist");
     //RuleFor(x => x.City)
     //    .MustAsync(IsExist).WithMessage("City with same Id does not exist");
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Hotel name must be entered")
     .MinimumLength(2).WithMessage("Hotel name too short")
     .MaximumLength(20).WithMessage("Hotel name too long")
     .Matches("^\\D*$").WithMessage("Invalid hotel name entered");
     RuleFor(x => x.Stars)
     .NotNull().WithMessage("Hotel stars count must be entered")
     .LessThan(6).WithMessage("Hotel stars count must be less than 6")
     .GreaterThan(0).WithMessage("Hotel stars count must be greater than 0");
 }
示例#9
0
 public UnitOfWork(ICityRepository cityRepository, IClientRepository clientRepository, IClimateRepository climateRepository,
                   ICountryRepository countryRepository, IDiscountRepository discountRepository, IDurationRepository durationRepository,
                   IHotelRepository hotelRepository, IPassDiscountRepository passDiscountRepository, IPassRepository passRepository,
                   ITourRepository tourRepository, TravelCompanyDBContext context)
 {
     _cityRepository         = cityRepository;
     _clientRepository       = clientRepository;
     _climateRepository      = climateRepository;
     _countryRepository      = countryRepository;
     _discountRepository     = discountRepository;
     _durationRepository     = durationRepository;
     _hotelRepository        = hotelRepository;
     _passDiscountRepository = passDiscountRepository;
     _passRepository         = passRepository;
     _tourRepository         = tourRepository;
     _context = context;
 }
示例#10
0
 public TourValidator(TravelCompanyDBContext context) : base(context)
 {
     RuleFor(x => x)
     .MustAsync(IsUnique).WithMessage("A tour with same name is already exist");
     //RuleFor(x => x.Duration)
     //    .MustAsync(IsExist).WithMessage("Duration with same Id does not exist");
     //RuleFor(x => x.Hotel)
     //    .MustAsync(IsExist).WithMessage("Hotel with same Id does not exist");
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Tour name must be entered")
     .MinimumLength(10).WithMessage("Tour name too short")
     .MaximumLength(80).WithMessage("Tour name too long");
     RuleFor(x => x.Price)
     .NotNull().WithMessage("Tour price must be entered")
     .GreaterThan(0).WithMessage("Tour price must be greater than 0");
     RuleFor(x => x.StartDate)
     .NotNull().WithMessage("Tour start date must be entered");
 }
示例#11
0
 public HotelRepository(TravelCompanyDBContext context) : base(context)
 {
 }
 public DurationRepository(TravelCompanyDBContext context) : base(context)
 {
 }
 public DiscountRepository(TravelCompanyDBContext context) : base(context)
 {
 }
 public MyAbstractValidator(TravelCompanyDBContext context)
 {
     _context = context;
 }
 public TourRepository(TravelCompanyDBContext context) : base(context)
 {
 }
示例#16
0
 public GenericRepository(TravelCompanyDBContext context)
 {
     _context = context;
     _set     = context.Set <TEntity>();
 }
示例#17
0
 public CountryRepository(TravelCompanyDBContext context) : base(context)
 {
 }
 public ClientRepository(TravelCompanyDBContext context) : base(context)
 {
 }