/// <summary> /// Processes the education history information. /// </summary> /// <param name="educationHistoryInfo"></param> /// <returns></returns> /// <exception cref="ArgumentNullException">educationHistoryInfo</exception> public string ProcessEducationHistoryInfo(IEducationHistoryView educationHistoryInfo) { if (educationHistoryInfo == null) { throw new ArgumentNullException(nameof(educationHistoryInfo)); } if (educationHistoryInfo.EmployeeId == 0) { var user = this.usersRepository.GetUserById((int)this.session.GetSessionValue(SessionKey.UserId)); var employee = this.employeeOnBoardRepository.GetEmployeeByEmail(user.Email); if (employee != null) { educationHistoryInfo.EmployeeId = employee.EmployeeId; } else { educationHistoryInfo.EmployeeId = user.UserId; } } var message = this.applicationeducationhistoryRepository.SaveEducationHistoryInfo(educationHistoryInfo); return(message); }
/// <summary> /// Updates the education history information. /// </summary> /// <param name="educationHistoryInfo">The education history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">educationHistoryInfo</exception> /// <exception cref="System.ArgumentNullException">educationHistoryInfo</exception> public string UpdateEducationHistoryInfo(IEducationHistoryView educationHistoryInfo) { if (educationHistoryInfo == null) { throw new ArgumentNullException(nameof(educationHistoryInfo)); } var result = string.Empty; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { var data = dbContext.EducationHistories.Find(educationHistoryInfo.EducationHistoryId); data.SchoolName = educationHistoryInfo.SchoolName; data.Degree = educationHistoryInfo.Degree; data.GraduationYear = educationHistoryInfo.GraduationYear; data.Note = educationHistoryInfo.Note; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Update Educational - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Gets the education history view. /// </summary> /// <param name="educationHistory">The education history.</param> /// <param name="processingMessage">The processing message.</param> /// <returns></returns> public IEducationHistoryView GetEducationHistoryView(IEducationHistoryView educationHistory, string processingMessage) { var viewModel = applicationeducationhistoryViewModelFactory.CreateUpdatedEducationHistoryView(educationHistory, processingMessage); return(viewModel); }
/// <summary> /// Delete the education history /// </summary> /// <param name="educationHistoryInfo"></param> /// <param name="processingMessage"></param> /// <returns></returns> /// <exception cref="ArgumentNullException">educationHistoryInfo</exception> public IEducationHistoryView EditUpdatedEducationHistoryView(IEducationHistoryView educationHistoryInfo, string processingMessage) { if (educationHistoryInfo == null) { throw new ArgumentNullException(nameof(educationHistoryInfo)); } educationHistoryInfo.ProcessingMessage = processingMessage; return(educationHistoryInfo); }
/// <summary> /// Processes the education history edit view. /// </summary> /// <param name="educationHistoryInfo">The education history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">educationHistoryInfo</exception> public string ProcessEducationHistoryEditView(IEducationHistoryView educationHistoryInfo) { if (educationHistoryInfo == null) { throw new ArgumentNullException(nameof(educationHistoryInfo)); } var message = this.applicationeducationhistoryRepository.UpdateEducationHistoryInfo(educationHistoryInfo); return(message); }
/// <summary> /// Saves the education history information. /// </summary> /// <param name="educationHistoryInfo">The education history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">educationHistoryInfo</exception> /// <exception cref="System.ArgumentNullException">educationHistoryInfo</exception> public string SaveEducationHistoryInfo(IEducationHistoryView educationHistoryInfo) { if (educationHistoryInfo == null) { throw new ArgumentNullException(nameof(educationHistoryInfo)); } var result = string.Empty; var newRecord = new EducationHistory { //note dont include primary key here EmployeeId = educationHistoryInfo.EmployeeId, SchoolName = educationHistoryInfo.SchoolName, Degree = educationHistoryInfo.Degree, GraduationYear = educationHistoryInfo.GraduationYear, Note = educationHistoryInfo.Note, IsActive = true, DateCreated = DateTime.UtcNow, }; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.EducationHistories.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveRegistrationInfo - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }