From 26ca0872a13326ed8709b21b602a87aef181c0d3 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 19 Jan 2021 22:15:32 +0000 Subject: [PATCH] --- server/AyaNova/biz/AyaType.cs | 4 ++- server/AyaNova/models/AyContext.cs | 1 + server/AyaNova/models/PartWarehouse.cs | 49 ++++++++++++++++++++++++++ server/AyaNova/util/AySchema.cs | 11 ++++-- 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 server/AyaNova/models/PartWarehouse.cs diff --git a/server/AyaNova/biz/AyaType.cs b/server/AyaNova/biz/AyaType.cs index 17216d8c..953a3d8c 100644 --- a/server/AyaNova/biz/AyaType.cs +++ b/server/AyaNova/biz/AyaType.cs @@ -130,7 +130,9 @@ namespace AyaNova.Biz [CoreBizObject] TaxCode = 64, [CoreBizObject] - PartAssembly = 65 + PartAssembly = 65, + [CoreBizObject] + PartWarehouse = 66 diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs index 77c91ef8..0ac6bd50 100644 --- a/server/AyaNova/models/AyContext.cs +++ b/server/AyaNova/models/AyContext.cs @@ -40,6 +40,7 @@ namespace AyaNova.Models public virtual DbSet Notification { get; set; } public virtual DbSet NotifyDeliveryLog { get; set; } public virtual DbSet Part { get; set; } + public virtual DbSet PartWarehouse { get; set; } public virtual DbSet PartSerial { get; set; } public virtual DbSet PartAssembly { get; set; } public virtual DbSet PartAssemblyItem { get; set; } diff --git a/server/AyaNova/models/PartWarehouse.cs b/server/AyaNova/models/PartWarehouse.cs new file mode 100644 index 00000000..249670c8 --- /dev/null +++ b/server/AyaNova/models/PartWarehouse.cs @@ -0,0 +1,49 @@ +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 PartWarehouse : ICoreBizObjectModel + { + public long Id { get; set; } + public uint Concurrency { get; set; } + + [Required] + public string Name { get; set; } + public bool Active { get; set; } + public string Notes { get; set; } + public string Wiki { get; set; } + public string CustomFields { get; set; } + public List Tags { get; set; } + + + public PartWarehouse() + { + Tags = new List(); + } + + [NotMapped, JsonIgnore] + public AyaType AyaType { get => AyaType.PartWarehouse; } + + }//eoc + +}//eons +/* +CREATE TABLE [dbo].[APARTWAREHOUSE]( + [AID] [uniqueidentifier] NOT NULL, + [ACREATED] [datetime] NOT NULL, + [AMODIFIED] [datetime] NOT NULL, + [AACTIVE] [bit] NOT NULL, + [ACREATOR] [uniqueidentifier] NOT NULL, + [AMODIFIER] [uniqueidentifier] NOT NULL, + [ANAME] [nvarchar](255) NOT NULL, + [ADESCRIPTION] [nvarchar](255) NULL, + [AREGIONID] [uniqueidentifier] NULL,//tagify +*/ \ No newline at end of file diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 98ec3a63..7629df8c 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -22,8 +22,8 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 15; - internal const long EXPECTED_COLUMN_COUNT = 669; - internal const long EXPECTED_INDEX_COUNT = 117; + internal const long EXPECTED_COLUMN_COUNT = 676; + internal const long EXPECTED_INDEX_COUNT = 119; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! @@ -665,8 +665,13 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); "cost decimal(19,4) not null, retail decimal(19,4) not null, unitofmeasure text, upc text " + " )"); + //PARTWAREHOUSE + await ExecQueryAsync("CREATE TABLE apartwarehouse (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool not null, " + + "notes text, wiki text, customfields text, tags varchar(255) ARRAY)"); + await ExecQueryAsync("INSERT INTO apartwarehouse(name, active) VALUES ('#1', true);"); + //PARTSERIAL - await ExecQueryAsync("CREATE TABLE apartserial (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial text not null, "+ + await ExecQueryAsync("CREATE TABLE apartserial (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial text not null, " + "partid bigint not null REFERENCES apart on delete cascade, CONSTRAINT UNQ_PartSerialPart UNIQUE (partid, serial) )");//ensure not duplicate partid/serial combo //PARTASSEMBLY