Ejemplo n.º 1
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);
        }