Ejemplo n.º 1
0
        public StaffNestedModel GetAllStaffAndChildByID(string staffIDparam)
        {
            StaffNestedModel staffWholeEntity = new StaffNestedModel();
            Guid             staffID          = new Guid(staffIDparam);

            try
            {
                Staff staff = _dbContext.Staffs.Where(i => i.ID == staffID).FirstOrDefault();
                List <Staff_JobHistory> staffJob             = _dbContext.Staff_JobHistory.Where(i => i.StaffID == staffID).ToList();
                var staffEducationHistory                    = _dbContext.Staff_EducationalHistory.Where(i => i.StaffID == staffID).ToList();
                Staff_SkillCertificate staffSkillCertificate = _dbContext.Staff_SkillCertificate.Where(i => i.StaffID == staffID).FirstOrDefault();
                var staffTechCertificate = _dbContext.Staff_TechnicalCertificate.Where(i => i.StaffID == staffID).ToList();
                Staff_TranslateInterpretExperience staffTRExperience = _dbContext.Staff_TranslateInterpretExperience.Where(i => i.StaffID == staffID).FirstOrDefault();
                Staff_BankAccountInfo      staffBankPayment          = _dbContext.Staff_BankAccountInfo.Where(i => i.StaffID == staffID).FirstOrDefault();
                Staff_TransproInformation  staffTransPro             = _dbContext.Staff_TransproInformation.Where(i => i.StaffID == staffID).FirstOrDefault();
                Staff_NarrationInformation staffNarration            = _dbContext.Staff_NarrationInformation.Where(i => i.StaffID == staffID).FirstOrDefault();

                staffWholeEntity.staff = Mapper.Map <Staff, StaffModel>(staff);
                foreach (Staff_JobHistory job in staffJob)
                {
                    staffWholeEntity.staffJobHistory.Add(Mapper.Map <Staff_JobHistory, JobHistoryModel>(job));
                }

                foreach (Staff_EducationalHistory eh in staffEducationHistory)
                {
                    staffWholeEntity.staffEducationalHistory.EducationalInformation.Add(eh);
                }

                if (staffSkillCertificate != null)
                {
                    staffWholeEntity.staffSkillCertificate.SkillCertificateModel = staffSkillCertificate;
                }

                foreach (Staff_TechnicalCertificate tc in staffTechCertificate)
                {
                    staffWholeEntity.staffSkillCertificate.TechnicalCertificateModel.Add(tc);
                }
                staffWholeEntity.staffTRExperience         = Mapper.Map <Staff_TranslateInterpretExperience, TranslateInterpretExperienceModel>(staffTRExperience);
                staffWholeEntity.staffBankAccountInfoModel = Mapper.Map <Staff_BankAccountInfo, StaffBankAccountInfoModel>(staffBankPayment);
                staffWholeEntity.transproInformationModel  = Mapper.Map <Staff_TransproInformation, TransproInformationModel>(staffTransPro);
                staffWholeEntity.narrationInformationModel = Mapper.Map <Staff_NarrationInformation, NarrationInformationModel>(staffNarration);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(staffWholeEntity);
        }
Ejemplo n.º 2
0
        public bool SaveTransPro(TransproInformationModel transproInformationModel)
        {
            var isSuccessful = true;
            Staff_TransproInformation staffTransproInformation = null;

            try
            {
                if (transproInformationModel != null)
                {
                    staffTransproInformation = Mapper.Map <TransproInformationModel, Staff_TransproInformation>(transproInformationModel);
                    if (staffTransproInformation.ID == Guid.Empty)
                    {
                        staffTransproInformation.ID          = Guid.NewGuid();
                        staffTransproInformation.CreatedBy   = transproInformationModel.CurrentUserID;
                        staffTransproInformation.CreatedDate = DateTime.Now;
                        _dbContext.Staff_TransproInformation.Add(staffTransproInformation);
                    }
                    else
                    {
                        staffTransproInformation.UpdatedBy               = transproInformationModel.CurrentUserID;
                        staffTransproInformation.UpdatedDate             = DateTime.Now;
                        _dbContext.Entry(staffTransproInformation).State = EntityState.Modified;
                    }
                }
                _dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                isSuccessful = false;
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(transproInformationModel.CreatedBy.Value, "staffTRExperience", message);
                throw new Exception(message);
            }
            return(isSuccessful);
        }