private async Task<ITableRow> AddNewRowAsync(Authentication authentication, ITableContent content)
 {
     var table = content.Table;
     var parent = table.Parent;
     if (parent != null)
     {
         if (parent.Content.Any() == false)
             return null;
         var relationID = parent.Content.Random().ID;
         return await content.AddNewAsync(authentication, relationID);
     }
     return await content.AddNewAsync(authentication, null);
 }
Example #2
0
        public static async Task <ITableRow> NewRandomRowAsync(this ITableContent content, Authentication authentication)
        {
            var table         = content.Table;
            var parentContent = table.Parent?.Content;

            if (parentContent != null)
            {
                var parentRow = parentContent.Random();
                if (parentRow == null)
                {
                    return(null);
                }
                return(await content.AddNewAsync(authentication, parentRow.ID));
            }
            return(await content.AddNewAsync(authentication, null));
        }
Example #3
0
        public static async Task CreateRowAsync(this ITableContent content, Authentication authentication)
        {
            var    table         = content.Table;
            var    parentContent = table.Parent.Content;
            string relationID    = null;

            if (parentContent != null && parentContent.Any() == true)
            {
                relationID = parentContent.Random().ID;
            }

            var row = await content.AddNewAsync(authentication, relationID);

            var types = table.GetService(typeof(ITypeCollection)) as ITypeCollection;

            foreach (var item in table.TableInfo.Columns)
            {
                if (item.AutoIncrement == false)
                {
                    //row.SetField(authentication, item.Name, TypeContextExtensions.GetRandomValue(types, item));
                }
            }

            if (RandomUtility.Within(25) == true)
            {
                await row.SetTagsAsync(authentication, tags.Random());
            }

            if (RandomUtility.Within(25) == true)
            {
                await row.SetIsEnabledAsync(authentication, RandomUtility.NextBoolean());
            }

            await content.EndNewAsync(authentication, row);
        }
        public static async Task <ITableRow> AddRandomRowAsync(this ITableContent content, Authentication authentication)
        {
            var row = await content.AddNewAsync(authentication, null);

            await row.InitializeRandomAsync(authentication);

            await content.EndNewAsync(authentication, row);

            return(row);
        }