/// <summary> /// Favorite an asset. /// </summary> /// <param name="assetId">The asset to favorite</param> /// <param name="personId">The person that is executing the command</param> /// <returns></returns> public async Task AddToFavoritesAsync(string assetId, string personId) { try { var asset = await this.FetchAssetByIdAsync(assetId); // Cache aside this?! var slim = new SlimAsset(asset); var favorite = new AssetFavorite { Id = AssetFavorite.CreateId(slim.Id, personId), Asset = slim, PersonId = personId }; await this.docClient.CreateDocumentAsync(peopleCollectionUri, favorite); } catch (DocumentClientException dce) { ; //debug this } catch (Exception ex) { ; //debug this. } }
/// <summary> /// Un-Favorite an asset. /// </summary> /// <param name="assetId">The asset to un-favorite</param> /// <param name="personId">The person that is executing the command</param> /// <returns></returns> public async Task RemoveFromFavoritesAsync(string assetId, string personId) { try { var link = UriFactory.CreateDocumentUri("fs", "people", AssetFavorite.CreateId(assetId, personId)); await this.docClient.DeleteDocumentAsync(link); } catch (DocumentClientException dce) { if (dce.StatusCode == HttpStatusCode.NotFound) { //cool, already gone? return; } } catch (Exception ex) { ; //debug this } }