Пример #1
0
        public ValidationFailure CreateConfigurationValidate(SaucerConfiguration saucerConfiguration, ValidationContext <SaucerConfiguration> context)
        {
            var saucerConfigurationsRetrieved = _saucerConfigurationRepository.FindBy(saucerConfig => saucerConfig.SaucerId == saucerConfiguration.SaucerId && saucerConfig.IngredientId == saucerConfiguration.IngredientId && saucerConfig.IsActive);

            if (saucerConfigurationsRetrieved.IsNotEmpty())
            {
                return(new ValidationFailure("SaucerConfiguration", "Ya existe configuracion"));
            }

            return(null);
        }
 public SuccessResponse Update(SaucerConfigurationRequest request)
 {
     try
     {
         var currentSaucerConfiguration = _saucerConfigurationRepository.FindBy(request.Id);
         currentSaucerConfiguration.ThrowExceptionIfRecordIsNull();
         var saucerConfigurationToCopy = TypeAdapter.Adapt <SaucerConfiguration>(request);
         TypeAdapter.Adapt(saucerConfigurationToCopy, currentSaucerConfiguration);
         _saucerConfigurationValidator.ValidateAndThrowException(currentSaucerConfiguration, "Base,Update");
         _saucerConfigurationRepository.Update(currentSaucerConfiguration);
         return(new SuccessResponse {
             IsSuccess = true
         });
     }
     catch (DataAccessException)
     {
         throw new ApplicationException();
     }
 }
Пример #3
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);
        }
Пример #4
0
        public List <ReservationDetail> BySaucer(int saucerId)
        {
            var saucerConfigurations = _saucerConfigurationRepository.FindBy(saucerConfiguration => saucerConfiguration.SaucerId == saucerId && saucerConfiguration.Status);

            return(TypeAdapter.Adapt <List <ReservationDetail> >(saucerConfigurations));
        }