Esempio n. 1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeOnConstructionSite == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Radnik_na_odabranom_gradilištu"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                EmployeeByConstructionSiteResponse response = employeeByConstructionSiteService.Delete(CurrentEmployeeOnConstructionSite);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_brisanja_sa_serveraUzvičnik"));
                    return;
                }

                response = new EmployeeByConstructionSiteSQLiteRepository().Delete(CurrentEmployeeOnConstructionSite.Identifier);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_brisanjaUzvičnik"));
                    return;
                }

                DisplayEmployeesNotOnConstructionSiteData();
                DisplayEmployeesOnConstructionSiteData();
            });
            th.IsBackground = true;
            th.Start();
        }
Esempio n. 2
0
        public void DisplayEmployeesOnConstructionSiteData()
        {
            EmployeeOnConstructionSiteDataLoading = true;

            EmployeeByConstructionSiteListResponse response = new EmployeeByConstructionSiteSQLiteRepository()
                                                              .GetByConstructionSiteAndBusinessPartner(CurrentConstructionSite.Identifier, CurrentBusinessPartner?.Identifier, currentPageRight, itemsPerPageRight);

            if (response.Success)
            {
                EmployeesOnConstructionSiteFromDB = new ObservableCollection <EmployeeByConstructionSiteViewModel>(response?.EmployeeByConstructionSites ?? new List <EmployeeByConstructionSiteViewModel>());
                totalItemsRight = response.TotalItems;
            }
            else
            {
                EmployeesOnConstructionSiteFromDB = new ObservableCollection <EmployeeByConstructionSiteViewModel>();
                totalItemsRight         = 0;
                MainWindow.ErrorMessage = response.Message;
            }

            int itemFrom = totalItemsRight != 0 ? (currentPageRight - 1) * itemsPerPageRight + 1 : 0;
            int itemTo   = currentPageRight * itemsPerPageRight < totalItemsRight ? currentPageRight * itemsPerPageRight : totalItemsRight;

            PaginationDisplayRight = itemFrom + " - " + itemTo + " od " + totalItemsRight;

            EmployeeOnConstructionSiteDataLoading = false;
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeNotOnConstructionSite == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Radnik_bez_gradilišta"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                EmployeeByConstructionSiteViewModel employeeByConstructionSite = new EmployeeByConstructionSiteViewModel()
                {
                    Identifier       = Guid.NewGuid(),
                    Employee         = CurrentEmployeeNotOnConstructionSite,
                    ConstructionSite = CurrentConstructionSite,
                    BusinessPartner  = CurrentBusinessPartner,
                    StartDate        = CurrentEmployeeNotOnConstructionSite.ContractStartDate,
                    EndDate          = CurrentEmployeeNotOnConstructionSite.ContractEndDate,
                    Company          = new CompanyViewModel()
                    {
                        Id = MainWindow.CurrentCompanyId
                    },
                    CreatedBy = new UserViewModel()
                    {
                        Id = MainWindow.CurrentUserId
                    }
                };

                EmployeeByConstructionSiteResponse response = new EmployeeByConstructionSiteSQLiteRepository().Create(employeeByConstructionSite);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik"));
                    return;
                }

                response = employeeByConstructionSiteService.Create(employeeByConstructionSite);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik"));
                    return;
                }

                MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_unetiUzvičnik"));

                DisplayEmployeesNotOnConstructionSiteData();
                DisplayEmployeesOnConstructionSiteData();
            });
            th.IsBackground = true;
            th.Start();
        }
Esempio n. 4
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentBusinessPartnerOnConstructionSite == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Poslovni_partner_na_odabranom_gradilištu"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                // Remove business partner on construction site
                BusinessPartnerByConstructionSiteResponse response = businessPartnerByConstructionSiteService.Delete(CurrentBusinessPartnerOnConstructionSite);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_brisanja_sa_serveraUzvičnik"));
                    return;
                }

                // Remove employees on that construction site from that business partner
                EmployeeByConstructionSiteListResponse employeesResponse = new EmployeeByConstructionSiteSQLiteRepository()
                                                                           .GetByConstructionSiteAndBusinessPartner(
                    CurrentBusinessPartnerOnConstructionSite.ConstructionSite.Identifier,
                    CurrentBusinessPartnerOnConstructionSite.BusinessPartner.Identifier);

                foreach (var item in employeesResponse.EmployeeByConstructionSites)
                {
                    item.RealEndDate = CurrentBusinessPartnerOnConstructionSite.RealEndDate;
                    EmployeeByConstructionSiteResponse employeeResponse = employeeByConstructionSiteService.Delete(item);
                    new EmployeeByConstructionSiteSQLiteRepository().Delete(item.Identifier);
                }


                response = new BusinessPartnerByConstructionSiteSQLiteRepository().Delete(CurrentBusinessPartnerOnConstructionSite.BusinessPartner.Identifier, CurrentConstructionSite.Identifier);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_brisanjaUzvičnik"));
                    return;
                }

                DisplayBusinessPartnersOnConstructionSiteData();

                ConstructionSiteBusinessPartnerUpdated();
            });
            th.IsBackground = true;
            th.Start();
        }
        public void DisplayEmployeesOnConstructionSiteData()
        {
            EmployeeOnConstructionSiteDataLoading = true;

            EmployeeByConstructionSiteListResponse response = new EmployeeByConstructionSiteSQLiteRepository()
                                                              .GetByConstructionSiteAndBusinessPartner(CurrentConstructionSite.Identifier, CurrentBusinessPartnerOnConstructionSite?.BusinessPartner?.Identifier);

            if (response.Success)
            {
                EmployeesOnConstructionSiteFromDB = new ObservableCollection <EmployeeByConstructionSiteViewModel>(response?.EmployeeByConstructionSites ?? new List <EmployeeByConstructionSiteViewModel>());
            }
            else
            {
                EmployeesOnConstructionSiteFromDB = new ObservableCollection <EmployeeByConstructionSiteViewModel>();
                MainWindow.ErrorMessage           = response.Message;
            }

            EmployeeOnConstructionSiteDataLoading = false;
        }