This commit is contained in:
2018-11-30 18:22:20 +00:00
parent 2a16580ddc
commit c3647d6fc1
8 changed files with 46 additions and 35 deletions

View File

@@ -380,7 +380,7 @@ namespace AyaNova
// ******************** TESTING WIPE DB *****************************
//
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
var TESTING_REFRESH_DB = true;//#############################################################################################
var TESTING_REFRESH_DB = false;//#############################################################################################
#if (DEBUG)
//TESTING

View File

@@ -160,8 +160,12 @@ namespace AyaNova.Biz
//put
internal bool Put(DataFilter dbObj, DataFilter inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//Replace the db object with the PUT object
CopyObject.Copy(inObj, dbObj, "Id,Serial");
CopyObject.Copy(inObj, dbObj, "Id");
//Set "original" value of concurrency token to input token
//this will allow EF to check it out
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = inObj.ConcurrencyToken;
@@ -278,7 +282,7 @@ namespace AyaNova.Biz
}
if (filterItem["value"] == null)
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"value\" property ");
//NOTE: value of nothing, null or empty is a valid value so no checking for it here
//NOTE: value of nothing, null or empty is a valid value so no checking for it here
}
}
catch (Newtonsoft.Json.JsonReaderException ex)

View File

@@ -170,6 +170,10 @@ namespace AyaNova.Biz
//put
internal bool Put(Tag dbObj, Tag inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//Ensure it follows the rules
inObj.Name = CleanTagName(inObj.Name);

View File

@@ -187,6 +187,10 @@ namespace AyaNova.Biz
//put
internal bool Put(TagGroup dbObj, TagGroup inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//Ensure it follows the rules
inObj.Name = CleanTagGroupName(inObj.Name);

View File

@@ -220,6 +220,10 @@ namespace AyaNova.Biz
//put
internal bool Put(User dbObj, User inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//Get a snapshot of the original db value object before changes
User SnapshotObj = new User();
CopyObject.Copy(dbObj, SnapshotObj);

View File

@@ -45,7 +45,10 @@ namespace AyaNova.Biz
//put
internal bool Put(UserOptions dbObj, UserOptions inObj)
{
//preserve the owner ID if none was specified
if (inObj.OwnerId == 0)
inObj.OwnerId = dbObj.OwnerId;
//Replace the db object with the PUT object
CopyObject.Copy(inObj, dbObj, "Id, UserId, OwnerId");
//Set "original" value of concurrency token to input token

View File

@@ -33,7 +33,7 @@ namespace AyaNova.Biz
}
}
internal WidgetBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
{
ct = dbcontext;
@@ -227,6 +227,9 @@ 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;
//Replace the db object with the PUT object
CopyObject.Copy(inObj, dbObj, "Id,Serial");

View File

@@ -20,7 +20,7 @@ namespace raven_integration
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("Test DataFilter");
// d.ownerId = 1L;
// d.ownerId = 1L;
d["public"] = true;
d.listKey = "Widget";
@@ -32,45 +32,34 @@ namespace raven_integration
df.value = "Generic";//lots of seed widgets start with Generic
dfilter.Add(df);
d.filter=dfilter.ToString();//it expects it to be a json string, not actual json
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["data"]["id"].Value<long>();
string Name = a.ObjectResponse["data"]["name"].Value<string>();
Name.Should().StartWith("Test DataFilter");
// // //RETRIEVE
// // /*
// // {
// // "data": {
// // "id": 24,
// // "created": "2018-03-28T21:07:41.9703503Z",
// // "concurrencyToken": 9502,
// // "ownerId": 1,
// // "name": "یونی‌کُد چیست؟"
// // }
// // }
// // */
// // //Get one
// // a = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
// // Util.ValidateDataReturnResponseOk(a);
// // a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("testtag");
//RETRIEVE
//Get one
a = await Util.GetAsync("DataFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
Util.ValidateDataReturnResponseOk(a);
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataFilter");
// // //UPDATE
// // //PUT
// // d.Id = tagId;
// // d.name = Util.Uniquify("PutTestTag");
// // d.created = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture);
// // d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
// // d.OwnerId = 1L;
//Get as alternate user should work for public filter
a = await Util.GetAsync("DataFilter/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited"));
Util.ValidateDataReturnResponseOk(a);
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataFilter");
// // ApiResponse PUTTestResponse = await Util.PutAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
// // Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
//UPDATE
//PUT, make private
d["public"] = false;
d.name = Util.Uniquify("Put - Test DataFilter (privatized)");
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
ApiResponse PUTTestResponse = await Util.PutAsync("DataFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
// // //check PUT worked
// // ApiResponse checkPUTWorked = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));