213 lines
6.5 KiB
C#
213 lines
6.5 KiB
C#
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Saxonite.Net.Standard.Base.Bus
|
|
{
|
|
//=======================================================================
|
|
// ActivityIndex.
|
|
//=======================================================================
|
|
public abstract class SaxActivityFeedback : SacsHierarchyItem
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
Pos,
|
|
// Item.
|
|
ItemType,
|
|
ItemType_Code,
|
|
ItemType_Desc,
|
|
ItemId,
|
|
// Feedback.
|
|
ViewCount,
|
|
FeedbackCount,
|
|
FeedbackTotal,
|
|
FeedbackAverage,
|
|
// Common.
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public ItemId ItemId { get; set; } = new ItemId();
|
|
public long ViewCount { get; set; }
|
|
public long FeedbackCount { get; set; }
|
|
public long FeedbackTotal { get; set; }
|
|
public decimal FeedbackAverage { get; set; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data() { }
|
|
// Properties.
|
|
public ItemId ItemId
|
|
{
|
|
get { return data.ItemId; }
|
|
set { CheckChanged(data.ItemId, value); data.ItemId = value; }
|
|
}
|
|
public long ViewCount
|
|
{
|
|
get { return data.ViewCount; }
|
|
set { CheckChanged(data.ViewCount, value); data.ViewCount = value; }
|
|
}
|
|
public long FeedbackCount
|
|
{
|
|
get { return data.FeedbackCount; }
|
|
set { CheckChanged(data.FeedbackCount, value); data.FeedbackCount = value; }
|
|
}
|
|
public long FeedbackTotal
|
|
{
|
|
get { return data.FeedbackTotal; }
|
|
set { CheckChanged(data.FeedbackTotal, value); data.FeedbackTotal = value; }
|
|
}
|
|
public decimal FeedbackAverage
|
|
{
|
|
get { return data.FeedbackAverage; }
|
|
set { CheckChanged(data.FeedbackAverage, value); data.FeedbackAverage = value; }
|
|
}
|
|
// Population.
|
|
internal void PopulateFrom(Data data)
|
|
{
|
|
ItemId = data.ItemId;
|
|
ViewCount = data.ViewCount;
|
|
FeedbackCount = data.FeedbackCount;
|
|
FeedbackTotal = data.FeedbackTotal;
|
|
FeedbackAverage = data.FeedbackAverage;
|
|
base.PopulateFrom(data);
|
|
}
|
|
public Data Clone()
|
|
{
|
|
Data data = new Data();
|
|
data.PopulateFrom(this);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Error field - identify properties with validation error.
|
|
public new class ErrField : SacsHierarchyItem.ErrField
|
|
{
|
|
// Identifies the field that has invalid data.
|
|
public ValidValue ItemId { get; set; } = ValidValue.Valid;
|
|
public ValidValue ViewCount { get; set; } = ValidValue.Valid;
|
|
public ValidValue FeedbackCount { get; set; } = ValidValue.Valid;
|
|
public ValidValue FeedbackTotal { get; set; } = ValidValue.Valid;
|
|
public ValidValue FeedbackAverage { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SaxActivityFeedback(ItemId itemId) : base()
|
|
{
|
|
base.SetData(data);
|
|
ItemId = itemId;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Item Types.
|
|
private readonly static List<Sax.DataItemType> validItemTypes = new List<Sax.DataItemType>()
|
|
{ Sax.DataItemType.Article, Sax.DataItemType.OrganisationEvent, Sax.DataItemType.OrganisationOpportunity };
|
|
public static List<Sax.DataItemType> ValidItemTypes { get { return new List<Sax.DataItemType>(validItemTypes); } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public Data GetData() { return data.Clone(); }
|
|
public void SetData(Data data)
|
|
{
|
|
String fn = GetType().Name + ".SetData";
|
|
// Properties that cannot be changed if previously specified.
|
|
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
|
throw new NotSupportedException(fn + " Id cannot be changed");
|
|
if (ItemId.IsValid(ItemId) && ItemId.Type != data.ItemId.Type && SysId.ToInt(ItemId.Id) != SysId.ToInt(data.ItemId.Id))
|
|
throw new NotSupportedException(fn + " Item Id cannot be changed");
|
|
this.data.PopulateFrom(data);
|
|
}
|
|
public ItemId ItemId
|
|
{
|
|
get { return data.ItemId; }
|
|
protected set { data.ItemId = value; }
|
|
}
|
|
public long ViewCount
|
|
{
|
|
get { return data.ViewCount; }
|
|
set { data.ViewCount = value; }
|
|
}
|
|
public long FeedbackCount
|
|
{
|
|
get { return data.FeedbackCount; }
|
|
set { data.FeedbackCount = value; }
|
|
}
|
|
public long FeedbackTotal
|
|
{
|
|
get { return data.FeedbackTotal; }
|
|
set { data.FeedbackTotal = value; }
|
|
}
|
|
public decimal FeedbackAverage
|
|
{
|
|
get { return data.FeedbackAverage; }
|
|
set { data.FeedbackAverage = value; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Flags - positions 1-16 available.
|
|
|
|
//-------------------------------------------------------------------
|
|
// A s s o c i a t e d D a t a
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a r a m s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>
|
|
/// Combination Sport and Region Ids to index activities.
|
|
/// </summary>
|
|
public class SportFeedbackAverages
|
|
{
|
|
public SportFeedbackAverages(SysId sportId, SysId regionId)
|
|
{
|
|
FeedbackTotal = sportId;
|
|
FeedbackAverage = regionId;
|
|
}
|
|
public SysId FeedbackTotal { get; }
|
|
public SysId FeedbackAverage { get; }
|
|
}
|
|
/// <summary>
|
|
/// Item list parameters.
|
|
/// </summary>
|
|
public new class Params : SacsHierarchyItem.Params
|
|
{
|
|
// List filtering.
|
|
public List<ItemId> ItemIdsIncluded { get; } = new List<ItemId>();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// Item list extension methods.
|
|
public static class SaxActivityFeedbackList
|
|
{
|
|
}
|
|
|
|
//=======================================================================
|
|
}
|