diff --git a/server/AyaNova/models/PM.cs b/server/AyaNova/models/PM.cs index 7a54097a..5a1b2eda 100644 --- a/server/AyaNova/models/PM.cs +++ b/server/AyaNova/models/PM.cs @@ -1,33 +1,45 @@ -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 partial class PM { public long Id { get; set; } public uint ConcurrencyToken { get; set; } [Required] - public string Name { get; set; } - public bool Active { get; set; } - public string Notes { get; set; } - public string Wiki {get;set;} + public uint Serial { 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; } - + + + //dependents + public List PMItems { get; set; } public PM() { Tags = new List(); + PMItems = new List(); } + + //Not persisted business properties + //NOTE: this could be a common class applied to everything for common biz rule stuff + //i.e. specific rights in situations based on rules, like candelete, canedit etc + [NotMapped] + public bool NonDataBaseExampleColumn { get; set; }//example of how to add a property that is not persisted but is used by both ends dynamically, should come up with a naming scheme so can see them at a glance + + }//eoc }//eons diff --git a/server/AyaNova/models/PMItem.cs b/server/AyaNova/models/PMItem.cs index decc8a6c..747fa713 100644 --- a/server/AyaNova/models/PMItem.cs +++ b/server/AyaNova/models/PMItem.cs @@ -1,7 +1,6 @@ -using System; using System.Collections.Generic; -using AyaNova.Biz; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace AyaNova.Models @@ -22,12 +21,25 @@ namespace AyaNova.Models public string CustomFields { get; set; } public List Tags { get; set; } + //Principle + [Required]//this required annotation should cause a cascade delete to happen automatically when wo is deleted, need to test that + public long PMId { get; set; }//fk + public PM PM { get; set; } + + //Dependents public PMItem() { Tags = new List(); } + //Not persisted business properties + //NOTE: this could be a common class applied to everything for common biz rule stuff + //i.e. specific rights in situations based on rules, like candelete, canedit etc + [NotMapped] + public bool NonDataBaseExampleColumn { get; set; }//example of how to add a property that is not persisted but is used by both ends dynamically, should come up with a naming scheme so can see them at a glance + + }//eoc }//eons diff --git a/server/AyaNova/models/Quote.cs b/server/AyaNova/models/Quote.cs index ceab783c..f77faa5c 100644 --- a/server/AyaNova/models/Quote.cs +++ b/server/AyaNova/models/Quote.cs @@ -1,33 +1,44 @@ -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 partial class Quote { public long Id { get; set; } public uint ConcurrencyToken { get; set; } [Required] - public string Name { get; set; } - public bool Active { get; set; } - public string Notes { get; set; } - public string Wiki {get;set;} + public uint Serial { 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; } - + + + //dependents + public List QuoteItems { get; set; } public Quote() { Tags = new List(); + QuoteItems = new List(); } + + //Not persisted business properties + //NOTE: this could be a common class applied to everything for common biz rule stuff + //i.e. specific rights in situations based on rules, like candelete, canedit etc + [NotMapped] + public bool NonDataBaseExampleColumn { get; set; }//example of how to add a property that is not persisted but is used by both ends dynamically, should come up with a naming scheme so can see them at a glance + + }//eoc }//eons diff --git a/server/AyaNova/models/QuoteItem.cs b/server/AyaNova/models/QuoteItem.cs index 758e8047..857d61b9 100644 --- a/server/AyaNova/models/QuoteItem.cs +++ b/server/AyaNova/models/QuoteItem.cs @@ -1,7 +1,6 @@ -using System; using System.Collections.Generic; -using AyaNova.Biz; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; namespace AyaNova.Models @@ -22,12 +21,25 @@ namespace AyaNova.Models public string CustomFields { get; set; } public List Tags { get; set; } + //Principle + [Required]//this required annotation should cause a cascade delete to happen automatically when wo is deleted, need to test that + public long QuoteId { get; set; }//fk + public Quote Quote { get; set; } + + //Dependents public QuoteItem() { Tags = new List(); } + //Not persisted business properties + //NOTE: this could be a common class applied to everything for common biz rule stuff + //i.e. specific rights in situations based on rules, like candelete, canedit etc + [NotMapped] + public bool NonDataBaseExampleColumn { get; set; }//example of how to add a property that is not persisted but is used by both ends dynamically, should come up with a naming scheme so can see them at a glance + + }//eoc }//eons diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 543523bf..7bee26e8 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -385,7 +385,7 @@ namespace AyaNova.Util //WORKORDER await ExecQueryAsync("CREATE TABLE aworkorder (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); - await ExecQueryAsync("CREATE INDEX aworkorder_number_id_idx ON aworkorder (id, serial);"); + await ExecQueryAsync("CREATE INDEX aworkorder_serial_id_idx ON aworkorder (id, serial);");//is this necessary or fruitful? await ExecQueryAsync("CREATE INDEX aworkorder_tags ON aworkorder using GIN(tags)"); //WORKORDERITEM @@ -407,13 +407,13 @@ namespace AyaNova.Util await ExecQueryAsync("CREATE INDEX aworkordertemplateitem_tags ON aworkordertemplateitem using GIN(tags)"); //QUOTE - await ExecQueryAsync("CREATE TABLE aquote (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aquote (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); - await ExecQueryAsync("CREATE UNIQUE INDEX aquote_name_id_idx ON aquote (id, name);"); + await ExecQueryAsync("CREATE UNIQUE INDEX aquote_serial_id_idx ON aquote (id, serial);");//is this necessary or fruitful? await ExecQueryAsync("CREATE INDEX aquote_tags ON aquote using GIN(tags)"); //QUOTEITEM - await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGSERIAL PRIMARY KEY, quoteid bigint not null REFERENCES aquote (id), name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aquoteitem_name_id_idx ON aquoteitem (id, name);"); await ExecQueryAsync("CREATE INDEX aquoteitem_tags ON aquoteitem using GIN(tags)"); @@ -431,13 +431,13 @@ namespace AyaNova.Util await ExecQueryAsync("CREATE INDEX aquotetemplateitem_tags ON aquotetemplateitem using GIN(tags)"); //PM - await ExecQueryAsync("CREATE TABLE apm (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apm (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); - await ExecQueryAsync("CREATE UNIQUE INDEX apm_name_id_idx ON apm (id, name);"); + await ExecQueryAsync("CREATE UNIQUE INDEX apm_serial_id_idx ON apm (id, serial);");//is this necessary or fruitful? await ExecQueryAsync("CREATE INDEX apm_tags ON apm using GIN(tags)"); //PMITEM - await ExecQueryAsync("CREATE TABLE apmitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apmitem (id BIGSERIAL PRIMARY KEY, pmid bigint not null REFERENCES apm (id), name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX apmitem_name_id_idx ON apmitem (id, name);"); await ExecQueryAsync("CREATE INDEX apmitem_tags ON apmitem using GIN(tags)");