Exemple #1
0
 /// <summary>
 /// Creates a new <see cref="Organization" /> instance from the provided model.
 /// </summary>
 /// <param name="model">The model coming from the API.</param>
 /// <returns>Returns the created organization instance.</returns>
 private Organization GetOrganization(Models.Contacts.Contact model)
 {
     return(new Organization
     {
         Name = model.name
     });
 }
Exemple #2
0
        /// <summary>
        /// Creates a new <see cref="Contact" /> instance from the provided model.
        /// </summary>
        /// <param name="model">The model coming from the API.</param>
        /// <returns>Returns the created contact instance.</returns>
        private Contact GetContact(Models.Contacts.Contact model)
        {
            // Initializes the contact
            Contact contact;

            // Checks whether the contact is an organization or a person
            if (string.IsNullOrWhiteSpace(model.familyname))
            {
                contact = this.GetOrganization(model);
            }
            else
            {
                contact = this.GetPerson(model);
            }

            // Sets the contact specific properties
            contact.Id = model.id;
            contact.CreationDateTime = string.IsNullOrWhiteSpace(model.create) ? DateTime.Now : DateTime.Parse(model.create);
            contact.UpdateDateTime   = string.IsNullOrWhiteSpace(model.update) ? DateTime.Now :DateTime.Parse(model.update);
            contact.Category         = model.category == null ? null : this.GetCategory(model.category) as ContactCategory;
            contact.CustomerNumber   = model.customerNumber;
            contact.Description      = model.description;

            // Returns the created contact
            return(contact);
        }
Exemple #3
0
 /// <summary>
 /// Creates a new <see cref="Person" /> instance from the provided model.
 /// </summary>
 /// <param name="model">The model coming from the API.</param>
 /// <returns>Returns the created person instance.</returns>
 private Person GetPerson(Models.Contacts.Contact model)
 {
     return(new Person
     {
         FirstName = model.surename,
         LastName = model.familyname,
         Position = model.titel,
         AcademicTitle = model.academicTitle,
         Gender = model.gender == "m" ? Gender.Male : Gender.Female,
         Birthday = string.IsNullOrWhiteSpace(model.birthday) ? (Nullable <DateTime>)null : DateTime.Parse(model.birthday),
         Organization = model.parent == null ? null : this.GetContact(model.parent) as Organization
     });
 }