private void AddRequest() { var viewModel = new RequestDialogViewModel(); var view = new RequestDialog(viewModel); viewModel.SetView(view); view.Show(); }
private void OpenRequest(object sender) { var selectedItem = sender as RequestForListDto; if (selectedItem == null) { return; } 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.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.FirstOrDefault(i => i.Id == request.Type.ParentId); requestModel.SelectedService = requestModel.ServiceList.FirstOrDefault(i => i.Id == request.Type.Id); requestModel.Description = request.Description; requestModel.IsChargeable = request.IsChargeable; requestModel.IsImmediate = request.IsImmediate; 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; 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.RequestId = request.Id; viewModel.ContactList = new ObservableCollection <ContactDto>(request.Contacts); view.Show(); }
public void ShowRequestDialog(string title, string message, Action <IEnumerable <string> > closed) { if (_dxSwapChainPanel == null) { throw new InvalidOperationException("WSANativeFacebook.ConfigureDialogs must first be called from MainPage.xaml.cs"); } Dictionary <string, string> parameters = new Dictionary <string, string>() { { "title", title }, { "message", message }, }; string requestBaseUri = string.Format("{0}?app_id={1}&display=popup&redirect_uri={2}", WSAFacebookConstants.RequestDialogUri, _facebookAppId, WSAFacebookConstants.WebRedirectUri); RequestDialog dialog = new RequestDialog(Screen.width, Screen.height); dialog.Show(requestBaseUri, parameters, WSAFacebookConstants.RequestDialogResponseUri, _dxSwapChainPanel, closed); }
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(); }