Files
raven/server/AyaNova/models/Unit.cs
2023-03-08 21:23:16 +00:00

178 lines
6.0 KiB
C#

using System;
using System.Collections.Generic;
using AyaNova.Biz;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace AyaNova.Models
{
//NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal,
//otherwise the server will call it an invalid record if the field isn't sent from client
public class Unit : ICoreBizObjectModel
{
public long Id { get; set; }
public uint Concurrency { get; set; }
public bool Active { get; set; }
public string Notes { get; set; }
public string Wiki { get; set; }
public string CustomFields { get; set; }
public List<string> Tags { get; set; }
[Required]
public string Serial { get; set; }
[Required]
public long CustomerId { get; set; }
[NotMapped]
public string CustomerViz { get; set; }
public long? ParentUnitId { get; set; }
[NotMapped]
public string ParentUnitViz { get; set; }
public long? UnitModelId { get; set; }
[NotMapped]
public string UnitModelNameViz { get; set; }
public bool UnitHasOwnAddress { get; set; }
public bool BoughtHere { get; set; }
public long? PurchasedFromVendorId { get; set; }
[NotMapped]
public string PurchasedFromVendorViz { get; set; }
public string Receipt { get; set; }
public DateTime? PurchasedDate { get; set; }
public string Description { get; set; }
public long? ReplacedByUnitId { get; set; }
[NotMapped]
public string ReplacedByUnitViz { get; set; }
public bool OverrideModelWarranty { get; set; }
public int? WarrantyLength { get; set; }//MONTHS
public string WarrantyTerms { get; set; }
// public bool UsesBanking { get; set; }
public long? ContractId { get; set; }
[NotMapped]
public string ContractViz { get; set; }
public DateTime? ContractExpires { get; set; }
public bool Metered { get; set; }
[NotMapped]
public long LastMeterViz { get; set; }
[NotMapped]
public DateTime? LastMeterDateViz { get; set; }
[NotMapped]
public long? LastWorkOrderViz { get; set; }
[NotMapped]
public long? LastWorkOrderCompletedViz { get; set; }
[NotMapped]
public DateTime? LastServiceDateViz { get; set; }
[NotMapped]
public DateTime? LastServiceDateCompletedViz { get; set; }
[NotMapped]
public string LastMeterNotesViz { get; set; }
public bool LifeTimeWarranty { get; set; }
public string Text1 { get; set; }
public string Text2 { get; set; }
public string Text3 { get; set; }
public string Text4 { get; set; }
//PHYSICAL ADDRESS
public string Address { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string Country { get; set; }
public string AddressPostal { get; set; }
public decimal? Latitude { get; set; }
public decimal? Longitude { get; set; }
//workaround for notification
[NotMapped, JsonIgnore]
public string Name { get; set; }
public Unit()
{
Tags = new List<string>();
}
[NotMapped, JsonIgnore]
public AyaType AyaType { get => AyaType.Unit; }
// //convenience links
// [JsonIgnore]
// public Customer Customer { get; set; }
// [JsonIgnore]
// public UnitModel UnitModel { get; set; }
// // [JsonIgnore]
// // public Unit ParentUnit { get; set; }
// [JsonIgnore]
// public Vendor PurchasedFromVendor { get; set; }
// // [JsonIgnore]
// // public Unit ReplacedByUnit { get; set; }
}//eoc
//DTO object used when Customer posts a new unit of their own when using CSR form
public class CustomerPostUnit
{
[Required]
public string Serial { get; set; }
[Required]
public long CustomerId { get; set; }
public long? UnitModelId { get; set; }
public string Description { get; set; }
}//eoc
}//eons
/*
CREATE TABLE [dbo].[AUNIT](
[AID] [uniqueidentifier] NOT NULL,
[ACREATED] [datetime] NOT NULL,
[AMODIFIED] [datetime] NOT NULL,
[AACTIVE] [bit] NOT NULL,
[ACREATOR] [uniqueidentifier] NOT NULL,
[AMODIFIER] [uniqueidentifier] NOT NULL,
[ASERIAL] [nvarchar](255) NOT NULL,// MIGRATE: Can't make this unique, but *can* make it unique with the model id UNIQUE(aserial,aunitmodelid) to catch dupes
[ANOTES] [ntext] NULL,
[ACLIENTID] [uniqueidentifier] NULL,
[APARENTUNITID] [uniqueidentifier] NULL,
[AUNITMODELID] [uniqueidentifier] NULL,
[AUNITHASOWNADDRESS] [bit] NOT NULL,//do we need this? it only ever drove the UI, but I guess that's still valid
[ABOUGHTHERE] [bit] NOT NULL,
[APURCHASEDFROMID] [uniqueidentifier] NULL,
[ARECEIPT] [nvarchar](255) NULL,
[APURCHASEDDATE] [datetime] NULL,
[ADESCRIPTION] [nvarchar](255) NULL,
[AREPLACEDBYUNITID] [uniqueidentifier] NULL,
[AOVERRIDEMODELWARRANTY] [bit] NOT NULL,
[AWARRANTYTERMS] [nvarchar](255) NULL,
[ACUSTOM2] [ntext] NULL,
[ACUSTOM3] [ntext] NULL,
[ACUSTOM4] [ntext] NULL,
[ACUSTOM5] [ntext] NULL,
[ACUSTOM6] [ntext] NULL,
[ACUSTOM7] [ntext] NULL,
[ACUSTOM8] [ntext] NULL,
[ACUSTOM9] [ntext] NULL,
[ACUSTOM0] [ntext] NULL,
[ACUSTOM1] [ntext] NULL,
[AUSESBANKING] [bit] NOT NULL,
[AMETERED] [bit] NOT NULL,
[ALIFETIMEWARRANTY] [bit] NOT NULL,
[AWARRANTYLENGTH] [int] NULL,
[ALASTWORKORDERID] [uniqueidentifier] NULL,//MIGRATE: DROP as per case 3536, will determine live from query instead if necessary
[ALASTSERVICEDATE] [datetime] NULL,//MIGRATE: DROP case 3536
[ATEXT1] [nvarchar](255) NULL,
[ATEXT2] [nvarchar](255) NULL,
[ATEXT3] [nvarchar](255) NULL,
[ATEXT4] [nvarchar](255) NULL,
*/