Exemplo n.º 1
0
        public bool SaveNarration(NarrationCommon narrationCommon)
        {
            var isSuccessful = true;
            Staff_NarrationInformation staffNarrationInformation = null;
            Staff_NarrationVoiceFiles  staffNarrationVoiceFiles  = null;

            try
            {
                if (narrationCommon.NarrationInformationModel != null)
                {
                    staffNarrationInformation = Mapper.Map <NarrationInformationModel, Staff_NarrationInformation>(narrationCommon.NarrationInformationModel);
                    if (staffNarrationInformation.ID == Guid.Empty)
                    {
                        staffNarrationInformation.ID          = Guid.NewGuid();
                        staffNarrationInformation.CreatedBy   = narrationCommon.NarrationInformationModel.CurrentUserID;
                        staffNarrationInformation.CreatedDate = DateTime.Now;
                        _dbContext.Staff_NarrationInformation.Add(staffNarrationInformation);
                    }
                    else
                    {
                        staffNarrationInformation.UpdatedBy               = narrationCommon.NarrationInformationModel.CurrentUserID;
                        staffNarrationInformation.UpdatedDate             = DateTime.Now;
                        _dbContext.Entry(staffNarrationInformation).State = EntityState.Modified;
                    }
                }

                if (narrationCommon.NarrationVoiceFilesModel != null)
                {
                    staffNarrationVoiceFiles = Mapper.Map <NarrationVoiceFilesModel, Staff_NarrationVoiceFiles>(narrationCommon.NarrationVoiceFilesModel);
                    if (staffNarrationVoiceFiles.ID == Guid.Empty)
                    {
                        staffNarrationVoiceFiles.ID          = Guid.NewGuid();
                        staffNarrationVoiceFiles.CreatedBy   = narrationCommon.NarrationVoiceFilesModel.CurrentUserID;
                        staffNarrationVoiceFiles.CreatedDate = DateTime.Now;
                        _dbContext.Staff_NarrationVoiceFiles.Add(staffNarrationVoiceFiles);
                    }
                    else
                    {
                        staffNarrationVoiceFiles.UpdatedBy               = narrationCommon.NarrationVoiceFilesModel.CurrentUserID;
                        staffNarrationVoiceFiles.UpdatedDate             = DateTime.Now;
                        _dbContext.Entry(staffNarrationVoiceFiles).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(narrationCommon.NarrationInformationModel.CreatedBy.Value, "staffTRExperience", message);
                throw new Exception(message);
            }
            return(isSuccessful);
        }
Exemplo n.º 2
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);
        }