private string GetStageName(CalendarStageService calendarStageService, List <DataService.CalendarStage> calendarStages)
        {
            string result = "undefined";

            foreach (var stage in calendarStages)
            {
                if (stage.Id == calendarStageService.CalendarStageId)
                {
                    result = stage.Name;
                }
            }
            return(result);
        }
        internal CustomizeData GetCustomizeData(int currentUnitId)
        {
            var result      = new CustomizeData();
            var dataService = new QNomyDataService();

            result.UnitId           = currentUnitId;
            result.ConfigId         = dataService.GetConfigId(currentUnitId);
            result.NotShownServices = new List <CustomizeStageService>();
            result.Stages           = new List <CustomizeCalendarStage>();
            List <CalendarStage> calendarStages = dataService.GetClendarStages(result.ConfigId);

            var services      = dataService.GetServicesForUnit(currentUnitId);
            var stageServices = dataService.GetClendarStageServices(result.ConfigId);


            foreach (var stage in calendarStages)
            {
                if (stage.StageType == CalendarStageType.None)
                {
                    continue;
                }

                var calendarStage = new CustomizeCalendarStage {
                    Id = stage.Id, Name = stage.Name, StageType = stage.StageType, SortOrder = stage.SortOrder, IsServiceDefault = stage.IsServiceDefault, CalendarStageConfigId = stage.CalendarStageConfigId
                };
                calendarStage.Services = new List <CustomizeStageService>();
                result.Stages.Add(calendarStage);
            }

            CustomizeCalendarStage defaultInServiceStageForNotMappedServices = result.Stages.Find(x => x.IsServiceDefault); //can be null;

            foreach (var service in services)
            {
                CustomizeCalendarStage stage           = null;
                CalendarStageService   stageForService = stageServices.Find(x => x.ServiceId == service.Id);
                if (stageForService == null)
                {
                    stage = defaultInServiceStageForNotMappedServices;
                }
                else
                {
                    stage = result.Stages.Find(x => x.Id == stageForService.CalendarStageId);
                }

                if (stage != null && stage.StageType == CalendarStageType.None)
                {
                    stage = null;
                }

                if (stage == null)
                {
                    result.NotShownServices.Add(new CustomizeStageService()
                    {
                        ServiceId = service.Id, Name = service.Name, CalendarStageId = -1
                    });
                }
                else
                {
                    stage.Services.Add(new CustomizeStageService()
                    {
                        ServiceId = service.Id, Name = service.Name, CalendarStageId = stage.Id
                    });
                }
            }

            return(result);
        }