public static async Task <bool> GenerateRowAsync(this ITableContent content, Authentication authentication) { var row = await NewRandomRowAsync(content, authentication); if (FillFields(row, authentication) == true) { if (RandomUtility.Within(25) == true) { await row.SetTagsAsync(authentication, tags.Random()); } if (RandomUtility.Within(25) == true) { await row.SetIsEnabledAsync(authentication, RandomUtility.NextBoolean()); } try { await content.EndNewAsync(authentication, row); return(true); } catch { return(false); } } return(false); }
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); }