示例#1
0
        public async Task UpdateTest()
        {
            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            var result = await sqless.Update(UpdateRequest);

            Assert.IsTrue(result > 0);
        }
示例#2
0
        public async Task NoAccessSelectTest()
        {
            var reqeust = new SqlessEditRequest()
            {
                Table  = Tables.User,
                Fields = new List <SqlessEditField>()
                {
                    new SqlessEditField()
                    {
                        Field = "Password",
                        Value = "1",
                        Type  = System.Data.DbType.String
                    }
                }
            };

            using Sqless sqless = new Sqless(Global.GetOwnerAccessConfig("1"));
            try
            {
                var result = await sqless.Update(reqeust);
            }
            catch (UnauthorizedAccessException)
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsTrue(false);
        }
示例#3
0
        public async Task UpdateOwnerField1Test()
        {
            var request = new SqlessEditRequest()
            {
                Table  = Tables.User,
                Fields = new List <SqlessEditField>()
                {
                    new SqlessEditField()
                    {
                        Field = "Name",
                        Value = "1",
                        Type  = System.Data.DbType.String
                    }
                }
            };

            using Sqless sqless = new Sqless(Global.GetOwnerAccessConfig("1"));
            var result = await sqless.Update(request);

            Assert.IsTrue(result > 0);
        }
示例#4
0
        public async Task UpdateOwnerFieldTest()
        {
            var updateRequest = new SqlessEditRequest()
            {
                Table  = Tables.User,
                Fields = new List <SqlessEditField>()
                {
                    new SqlessEditField()
                    {
                        Field = "Uid",
                        Value = "2",
                        Type  = System.Data.DbType.String
                    }
                }
            };

            using Sqless updateSqless = new Sqless(Global.GetOwnerAccessConfig("1"));
            var updateResult = await updateSqless.Update(updateRequest);

            Assert.IsTrue(updateResult > 0);

            var selectRequest = new SqlessSelectRequest()
            {
                Table  = Tables.User,
                Fields = new List <Query.SqlessField>()
                {
                    new SqlessField()
                    {
                        Field = "Uid"
                    }
                }
            };

            using Sqless selectSqless = new Sqless(Global.GetOwnerAccessConfig("1"));
            var selectResult = await selectSqless.SelectFirstOrDefault <string>(selectRequest);

            Assert.AreEqual(selectResult, "1");
        }
示例#5
0
        public virtual async Task <ActionResult> Update(SqlessEditRequest request)
        {
            using Sqless sqless = await GetSqless(request);

            return(Ok(await sqless.Update(request)));
        }