public async Task <IHttpActionResult> update([FromBody] HrPslEmployeeVM entity) { var result = await employeeService.UpdateAsync(entity); await LogData(entity.EmployeeCode, entity.HrPslEmployeeID.ToString()); return(Ok(result)); }
public async Task <IHttpActionResult> add([FromBody] HrPslEmployeeVM entity) { var result = await employeeService.InsertAsync(entity); await LogData(entity.EmployeeCode, result.ToString()); if (result != 0) { return(Ok(true)); } return(Ok(false)); }
public async Task <IHttpActionResult> delete([FromBody] HrPslEmployeeVM entity) { var q1 = billMasterService.getByEmp(entity.HrPslEmployeeID); var q = entryMasterService.getByEmp(entity.HrPslEmployeeID); if (q.Count == 0 && q1.Count == 0) { var result = await employeeService.DeleteAsync(entity); await LogData(entity.EmployeeCode, entity.HrPslEmployeeID.ToString()); return(Ok(result)); } else { return(Ok(false)); } // return Ok(await employeeService.DeleteAsync(entity)); }
public Task <bool> UpdateAsync(HrPslEmployeeVM entity) { return(Task.Run <bool>(() => { //if (entity.Item_Base64_Photo != null) //{ // string base64 = entity.Item_Base64_Photo; // entity.Item_Base64_Photo = String.Format(base64); // base64 = base64.Remove(0, base64.IndexOf("base64,") + 7); // entity.EMP_PHOTO = Convert.FromBase64String(base64); //} HrPslEmployee Employee = new HrPslEmployee { HrPslEmployeeID = entity.HrPslEmployeeID, EmployeeCode = entity.EmployeeCode, EmployeeFirstName = entity.EmployeeFirstName, EmployeeFirstNameEn = entity.EmployeeFirstNameEn, EmployeeLastName = entity.EmployeeLastName, EmployeeLastNameEn = entity.EmployeeLastNameEn, DateOfJoin = entity.DateOfJoin, HrPslJobTitleID = entity.HrPslJobTitleID, HrPslBranchID = entity.HrPslBranchID, HrPslDeptartmentID = entity.HrPslDeptartmentID, HrPslContractTypeID = entity.HrPslContractTypeID, HrPslEmployeeStatusID = entity.HrPslEmployeeStatusID, WorkMobileNum = entity.WorkMobileNum, DirectManagerID = entity.DirectManagerID, HrPslEmployeeJobLevelID = entity.HrPslEmployeeJobLevelID, HrPslManagementId = entity.HrPslManagementId, GenderID = entity.GenderID, HrPslMaritalstatusID = entity.HrPslMaritalstatusID, HrPslReligionID = entity.HrPslReligionID, HrPslCountyID = entity.HrPslCountyID, HrPslCityID = entity.HrPslCityID, Address = entity.Address, HrPslNationalityID = entity.HrPslNationalityID, NationalID = entity.NationalID, NationalIdExpData = entity.NationalIdExpData, PassportNo = entity.PassportNo, PassportNoExpDate = entity.PassportNoExpDate, DateOfBirth = entity.DateOfBirth, ResidenceType = entity.ResidenceType, ResidencyNumber = entity.ResidencyNumber, ResidenceExpireDate = entity.ResidenceExpireDate, DrivingLicenseNumber = entity.DrivingLicenseNumber, DrivingLicenseIssueDate = entity.DrivingLicenseIssueDate, DrivingLicenseExpireDate = entity.DrivingLicenseExpireDate, DrivingLicenseIssuer = entity.DrivingLicenseIssuer, DrivingLicenseType = entity.DrivingLicenseType, HasCar = entity.HasCar, GlBankID = entity.GlBankID, BankAccountNumber = entity.BankAccountNumber, HasChronicDisease = entity.HasChronicDisease, ChronicDiseaseDescreption = entity.ChronicDiseaseDescreption, HasInjuries = entity.HasInjuries, InjuriesDescreption = entity.InjuriesDescreption, BloodGroup = entity.BloodGroup }; EmployeeRep.Update(Employee, Employee.HrPslEmployeeID); //Remove all related data to employee EmployeeAcademicDegreeRep.DeleteRange(EmployeeAcademicDegreeRep.FilterAsync(p => p.HrPslEmployeeID == entity.HrPslEmployeeID).Result); EmployeeContactsRep.DeleteRange(EmployeeContactsRep.FilterAsync(p => p.HrPslEmployeeID == entity.HrPslEmployeeID).Result); EmployeeExperienceRep.DeleteRange(EmployeeExperienceRep.FilterAsync(p => p.HrPslEmployeeID == entity.HrPslEmployeeID).Result); EmployeeFamilyDetailsRep.DeleteRange(EmployeeFamilyDetailsRep.FilterAsync(p => p.HrPslEmployeeID == entity.HrPslEmployeeID).Result); EmployeeTrainingCourcesRep.DeleteRange(EmployeeTrainingCourcesRep.FilterAsync(p => p.HrPslEmployeeID == entity.HrPslEmployeeID).Result); //Add all related data to employee EmployeeAcademicDegreeRep.AddRange(entity.AcademicDegrees); EmployeeContactsRep.AddRange(entity.Contacts); EmployeeExperienceRep.AddRange(entity.Experiences); EmployeeFamilyDetailsRep.AddRange(entity.FamilyDetails); EmployeeTrainingCourcesRep.AddRange(entity.TrainingCourses); //todo:Remove this after full integration with HR project //EditEmployeeOnHRProjectEmployeeTable(emp); return true; })); }