public static Section Parse(SerializableSection section) { if (section == null) { return(null); } List <Unit> subUnits = new List <Unit>(); foreach (var subUnit in section.SubUnits) { if (subUnit is SerializableSection) { subUnits.Add(SerializableSection.Parse(subUnit as SerializableSection)); } if (subUnit is SerializableTeam) { subUnits.Add(SerializableTeam.Parse(subUnit as SerializableTeam)); } } OrganizationUnit parentUnit = null; if (section.ParentUnit is SerializableSection) { parentUnit = SerializableSection.Parse(section.ParentUnit as SerializableSection); } if (section.ParentUnit is SerializableDepartment) { parentUnit = SerializableDepartment.Parse(section.ParentUnit as SerializableDepartment); } return(new Section(section.Id, section.Name, section.ParentUnitId, section.AuthorId) { Department = SerializableDepartment.Parse(section.Department), ParentUnit = parentUnit, StaffList = section.StaffList.Select(x => SerializableStaff.Parse(x)).ToList(), SubUnits = subUnits }); }
public static Staff Parse(SerializableStaff staff) { if (staff == null) { return(null); } UserCard userCard = null; User user = null; Position position = null; Credentials credentials = null; Department department = null; Section section = null; Team team = null; if (staff.ErtisUser != null && staff.ErtisUser.Card != null) { userCard = SerializableUserCard.Parse(staff.ErtisUser.Card); } if (staff.ErtisUser != null) { user = SerializableUser.Parse(staff.ErtisUser); } if (staff.Position != null) { position = SerializablePosition.Parse(staff.Position); } if (staff.UserCredentials != null) { credentials = SerializableCredentials.Parse(staff.UserCredentials); } if (staff.Department != null) { department = SerializableDepartment.Parse(staff.Department); } if (staff.Section != null) { section = SerializableSection.Parse(staff.Section); } if (staff.Team != null) { team = SerializableTeam.Parse(staff.Team); } return(new Staff(staff.Id, user, position) { PositionId = staff.PositionId, UserId = staff.UserId, CredentialsId = staff.CredentialsId, UserCredentials = credentials, DepartmentId = staff.DepartmentId, Department = department, Section = section, SectionId = staff.SectionId, Team = team, TeamId = staff.TeamId }); }