コード例 #1
0
        public PlanPaginationDTO GetByCompanyId(PlanGetByCompanyIdRequestDTO requestDto)
        {
            var plans    = _planRepository.GetByCompanyIdGrouped(requestDto.Page, requestDto.ItemsPerPage, requestDto.CompanyId, requestDto.FromDate, requestDto.ToDate);
            var planDtos = new List <PlanDTO>();

            foreach (var item in plans.Plans)
            {
                var shifts     = PlanHelper.ShiftsToList(item.Shifts);
                var shiftNames = PlanHelper.GetShiftNames(shifts);

                var mealIds = new List <int>();
                var meals   = new List <MealDTO>();
                foreach (var meal in item.Meals)
                {
                    mealIds.Add(meal.Id);
                    meals.Add(new MealDTO
                    {
                        Id          = meal.Id,
                        Name        = meal.Name,
                        NameForeign = meal.NameForeign,
                        ImageBase64 = "",
                        PlanId      = 0,
                        Allergens   = new List <CommonNameDTO>(),
                        Ingredients = new List <CommonNameDTO>()
                    });
                }

                planDtos.Add(new PlanDTO
                {
                    Ids          = item.Ids,
                    Shifts       = shifts,
                    ShiftNames   = shiftNames,
                    Date         = item.Date,
                    EditableFrom = item.EditableFrom,
                    EditableTo   = item.EditableTo,
                    CompanyId    = item.CompanyId,
                    MealIds      = mealIds,
                    Meals        = meals
                });
            }

            return(new PlanPaginationDTO
            {
                Plans = planDtos,
                TotalRows = plans.TotalRows
            });
        }