Exemplo n.º 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;
            }
        }
 public int Insert(PromotionsRecordsJobsVacancies PromotionRecordJobVacancy)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.PromotionsRecordsJobsVacancies.Add(PromotionRecordJobVacancy);
             db.SaveChanges();
             return(PromotionRecordJobVacancy.PromotionRecordJobVacancyID);
         }
     }
     catch
     {
         throw;
     }
 }
 public int Delete(int PromotionRecordJobVacancyID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             PromotionsRecordsJobsVacancies PromotionRecordJobVacancyObj = db.PromotionsRecordsJobsVacancies.FirstOrDefault(x => x.PromotionRecordJobVacancyID.Equals(PromotionRecordJobVacancyID));
             db.PromotionsRecordsJobsVacancies.Remove(PromotionRecordJobVacancyObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }