1.2.11.12 Online Events
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Diagnostics;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -23,12 +24,14 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
// Organisation Event data.
|
||||
private class EventListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public String EventDateFmt { get; set; }
|
||||
public String EventTimeFmt { get; set; }
|
||||
public String EventAtDateFmt { get; set; }
|
||||
public String EventAtTimeFmt { get; set; }
|
||||
public String EventToDateFmt { get; set; }
|
||||
public String EventToTimeFmt { get; set; }
|
||||
public String Duration { get; set; }
|
||||
public String TypeCode { get; set; }
|
||||
public String TypeDesc { get; set; }
|
||||
public String Summary { get; set; }
|
||||
public String Details { get; set; }
|
||||
public String SportCaptionPrimary { get; set; }
|
||||
public String RegionCaptionCountry { get; set; }
|
||||
public String PublishedOnFmt { get; set; }
|
||||
@@ -36,9 +39,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
}
|
||||
private class EventItemData : EventListData
|
||||
{
|
||||
public String EventOn_Calendar { get; set; }
|
||||
public String EventOn_YYYYMMDD { get; set; }
|
||||
public String EventAt_Calendar { get; set; }
|
||||
public String EventAt_YYYYMMDD { get; set; }
|
||||
public String EventAt_HHMM { get; set; }
|
||||
public String EventTo_Calendar { get; set; }
|
||||
public String EventTo_YYYYMMDD { get; set; }
|
||||
public String EventTo_HHMM { get; set; }
|
||||
public String Details { get; set; }
|
||||
public String SportIdPrimary { get; set; }
|
||||
public String RegionIdCountry { get; set; }
|
||||
public String PublishedOn_YYYYMMDD { get; set; }
|
||||
@@ -47,30 +54,51 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
private void PopulateEventResponseListData(Model_Organisation_Events model, SaxOrganisationEvent organisationEvent, EventListData data)
|
||||
{
|
||||
data.Id = model.EncryptId(organisationEvent.Id);
|
||||
data.EventDateFmt = Localiser.FormatDate(organisationEvent.EventAt);
|
||||
data.EventTimeFmt = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
|
||||
// 'At' date/time.
|
||||
data.EventAtDateFmt = Localiser.FormatDate(organisationEvent.EventAt);
|
||||
if (organisationEvent.HasValidEventAtTime())
|
||||
data.EventAtTimeFmt = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
|
||||
// 'To' date/time.
|
||||
data.EventToDateFmt = Localiser.FormatDate(organisationEvent.EventTo);
|
||||
if (organisationEvent.HasValidEventToTime())
|
||||
data.EventToTimeFmt = DateUtil.Format(organisationEvent.EventTo, "HH:mm");
|
||||
// Event properties.
|
||||
if (DateUtil.IsValid(organisationEvent.EventTo) && organisationEvent.EventTo > organisationEvent.EventAt)
|
||||
data.Duration = DateUtil.FormatNumberOfSeconds(((DateTime)organisationEvent.EventTo - organisationEvent.EventAt).TotalSeconds);
|
||||
data.TypeCode = EventTypeCodes.GetCodeForType(organisationEvent.EventType);
|
||||
data.TypeDesc = Localiser.GetEventTypeCaption(organisationEvent.EventType);
|
||||
data.Summary = organisationEvent.Summary;
|
||||
data.Details = organisationEvent.Details;
|
||||
data.SportCaptionPrimary = model.GetSportCaption(organisationEvent.SportIdPrimary);
|
||||
data.RegionCaptionCountry = model.GetRegionCaption(organisationEvent.RegionIdCountry);
|
||||
data.CreatedOnFmt = Localiser.FormatDate(organisationEvent.CreateStamp.On);
|
||||
data.PublishedOnFmt = Localiser.FormatDate(organisationEvent.PublishedAt);
|
||||
data.ExpiresOnFmt = Localiser.FormatDate(organisationEvent.ExpiresAt);
|
||||
if (DateUtil.IsValid(organisationEvent.PublishedAt))
|
||||
data.PublishedOnFmt = Localiser.FormatDate(organisationEvent.PublishedAt);
|
||||
if (DateUtil.IsValid(organisationEvent.ExpiresAt))
|
||||
data.ExpiresOnFmt = Localiser.FormatDate(organisationEvent.ExpiresAt);
|
||||
data.StatusCode = organisationEvent.StatusCode;
|
||||
data.StatusDesc = organisationEvent.StatusDesc;
|
||||
}
|
||||
private void PopulateEventResponseItemData(Model_Organisation_Events model, SaxOrganisationEvent organisationEvent, EventItemData data)
|
||||
{
|
||||
PopulateEventResponseListData(model, organisationEvent, data as EventListData);
|
||||
data.EventOn_Calendar = model.FormatDateForForm(organisationEvent.EventAt);
|
||||
data.EventOn_YYYYMMDD = DateUtil.Format(organisationEvent.EventAt, "yyyyMMdd");
|
||||
data.EventAt_HHMM = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
|
||||
// 'At' date/time.
|
||||
data.EventAt_Calendar = model.FormatDateForForm(organisationEvent.EventAt);
|
||||
data.EventAt_YYYYMMDD = DateUtil.Format(organisationEvent.EventAt, "yyyyMMdd");
|
||||
if (organisationEvent.HasValidEventAtTime())
|
||||
data.EventAt_HHMM = DateUtil.Format(organisationEvent.EventAt, "HH:mm");
|
||||
// 'To' date/time.
|
||||
data.EventTo_Calendar = model.FormatDateForForm(organisationEvent.EventTo);
|
||||
data.EventTo_YYYYMMDD = DateUtil.Format(organisationEvent.EventTo, "yyyyMMdd");
|
||||
if (organisationEvent.HasValidEventToTime())
|
||||
data.EventTo_HHMM = DateUtil.Format(organisationEvent.EventTo, "HH:mm");
|
||||
// Event properties.
|
||||
data.Details = organisationEvent.Details;
|
||||
data.RegionIdCountry = model.GetEncryptedRegionId(organisationEvent.RegionIdCountry);
|
||||
data.SportIdPrimary = model.GetEncryptedSportId(organisationEvent.SportIdPrimary);
|
||||
data.PublishedOn_YYYYMMDD = DateUtil.Format(organisationEvent.PublishedAt, "yyyyMMdd");
|
||||
data.ExpiresOn_YYYYMMDD = DateUtil.Format(organisationEvent.ExpiresAt, "yyyyMMdd");
|
||||
if (DateUtil.IsValid(organisationEvent.PublishedAt))
|
||||
data.PublishedOn_YYYYMMDD = DateUtil.Format(organisationEvent.PublishedAt, "yyyyMMdd");
|
||||
if (DateUtil.IsValid(organisationEvent.ExpiresAt))
|
||||
data.ExpiresOn_YYYYMMDD = DateUtil.Format(organisationEvent.ExpiresAt, "yyyyMMdd");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -101,6 +129,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
public OrganisationData Organisation { get; } = new OrganisationData();
|
||||
// Reference data.
|
||||
public List<CodeDesc> EventTypes { get; } = new List<CodeDesc>();
|
||||
public String EventTypeDefault { get; set; }
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -140,6 +169,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
// Reference data - organisationEvent types.
|
||||
foreach (TypeCodeDesc eventType in EventTypeCodes)
|
||||
responseData.EventTypes.Add(eventType.Code, Localiser.GetEventTypeCaption((Sax.EventType)eventType.Type));
|
||||
// ToDo: Organisation default Event Type.
|
||||
responseData.EventTypeDefault = EventTypeCodes.GetCodeForType(Sax.EventType.Playing);
|
||||
|
||||
// User organisation.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
@@ -170,17 +201,34 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
SaxOrganisationEvent.Params prmEvent = new SaxOrganisationEvent.Params();
|
||||
prmEvent.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmEvent.OrganisationIdsIncluded.Add(organisationId);
|
||||
switch (model.Filter.Period.PeriodType)
|
||||
{
|
||||
case Model_Organisation_Events.PeriodType.FromThisMonth:
|
||||
prmEvent.EventFrom = DateUtil.StartOfMonth(DateTime.Today);
|
||||
break;
|
||||
case Model_Organisation_Events.PeriodType.FromLastMonth:
|
||||
prmEvent.EventFrom = DateUtil.StartOfMonth(DateUtil.IncrementMonth(DateTime.Today, -1));
|
||||
break;
|
||||
case Model_Organisation_Events.PeriodType.FromNextMonth:
|
||||
prmEvent.EventFrom = DateUtil.StartOfMonth(DateUtil.IncrementMonth(DateTime.Today, 1));
|
||||
break;
|
||||
case Model_Organisation_Events.PeriodType.FromThisWeek:
|
||||
default:
|
||||
prmEvent.EventFrom = DateUtil.StartOfWorkingWeek(DateTime.Today);
|
||||
break;
|
||||
}
|
||||
prmEvent.EventFilter = model.Filter.Event;
|
||||
prmEvent.StatusCat = SaxOrganisationEvent.StatusCat.NotDeleted;
|
||||
prmEvent.SortColumns.Add(ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventAt_DateTime));
|
||||
model.Paging.ItemTotal = (ulong)ActivityMgr.GetOrganisationEventCount(prmEvent);
|
||||
model.PopulatePagingTo(prmEvent.ResultsPaging);
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Id);
|
||||
ColumnDfn colEventAt = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventAt_DateTime);
|
||||
ColumnDfn colEventTo = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventTo_DateTime);
|
||||
ColumnDfn colEventTypeCode = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.EventTypeCode);
|
||||
ColumnDfn colSummary = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Summary);
|
||||
ColumnDfn colDetails = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Details);
|
||||
ColumnDfn colRegionId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.RegionIdCountry);
|
||||
ColumnDfn colRegionName = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.Region_Name);
|
||||
ColumnDfn colSportId = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.SportIdPrimary);
|
||||
@@ -191,7 +239,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
ColumnDfn colCreatedOn = ActivityMgr.GetOrganisationEventColumnDfn(SaxOrganisationEvent.Column.CreateOn_Date);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId, colEventAt, colEventTypeCode, colSummary, colDetails,
|
||||
colId, colEventAt, colEventTo, colEventTypeCode, colSummary,
|
||||
colRegionId, colRegionName, colSportId, colSportName,
|
||||
colPublishedOn, colExpiresOn,
|
||||
colStatus, colCreatedOn
|
||||
@@ -207,15 +255,15 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
DateTime eventAt = values.GetDateTime(colEventAt.DataName);
|
||||
DateTime? eventTo = values.GetDateTime(colEventTo.DataName);
|
||||
EventListData eventData = new EventListData()
|
||||
{
|
||||
Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))),
|
||||
EventDateFmt = Localiser.FormatDate(values.GetDateTime(colEventAt.DataName)),
|
||||
EventTimeFmt = DateUtil.Format(values.GetDateTime(colEventAt.DataName), "HH:mm"),
|
||||
EventAtDateFmt = Localiser.FormatDate(values.GetDateTime(colEventAt.DataName)),
|
||||
TypeCode = values.GetString(colEventTypeCode.DataName),
|
||||
TypeDesc = Localiser.GetEventTypeCaption((Sax.EventType)EventTypeCodes.GetTypeForCode(values.GetString(colEventTypeCode.DataName))),
|
||||
Summary = ActivityMgr.GetOrganisationEventDataValue(colSummary, values).AsString(),
|
||||
Details = ActivityMgr.GetOrganisationEventDataValue(colDetails, values).AsString(),
|
||||
RegionCaptionCountry = model.GetRegionCaption(values.GetString(colRegionId.DataName).ToSysId()),
|
||||
SportCaptionPrimary = model.GetSportCaption(values.GetString(colSportId.DataName).ToSysId()),
|
||||
CreatedOnFmt = Localiser.FormatDate(values.GetDateTime(colCreatedOn.DataName)),
|
||||
@@ -224,6 +272,14 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
};
|
||||
if (SaxOrganisationEvent.HasValidEventTime(eventAt))
|
||||
eventData.EventAtTimeFmt = DateUtil.Format(eventAt, "HH:mm");
|
||||
if (DateUtil.IsValid(eventTo) && eventAt.Date != ((DateTime)eventTo).Date)
|
||||
eventData.EventToDateFmt = Localiser.FormatDate(eventTo);
|
||||
if (SaxOrganisationEvent.HasValidEventTime(eventTo))
|
||||
eventData.EventToTimeFmt = DateUtil.Format(eventTo, "HH:mm");
|
||||
if (DateUtil.IsValid(eventTo) && eventTo > eventAt)
|
||||
eventData.EventAtTimeFmt = DateUtil.FormatNumberOfSeconds(((DateTime)eventTo - eventAt).TotalSeconds);
|
||||
responseData.Events.Add(eventData);
|
||||
}
|
||||
}
|
||||
@@ -254,7 +310,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
public IActionResult Ajax_GetEvent(Model_Organisation_Events model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetEvent";
|
||||
String messageTitle = Localiser["organisation.caption.organisationEvent"];
|
||||
String messageTitle = Localiser["organisation.caption.event"];
|
||||
AjaxResponse_Event responseData = new AjaxResponse_Event(model);
|
||||
|
||||
// Validate session and referrer.
|
||||
@@ -309,7 +365,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
public IActionResult Ajax_StoreEvent(Model_Organisation_Events model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreEvent";
|
||||
String messageTitle = Localiser["organisation.caption.organisationEvent"];
|
||||
String messageTitle = Localiser["organisation.caption.event"];
|
||||
AjaxResponse_Event responseData = new AjaxResponse_Event(model);
|
||||
|
||||
// Validate session and referrer.
|
||||
@@ -388,11 +444,33 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
organisationEvent.SportIdPrimary = model.ExtractSysId(model.EventSportIdPrimary);
|
||||
if (model.EventRegionIdCountry != null)
|
||||
organisationEvent.RegionIdCountry = model.ExtractSysId(model.EventRegionIdCountry);
|
||||
if (model.EventDate != null)
|
||||
if (model.EventAtDate != null)
|
||||
{
|
||||
organisationEvent.EventAt = model.ParseDateFromForm(model.EventDate);
|
||||
if (!StringUtil.IsEmpty(model.EventTime))
|
||||
organisationEvent.EventAt = DateUtil.SetTime(organisationEvent.EventAt, DateUtil.ParseExact(model.EventTime, "HH:mm"));
|
||||
// 'At' date.
|
||||
organisationEvent.EventAt = model.ParseDateFromForm(model.EventAtDate);
|
||||
if (model.EventAtTimeSet && !StringUtil.IsBlank(model.EventAtTime))
|
||||
{
|
||||
// For midnight (00:00) set +1 minute so that the value is treated as a valid start time.
|
||||
if (model.EventAtTime.Equals("00:00"))
|
||||
model.EventAtTime = "00:01";
|
||||
organisationEvent.EventAt = DateUtil.SetTime(organisationEvent.EventAt, DateUtil.ParseExact(model.EventAtTime, "HH:mm"));
|
||||
}
|
||||
if (model.EventToDateSet || model.EventToTimeSet)
|
||||
{
|
||||
// 'To' date.
|
||||
organisationEvent.EventTo = organisationEvent.EventAt;
|
||||
if (model.EventToDate != null && model.EventToDateSet)
|
||||
organisationEvent.EventTo = model.ParseDateFromForm(model.EventToDate);
|
||||
// 'To' time.
|
||||
if (model.EventAtTimeSet && model.EventToTimeSet && !StringUtil.IsBlank(model.EventToTime))
|
||||
{
|
||||
// For midnight (00:00) set +1 minute so that the value is treated as a valid finish time.
|
||||
if (model.EventToTime.Equals("00:00"))
|
||||
model.EventToTime = "00:01";
|
||||
organisationEvent.EventTo = DateUtil.SetTime(organisationEvent.EventTo ?? organisationEvent.EventAt, DateUtil.ParseExact(model.EventToTime, "HH:mm"));
|
||||
}
|
||||
}
|
||||
else organisationEvent.EventTo = null;
|
||||
}
|
||||
if (model.EventTypeCode != null)
|
||||
organisationEvent.EventType = (Sax.EventType)EventTypeCodes.GetTypeForCode(model.EventTypeCode);
|
||||
|
||||
Reference in New Issue
Block a user