private static void AddOptionalUserProperties(XAttribute firstName, User userToAdd, XAttribute lastName, XAttribute email) { if (firstName != null) { userToAdd.FirstName = firstName.Value; } if (lastName != null) { userToAdd.FirstName = lastName.Value; } if (email != null) { userToAdd.FirstName = email.Value; } }
private static User CreateUserToAdd(XElement xmlUser) { var userToAdd = new User() { Username = xmlUser.Attribute("username").Value, IsDeleted = xmlUser.Attribute("is-deleted").Value.Equals("1"), RegistrationDate = DateTime.Parse(xmlUser.Attribute("registration-date").Value), IpAddress = xmlUser.Attribute("ip-address").Value }; var firstName = xmlUser.Attribute("first-name"); var lastName = xmlUser.Attribute("last-name"); var email = xmlUser.Attribute("email"); AddOptionalUserProperties(firstName, userToAdd, lastName, email); return userToAdd; }