示例#1
0
        /// <inheritdoc />
        /// <summary>
        /// Overloaded constructor.
        /// Builds the needed references.
        /// </summary>
        /// <param name="customer">A given customer.</param>
        public CustomerDto(backend.Model.Customer customer) : this()
        {
            if (customer.Addresses == null || !customer.Addresses.Any())
            {
                throw new ArgumentNullException(nameof(customer.Addresses));
            }
            CustomerId = customer.CustomerId;
            Salutation = customer.Salutation;
            FirstName  = customer.FirstName;
            LastName   = customer.LastName;
            BirthDay   = customer.BirthDay;
            Number     = customer.Number;
            Memo       = customer.Memo;

            Address = new AddressDto(customer.Addresses.FirstOrDefault());
        }
 /// <summary>
 /// Address factory method.
 /// Builts addresses from address dtos.
 /// </summary>
 /// <param name="addressDto">A given address dto.</param>
 /// <returns>Customer</returns>
 public static Address AddressFactory(AddressDto addressDto)
 {
     return(new Address(addressDto.Street, addressDto.PostalCode, addressDto.City,
                        addressDto.Country, addressDto.PhoneNumbers, addressDto.Emails, addressDto.Socials));
 }
示例#3
0
 /// <summary>
 /// Standard constructor.
 /// Builds the needed references.
 /// </summary>
 public CustomerDto()
 {
     BirthDay   = DateTime.Now;
     CustomerId = Guid.NewGuid();
     Address    = new AddressDto();
 }