using System; using AyaNova.Biz; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace AyaNova.Models { //SERVICEBANK LEDGER //NOTE: following pattern outlined here: //https://dba.stackexchange.com/a/19368 public class ServiceBank : ICoreBizObjectModel { public long Id { get; set; } public uint Concurrency { get; set; } [Required] public string Name { get; set; } [Required] public DateTime EntryDate { get; set; } public DateTime? LastEntryDate { get; set; } [Required] public long ObjectId { get; set; } [Required] public AyaType AType { get; set; } [Required] public long SourceId { get; set; } [Required] public AyaType SourceType { get; set; } [Required] public decimal Incidents { get; set; } [Required] public decimal IncidentsBalance { get; set; } public decimal? LastIncidentsBalance { get; set; } [Required] public decimal Currency { get; set; } [Required] public decimal CurrencyBalance { get; set; } public decimal? LastCurrencyBalance { get; set; } [Required] public decimal Hours { get; set; } [Required] public decimal HoursBalance { get; set; } public decimal? LastHoursBalance { get; set; } public ServiceBank() { EntryDate = DateTime.UtcNow; } [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.ServiceBank; } }//eoc //Data transfer version used by UI to make new entry or consume banked time //this way the client doesn't need to bother with balances or last entries and such public class dtServiceBank { public long Id { get; set; } public uint Concurrency { get; set; } [Required] public string Name { get; set; } [Required] public long ObjectId { get; set; } [Required] public AyaType AType { get; set; } [Required] public long SourceId { get; set; } [Required] public AyaType SourceType { get; set; } [Required] public decimal Incidents { get; set; } [Required] public decimal Currency { get; set; } [Required] public decimal Hours { get; set; } }//eoc }//eons /* CREATE TABLE [dbo].[ASERVICEBANK]( [AID] [uniqueidentifier] NOT NULL, [ACREATED] [datetime] NOT NULL,//displays as "Entered" in v7 ui [ACREATOR] [uniqueidentifier] NOT NULL, [ADESCRIPTION] [nvarchar](255) NULL, [ASOURCEROOTOBJECTTYPE] [smallint] NOT NULL, [AEFFECTIVEDATE] [datetime] NULL,//docs for v7 say for what have you purposes, not relevant, for v8 IMPORT AS transactiondat [AINCIDENTS] [decimal](19, 5) NULL, [AINCIDENTSBALANCE] [decimal](19, 5) NULL, [ACURRENCY] [decimal](19, 5) NULL, [ACURRENCYBALANCE] [decimal](19, 5) NULL, [AHOURS] [decimal](19, 5) NULL, [AHOURSBALANCE] [decimal](19, 5) NULL, [AAPPLIESTOROOTOBJECTID] [uniqueidentifier] NOT NULL, [AAPPLIESTOROOTOBJECTTYPE] [smallint] NOT NULL, [ASOURCEROOTOBJECTID] [uniqueidentifier] NULL, */