v1.2.10.2
This commit is contained in:
@@ -6,6 +6,7 @@ using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -23,9 +24,11 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
private static readonly String AttributeName_Type = "Type";
|
||||
private static readonly String ElementName_Type = "Type";
|
||||
private static readonly String ElementName_UserAccountId = "UserAccountId";
|
||||
private static readonly String ElementName_Name = "Name";
|
||||
private static readonly String ElementName_Title = "Title";
|
||||
private static readonly String ElementName_FirstName = "FirstName";
|
||||
private static readonly String ElementName_LastName = "LastName";
|
||||
private static readonly String ElementName_Phone = "Phone";
|
||||
private static readonly String ElementName_Email = "Email";
|
||||
private static readonly String ElementName_EmailAddress = "EmailAddress";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -33,9 +36,11 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
public Sax.SportContactType ContactType { get; set; }
|
||||
public SysId UserAccountId { get; set; }
|
||||
public String Name { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String FirstName { get; set; }
|
||||
public String LastName { get; set; }
|
||||
public String EmailAddress { get; set; }
|
||||
public String Phone { get; set; }
|
||||
public String Email { get; set; }
|
||||
}
|
||||
private Dictionary<Sax.SportContactType, ContactData> contacts { get; } = new Dictionary<Sax.SportContactType, ContactData>();
|
||||
|
||||
@@ -66,10 +71,28 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
//-------------------------------------------------------------------
|
||||
// Contacts.
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Extract the name associated with the specified type.</summary>
|
||||
public String GetContactName(Sax.SportContactType contactType)
|
||||
/// <summary>Extract the title associated with the specified type.</summary>
|
||||
public String GetContactTitle(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Name;
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Title;
|
||||
}
|
||||
|
||||
/// <summary>Extract the first name associated with the specified type.</summary>
|
||||
public String GetContactFirstName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).FirstName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the last name associated with the specified type.</summary>
|
||||
public String GetContactLastName(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).LastName;
|
||||
}
|
||||
|
||||
/// <summary>Extract the email address associated with the specified type.</summary>
|
||||
public String GetContactEmailAddress(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).EmailAddress;
|
||||
}
|
||||
|
||||
/// <summary>Extract the phone associated with the specified type.</summary>
|
||||
@@ -78,19 +101,25 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Phone;
|
||||
}
|
||||
|
||||
/// <summary>Extract the email associated with the specified type.</summary>
|
||||
public String GetContactEmail(Sax.SportContactType contactType)
|
||||
{
|
||||
return contacts.GetValueOrDefault(contactType, new ContactData()).Email;
|
||||
}
|
||||
|
||||
/// <summary>Set the name associated with the specified contact.</summary>
|
||||
public bool SetContactName(Sax.SportContactType contactType, String name)
|
||||
public bool SetContactName(Sax.SportContactType contactType, String title, String firstName, String lastName)
|
||||
{
|
||||
if ((int)contactType < 1 || name.IsEmpty()) return false;
|
||||
if ((int)contactType < 1 || lastName.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Name = name;
|
||||
contact.Title = title;
|
||||
contact.FirstName = firstName;
|
||||
contact.LastName = lastName;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the email address associated with the specified contact.</summary>
|
||||
public bool SetContactEmailAddress(Sax.SportContactType contactType, String emailAddress)
|
||||
{
|
||||
if ((int)contactType < 1 || emailAddress.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.EmailAddress = emailAddress;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,16 +133,6 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Set the email associated with the specified contact.</summary>
|
||||
public bool SetContactEmail(Sax.SportContactType contactType, String email)
|
||||
{
|
||||
if ((int)contactType < 1 || email.IsEmpty()) return false;
|
||||
ContactData contact = GetContactData(contactType);
|
||||
if (contact == null) return false;
|
||||
contact.Email = email;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Clear the value associated with the specified method.</summary>
|
||||
public bool ClearContact(Sax.SportContactType contactType)
|
||||
@@ -140,16 +159,20 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
XElement contactsElement = doc.AppendElement(ElementName_Contacts);
|
||||
foreach (ContactData contactData in contacts.Values)
|
||||
{
|
||||
if ((int)contactData.ContactType < 1 || (!SysId.IsValid(contactData.UserAccountId) && contactData.Name.IsEmpty())) continue;
|
||||
if ((int)contactData.ContactType < 1 || (!SysId.IsValid(contactData.UserAccountId) && StringUtil.IsBlank(contactData.LastName))) continue;
|
||||
XElement contactElement = contactsElement.AppendElement(ElementName_Contact);
|
||||
contactElement.SetAttribute(AttributeName_Type, ((int)contactData.ContactType).ToString());
|
||||
contactElement.AppendElement(ElementName_Type, contactData.ContactType.ToString());
|
||||
if (!StringUtil.IsBlank(contactData.Name))
|
||||
contactElement.AppendElement(ElementName_Name, contactData.Name);
|
||||
if (!StringUtil.IsBlank(contactData.Title))
|
||||
contactElement.AppendElement(ElementName_Title, contactData.Title);
|
||||
if (!StringUtil.IsBlank(contactData.FirstName))
|
||||
contactElement.AppendElement(ElementName_FirstName, contactData.FirstName);
|
||||
if (!StringUtil.IsBlank(contactData.LastName))
|
||||
contactElement.AppendElement(ElementName_LastName, contactData.LastName);
|
||||
if (!StringUtil.IsBlank(contactData.EmailAddress))
|
||||
contactElement.AppendElement(ElementName_EmailAddress, contactData.EmailAddress);
|
||||
if (!StringUtil.IsBlank(contactData.Phone))
|
||||
contactElement.AppendElement(ElementName_Phone, contactData.Phone);
|
||||
if (!StringUtil.IsBlank(contactData.Email))
|
||||
contactElement.AppendElement(ElementName_Email, contactData.Email);
|
||||
}
|
||||
return doc.GetXml();
|
||||
}
|
||||
@@ -187,9 +210,11 @@ namespace Saxonite.Net.Standard.Base.Bus
|
||||
{
|
||||
ContactType = contactType,
|
||||
UserAccountId = rootChildElement.GetChildText(ElementName_UserAccountId).ToSysId(),
|
||||
Name = rootChildElement.GetChildText(ElementName_Name),
|
||||
Title = rootChildElement.GetChildText(ElementName_Title),
|
||||
FirstName = rootChildElement.GetChildText(ElementName_FirstName),
|
||||
LastName = rootChildElement.GetChildText(ElementName_LastName),
|
||||
EmailAddress = rootChildElement.GetChildText(ElementName_EmailAddress),
|
||||
Phone = rootChildElement.GetChildText(ElementName_Phone),
|
||||
Email = rootChildElement.GetChildText(ElementName_Email),
|
||||
};
|
||||
contacts.Add(contactType, contactData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user