/// <summary> /// 删除工作经历 /// </summary> /// <param name="id">工作经历Id</param> /// <returns>删除成功返回true,否则返回false</returns> public bool DeleteWorkExperience(long id) { if (id == 0) { return(false); } WorkExperience workExperience = workExperienceRepository.Get(id); if (workExperience == null) { return(false); } //OK if (GetWorkExperiences(workExperience.UserId).Count() == 1) { workExperienceRepository.DeleteByEntityId(id); profileRepository.UpdateIntegrity(workExperience.UserId); } else { workExperienceRepository.DeleteByEntityId(id); } UserProfile userProfile = profileRepository.Get(workExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); return(true); }
/// <summary> /// 更新工作经历 /// </summary> /// <param name="workExperience"><see cref="WorkExperience"/></param> public void UpdateWorkExperience(WorkExperience workExperience) { if (workExperience == null) { return; } workExperienceRepository.Update(workExperience); UserProfile userProfile = profileRepository.Get(workExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); }
/// <summary> /// 转换成EducationExperienceEditModel /// </summary> /// <param name="workExperience"></param> /// <returns></returns> public static WorkExperienceEditModel AsEditModel(this WorkExperience workExperience) { return(new WorkExperienceEditModel { Id = workExperience.Id, StartDate = workExperience.StartDate.Year, JobDescription = workExperience.JobDescription, EndDate = workExperience.EndDate.Year, CompanyName = workExperience.CompanyName, CompanyAreaCode = workExperience.CompanyAreaCode, }); }
/// <summary> /// 新建实体时使用 /// </summary> public static WorkExperience New() { WorkExperience workExperience = new WorkExperience() { CompanyName = string.Empty, StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow, JobDescription = string.Empty, CompanyAreaCode = string.Empty, UserId = 0, }; return(workExperience); }
/// <summary> /// 添加工作经历 /// </summary> /// <param name="workExperience"><see cref="WorkExperience"/></param> /// <returns>创建成功返回true,否则返回false</returns> public bool CreateWorkExperience(WorkExperience workExperience) { if (workExperience == null) { return(false); } long affectId = Convert.ToInt64(workExperienceRepository.Insert(workExperience)); UserProfile userProfile = profileRepository.Get(workExperience.UserId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Update())); if (affectId > 0) { profileRepository.UpdateIntegrity(workExperience.UserId); return(true); } return(false); }
/// <summary> /// 转换为WorkExperience用于数据库存储 /// </summary> public WorkExperience AsWorkExperience(long userId) { WorkExperience workExperience; if (Id > 0) { UserProfileService userProfileService = new UserProfileService(); workExperience = userProfileService.GetWorkExperience(Id, userId); if (!string.IsNullOrEmpty(CompanyAreaCode)) { workExperience.CompanyAreaCode = this.CompanyAreaCode; } else { workExperience.CompanyAreaCode = string.Empty; } workExperience.CompanyName = this.CompanyName; workExperience.EndDate = new DateTime(this.EndDate, 1, 1); workExperience.StartDate = new DateTime(this.StartDate, 1, 1); if (workExperience.StartDate > workExperience.EndDate) { DateTime tempDate = workExperience.EndDate; workExperience.EndDate = workExperience.StartDate; workExperience.StartDate = tempDate; } if (!string.IsNullOrEmpty(JobDescription)) { workExperience.JobDescription = this.JobDescription; } else { workExperience.JobDescription = string.Empty; } } else { workExperience = WorkExperience.New(); if (!string.IsNullOrEmpty(CompanyAreaCode)) { workExperience.CompanyAreaCode = this.CompanyAreaCode; } else { workExperience.CompanyAreaCode = string.Empty; } workExperience.CompanyName = this.CompanyName; workExperience.EndDate = new DateTime(this.EndDate, 1, 1); workExperience.StartDate = new DateTime(this.StartDate, 1, 1); if (workExperience.StartDate > workExperience.EndDate) { DateTime tempDate = workExperience.EndDate; workExperience.EndDate = workExperience.StartDate; workExperience.StartDate = tempDate; } if (!string.IsNullOrEmpty(JobDescription)) { workExperience.JobDescription = this.JobDescription; } else { workExperience.JobDescription = string.Empty; } workExperience.UserId = userId; } return(workExperience); }