Esempio n. 1
0
        public ActionResult Index()
        {
            bool es = User.Identity.IsAuthenticated;

            List <Food> foodList = foodService.GetAll();

            string strUserId = User.Identity.GetUserId();

            foodList = foodService.GetAll().Where(x => x.ApplicationUserId == strUserId).ToList();

            return(View(foodList));
        }
Esempio n. 2
0
        //TODO find the best place to put the ordination
        //Pagination
        public string GetAllPaginated(int page, int numberPerPage)
        {
            IPagedList <Food> foodsPaginated = _service.GetAll().OrderBy(f => f.Name).ToPagedList(page, numberPerPage);
            string            result         = foodsPaginated.TotalItemCount > 0 ? JsonHelper <Food> .SerializePagedList(foodsPaginated) : string.Empty;

            return(result);
        }
Esempio n. 3
0
        // GET: Picker
        public ActionResult Index()
        {
            bool es = User.Identity.IsAuthenticated;

            List <Food> foodList = foodService.GetAll();

            string strUserId = User.Identity.GetUserId();

            foodList = foodService.GetAll().Where(x => x.ApplicationUserId == strUserId).ToList();

            //List<Food> foodList = _uw.foodRep.GetAll();
            //ViewBag.RandomFood = _uw.foodRep.RandomFood();
            //ViewBag.HealthyRandomFood = _uw.foodRep.HealtyRandomFood();

            return(View(foodList));
        }
Esempio n. 4
0
        public IActionResult GetAll()
        {
            var result = _foodService.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Esempio n. 5
0
 public async Task <IActionResult> GetALl([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
 {
     try
     {
         return(Ok(await _foodService.GetAll(pageIndex, pageSize)));
     }
     catch (Exception e)
     {
         return(NotFound(e));
     }
 }
Esempio n. 6
0
 public IActionResult GetAll()
 {
     try
     {
         return(Ok(_foodService.GetAll()));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("GetFoods", ex.Message);
         return(BadRequest(ModelState));
     }
 }
Esempio n. 7
0
        public async Task <IActionResult> OnGet()
        {
            var foodList = await _foodService.GetAll();

            var vm = new UserOrderViewModel
            {
                FoodList = foodList.ToList(),
                UserId   = "55656",
                UserName = User.Identity.Name
            };

            return(Page());
        }
Esempio n. 8
0
        public ActionResult OrderFood(ReservationDTO reservation)
        {
            if (reservation == null || reservation.Id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "no valid reservaion"));
            }

            var allFoodsFromService = _foodService.GetAll();

            if (allFoodsFromService == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable));
            }
            var foods  = new List <FoodDTO>();
            var drinks = new List <FoodDTO>();

            foreach (var item in allFoodsFromService)
            {
                if (item.FoodCategoryName.Equals("Mad"))
                {
                    foods.Add(item);
                }
                else if (item.FoodCategoryName.Equals("Drikkevare"))
                {
                    drinks.Add(item);
                }
            }

            var cvm = new CustomViewModel
            {
                ListDrink    = foods,
                ListFood     = drinks,
                OrderSummary = new List <FoodDTO>(),
                Reservation  = reservation
            };

            return(View(cvm));
        }
Esempio n. 9
0
        public async Task GetFood_ReturnValueEqualsExpected_Success()
        {
            var expected = GetTestData();
            var value    = expected.Select(x => _mapper.Map <Food>(x));

            _foodRepositoryMock.Setup(x => x.GetAllAsync()).ReturnsAsync(value);

            var actual = await _service.GetAll();

            var expectedSer = JsonConvert.SerializeObject(expected);
            var actualSer   = JsonConvert.SerializeObject(actual);

            Assert.AreEqual(expectedSer, actualSer);
        }
Esempio n. 10
0
        public async Task <IActionResult> Insert()
        {
            QueryResponse <FoodCategory> categories = await foodCategoryService.GetAll();

            QueryResponse <Food> foods = await foodService.GetAll();

            QueryResponse <Meal> meals = await mealService.GetAll();

            ViewBag.Path       = environment.ContentRootPath + "//wwwroot//img//refeicao//";
            ViewBag.Categories = categories.Data;
            ViewBag.Foods      = foods.Data;
            ViewBag.Meals      = meals.Data;

            return(View());
        }
Esempio n. 11
0
        public MainWindowViewModel(ITimeService timeService, IAnimalService animalService, IFoodService foodService, IOpenCommandAnimal openCommandAnimal, IOpenCommandFood openCommandFood)
        {
            _timeService   = timeService;
            _animalService = animalService;
            _foodService   = foodService;
            _currentTime   = _timeService.CurrentTime;

            _hungry       = new ObservableCollection <AnimalModel>(_animalService.GetHungryAnimals());
            _foodModels   = new ObservableCollection <FoodModel>(_foodService.GetAll());
            _animalModels = new ObservableCollection <AnimalModel>(_animalService.GetAllAnimals());

            _openAddAnimalWindow = openCommandAnimal;
            _openCommandFood     = openCommandFood;

            _foodPath   = ConfigurationManager.AppSettings["FoodSerializationPath"];
            _animalPath = ConfigurationManager.AppSettings["AnimalSerializationPath"];
        }
Esempio n. 12
0
        public IActionResult GetAll()
        {
            try
            {
                var foods = _foodService.GetAll();

                if (foods == null)
                {
                    return(NotFound());
                }
                return(Ok(foods));
            }
            catch
            {
                return(BadRequest());
            }
        }
Esempio n. 13
0
 public async Task <IEnumerable <FoodDto> > GetAll()
 {
     return(await _service.GetAll());
 }
Esempio n. 14
0
        public async Task <IActionResult> OnGet()
        {
            FoodList = await _foodService.GetAll();

            return(Page());
        }
 public async Task <ActionResult <IEnumerable <FoodItem> > > GetAll()
 {
     return(await _service.GetAll());
 }
        public IActionResult GetAll()
        {
            var menus = _foodService.GetAll();

            return(Ok(menus));
        }
        public async Task <IActionResult> Get()
        {
            var result = await _foodService.GetAll();

            return(Ok(result));
        }
 public IActionResult Get()
 {
     return(Ok(service.GetAll()));
 }