예제 #1
0
 public ServicesManager(
     DataManager dataManager
     )
 {
     _dataManager      = dataManager;
     _categoryService  = new CategoryService(_dataManager);
     _tagService       = new TagService(_dataManager);
     _dishesService    = new DishesService(_dataManager);
     _basketService    = new BasketService(_dataManager);
     _imageService     = new ImageService(_dataManager);
     _orderInfoService = new OrderInfoService(_dataManager);
 }
예제 #2
0
        // GET: api/Allergens
        public IEnumerable <AllergenDTO> GetAllergens(int id)
        {
            try
            {
                dishesService = new DishesService(User.Identity.Name);
            }
            catch (UserNotFoundException)
            {
                return(null);
            }

            IEnumerable <Allergen> allergens = dishesService.GetAllergens(id);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Allergen, AllergenDTO>();
            });
            IMapper iMapper = config.CreateMapper();

            return(iMapper.Map <IEnumerable <Allergen>, IEnumerable <AllergenDTO> >(allergens));
        }
예제 #3
0
        public IHttpActionResult GetDish(int id)
        {
            try
            {
                dishesService = new DishesService(User.Identity.Name);
            }
            catch (UserNotFoundException)
            {
                return(NotFound());
            }

            Dish dish = dishesService.Get(id);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Dish, DishDTO>();
            });
            IMapper iMapper = config.CreateMapper();

            DishDTO dishDTO = iMapper.Map <Dish, DishDTO>(dish);

            return(Ok(dishDTO));
        }
예제 #4
0
        // GET: api/Dishes
        public IEnumerable <DishDTO> GetDishes(
            string filterOption = null, string sortOption = null,
            int pageSize        = 20, int pageNumber      = 1)
        {
            try
            {
                dishesService = new DishesService(User.Identity.Name);
            }
            catch (UserNotFoundException)
            {
                return(null);
            }

            IEnumerable <Dish> dishes = dishesService.Get(
                filterOption, sortOption, pageSize, pageNumber);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Dish, DishDTO>();
            });
            IMapper iMapper = config.CreateMapper();

            return(iMapper.Map <IEnumerable <Dish>, IEnumerable <DishDTO> >(dishes));
        }