public static void Delete(Title title) { CloudTable table = GetTable(_tableName); TableOperation deleteTitle = TableOperation.Delete(title); table.Execute(deleteTitle); List <AuthorTitle> authors = new List <AuthorTitle>(); foreach (string authorId in title.AuthorIds) { authors.Add(new AuthorTitle() { AuthorId = authorId, TitleId = title.TitleId, ETag = "*" }); } AuthorTitle.Delete(authors); }
public static void Update(Title title) { CloudTable table = GetTable(_tableName); TableOperation updateTitle = TableOperation.Replace(title); table.Execute(updateTitle); List <AuthorTitle> authors = new List <AuthorTitle>(); foreach (string authorId in title.AuthorIds) { authors.Add(new AuthorTitle() { AuthorId = authorId, TitleId = title.TitleId }); } AuthorTitle.Create(authors); }
public static Title Get(string titleId) { CloudTable table = GetTable(_tableName); TableQuery <Title> getTitle = new TableQuery <Title>().Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, titleId)); Title title = table.ExecuteQuery(getTitle).FirstOrDefault(); if (title != null) { title.AuthorIds = new List <string>(); List <AuthorTitle> authors = AuthorTitle.ListAuthorsByTitle(titleId); foreach (AuthorTitle author in authors) { title.AuthorIds.Add(author.AuthorId); } } return(title); }
public static List <Title> ListTitlesByAuthor(string authorId) { List <Title> titles = new List <Title>(); List <AuthorTitle> authorTitles = AuthorTitle.ListTitlesByAuthor(authorId); if (authorTitles.Count > 0) { foreach (AuthorTitle authorTitle in authorTitles) { Title title = Get(authorTitle.TitleId); if (title != null) { titles.Add(title); } } } return(titles); }