예제 #1
0
        public async Task InsertTest()
        {
            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            var result = await sqless.Insert(InsertRequest);

            Assert.IsTrue(result > 0);
        }
예제 #2
0
        public async Task InsertTest2()
        {
            var request = new SqlessEditRequest()
            {
                Table = Tables.Product
            };

            request.LoadFromObject(new Product()
            {
                Id    = Guid.NewGuid().ToString(),
                Name  = new Random().Next(100000, 999999).ToString(),
                Price = new Random().Next(1, 100)
            });

            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            var result = await sqless.Insert(request);

            Assert.IsTrue(result > 0);
        }
예제 #3
0
        private async Task <string> Insert()
        {
            var id      = "DeleteTest_" + Guid.NewGuid().ToString("D");
            var request = new SqlessEditRequest()
            {
                Table = Tables.User
            };

            request.LoadFromObject(new User
            {
                Uid      = id,
                Name     = DateTime.Now.ToString("hhmmss"),
                Password = new Random().Next(100000, 999999).ToString()
            });

            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            var result = await sqless.Insert(request);

            Assert.IsTrue(result > 0);
            return(id);
        }
예제 #4
0
        public async Task InsertTest3()
        {
            var request = new SqlessEditRequest()
            {
                Table = Tables.Order
            };

            request.LoadFromObject(new Order()
            {
                Id        = Guid.NewGuid().ToString(),
                ProductId = new Random().Next(1, 4).ToString(),
                Uid       = new Random().Next(1, 5).ToString(),
                Status    = 1,
                Time      = DateTimeOffset.Now.ToUnixTimeSeconds()
            });

            using Sqless sqless = new Sqless(Global.AllowUnspecifiedConfig);
            var result = await sqless.Insert(request);

            Assert.IsTrue(result > 0);
        }
예제 #5
0
        public async Task InsertTest()
        {
            var order = new Order()
            {
                Id        = Guid.NewGuid().ToString(),
                ProductId = "1",
                Status    = 1,
                Time      = DateTimeOffset.Now.ToUnixTimeSeconds(),
            };
            var request = new SqlessEditRequest()
            {
                Table        = Tables.Order,
                AccessParams = new string[] { "AccessTestUid", "123456" },
            };

            request.LoadFromObject(order);

            var uid = await Global.PasswordAccessConfig.GetUid(request.AccessParams);

            using Sqless sqless = new Sqless(Global.GetOwnerAccessConfig(uid));
            var result = await sqless.Insert(request);

            Assert.IsTrue(result > 0);
        }
예제 #6
0
        public virtual async Task <ActionResult> Insert(SqlessEditRequest request)
        {
            using Sqless sqless = await GetSqless(request);

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