/// <summary> /// For Insert and Update the Employee /// </summary> /// <param name="employeeAttributeModel"></param> /// <returns></returns> public BaseAttributeModel InsertUpdateEmployee(EmployeeAttributeModel employeeAttributeModel) { var response = new BaseAttributeModel(); try { employeeAttributeModel.IsActive = true; employeeAttributeModel.EmployeeLanguages = GetEmployeeLanguageMaps(employeeAttributeModel); var employeeEntity = Mapper.Map <EmployeeAttributeModel, Employee>(employeeAttributeModel); bool flag = employeeServiceManager.InsertUpdateEmployee(employeeEntity); response.Success = flag; response.Exceptions = (flag == true) ? null : (new List <Exception> { new Exception(ExceptionMessage.SaveEmployeeErorrMsg) }); response.StatusCode = (flag == true) ? APIErrorCodes.APISuccessCode : APIErrorCodes.APIMethodCallingErrorCode; } catch (Exception ex) { response.Success = false; response.StatusCode = APIErrorCodes.APIMethodCallingErrorCode; response.Exceptions = new List <Exception> { new Exception(ex.Message.ToString()) }; //Here we track the Exception at WebAPI Methods } return(response); }
/// <summary> /// For Getting the Employees By EmployeeId /// </summary> /// <param name="empId"></param> /// <returns></returns> public EmployeeAttributeModel GetEmployeeByEmpId(int empId) { var response = new EmployeeAttributeModel(); try { var employeeEntity = employeeServiceManager.GetEmployeeByEmpId(empId); response = Mapper.Map <Employee, EmployeeAttributeModel>(employeeEntity); response.LanguageIds = (from p in response.EmployeeLanguages select p.LanguageId).ToArray(); response.EmployeeLanguages = null; response.StatusCode = APIErrorCodes.APISuccessCode; response.Success = true; } catch (Exception ex) { response.Success = false; response.StatusCode = APIErrorCodes.APIMethodCallingErrorCode; response.Exceptions = new List <Exception> { new Exception(ex.Message.ToString()) }; //Here we track the Exception at WebAPI Methods } return(response); }
/// <summary> /// Map the employee and Languages from LanguageIds array comming from the View /// </summary> /// <param name="employeeAttributeModel"></param> /// <returns></returns> public List <EmployeeLanguagesAttributeModel> GetEmployeeLanguageMaps(EmployeeAttributeModel employeeAttributeModel) { var employeeLanguageMapsListAttributeModel = new List <EmployeeLanguagesAttributeModel>(); if (employeeAttributeModel != null && employeeAttributeModel.LanguageIds != null) { foreach (int languageId in employeeAttributeModel.LanguageIds) { employeeLanguageMapsListAttributeModel.Add(new EmployeeLanguagesAttributeModel { Id = 0, EmpId = employeeAttributeModel.EmpId, LanguageId = languageId, IsActive = true }); } } return(employeeLanguageMapsListAttributeModel); }
public BaseAttributeModel Save(EmployeeAttributeModel employeeAttributeModel) { return(model.InsertUpdateEmployee(employeeAttributeModel)); }