private void PopulateBusinessPartnerTypeData() { BusinessPartnerTypeDataLoading = true; BusinessPartnerTypeListResponse response = new BusinessPartnerTypeSQLiteRepository() .GetBusinessPartnerTypes(MainWindow.CurrentCompanyId); if (response.Success) { BusinessPartnerTypesFromDB = new ObservableCollection <BusinessPartnerTypeViewModel>( response.BusinessPartnerTypes ?? new List <BusinessPartnerTypeViewModel>()); List <BusinessPartnerTypeViewModel> currentBusinessPartnerType = new BusinessPartnerTypeSQLiteRepository() .GetBusinessPartnerTypesByBusinessPartner(MainWindow.CurrentCompanyId, CurrentBusinessPartner.Identifier).BusinessPartnerTypes; foreach (var businessPartnerType in BusinessPartnerTypesFromDB.Where(x => currentBusinessPartnerType.Select(y => y.Identifier).Contains(x.Identifier))) { businessPartnerType.IsSelected = true; } } else { BusinessPartnerTypesFromDB = new ObservableCollection <BusinessPartnerTypeViewModel>(); MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_prilikom_učitavanja_podatakaUzvičnik")); } BusinessPartnerTypeDataLoading = false; }
public void DisplayData() { BusinessPartnerTypesDataLoading = true; string SearchObjectJson = JsonConvert.SerializeObject(BusinessPartnerTypeSearchObject, Formatting.Indented, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Unspecified }); BusinessPartnerTypeListResponse response = new BusinessPartnerTypeSQLiteRepository() .GetBusinessPartnerTypesByPage(MainWindow.CurrentCompanyId, BusinessPartnerTypeSearchObject, currentPage, itemsPerPage); if (response.Success) { BusinessPartnerTypesFromDB = new ObservableCollection <BusinessPartnerTypeViewModel>(response.BusinessPartnerTypes ?? new List <BusinessPartnerTypeViewModel>()); totalItems = response.TotalItems; } else { BusinessPartnerTypesFromDB = new ObservableCollection <BusinessPartnerTypeViewModel>(); totalItems = 0; MainWindow.ErrorMessage = response.Message; } int itemFrom = totalItems != 0 ? (currentPage - 1) * itemsPerPage + 1 : 0; int itemTo = currentPage * itemsPerPage < totalItems ? currentPage * itemsPerPage : totalItems; PaginationDisplay = itemFrom + " - " + itemTo + " od " + totalItems; BusinessPartnerTypesDataLoading = false; }
private void btnSave_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentBusinessPartnerType.Name)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Ime_vrste")); return; } #endregion Thread th = new Thread(() => { SaveButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SaveButtonEnabled = false; CurrentBusinessPartnerType.IsSynced = false; CurrentBusinessPartnerType.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentBusinessPartnerType.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; //BusinessPartnerTypeResponse response = new BusinessPartnerTypeSQLiteRepository().Delete(CurrentBusinessPartnerType.Identifier); BusinessPartnerTypeResponse response = new BusinessPartnerTypeSQLiteRepository().Create(CurrentBusinessPartnerType); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; return; } response = businessPartnerTypeService.Create(CurrentBusinessPartnerType); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; BusinessPartnerTypeCreatedUpdated(); if (IsCreateProcess) { CurrentBusinessPartnerType = new BusinessPartnerTypeViewModel(); CurrentBusinessPartnerType.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtName.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } } }); th.IsBackground = true; th.Start(); txtName.Focus(); }