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);
        }
Example #2
0
        public DTO.ReservationDetail Execute(ReservationDetail reservationDetail)
        {
            var reservationDetailDto = TypeAdapter.Adapt <DTO.ReservationDetail>(reservationDetail);
            var reservation          = _reservationRepository.FindBy(reservationDetail.ReservationId);

            reservationDetailDto.Reservation = TypeAdapter.Adapt <DTO.Reservation>(reservation);
            var ingredient = _ingredientRepository.FindBy(reservationDetail.IngredientId);

            reservationDetailDto.Ingredient = TypeAdapter.Adapt <DTO.Ingredient>(ingredient);
            return(reservationDetailDto);
        }
Example #3
0
 public SuccessResponse Update(IngredientRequest request)
 {
     try
     {
         var currentIngredient = _ingredientRepository.FindBy(request.Id);
         currentIngredient.ThrowExceptionIfRecordIsNull();
         var isReference = _ingredientRepository.IsReference(request.Id);
         isReference.ThrowExceptionIfIsReference();
         var ingredientToCopy = TypeAdapter.Adapt <Ingredient>(request);
         TypeAdapter.Adapt(ingredientToCopy, currentIngredient);
         _ingredientValidator.ValidateAndThrowException(currentIngredient, "Base");
         _ingredientRepository.Update(currentIngredient);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
Example #4
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);
        }
Example #5
0
        public NutritionInformation FindBySaucer(int saucerId)
        {
            var nutritionInformation = new NutritionInformation();
            var saucerConfigurations = _saucerConfigurationRepository.FindBy(saucerConfiguration => saucerConfiguration.SaucerId == saucerId && saucerConfiguration.Status);

            saucerConfigurations.ForEach(saucerConfiguration =>
            {
                var ingredient = _ingredientRepository.FindBy(saucerConfiguration.IngredientId);
                var portion    = saucerConfiguration.Portion;

                nutritionInformation.Energy       += (ingredient.Energy * portion);
                nutritionInformation.Protein      += (ingredient.Protein * portion);
                nutritionInformation.Carbohydrate += (ingredient.Carbohydrate * portion);
                nutritionInformation.Sugar        += (ingredient.Sugar * portion);
                nutritionInformation.Lipid        += (ingredient.Lipid * portion);
                nutritionInformation.Sodium       += (ingredient.Sodium * portion);
            });
            return(nutritionInformation);
        }