Exemplo n.º 1
0
        public async Task UpsertInsertTest()
        {
            var newUid  = "UpsertTest_" + Guid.NewGuid().ToString();
            var request = new SqlessEditRequest()
            {
                Table   = Tables.User,
                Queries = new List <Query.SqlessQuery>()
                {
                    new Query.SqlessQuery()
                    {
                        Field = "Uid",
                        Value = newUid,
                        Type  = Query.SqlessQueryType.Equal
                    }
                }
            };

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

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

            Assert.IsTrue(result > 0);
        }
Exemplo n.º 2
0
        public virtual async Task <ActionResult> Upsert(SqlessEditRequest request)
        {
            using Sqless sqless = await GetSqless(request);

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