コード例 #1
0
        public ValidationFailure ReferencesValidate(Reservation reservation, ValidationContext <Reservation> context)
        {
            var worker = _workerRepository.FindBy(reservation.WorkerId);

            if (worker.IsNull() || worker.Status.Equals(GlobalConstants.StatusDeactivated))
            {
                return(new ValidationFailure("Reservation", "El trabajador esta desactivado o no existe"));
            }

            var saucer = _saucerRepository.FindBy(reservation.SaucerId);

            if (saucer.IsNull() || saucer.Status.Equals(GlobalConstants.StatusDeactivated))
            {
                return(new ValidationFailure("Reservation", "El platillo esta desactivado o no existe"));
            }

            var dealer = _dealerRepository.FindBy(reservation.DealerId);

            if (dealer.IsNull() || dealer.Status.Equals(GlobalConstants.StatusDeactivated))
            {
                return(new ValidationFailure("Reservation", "El distribuidor esta desactivado o no existe"));
            }

            var mealType = new MealType().ConvertToCollection().FirstOrDefault(mealTp => mealTp.Value == reservation.MealType);

            if (mealType.IsNull())
            {
                return(new ValidationFailure("Reservation", "El tipo de comida no existe"));
            }

            return(null);
        }