예제 #1
0
        public CustomPizza FromCreateCustomPizzaModel(IPizzaFactoryDbContext pizzaContext, CreateCustomPizzaModel customPizzaModel)
        {
            var     ingredients = new List <Ingredient>();
            decimal price       = 2.00M;

            foreach (var item in customPizzaModel.Ingredients)
            {
                var ingredient = pizzaContext.Ingredients.Find(item);
                if (ingredient.Name != "none" && !ingredients.Contains(ingredient))
                {
                    ingredients.Add(ingredient);
                    price += ingredient.Price;
                }
            }

            CustomPizza pizza = new CustomPizza()
            {
                Name        = customPizzaModel.Name,
                Description = customPizzaModel.Description,
                Ingredients = ingredients,
                Price       = price
            };

            return(pizza);
        }
        public CustomPizzaService(IPizzaFactoryDbContext pizzaContext, IMapper mapper, IValidator validator)
        {
            Guard.WhenArgument(pizzaContext, nameof(pizzaContext)).IsNull().Throw();
            Guard.WhenArgument(mapper, nameof(mapper)).IsNull().Throw();
            Guard.WhenArgument(validator, nameof(validator)).IsNull().Throw();

            this.pizzaContext = pizzaContext;
            this.mapper       = mapper;
            this.validator    = validator;
        }
        public ApplicationUserService(IIdentityDbContext userContext, IPizzaFactoryDbContext pizzaContext, IOrderDbContext orderContext, IMapper mapper, IValidator validator)
        {
            Guard.WhenArgument(userContext, nameof(userContext)).IsNull().Throw();
            Guard.WhenArgument(pizzaContext, nameof(pizzaContext)).IsNull().Throw();
            Guard.WhenArgument(orderContext, nameof(orderContext)).IsNull().Throw();
            Guard.WhenArgument(mapper, nameof(mapper)).IsNull().Throw();
            Guard.WhenArgument(validator, nameof(validator)).IsNull().Throw();

            this.userContext  = userContext;
            this.pizzaContext = pizzaContext;
            this.orderContext = orderContext;
            this.mapper       = mapper;
            this.validator    = validator;
        }
예제 #4
0
        public IngredientService(IPizzaFactoryDbContext pizzaContext)
        {
            Guard.WhenArgument(pizzaContext, nameof(pizzaContext)).IsNull().Throw();

            this.pizzaContext = pizzaContext;
        }