v1.2.10.2
This commit is contained in:
@@ -15,6 +15,8 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax.Config;
|
||||
using static Saxonite.Net.Standard.Base.Bus.SaxArticle;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
{
|
||||
@@ -37,10 +39,21 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
private class ProfileSportResponseItemData : ProfileSportResponseListData
|
||||
{
|
||||
public String SportAbout { get; set; }
|
||||
public List<SportContactData> Contacts { get; set; }
|
||||
public String SportParticipatingCode { get; set; }
|
||||
public String SportPreparingCode { get; set; }
|
||||
public String SportOfficiatingCode { get; set; }
|
||||
}
|
||||
public class SportContactData
|
||||
{
|
||||
public String ContactType { get; set; }
|
||||
public String ContactTypeDesc { 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; }
|
||||
}
|
||||
private void PopulateProfileSportResponseListData(Model_Account model, SaxUserSport userSport, SaxSport sport, ProfileSportResponseListData data)
|
||||
{
|
||||
data.Id = model.EncryptId(userSport.Id);
|
||||
@@ -55,6 +68,24 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
{
|
||||
PopulateProfileSportResponseListData(model, userSport, sport, data);
|
||||
data.SportAbout = userSport.About;
|
||||
// Sport Contacts.
|
||||
SaxSportContactsData sportContacts = new SaxSportContactsData(userSport.ContactsData);
|
||||
foreach (Sax.SportContactType contactType in sportContacts.ContactTypes)
|
||||
{
|
||||
if (data.Contacts == null) data.Contacts = new List<SportContactData>();
|
||||
SportContactData sportContact =
|
||||
new SportContactData()
|
||||
{
|
||||
ContactType = SportContactTypeCodes.GetCodeForType(contactType),
|
||||
ContactTypeDesc = Localiser.GetSportContactTypeCaption(contactType),
|
||||
Title = sportContacts.GetContactTitle(contactType),
|
||||
FirstName = sportContacts.GetContactFirstName(contactType),
|
||||
LastName = sportContacts.GetContactLastName(contactType),
|
||||
EmailAddress = sportContacts.GetContactEmailAddress(contactType),
|
||||
Phone = sportContacts.GetContactPhone(contactType),
|
||||
};
|
||||
data.Contacts.Add(sportContact);
|
||||
}
|
||||
data.SportParticipatingCode = SportParticipatingCodes.GetCodeForType(userSport.Participating);
|
||||
data.SportPreparingCode = SportPreparingCodes.GetCodeForType(userSport.Preparing);
|
||||
data.SportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(userSport.Officiating);
|
||||
@@ -352,6 +383,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
// Populate item properties.
|
||||
if (model.ProfileSportAbout != null)
|
||||
userSport.About = model.ProfileSportAbout;
|
||||
if (model.Contacts.ContactsData != null)
|
||||
userSport.ContactsData = model.Contacts.ContactsData.ToXml();
|
||||
if (model.ProfileSportParticipatingCode != null)
|
||||
userSport.Participating = model.ProfileSportParticipating;
|
||||
if (model.ProfileSportPreparingCode != null)
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
{
|
||||
String methodValue = ContactMethod[idx];
|
||||
String value = ContactValue[idx];
|
||||
if (methodValue == null & value == null) continue;
|
||||
if (methodValue == null && value == null) continue;
|
||||
Sax.ContactMethod method = EnumUtil.ParseEnum(methodValue, Sax.ContactMethod.Unknown);
|
||||
if (method > 0 && !value.IsEmpty() && SaxContactMethodHelper.IsValidContactMethodValue(method, value))
|
||||
ContactData.SetContactMethodValue(method, value);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -8,10 +9,13 @@ using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using Saxonite.Net.Core.Web.Base.Models;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax;
|
||||
using static Saxonite.Net.Standard.Base.Bus.SaxArticle;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Online.Models
|
||||
{
|
||||
@@ -87,11 +91,13 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
public String Count { get; set; }
|
||||
public String[] ContactType { get; set; }
|
||||
public String[] UserAccountId { get; set; }
|
||||
public String[] ContactName { get; set; }
|
||||
public String[] ContactPhone { get; set; }
|
||||
public String[] ContactEmail { 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; }
|
||||
/// <summary>Sport Contacts to be populated during validation.</summary>
|
||||
public SaxSportContactsData SportContactsData { get; set; }
|
||||
public SaxSportContactsData ContactsData { get; set; }
|
||||
}
|
||||
public SportsContactsData Contacts {get; } = new SportsContactsData();
|
||||
|
||||
@@ -197,6 +203,8 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
// Validate Sport data.
|
||||
public bool ValidateProfileSportData(SaxController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
String fn = GetType().Name + ".ValidateProfileSportData";
|
||||
|
||||
// Sport.
|
||||
if (ProfileSportId != null)
|
||||
{
|
||||
@@ -216,6 +224,40 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
}
|
||||
}
|
||||
|
||||
// Sport Contacts.
|
||||
if (Contacts != null)
|
||||
{
|
||||
Contacts.ContactsData = new SaxSportContactsData("");
|
||||
Contacts.ContactType= Contacts.ContactType ?? new String[0];
|
||||
Contacts.Title= Contacts.Title ?? new String[0];
|
||||
Contacts.FirstName = Contacts.FirstName ?? new String[0];
|
||||
Contacts.LastName = Contacts.LastName ?? new String[0];
|
||||
Contacts.EmailAddress = Contacts.EmailAddress ?? new String[0];
|
||||
for (int idx = 0; idx < Contacts.ContactType.Length; idx++)
|
||||
{
|
||||
String contactTypeValue = Contacts.ContactType[idx];
|
||||
String title = idx < Contacts.Title.Length ? Contacts.Title[idx] : null;
|
||||
String firstName = idx < Contacts.FirstName.Length ? Contacts.FirstName[idx] : null;
|
||||
String lastName = idx < Contacts.LastName.Length ? Contacts.LastName[idx] : null;
|
||||
String emailAddress = idx < Contacts.EmailAddress.Length ? Contacts.EmailAddress[idx] : null;
|
||||
String phone = idx < Contacts.Phone.Length ? Contacts.Phone[idx] : null;
|
||||
if (StringUtil.IsBlank(contactTypeValue) && StringUtil.IsBlank(lastName)) continue;
|
||||
Sax.SportContactType contactType= (Sax.SportContactType)SportContactTypeCodes.GetTypeForCode(contactTypeValue);
|
||||
if (contactType > 0)
|
||||
{
|
||||
Contacts.ContactsData.SetContactName(contactType, title, firstName, lastName);
|
||||
Contacts.ContactsData.SetContactEmailAddress(contactType, emailAddress);
|
||||
Contacts.ContactsData.SetContactPhone(contactType, phone);
|
||||
}
|
||||
else SaLogger.Warn(fn + " Invalid Sport Contact data. Type: " + contactTypeValue + ". Last name: " + lastName);
|
||||
}
|
||||
if (Contacts.ContactsData.ContactTypes.Count != Contacts.Count.ToInt())
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent Contact Methods received. Expected: " + Contacts.Count + ". Received: " + Contacts.ContactsData.ContactTypes.Count);
|
||||
responseData.SetMessage("caption.contact.method", "System error");
|
||||
}
|
||||
}
|
||||
|
||||
return !responseData.HasControlErrors();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user