/// <summary> /// Saves the employment history information. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employmentHistoryInfo</exception> public string SaveEmploymentHistoryInfo(IEmploymentHistoryView employmentHistoryInfo) { if (employmentHistoryInfo == null) throw new ArgumentNullException(nameof(employmentHistoryInfo)); var result = string.Empty; var newRecord = new EmploymentHistory { EmployeeId = employmentHistoryInfo.EmployeeId, CompanyName = employmentHistoryInfo.CompanyName, StartDate = employmentHistoryInfo.StartDate, EndDate = employmentHistoryInfo.EndDate, ReasonExit = employmentHistoryInfo.ReasonExit, LevelOnExit = employmentHistoryInfo.LevelOnExit, JobFunction = employmentHistoryInfo.JobFunction, DateCreated = employmentHistoryInfo.DateCreated, IsActive = true }; try { using ( var dbContext = (HRMSEntities) this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.EmploymentHistories.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveEmploymentHistoryInfo - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return result; }
/// <summary> /// Updates the employment history information. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employmentHistoryInfo</exception> public string UpdateEmploymentHistoryInfo(IEmploymentHistoryView employmentHistoryInfo) { if (employmentHistoryInfo == null) throw new ArgumentNullException(nameof(employmentHistoryInfo)); var result = string.Empty; try { using ( var dbContext = (HRMSEntities) this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { var data = dbContext.EmploymentHistories.SingleOrDefault(x => x.EmploymentHistoryId == employmentHistoryInfo.EmploymentHistoryId); data.CompanyName = employmentHistoryInfo.CompanyName; data.StartDate = employmentHistoryInfo.StartDate; data.EndDate = employmentHistoryInfo.EndDate; data.ReasonExit = employmentHistoryInfo.ReasonExit; data.LevelOnExit = employmentHistoryInfo.LevelOnExit; data.JobFunction = employmentHistoryInfo.JobFunction; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveEmploymentHistoryInfo - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return result; }
/// <summary> /// Processes the employment history information. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employmentHistoryInfo</exception> public string ProcessEmploymentHistoryInfo(IEmploymentHistoryView employmentHistoryInfo) { if (employmentHistoryInfo == null) { throw new ArgumentNullException(nameof(employmentHistoryInfo)); } if (employmentHistoryInfo.EmployeeId == 0) { var user = this.usersRepository.GetUserById((int)this.session.GetSessionValue(SessionKey.UserId)); var employee = this.employeeOnBoardRepository.GetEmployeeByEmail(user.Email); if (employee != null) { employmentHistoryInfo.EmployeeId = employee.EmployeeId; } else { employmentHistoryInfo.EmployeeId = user.UserId; } } //Store Compnay Information var message = this.employmentHistoryRepository.SaveEmploymentHistoryInfo(employmentHistoryInfo); return(message); }
/// <summary> /// Gets the employment history view. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <param name="processingMessage">The processing message.</param> /// <returns></returns> public IEmploymentHistoryView GetEmploymentHistoryView(IEmploymentHistoryView employmentHistoryInfo, string processingMessage) { var viewModel = this.employmentHistoryViewsFactoryModel.CreateUpdatedEmploymentHistoryView(employmentHistoryInfo, processingMessage); return(viewModel); }
/// <summary> /// Creates the updated employment history view. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <param name="processMessage">The process message.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employmentHistoryInfo</exception> public IEmploymentHistoryView CreateUpdatedEmploymentHistoryView(IEmploymentHistoryView employmentHistoryInfo, string processMessage) { if (employmentHistoryInfo == null) { throw new ArgumentNullException(nameof(employmentHistoryInfo)); } employmentHistoryInfo.ProcessingMessage = processMessage; return(employmentHistoryInfo); }
/// <summary> /// Processes the edit employment history information. /// </summary> /// <param name="employmentHistoryInfo">The employment history information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">employmentHistoryInfo</exception> public string ProcessEditEmploymentHistoryInfo(IEmploymentHistoryView employmentHistoryInfo) { if (employmentHistoryInfo == null) { throw new ArgumentNullException(nameof(employmentHistoryInfo)); } //Store Compnay Information var message = this.employmentHistoryRepository.UpdateEmploymentHistoryInfo(employmentHistoryInfo); return(message); }