示例#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);
        }
示例#2
0
        public ValidationFailure ReferencesValidate(DealerSaucer dealerSaucer, ValidationContext <DealerSaucer> context)
        {
            var dealer = _dealerRepository.FindBy(dealerSaucer.DealerId);

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

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

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

            var dealerSaucerRetrieved = _dealerSaucerRepository.FindBy(deaSau => deaSau.DealerId == dealerSaucer.DealerId && deaSau.SaucerId == dealerSaucer.SaucerId);

            if (dealerSaucerRetrieved.IsNotEmpty())
            {
                return(new ValidationFailure("DealerSaucer", "Ya existe la relacion"));
            }

            return(null);
        }
 public SuccessResponse Update(SaucerRequest request)
 {
     try
     {
         var currentSaucer = _saucerRepository.FindBy(request.Id);
         currentSaucer.ThrowExceptionIfRecordIsNull();
         var saucerToCopy = TypeAdapter.Adapt <Saucer>(request);
         TypeAdapter.Adapt(saucerToCopy, currentSaucer);
         _saucerValidator.ValidateAndThrowException(currentSaucer, "Base");
         _saucerRepository.Update(currentSaucer);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
示例#4
0
        public DTO.Menu Execute(Menu menu)
        {
            var menuDto = TypeAdapter.Adapt <DTO.Menu>(menu);
            var dealer  = _dealerRepository.FindBy(menu.DealerId);

            menuDto.Dealer = TypeAdapter.Adapt <DTO.Dealer>(dealer);
            var saucer = _saucerRepository.FindBy(menu.SaucerId);

            menuDto.Saucer = TypeAdapter.Adapt <DTO.Saucer>(saucer);
            return(menuDto);
        }
        public DTO.SaucerConfiguration Execute(SaucerConfiguration saucerConfiguration)
        {
            var saucerConfigurationDto = TypeAdapter.Adapt <DTO.SaucerConfiguration>(saucerConfiguration);
            var saucer = _saucerRepository.FindBy(saucerConfiguration.SaucerId);

            saucerConfigurationDto.Saucer = TypeAdapter.Adapt <DTO.Saucer>(saucer);
            var ingredient = _ingredientRepository.FindBy(saucerConfiguration.IngredientId);

            saucerConfigurationDto.Ingredient = TypeAdapter.Adapt <DTO.Ingredient>(ingredient);
            return(saucerConfigurationDto);
        }
        public ValidationFailure ReferencesValidate(SaucerMultimedia saucerMultimedia, ValidationContext <SaucerMultimedia> context)
        {
            var saucer = _saucerRepository.FindBy(saucerMultimedia.SaucerId);

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

            return(null);
        }
        public DTO.Reservation Execute(Reservation reservation)
        {
            var reservationDto = TypeAdapter.Adapt <DTO.Reservation>(reservation);
            var worker         = _workerRepository.FindBy(reservation.WorkerId);

            reservationDto.Worker = TypeAdapter.Adapt <DTO.Worker>(worker);
            var saucer = _saucerRepository.FindBy(reservation.SaucerId);

            reservationDto.Saucer = TypeAdapter.Adapt <DTO.Saucer>(saucer);
            var dealer = _dealerRepository.FindBy(reservation.DealerId);

            reservationDto.Dealer = TypeAdapter.Adapt <DTO.Dealer>(dealer);
            return(reservationDto);
        }
示例#8
0
        public ValidationFailure ReferencesValidate(SaucerConfiguration saucerConfiguration, ValidationContext <SaucerConfiguration> context)
        {
            var saucer = _saucerRepository.FindBy(saucerConfiguration.SaucerId);

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

            var ingredient = _ingredientRepository.FindBy(saucerConfiguration.IngredientId);

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

            return(null);
        }