Ejemplo n.º 1
0
        public async Task UpdateMenuById(MenuUpdateSpecParams updateSpecParams)
        {
            var spec = new MenusWithDateAndIncludes(updateSpecParams.Id);
            var menu = await _unitOfWork.Repository <Menu>().GetEntityWithSpec(spec);

            if (updateSpecParams.FoodFirst != null)
            {
                menu.FoodFirst = updateSpecParams.FoodFirst;
            }

            if (updateSpecParams.FoodSecond != null)
            {
                menu.FoodSecond = updateSpecParams.FoodSecond;
            }

            if (updateSpecParams.FoodThird != null)
            {
                menu.FoodThird = updateSpecParams.FoodThird;
            }

            if (updateSpecParams.FoodFourth != null)
            {
                menu.FoodFourth = updateSpecParams.FoodFourth;
            }


            _unitOfWork.Repository <Menu>().Update(menu);
            await _unitOfWork.Complete();
        }
Ejemplo n.º 2
0
        public async Task <IReadOnlyList <MenuToReturnDto> > GetAllMenu([FromQuery] MenuSpecParams menuParams)
        {
            var spec  = new MenusWithDateAndIncludes(menuParams);
            var menus = await _unitOfWork.Repository <Menu>().ListAsync(spec);

            if (!menus.Any())
            {
                await StoreContextSeed.CalculateDaysAsync(_context, menuParams.Month, menuParams.Year, menuParams.DinnerTimeId, menuParams.SchoolNameId);

                menus = await _unitOfWork.Repository <Menu>().ListAsync(spec);
            }

            var data = _mapper.Map <IReadOnlyList <Menu>, IReadOnlyList <MenuToReturnDto> >(menus);

            return(data);
        }
Ejemplo n.º 3
0
        public async Task <Menu> GetMenuByDateAsync(int id)
        {
            var spec = new MenusWithDateAndIncludes(id);

            return(await _unitOfWork.Repository <Menu>().GetEntityWithSpec(spec));
        }