Exemple #1
0
        /// <summary>
        /// Add /Update JobType
        /// </summary>
        public JobType SaveJobType(JobType jobType)
        {
            JobType dbVersion = jobTypeRepository.Find(jobType.JobTypeId);

            //Code Duplication Check
            if (jobTypeRepository.DoesJobTypeCodeExists(jobType))
            {
                throw new CaresException(Resources.EmployeeManagement.JobType.JobTypeCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateJobTypePropertie(jobType, dbVersion);
                jobTypeRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new JobType();
                SetJobTypeProperties(jobType, dbVersion);
                jobTypeRepository.Add(dbVersion);
            }
            jobTypeRepository.SaveChanges();
            // To Load the proprties
            return(jobTypeRepository.Find(dbVersion.JobTypeId));
        }