Beispiel #1
0
        public int Close(PromotionsRecords PromotionRecordObj)
        {
            try
            {
                using (var db = new HCMEntities())
                {
                    PromotionsRecords PromotionRecord = db.PromotionsRecords.Find(PromotionRecordObj.PromotionRecordID);
                    PromotionRecord.PromotionRecordStatusID = PromotionRecordObj.PromotionRecordStatusID;
                    PromotionRecord.ClosingBy       = PromotionRecordObj.ClosingBy;
                    PromotionRecord.ClosingTime     = PromotionRecordObj.ClosingTime;
                    PromotionRecord.LastUpdatedBy   = PromotionRecordObj.LastUpdatedBy;
                    PromotionRecord.LastUpdatedDate = PromotionRecordObj.LastUpdatedDate;

                    foreach (PromotionsRecordsEmployees PromotionRecordEmployeeObj in PromotionRecordObj.PromotionsRecordsEmployees)
                    {
                        PromotionsRecordsEmployees     PromotionRecordEmployee   = db.PromotionsRecordsEmployees.Find(PromotionRecordEmployeeObj.PromotionRecordEmployeeID);
                        PromotionsRecordsJobsVacancies PromotionRecordJobVacancy = db.PromotionsRecordsJobsVacancies.Find(PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.PromotionRecordJobVacancyID);
                        OrganizationsJobs OrganizationJobVacancy = db.OrganizationsJobs.Find(PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.OrganizationsJobs.OrganizationJobID);
                        OrganizationJobVacancy.IsVacant        = PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.OrganizationsJobs.IsVacant;
                        OrganizationJobVacancy.IsReserved      = PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.OrganizationsJobs.IsReserved;
                        OrganizationJobVacancy.LastUpdatedBy   = PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.OrganizationsJobs.LastUpdatedBy.Value;
                        OrganizationJobVacancy.LastUpdatedDate = PromotionRecordEmployeeObj.PromotionsRecordsJobsVacancies.OrganizationsJobs.LastUpdatedDate;

                        EmployeesCareersHistory CurrentEmployeeCareerHistory = db.EmployeesCareersHistory.Find(PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.EmployeeCareerHistoryID);
                        CurrentEmployeeCareerHistory.IsActive        = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.IsActive;
                        CurrentEmployeeCareerHistory.LastUpdatedBy   = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.LastUpdatedBy.Value;
                        CurrentEmployeeCareerHistory.LastUpdatedDate = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.LastUpdatedDate;
                        OrganizationsJobs CurrentOrganizationJob = db.OrganizationsJobs.Find(PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.OrganizationsJobs.OrganizationJobID);
                        CurrentOrganizationJob.IsVacant        = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.OrganizationsJobs.IsVacant;
                        CurrentOrganizationJob.LastUpdatedBy   = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.OrganizationsJobs.LastUpdatedBy.Value;
                        CurrentOrganizationJob.LastUpdatedDate = PromotionRecordEmployeeObj.CurrentEmployeesCareersHistory.OrganizationsJobs.LastUpdatedDate;

                        EmployeesCareersHistory NewEmployeeCareerHistory = new EmployeesCareersHistory();
                        NewEmployeeCareerHistory.EmployeeCodeID            = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.EmployeeCodeID;
                        NewEmployeeCareerHistory.CareerHistoryTypeID       = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.CareerHistoryTypeID;
                        NewEmployeeCareerHistory.OrganizationJobID         = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.OrganizationJobID;
                        NewEmployeeCareerHistory.JoinDate                  = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.JoinDate;
                        NewEmployeeCareerHistory.CareerDegreeID            = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.CareerDegreeID;
                        NewEmployeeCareerHistory.TransactionStartDate      = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.TransactionStartDate;
                        NewEmployeeCareerHistory.CreatedBy                 = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.CreatedBy;
                        NewEmployeeCareerHistory.CreatedDate               = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.CreatedDate;
                        NewEmployeeCareerHistory.IsActive                  = PromotionRecordEmployeeObj.NewEmployeesCareersHistory.IsActive;
                        PromotionRecordEmployee.NewEmployeesCareersHistory = NewEmployeeCareerHistory;
                    }
                    return(db.SaveChanges());
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
 public int Insert(PromotionsRecordsEmployees PromotionRecordEmployee)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.PromotionsRecordsEmployees.Add(PromotionRecordEmployee);
             db.SaveChanges();
             return(PromotionRecordEmployee.PromotionRecordEmployeeID);
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #3
0
 public int Delete(int PromotionRecordEmployeeID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsEmployees PromotionRecordEmployeeObj = db.PromotionsRecordsEmployees.FirstOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployeeID));
             db.PromotionsRecordsEmployees.Remove(PromotionRecordEmployeeObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #4
0
 public int UpdateExamResult(int PromotionRecordEmployeeID, decimal?ExamResult, int LastUpdatedBy)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployeeID));
             PromotionsRecordsEmployeesObj.ByExamResult    = ExamResult;
             PromotionsRecordsEmployeesObj.LastUpdatedBy   = LastUpdatedBy;
             PromotionsRecordsEmployeesObj.LastUpdatedDate = DateTime.Now;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #5
0
 public int UpdateActualTaskPerformancePoints(int PromotionRecordEmployeeID, decimal ActualTaskPerformancePoints, int LastUpdatedBy)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployeeID));
             PromotionsRecordsEmployeesObj.ActualTaskPerformancePoints = ActualTaskPerformancePoints;
             PromotionsRecordsEmployeesObj.LastUpdatedBy   = LastUpdatedBy;
             PromotionsRecordsEmployeesObj.LastUpdatedDate = DateTime.Now;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #6
0
 public int UpdateDeserveExtraBonus(PromotionsRecordsEmployees PromotionRecordEmployee)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployee.PromotionRecordEmployeeID));
             PromotionsRecordsEmployeesObj.IsDeserveExtraBonus = PromotionRecordEmployee.IsDeserveExtraBonus;
             PromotionsRecordsEmployeesObj.LastUpdatedBy       = PromotionRecordEmployee.LastUpdatedBy;
             PromotionsRecordsEmployeesObj.LastUpdatedDate     = PromotionRecordEmployee.LastUpdatedDate;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #7
0
        public int RemoveAndRedistributeJobs(List <PromotionsRecordsEmployees> PromotionRecordEmployeeList, int UserIdentity)
        {
            try
            {
                int result = 0;
                using (var db = new HCMEntities())
                {
                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            foreach (var PromotionRecordEmployee in PromotionRecordEmployeeList.OrderBy(e => e.PromotionRecordJobVacancyID.HasValue ? e.PromotionRecordJobVacancyID.Value : 0))
                            {
                                PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployee.PromotionRecordEmployeeID));
                                PromotionsRecordsEmployeesObj.PromotionRecordJobVacancyID = PromotionRecordEmployee.PromotionRecordJobVacancyID;
                                if (PromotionRecordEmployee.RemovingBy != null)
                                {
                                    PromotionsRecordsEmployeesObj.RemovingBy     = PromotionRecordEmployee.RemovingBy;
                                    PromotionsRecordsEmployeesObj.RemovingReason = PromotionRecordEmployee.RemovingReason;
                                }
                                PromotionsRecordsEmployeesObj.IsRemovedAfterIncluding = PromotionRecordEmployee.IsRemovedAfterIncluding;
                                PromotionsRecordsEmployeesObj.PromotionDecisionID     = PromotionRecordEmployee.PromotionDecisionID;
                                PromotionsRecordsEmployeesObj.LastUpdatedBy           = PromotionRecordEmployee.LastUpdatedBy;
                                PromotionsRecordsEmployeesObj.LastUpdatedDate         = PromotionRecordEmployee.LastUpdatedDate;

                                result = db.SaveChanges(UserIdentity);// db.PromotionsRecordsEmployees.AddOrUpdate(PromotionsRecordsEmployeesObj);
                            }
                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                            throw;
                        }
                    }
                    return(result);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #8
0
 public int IncludeAgainAfterRemoved(int PromotionRecordEmployeeID, int LastUpdatedBy)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployeeID));
             PromotionsRecordsEmployeesObj.PromotionRecordJobVacancyID = null;
             PromotionsRecordsEmployeesObj.RemovingBy              = null;
             PromotionsRecordsEmployeesObj.RemovingReason          = string.Empty;
             PromotionsRecordsEmployeesObj.IsRemovedAfterIncluding = (bool?)null;
             PromotionsRecordsEmployeesObj.PromotionDecisionID     = null;
             PromotionsRecordsEmployeesObj.LastUpdatedBy           = LastUpdatedBy;
             PromotionsRecordsEmployeesObj.LastUpdatedDate         = DateTime.Now;
             return(db.SaveChanges());
         }
     }
     catch
     {
         throw;
     }
 }
Beispiel #9
0
        public int ResetByExamResults(List <PromotionsRecordsEmployees> PromotionRecordEmployeeList)
        {
            try
            {
                int result = 0;
                using (var db = new HCMEntities())
                {
                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            foreach (var PromotionRecordEmployee in PromotionRecordEmployeeList.OrderBy(e => e.PromotionRecordJobVacancyID.HasValue ? e.PromotionRecordJobVacancyID.Value : 0))
                            {
                                PromotionsRecordsEmployees PromotionsRecordsEmployeesObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(PromotionRecordEmployee.PromotionRecordEmployeeID));
                                PromotionsRecordsEmployeesObj.ByExamResult    = PromotionRecordEmployee.ByExamResult;
                                PromotionsRecordsEmployeesObj.LastUpdatedBy   = PromotionRecordEmployee.LastUpdatedBy;
                                PromotionsRecordsEmployeesObj.LastUpdatedDate = PromotionRecordEmployee.LastUpdatedDate;

                                result = db.SaveChanges();// db.PromotionsRecordsEmployees.AddOrUpdate(PromotionsRecordsEmployeesObj);
                            }
                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                            throw;
                        }
                    }
                    return(result);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #10
0
        public int ShuffleJob(PromotionsRecordsEmployees CurrentEmployee, PromotionsRecordsEmployees NewEmployee)
        {
            try
            {
                int result = 0;
                using (var db = new HCMEntities())
                {
                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            int?CurrentPromotionRecordJobVacancyID = CurrentEmployee.PromotionRecordJobVacancyID;
                            int?NewPromotionRecordJobVacancyID     = NewEmployee.PromotionRecordJobVacancyID;

                            // first make both objects vacancyID = null
                            PromotionsRecordsEmployees CurrentEmployeeObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(CurrentEmployee.PromotionRecordEmployeeID));
                            CurrentEmployeeObj.PromotionRecordJobVacancyID = null;
                            CurrentEmployeeObj.LastUpdatedBy   = CurrentEmployee.LastUpdatedBy;
                            CurrentEmployeeObj.LastUpdatedDate = DateTime.Now;

                            PromotionsRecordsEmployees NewEmployeeObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(NewEmployee.PromotionRecordEmployeeID));
                            NewEmployeeObj.PromotionRecordJobVacancyID = null;
                            NewEmployeeObj.LastUpdatedBy   = NewEmployeeObj.LastUpdatedBy;
                            NewEmployeeObj.LastUpdatedDate = DateTime.Now;

                            db.PromotionsRecordsEmployees.AddOrUpdate(CurrentEmployeeObj);
                            db.PromotionsRecordsEmployees.AddOrUpdate(NewEmployeeObj);

                            result = db.SaveChanges();

                            // now shuffle the vacancy ID

                            CurrentEmployeeObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(CurrentEmployee.PromotionRecordEmployeeID));
                            CurrentEmployeeObj.PromotionRecordJobVacancyID = NewPromotionRecordJobVacancyID;
                            CurrentEmployeeObj.LastUpdatedBy   = CurrentEmployee.LastUpdatedBy;
                            CurrentEmployeeObj.LastUpdatedDate = DateTime.Now;

                            NewEmployeeObj = db.PromotionsRecordsEmployees.SingleOrDefault(x => x.PromotionRecordEmployeeID.Equals(NewEmployee.PromotionRecordEmployeeID));
                            NewEmployeeObj.PromotionRecordJobVacancyID = CurrentPromotionRecordJobVacancyID;
                            NewEmployeeObj.LastUpdatedBy   = NewEmployeeObj.LastUpdatedBy;
                            NewEmployeeObj.LastUpdatedDate = DateTime.Now;

                            db.PromotionsRecordsEmployees.AddOrUpdate(CurrentEmployeeObj);
                            db.PromotionsRecordsEmployees.AddOrUpdate(NewEmployeeObj);

                            result = db.SaveChanges();

                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                            throw;
                        }
                    }
                    return(result);
                }
            }
            catch
            {
                throw;
            }
        }