This commit is contained in:
@@ -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
|
|
||||||
@@ -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>
|
/// <summary>
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
//do stuff with widget
|
//do stuff with widget
|
||||||
Widget outObj = inObj;
|
Widget outObj = inObj;
|
||||||
outObj.OwnerId = UserId;
|
|
||||||
|
|
||||||
//Test get serial id visible id number from generator
|
//Test get serial id visible id number from generator
|
||||||
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
//do stuff with widget
|
//do stuff with widget
|
||||||
Widget outObj = inObj;
|
Widget outObj = inObj;
|
||||||
outObj.OwnerId = UserId;
|
|
||||||
//Test get serial id visible id number from generator
|
//Test get serial id visible id number from generator
|
||||||
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
outObj.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
|
||||||
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
|
outObj.Tags = TagUtil.NormalizeTags(outObj.Tags);
|
||||||
@@ -140,10 +139,7 @@ namespace AyaNova.Biz
|
|||||||
//put
|
//put
|
||||||
internal bool Put(Widget dbObj, Widget inObj)
|
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
|
//make a snapshot of the original for validation but update the original to preserve workflow
|
||||||
Widget SnapshotOfOriginalDBObj = new Widget();
|
Widget SnapshotOfOriginalDBObj = new Widget();
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
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
|
//Name required
|
||||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ namespace AyaNova.Models
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public uint ConcurrencyToken { get; set; }
|
public uint ConcurrencyToken { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public long OwnerId { get; set; }
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public uint Serial { get; set; }
|
public uint Serial { get; set; }
|
||||||
public decimal? DollarAmount { get; set; }
|
public decimal? DollarAmount { get; set; }
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
//Add widget table
|
//Add widget table
|
||||||
//id, text, longtext, boolean, currency,
|
//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)");
|
"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
|
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
|
||||||
|
|||||||
@@ -462,8 +462,7 @@ namespace AyaNova.Util
|
|||||||
o.Active = true;
|
o.Active = true;
|
||||||
o.StartDate = f.Date.Between(DateTime.Now, DateTime.Now.AddMinutes(60));
|
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.EndDate = f.Date.Between(DateTime.Now.AddMinutes(90), DateTime.Now.AddHours(5));
|
||||||
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
|
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
|
||||||
o.OwnerId = 1;
|
|
||||||
//this is nonsense but just to test an enum
|
//this is nonsense but just to test an enum
|
||||||
o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited;
|
o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited;
|
||||||
o.Notes = f.Lorem.Paragraph();
|
o.Notes = f.Lorem.Paragraph();
|
||||||
|
|||||||
Reference in New Issue
Block a user