/// <summary> /// 删除教育经历 /// </summary> /// <param name="id">教育经历Id</param> /// <returns>删除成功返回true,否则返回false</returns> public bool DeleteEducationExperience(long id) { if (id == 0) { return(false); } EducationExperience educationExperience = educationExperienceRepository.Get(id); if (educationExperience == null) { return(false); } //OK if (GetEducationExperiences(educationExperience.UserId).Count() == 1) { educationExperienceRepository.DeleteByEntityId(id); profileRepository.UpdateIntegrity(educationExperience.UserId); } else { educationExperienceRepository.DeleteByEntityId(id); } UserProfile userProfile = profileRepository.Get(educationExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); return(true); }
/// <summary> /// 转换成EducationExperienceEditModel /// </summary> /// <param name="educationExperience"></param> /// <returns></returns> public static EducationExperienceEditModel AsEditModel(this EducationExperience educationExperience) { return(new EducationExperienceEditModel { Id = educationExperience.Id, Degree = educationExperience.Degree, School = educationExperience.School, Department = educationExperience.Department, StartYear = educationExperience.StartYear, }); }
/// <summary> /// 更新教育经历 /// </summary> /// <param name="educationExperience"><see cref="EducationExperience"/></param> public void UpdateEducationExperience(EducationExperience educationExperience) { if (educationExperience == null) { return; } educationExperienceRepository.Update(educationExperience); UserProfile userProfile = profileRepository.Get(educationExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); }
/// <summary> /// 新建实体时使用 /// </summary> public static EducationExperience New() { EducationExperience educationExperience = new EducationExperience() { School = string.Empty, Department = string.Empty, Degree = DegreeType.Undergraduate, StartYear = 0, UserId = 0 }; return(educationExperience); }
/// <summary> /// 转换为EducationExperience用于数据库存储 /// </summary> public EducationExperience AsEducationExperience(long userId) { EducationExperience educationExperience; if (Id > 0) { UserProfileService userProfileService = new UserProfileService(); educationExperience = userProfileService.GetEducationExperience(Id, userId); educationExperience.Degree = this.Degree; educationExperience.School = this.School; educationExperience.StartYear = this.StartYear; if (!string.IsNullOrEmpty(Department)) { educationExperience.Department = this.Department; } else { educationExperience.Department = string.Empty; } } else { educationExperience = EducationExperience.New(); educationExperience.Degree = this.Degree; educationExperience.School = this.School; educationExperience.StartYear = this.StartYear; if (!string.IsNullOrEmpty(Department)) { educationExperience.Department = this.Department; } else { educationExperience.Department = string.Empty; } educationExperience.UserId = userId; } return(educationExperience); }
/// <summary> /// 添加教育经历 /// </summary> /// <param name="educationExperience"><see cref="EducationExperience"/></param> /// <returns>创建成功返回true,否则返回false</returns> public bool CreateEducationExperience(EducationExperience educationExperience) { if (educationExperience == null) { return(false); } long affectId = Convert.ToInt64(educationExperienceRepository.Insert(educationExperience)); UserProfile userProfile = profileRepository.Get(educationExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); if (affectId > 0) { profileRepository.UpdateIntegrity(educationExperience.UserId); return(true); } return(false); }