This commit is contained in:
2019-05-16 23:03:05 +00:00
parent 32ceefafd8
commit 95f269706b
6 changed files with 8 additions and 76 deletions

View File

@@ -1,48 +0,0 @@
// using AyaNova.Models;
// using AyaNova.Biz;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.EntityFrameworkCore.Metadata;
// using System.Reflection;
// using System;
// namespace AyaNova.Biz
// {
// /// <summary>
// /// Returns owner Id if the object exists or 0 if exists but there is no owner ID property or -1 if the object doesn't exist
// /// </summary>
// internal static class AyaObjectOwnerId
// {
// internal static long Get(AyaTypeId o, AyContext ct)
// {
// if (o.IsEmpty) return -1;
// //Get the type of the model of AyaObject
// Type t = Type.GetType("AyaNova.Models." + o.ObjectType.ToString());
// //Run a find query on the db context based on the model's type
// object record = ct.Find(t, o.ObjectId);
// if (record == null)
// {
// return -1;
// }
// PropertyInfo ownerIdPropertyInfo = record.GetType().GetProperty("OwnerId");
// if (ownerIdPropertyInfo == null)
// return 0;//object exists and it doesn't have an ownerID property
// long ret = (long)ownerIdPropertyInfo.GetValue(record, null);
// return ret;
// }
// }
// }//eons

View File

@@ -71,15 +71,7 @@ namespace AyaNova.Biz
}
}
// /// <summary>
// /// Get the ownerId for the object in question
// /// </summary>
// /// <param name="ct">db context</param>
// /// <returns>0 if object doesn't have an owner Id, the owner Id or -1 if the object doesn't exist in the db</returns>
// public long OwnerId(AyContext ct)
// {
// return AyaObjectOwnerId.Get(this, ct);
// }
/// <summary>

View File

@@ -85,8 +85,7 @@ namespace AyaNova.Biz
{
//do stuff with widget
Widget outObj = inObj;
outObj.OwnerId = UserId;
//Test get serial id visible id number from generator
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
@@ -114,7 +113,7 @@ namespace AyaNova.Biz
{
//do stuff with widget
Widget outObj = inObj;
outObj.OwnerId = UserId;
//Test get serial id visible id number from generator
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
@@ -140,10 +139,7 @@ namespace AyaNova.Biz
//put
internal bool Put(Widget dbObj, Widget inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//make a snapshot of the original for validation but update the original to preserve workflow
Widget SnapshotOfOriginalDBObj = new Widget();
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
@@ -355,13 +351,7 @@ namespace AyaNova.Biz
// // }
// }
//OwnerId required
if (!isNew)
{
if (proposedObj.OwnerId == 0)
AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId");
}
//Name required
if (string.IsNullOrWhiteSpace(proposedObj.Name))
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");

View File

@@ -13,8 +13,7 @@ namespace AyaNova.Models
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
[Required]
public long OwnerId { get; set; }
[Required]
public string Name { get; set; }
public uint Serial { get; set; }
public decimal? DollarAmount { get; set; }

View File

@@ -205,7 +205,7 @@ namespace AyaNova.Util
//Add widget table
//id, text, longtext, boolean, currency,
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, serial bigint not null," +
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, serial bigint not null," +
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, count integer, notes text, customfields text, tags varchar(255) ARRAY)");
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS

View File

@@ -462,8 +462,7 @@ namespace AyaNova.Util
o.Active = true;
o.StartDate = f.Date.Between(DateTime.Now, DateTime.Now.AddMinutes(60));
o.EndDate = f.Date.Between(DateTime.Now.AddMinutes(90), DateTime.Now.AddHours(5));
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
o.OwnerId = 1;
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
//this is nonsense but just to test an enum
o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited;
o.Notes = f.Lorem.Paragraph();