} // ToString public Director FromModel() { try { return(new Director { Id = Id, Name = Name.Trim(), Surname = Surname.Trim(), Middle = (Middle ?? "").Trim(), DateOfBirth = DateOfBirth.IndexOf("-", StringComparison.Ordinal) == -1 ? DateTime.ParseExact(DateOfBirth, "d/M/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null, DirectorAddressInfo = new DirectorAddressInfo { AllAddresses = DirectorAddress == null ? null : new HashedSet <CustomerAddress>(DirectorAddress) }, Gender = (Gender)Enum.Parse(typeof(Gender), Gender.ToString()), Email = Email, Phone = Phone, IsDirector = IsDirector.Equals(Yes, StringComparison.InvariantCultureIgnoreCase) || IsDirector.Equals(On, StringComparison.InvariantCultureIgnoreCase), IsShareholder = IsShareholder.Equals(Yes, StringComparison.InvariantCultureIgnoreCase) || IsShareholder.Equals(On, StringComparison.InvariantCultureIgnoreCase), UserId = UserId }); } catch (Exception e) { _log.Error("Failed to convert DirectorModel to Director", e); return(null); } // try } // FromModel
} // FromModel public Director UpdateFromModel(ref Director director) { try { director.Name = Name; director.DateOfBirth = DateOfBirth.IndexOf("-", StringComparison.Ordinal) == -1 ? DateTime.ParseExact(DateOfBirth, "d/M/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; director.Middle = Middle; director.Surname = Surname; director.Gender = (Gender)Enum.Parse(typeof(Gender), Gender.ToString()); director.Email = Email; director.Phone = Phone; director.IsDirector = IsDirector.Equals(Yes, StringComparison.InvariantCultureIgnoreCase) || IsDirector.Equals(On, StringComparison.InvariantCultureIgnoreCase); director.IsShareholder = IsShareholder.Equals(Yes, StringComparison.InvariantCultureIgnoreCase) || IsShareholder.Equals(On, StringComparison.InvariantCultureIgnoreCase); return(director); } catch (Exception e) { _log.Error("Failed to convert Update DirectorModel to Director", e); return(null); } // try } // FromModel