예제 #1
0
        public EmployeeByBusinessPartnerResponse Create(EmployeeByBusinessPartnerViewModel employeeByBusinessPartner)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, employeeByBusinessPartner);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
예제 #2
0
        public EmployeeByBusinessPartnerResponse Delete(Guid employeeIdentifier, Guid businessPartnerIdentifier)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = new SqliteCommand();
                insertCommand.Connection = db;

                //Use parameterized query to prevent SQL injection attacks
                insertCommand.CommandText = "DELETE FROM EmployeeByBusinessPartners WHERE EmployeeIdentifier = @EmployeeIdentifier AND BusinessPartnerIdentifier = @BusinessPartnerIdentifier";
                insertCommand.Parameters.AddWithValue("@EmployeeIdentifier", employeeIdentifier);
                insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", businessPartnerIdentifier);
                try
                {
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
예제 #3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentEmployeeOnBusinessPartner == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Radnik_u_odabranoj_firmi"));
                return;
            }

            #endregion

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

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

                Sync();
            });
            th.IsBackground = true;
            th.Start();
        }
예제 #4
0
        public EmployeeByBusinessPartnerResponse Delete(EmployeeByBusinessPartnerViewModel employeeByBusinessPartner)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                response = WpfApiHandler.SendToApi <EmployeeByBusinessPartnerViewModel, EmployeeByBusinessPartnerResponse>(employeeByBusinessPartner, "Delete");
            }
            catch (Exception ex)
            {
                response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
예제 #5
0
        public JsonResult Delete([FromBody] EmployeeByBusinessPartnerViewModel employeeByBusinessPartner)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                response = this.employeeByBusinessPartnerService.Delete(employeeByBusinessPartner);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
예제 #6
0
        public EmployeeByBusinessPartnerResponse DeleteAll()
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
                {
                    db.Open();
                    db.EnableExtensions(true);

                    SqliteCommand insertCommand = new SqliteCommand();
                    insertCommand.Connection = db;

                    //Use parameterized query to prevent SQL injection attacks
                    insertCommand.CommandText = "DELETE FROM EmployeeByBusinessPartners";
                    try
                    {
                        insertCommand.ExecuteNonQuery();
                    }
                    catch (SqliteException error)
                    {
                        response.Success = false;
                        response.Message = error.Message;

                        MainWindow.ErrorMessage = error.Message;
                        return(response);
                    }
                    db.Close();
                }
            }
            catch (SqliteException error)
            {
                response.Success = false;
                response.Message = error.Message;
                return(response);
            }

            response.Success = true;
            return(response);
        }
예제 #7
0
        public EmployeeByBusinessPartnerResponse Delete(EmployeeByBusinessPartnerViewModel employeeByBysinessPartner)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                EmployeeByBusinessPartner deletedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository()
                                                                             .Delete(employeeByBysinessPartner.ConvertToEmployeeByBusinessPartner());

                Employee        employee        = unitOfWork.GetEmployeeRepository().GetEmployee((int)deletedEmployeeByBusinessPartner.EmployeeId);
                BusinessPartner businessPartner = unitOfWork.GetBusinessPartnerRepository().GetBusinessPartner((int)deletedEmployeeByBusinessPartner.BusinessPartnerId);

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = deletedEmployeeByBusinessPartner.EmployeeId,
                    CardDate    = (DateTime)deletedEmployeeByBusinessPartner.RealEndDate,
                    Description = "Radnik " + employee?.Name + " " + employee?.SurName + " je raskinuo ugovor sa firmom " + businessPartner?.Name + ". Prestanak je od: " + ((DateTime)deletedEmployeeByBusinessPartner.RealEndDate).ToString("dd.MM.yyyy"),
                    PlusMinus   = "-",
                    CreatedById = deletedEmployeeByBusinessPartner.CreatedById,
                    CompanyId   = deletedEmployeeByBusinessPartner.CompanyId,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now
                };
                unitOfWork.GetEmployeeCardRepository().Create(ec);

                unitOfWork.Save();

                response.EmployeeByBusinessPartner = deletedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
예제 #8
0
        public EmployeeByBusinessPartnerResponse Create(EmployeeByBusinessPartnerViewModel re)
        {
            EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse();

            try
            {
                EmployeeByBusinessPartner addedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository()
                                                                           .Create(re.ConvertToEmployeeByBusinessPartner());

                EmployeeCard ec = new EmployeeCard()
                {
                    Identifier  = Guid.NewGuid(),
                    EmployeeId  = re.Employee.Id,
                    CardDate    = re.StartDate,
                    Description = "Radnik " + re.Employee?.Name + " " + re.Employee?.SurName + " je sklopio ugovor sa firmom " + re.BusinessPartner?.Name + ". Radnik je u firmi od: " + re.StartDate.ToString("dd.MM.yyyy") + " do " + re.EndDate.ToString("dd.MM.yyyy"),
                    PlusMinus   = "+",
                    CreatedById = re.CreatedBy?.Id,
                    CompanyId   = re.Company?.Id,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now
                };
                unitOfWork.GetEmployeeCardRepository().Create(ec);

                unitOfWork.Save();

                response.EmployeeByBusinessPartner = addedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }