Пример #1
0
 public RequestItemViewModel()
 {
     _requestService       = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
     ServiceList           = new ObservableCollection <ServiceDto>();
     MasterList            = new ObservableCollection <WorkerDto>(_requestService.GetMasters(null));
     ExecuterList          = new ObservableCollection <WorkerDto>(_requestService.GetExecuters(null));
     EquipmentList         = new ObservableCollection <EquipmentDto>(_requestService.GetEquipments());
     ParentServiceList     = new ObservableCollection <ServiceDto>(_requestService.GetServices(null));
     SelectedParentService = ParentServiceList.FirstOrDefault();
     PeriodList            = new ObservableCollection <PeriodDto>(_requestService.GetPeriods());
     SelectedPeriod        = PeriodList.FirstOrDefault();
     CompanyList           = new ObservableCollection <ServiceCompanyDto>(_requestService.GetServiceCompanies());
     SelectedCompany       = CompanyList.FirstOrDefault();
     Rating      = new RequestRatingDto();
     GarantyList = new ObservableCollection <GarantyDto>(new GarantyDto[] {
         new GarantyDto {
             Id = 0, Name = "Обычная"
         },
         new GarantyDto {
             Id = 1, Name = "Гарантия"
         },
         new GarantyDto {
             Id = 2, Name = "Возможно гарантия"
         },
     });
     SelectedGaranty = GarantyList.FirstOrDefault();
 }
Пример #2
0
 public EditExecuterBindDialogViewModel(RequestServiceImpl.RequestService requestService, int serviceCompanyId)
 {
     _requestService   = requestService;
     _serviceCompanyId = serviceCompanyId;
     ExecuterList      = new ObservableCollection <WorkerDto>(_requestService.GetExecuters(null));
     TypeList          = new ObservableCollection <ServiceDto>(_requestService.GetServices(null));
     Weigth            = 100;
     Refresh();
 }
Пример #3
0
        public void RefreshExecuters()
        {
            var selectedExecuterId = SelectedExecuter?.Id;

            if (ShowAllExecuters || SelectedCompany == null || SelectedParentService == null)
            {
                ExecuterList = new ObservableCollection <WorkerDto>(_requestService.GetExecuters(null));
            }
            else if (_selectedHouseId.HasValue)
            {
                ExecuterList = new ObservableCollection <WorkerDto>(
                    _requestService.GetWorkersByHouseAndService(_selectedHouseId.Value, SelectedParentService.Id, false));
            }
            SelectedExecuter = ExecuterList.FirstOrDefault(m => m.Id == selectedExecuterId);
            if (SelectedExecuter == null)
            {
                SelectedExecuter = ExecuterList.FirstOrDefault();
            }
            OnPropertyChanged(nameof(ExecuterList));
        }
Пример #4
0
        public void InitCollections()
        {
            _requestService  = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            FilterStreetList = new ObservableCollection <FieldForFilterDto>();
            HouseList        = new ObservableCollection <HouseDto>();
            FlatList         = new ObservableCollection <FlatDto>();
            ServiceList      = new ObservableCollection <ServiceDto>();
            FilterMasterList = new ObservableCollection <FieldForFilterDto>(_requestService.GetMasters(null).Select(
                                                                                w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = $"{w.SurName} {w.FirstName} {w.PatrName}",
                Selected = false
            }).OrderBy(s => s.Name));

            FilterExecuterList = new ObservableCollection <FieldForFilterDto>(_requestService.GetExecuters(null).Select(
                                                                                  w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = $"{w.SurName} {w.FirstName} {w.PatrName}",
                Selected = false
            }).OrderBy(s => s.Name));

            FilterServiceCompanyList = new ObservableCollection <FieldForFilterDto>(_requestService.GetServiceCompanies().Select(
                                                                                        w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = w.Name,
                Selected = false
            }).OrderBy(s => s.Name));

            FilterStatusList = new ObservableCollection <FieldForFilterDto>(_requestService.GetRequestStatuses().Select(
                                                                                w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = w.Description,
                Selected = false
            }).OrderBy(s => s.Name));

            FilterUserList = new ObservableCollection <FieldForFilterDto>(_requestService.GetUsers().Select(
                                                                              w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = w.FullName,
                Selected = false
            }).OrderBy(s => s.Name));
            FilterRatingList = new ObservableCollection <FieldForFilterDto>(new [] { 1, 2, 3, 4, 5 }.Select(
                                                                                w => new FieldForFilterDto()
            {
                Id       = w,
                Name     = w.ToString(),
                Selected = false
            }).OrderBy(s => s.Name));
            FilterParentServiceList = new ObservableCollection <FieldForFilterDto>(_requestService.GetServices(null).Select(
                                                                                       w => new FieldForFilterDto()
            {
                Id       = w.Id,
                Name     = w.Name,
                Selected = false
            }).OrderBy(s => s.Name));
            foreach (var service in FilterParentServiceList)
            {
                service.PropertyChanged += ServiceOnPropertyChanged;
            }
            //foreach (var status in FilterStatusList)
            //{
            //    status.PropertyChanged += OnPropertyChanged;
            //}

            PaymentList = new ObservableCollection <PaymentDto>(new [] { new PaymentDto {
                                                                             Id = 0, Name = "Бесплатные"
                                                                         }, new PaymentDto {
                                                                             Id = 1, Name = "Платные"
                                                                         } });
            ChangeCity(_requestService.GetCities().FirstOrDefault().Id);
        }