private async Task <int> SaveEmployee(Employee employee) { var tEmp = this.TEmployee.FirstOrDefault(e => e.EmployeeId == employee.EmployeeId.Value); if (tEmp == null) { tEmp = new TEmployee(); this.TEmployee.Add(tEmp); } tEmp.EmployeeId = employee.EmployeeId.Value; tEmp.MailAddress = employee.Email.Value; tEmp.HumanId = employee.EmployeeAttr.HumanId.Value; var tHum = this.THuman.FirstOrDefault(e => e.Id == tEmp.HumanId); if (tHum == null) { tHum = new THuman(); this.THuman.Add(tHum); } tHum.Id = employee.EmployeeAttr.HumanId.Value; tHum.FirstName = employee.FirstName; tHum.LastName = employee.LastName; tHum.Sex = employee.Sex; tHum.Birthday = employee.Birthday; return(0); }
private async Task <int> SaveFamily(Employee employee) { //employee.FamilyIterator.Reset(); //家族情報 do { var family = employee.FamilyIterator.Current; var tFamily = this.TFamily.FirstOrDefault(e => e.EmployeeId == employee.EmployeeId.Value && e.HumanId == family.HumanId.Value); if (tFamily == null) { tFamily = new TFamily(); tFamily.EmployeeId = employee.EmployeeId.Value; tFamily.HumanId = family.HumanId.Value; tFamily.RelationShip = int.Parse(family.Relationship.Value); this.TFamily.Add(tFamily); } else { tFamily.EmployeeId = employee.EmployeeId.Value; tFamily.HumanId = family.HumanId.Value; tFamily.RelationShip = int.Parse(family.Relationship.Value); } var tHuman = THuman.FirstOrDefault(e => e.Id == family.HumanId.Value); if (tHuman == null) { tHuman = new THuman(); tHuman.Id = family.HumanId.Value; tHuman.FirstName = family.FullName.FirstName; tHuman.LastName = family.FullName.LastName; tHuman.Birthday = family.Birthday.Value; tHuman.Sex = family.Sex.Value; THuman.Add(tHuman); } else { tHuman.Id = family.HumanId.Value; tHuman.FirstName = family.FullName.FirstName; tHuman.LastName = family.FullName.LastName; tHuman.Birthday = family.Birthday.Value; tHuman.Sex = 4; } } while (employee.FamilyIterator.MoveNext()); return(0); }