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 }); }
public PlanDTO GetByIds(List <int> ids) { var plan = _planRepository.GetByIds(ids); var shifts = PlanHelper.ShiftsToList(plan.Shifts); var shiftNames = PlanHelper.GetShiftNames(shifts); var mealIds = new List <int>(); var meals = new List <MealDTO>(); foreach (var meal in plan.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>() }); } var planDto = new PlanDTO { Ids = plan.Ids, Shifts = shifts, ShiftNames = shiftNames, Date = plan.Date, EditableFrom = plan.EditableFrom, EditableTo = plan.EditableTo, CompanyId = plan.CompanyId, MealIds = mealIds, Meals = meals }; return(planDto); }