public MtCategory[] GetPostCategories(string postid, string username, string password)
{
ValidateUser(username, password, Config.CurrentBlog.AllowServiceAccess);
int postID = Int32.Parse(postid);
ICollection<Link> postCategories = Links.GetLinkCollectionByPostID(postID);
MtCategory[] categories = new MtCategory[postCategories.Count];
if (postCategories.Count > 0)
{
// REFACTOR: Might prefer seeing a dictionary come back straight from the provider.
// for now we'll build our own catid->catTitle lookup--we need it below bc collection
// from post is going to be null for title.
ICollection<LinkCategory> cats = Links.GetCategories(CategoryType.PostCollection, ActiveFilter.None);
Hashtable catLookup = new Hashtable(cats.Count);
foreach (LinkCategory currentCat in cats)
catLookup.Add(currentCat.Id, currentCat.Title);
int i = 0;
foreach(Link link in postCategories)
{
MtCategory _category = new MtCategory(link.CategoryID.ToString(CultureInfo.InvariantCulture), (string)catLookup[link.CategoryID]);
categories[i] = _category;
i++;
}
}
return categories;
}