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();
 }
Exemple #2
0
        private void RefreshRequest()
        {
            if (_requestService == null)
            {
                _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            }
            RequestList.Clear();
            var requests = _requestService.GetRequestList(RequestNum, FilterByCreateDate, FromDate, ToDate,
                                                          ExecuteFromDate, ExecuteToDate,
                                                          FilterStreetList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          _selectedHouse?.Id, SelectedFlat?.Id,
                                                          FilterParentServiceList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          SelectedService?.Id,
                                                          FilterStatusList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          FilterMasterList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          FilterExecuterList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          FilterServiceCompanyList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          FilterUserList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          FilterRatingList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                                                          SelectedPayment?.Id, ServiceCompanyBadWork, OnlyRetry, ClientPhone, OnlyGaranty, OnlyImmediate);

            foreach (var request in requests)
            {
                RequestList.Add(request);
            }
            RequestCount = RequestList.Count;
            OnPropertyChanged(nameof(RequestList));
        }
Exemple #3
0
        public AddRatingDialogViewModel(RequestServiceImpl.RequestService requestService, int requestId)
        {
            _requestService = requestService;
            _requestId      = requestId;
            RatingList      = new ObservableCollection <RequestRatingDto>(_requestService.GetRequestRating());
            var request = _requestService.GetRequest(_requestId);

            Refresh(null);
        }
Exemple #4
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();
 }
        public void InitCollections()
        {
            _requestService  = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            FilterStreetList = new ObservableCollection <FieldForFilterDto>();
            HouseList        = new ObservableCollection <HouseDto>();
            FlatList         = new ObservableCollection <FlatDto>();
            FondList         = new ObservableCollection <FondDto>();

            ChangeCity(_requestService.GetCities().FirstOrDefault().Id);
        }
 public GetScInfoDialogViewModel(RequestServiceImpl.RequestService requestService, int?serviceCompanyId, Window view)
 {
     _view                  = view;
     _requestService        = requestService;
     _serviceCompanyId      = serviceCompanyId;
     ServiceCompanyList     = new ObservableCollection <ServiceCompanyDto>(_requestService.GetServiceCompanies());
     SelectedServiceCompany = ServiceCompanyList.FirstOrDefault(s => s.Id == _serviceCompanyId);
     if (SelectedServiceCompany == null)
     {
         SelectedServiceCompany = ServiceCompanyList.FirstOrDefault();
     }
 }
Exemple #7
0
        private void RefreshRequest()
        {
            if (_requestService == null)
            {
                _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            }
            RequestList.Clear();
            var requests = _requestService.GetAlertedRequests();

            foreach (var request in requests)
            {
                RequestList.Add(request);
            }
            RequestCount = RequestList.Count;
            OnPropertyChanged(nameof(RequestList));
        }
        private void RefreshRequest()
        {
            if (_requestService == null)
            {
                _requestService = new RequestService(AppSettings.DbConnection);
            }
            FondList.Clear();
            var fonds = _requestService.GetServiceCompanyFondList(
                FilterStreetList.Where(w => w.Selected).Select(x => x.Id).ToArray(),
                _selectedHouse?.Id, SelectedFlat?.Id);

            foreach (var address in fonds)
            {
                FondList.Add(address);
            }
        }
Exemple #9
0
        public RequestDialogViewModel()
        {
            AlertExists     = false;
            _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            var contactInfo = new ContactDto {
                Id = 1, IsMain = true, PhoneNumber = AppSettings.LastIncomingCall
            };

            _callUniqueId   = _requestService.GetActiveCallUniqueId();
            StreetList      = new ObservableCollection <StreetDto>();
            HouseList       = new ObservableCollection <HouseDto>();
            FlatList        = new ObservableCollection <FlatDto>();
            AddressTypeList = new ObservableCollection <AddressTypeDto>(_requestService.GetAddressTypes());
            //if (AddressTypeList.Count > 0)
            //{
            //    SelectedAddressType = AddressTypeList.FirstOrDefault();
            //}
            CityList = new ObservableCollection <CityDto>(_requestService.GetCities());
            if (CityList.Count > 0)
            {
                SelectedCity = CityList.FirstOrDefault();
            }
            RequestList = new ObservableCollection <RequestItemViewModel> {
                new RequestItemViewModel()
            };
            //AppSettings.LastIncomingCall = "932";
            CanEditAddress = AppSettings.CurrentUser.Roles.Select(r => r.Name).Contains("admin");
            if (!string.IsNullOrEmpty(AppSettings.LastIncomingCall))
            {
                var clientInfoDto = _requestService.GetLastAddressByClientPhone(AppSettings.LastIncomingCall);
                if (clientInfoDto != null)
                {
                    SelectedStreet = StreetList.FirstOrDefault(s => s.Id == clientInfoDto.StreetId);
                    SelectedHouse  = HouseList.FirstOrDefault(h => h.Building == clientInfoDto.Building &&
                                                              h.Corpus == clientInfoDto.Corpus);
                    SelectedFlat = FlatList.FirstOrDefault(f => f.Flat == clientInfoDto.Flat);
                    contactInfo  = new ContactDto {
                        Id = 1, IsMain = true, PhoneNumber = AppSettings.LastIncomingCall, Name = clientInfoDto.Name
                    };
                }
            }
            ContactList = new ObservableCollection <ContactDto>(new[] { contactInfo });
        }
Exemple #10
0
        private void OpenRequest(object sender)
        {
            var selectedItem = sender as RequestForListDto;

            if (selectedItem == null)
            {
                return;
            }
            if (_requestService == null)
            {
                _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            }

            var request = _requestService.GetRequest(selectedItem.Id);

            if (request == null)
            {
                MessageBox.Show("Произошла непредвиденная ошибка!");
                return;
            }

            var viewModel = new RequestDialogViewModel();
            var view      = new RequestDialog(viewModel);

            viewModel.SetView(view);
            viewModel.RequestId      = request.Id;
            viewModel.SelectedCity   = viewModel.CityList.SingleOrDefault(i => i.Id == request.Address.CityId);
            viewModel.SelectedStreet = viewModel.StreetList.SingleOrDefault(i => i.Id == request.Address.StreetId);
            viewModel.SelectedHouse  = viewModel.HouseList.SingleOrDefault(i => i.Id == request.Address.HouseId);
            viewModel.SelectedFlat   = viewModel.FlatList.SingleOrDefault(i => i.Id == request.Address.Id);
            viewModel.Floor          = request.Floor;
            viewModel.Entrance       = request.Entrance;
            viewModel.FromTime       = request.FromTime;
            viewModel.ToTime         = request.ToTime;
            var requestModel = viewModel.RequestList.FirstOrDefault();

            requestModel.SelectedParentService = requestModel.ParentServiceList.SingleOrDefault(i => i.Id == request.Type.ParentId);
            requestModel.SelectedService       = requestModel.ServiceList.SingleOrDefault(i => i.Id == request.Type.Id);
            requestModel.Description           = request.Description;
            requestModel.IsChargeable          = request.IsChargeable;
            requestModel.IsImmediate           = request.IsImmediate;
            requestModel.IsBadWork             = request.IsBadWork;
            requestModel.IsRetry = request.IsRetry;
            //requestModel.Gatanty = request.Warranty;
            requestModel.SelectedGaranty  = requestModel.GarantyList.FirstOrDefault(g => g.Id == request.GarantyId);
            requestModel.RequestCreator   = request.CreateUser.ShortName;
            requestModel.RequestDate      = request.CreateTime;
            requestModel.RequestState     = request.State.Description;
            requestModel.SelectedMaster   = request.MasterId.HasValue ? _requestService.GetWorkerById(request.MasterId.Value) : null;
            requestModel.SelectedExecuter = request.ExecuterId.HasValue ? _requestService.GetWorkerById(request.ExecuterId.Value) : null;
            requestModel.RequestId        = request.Id;
            requestModel.Rating           = request.Rating;
            requestModel.AlertTime        = request.AlertTime;
            if (request.ServiceCompanyId.HasValue)
            {
                requestModel.SelectedCompany = requestModel.CompanyList.FirstOrDefault(c => c.Id == request.ServiceCompanyId.Value);
            }
            if (request.ExecuteDate.HasValue && request.ExecuteDate.Value.Date > DateTime.MinValue)
            {
                requestModel.SelectedDateTime = request.ExecuteDate.Value.Date;
                requestModel.SelectedPeriod   = requestModel.PeriodList.SingleOrDefault(i => i.Id == request.PeriodId);
            }
            requestModel.TermOfExecution = request.TermOfExecution;
            viewModel.ContactList        = new ObservableCollection <ContactDto>(request.Contacts);
            view.Show();
        }
Exemple #11
0
 public void InitCollections()
 {
     _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
 }
Exemple #12
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);
        }
Exemple #13
0
        public void OpenRequest(object sender)
        {
            var selectedItem = sender as RequestForListDto;

            if (selectedItem == null)
            {
                return;
            }
            if (_requestService == null)
            {
                _requestService = new RequestServiceImpl.RequestService(AppSettings.DbConnection);
            }

            var request = _requestService.GetRequest(selectedItem.Id);

            if (request == null)
            {
                MessageBox.Show("Произошла непредвиденная ошибка!");
                return;
            }

            var viewModel = new RequestDialogViewModel();
            var view      = new RequestDialog(viewModel);

            viewModel.SetView(view);
            viewModel.RequestId      = request.Id;
            viewModel.SelectedCity   = viewModel.CityList.SingleOrDefault(i => i.Id == request.Address.CityId);
            viewModel.SelectedStreet = viewModel.StreetList.SingleOrDefault(i => i.Id == request.Address.StreetId);
            viewModel.SelectedHouse  = viewModel.HouseList.SingleOrDefault(i => i.Id == request.Address.HouseId);
            viewModel.SelectedFlat   = viewModel.FlatList.SingleOrDefault(i => i.Id == request.Address.Id);
            viewModel.Floor          = request.Floor;
            viewModel.Entrance       = request.Entrance;
            viewModel.FromTime       = request.FromTime;
            viewModel.ToTime         = request.ToTime;
            var requestModel           = viewModel.RequestList.FirstOrDefault();
            var selectedParrentService = requestModel.ParentServiceList.SingleOrDefault(i => i.Id == request.Type.ParentId);

            if (selectedParrentService == null)
            {
                var parrentServiceType = _requestService.GetServiceById(request.Type.ParentId ?? 0);
                requestModel.ParentServiceList.Add(parrentServiceType);
                selectedParrentService = requestModel.ParentServiceList.SingleOrDefault(i => i.Id == request.Type.ParentId);
            }
            requestModel.SelectedParentService = selectedParrentService;
            var service = requestModel.ServiceList.SingleOrDefault(i => i.Id == request.Type.Id);

            if (service == null)
            {
                var serviceType = _requestService.GetServiceById(request.Type.Id);
                requestModel.ServiceList.Add(serviceType);
                service = requestModel.ServiceList.SingleOrDefault(i => i.Id == request.Type.Id);
            }
            requestModel.SelectedService = service;
            requestModel.Description     = request.Description;
            requestModel.IsChargeable    = request.IsChargeable;
            requestModel.IsImmediate     = request.IsImmediate;
            requestModel.IsBadWork       = request.IsBadWork;
            requestModel.IsRetry         = request.IsRetry;
            //requestModel.Gatanty = request.Warranty;
            requestModel.SelectedGaranty = requestModel.GarantyList.FirstOrDefault(g => g.Id == request.GarantyId);

            requestModel.RequestCreator = request.CreateUser.ShortName;
            requestModel.RequestDate    = request.CreateTime;
            requestModel.RequestState   = request.State.Description;
            var sched = _requestService.GetScheduleTaskByRequestId(request.Id);

            requestModel.SelectedAppointment = sched != null?new Appointment()
            {
                Id        = sched.Id,
                RequestId = sched.RequestId,
                StartTime = sched.FromDate,
                EndTime   = sched.ToDate,
            }: null;
            requestModel.OpenAppointment = requestModel.SelectedAppointment;
            var master = request.MasterId.HasValue ? _requestService.GetWorkerById(request.MasterId.Value) : null;

            if (master != null)
            {
                if (requestModel.MasterList.Count == 0 || requestModel.MasterList.All(e => e.Id != master.Id))
                {
                    requestModel.MasterList.Add(master);
                }
                requestModel.SelectedMaster = requestModel.MasterList.SingleOrDefault(i => i.Id == master.Id);
            }
            else
            {
                requestModel.SelectedMaster = null;
            }

            var executer = request.ExecuterId.HasValue ? _requestService.GetWorkerById(request.ExecuterId.Value) : null;

            if (executer != null)
            {
                if (requestModel.ExecuterList.All(e => e.Id != executer.Id))
                {
                    requestModel.ExecuterList.Add(executer);
                }
                requestModel.SelectedExecuter = requestModel.ExecuterList.SingleOrDefault(i => i.Id == executer.Id);
            }
            else
            {
                requestModel.SelectedExecuter = null;
            }
            requestModel.SelectedEquipment = requestModel.EquipmentList.SingleOrDefault(e => e.Id == request.Equipment?.Id);
            requestModel.RequestId         = request.Id;
            requestModel.Rating            = request.Rating;
            requestModel.AlertTime         = request.AlertTime;
            if (request.ServiceCompanyId.HasValue)
            {
                requestModel.SelectedCompany = requestModel.CompanyList.FirstOrDefault(c => c.Id == request.ServiceCompanyId.Value);
            }
            if (request.ExecuteDate.HasValue && request.ExecuteDate.Value.Date > DateTime.MinValue)
            {
                requestModel.SelectedDateTime = request.ExecuteDate.Value.Date;
                requestModel.SelectedPeriod   = requestModel.PeriodList.SingleOrDefault(i => i.Id == request.PeriodId);
            }
            requestModel.TermOfExecution = request.TermOfExecution;
            viewModel.ContactList        = new ObservableCollection <ContactDto>(request.Contacts);
            view.Show();
        }