public static EmployeeResponse ToEntity(this Employee request, PhoneMail phone, Docs docsFaceImage, Docs docsCopyPassport, Docs docsCopyofID, EquipmenAtSite equipmenAtSite, SiteEmployee siteEmployee, EmplyeePicture emplyeePicture = null, HealthDeclaration healthDeclaration = null) => new EmployeeResponse { EmployeeId = request.EmployeeId, IdentificationTypeId = request.IdentificationTypeId, IdentityNumber = request.IdentityNumber, PassportCountryId = request.PassportCountryId, FirstName = request.FirstName, LastName = request.LastName, FirstNameEn = request.FirstNameEn, LastNameEn = request.LastNameEn, OrganizationId = request.OrganizationId, BirthDate = request.BirthDate, GenderId = request.GenderId, Citizenship = request.Citizenship, UserInsert = request.UserInsert, DateInsert = request.DateInsert, UserUpdate = request.UserUpdate, DateUpdate = request.DateUpdate, State = request.State, Address = request.Address, Gender = request.Gender, IdentificationType = request.IdentificationType, Organization = request.Organization, PassportCountry = request.PassportCountry, EmployeeTraining = request.EmployeeTraining.Count > 0 ? new TrainingResponse((request.EmployeeTraining.Max(x => x.DateTo).Value.Date - DateTime.Now.Date).Days, "תדריך בטיחות") : new TrainingResponse(0, "תדריך בטיחות"), EmployeeAuthtorization = request.EmployeeAuthtorization.Count > 0 ? new TrainingResponse((request.EmployeeAuthtorization.Max(x => x.DateTo).Value.Date - DateTime.Now.Date).Days, "אישור עבודה בגובה"): new TrainingResponse(0, "אישור עבודה בגובה"), EmployeeWorkPermit = request.IdentificationTypeId == 1 || request.IdentificationTypeId == null ? new TrainingResponse(100, "היתר עבודה") :request.EmployeeWorkPermit.Count > 0 ? new TrainingResponse((request.EmployeeWorkPermit.Max(x => x.DateTo).Value.Date - DateTime.Now.Date).Days, "היתר עבודה"): new TrainingResponse(0, "היתר עבודה"), phonMail = phone, ProffesionType = request.EmployeeProffesionType.Count > 0? request.EmployeeProffesionType.First().ProffesionType:null, picturePath = docsFaceImage == null ? null: docsFaceImage.DocumentPath, IdentityFilePath = docsCopyofID == null ? null : docsCopyofID.DocumentPath, PassportFilePath = docsCopyPassport == null ? null : docsCopyPassport.DocumentPath, isEmployeeEntry = equipmenAtSite != null,//אם יש כניסה לאתר SiteId = siteEmployee == null ? null : siteEmployee.SiteId, EmployeePicture = emplyeePicture, HealthDeclaration = healthDeclaration, isHealthDeclaration = healthDeclaration == null ? false : true };
public static IQueryable <EquipmenAtSite> GetSiteByEquipmentIdAsync(this MastpenBitachonDbContext dbContext, EquipmenAtSite entity) => dbContext.EquipmenAtSite.Where(item => item.EquipmentId == entity.EquipmentId).Include(s => s.Site).DefaultIfEmpty();