/// <summary>
        /// Add the Atom entry to the collection. Return its id and the actual entry that was added to the collection.
        /// If the item could not be added return null.
        /// </summary>
        /// <param name="collection">collection name</param>
        /// <param name="entry">entry to be added</param>
        /// <param name="location">URI for the added entry</param>
        /// <returns></returns>
        protected override SyndicationItem AddEntry(string collection, SyndicationItem entry, out Uri location)
        {
            var blogEntry = entry.ConvertToModelEntry();

            bool isAdded = false;

            try
            {
                blogEntry.PrepareNewEntry();
                foreach (var sCat in entry.Categories)
                {
                    // search if the category already exists.
                    var category = unitOfWork.Categories.GetById(BlogEntry.StripeDownTitle(sCat.Label));
                    if (category == null)
                    {   // create a new category
                        category = new Category()
                        {
                            Name = sCat.Label, Value = BlogEntry.StripeDownTitle(sCat.Label)
                        };
                    }

                    blogEntry.Categories.Add(category);
                }

                // TODO: add author based on logged-in user.
                var author = this.unitOfWork.People.GetByEmailHash("4cf6ef00ca33cc3f4010b8f0fdd980fe");
                blogEntry.Author = author;

                this.unitOfWork.Entries.Add(blogEntry);
                this.unitOfWork.Commit();
                isAdded = true;
            }
            catch (Exception)
            {   // TODO: Catch only specific exceptions.
                isAdded = false;
            }

            if (isAdded)    // successful add
            {
                entry = blogEntry.ConvertToSyndicationItem(this.webOperationContext.BaseUri);

                ConfigureAtomEntry(collection, entry, blogEntry.BlogEntryId.ToString(), out location);
                this.sEntry = entry;
                return(sEntry);
            }
            else
            {
                this.sEntry = null;
                location    = null;
                return(null);
            }
        }
        /// <summary>
        /// Update the Atom entry specified by the id. If none exists, return null. Return the updated Atom entry. Return null if the entry does not exist.
        /// This method must be idempotent.
        /// </summary>
        /// <param name="collection">collection name</param>
        /// <param name="id">id of the entry</param>
        /// <param name="entry">Entry to put</param>
        /// <returns></returns>
        protected override SyndicationItem PutEntry(string collection, string id, System.ServiceModel.Syndication.SyndicationItem entry)
        {
            var headers = WebOperationContext.Current.IncomingRequest.Headers;

            var originalEntry = this.unitOfWork.Entries.GetById(id);

            if (originalEntry == null)
            {
                return(null);
            }

            var newEntry = entry.ConvertToModelEntry();

            try
            {
                originalEntry.Title             = newEntry.Title;
                originalEntry.Content           = newEntry.Content;
                originalEntry.StrippedDownTitle = BlogEntry.StripeDownTitle(newEntry.Title);
                originalEntry.LastUpdateDate    = newEntry.LastUpdateDate;

                originalEntry.Categories.Clear();
                foreach (var sCat in entry.Categories)
                {
                    // search if the category already exists.
                    var category = unitOfWork.Categories.GetById(BlogEntry.StripeDownTitle(sCat.Label));
                    if (category == null)
                    {   // create a new category
                        category = new Category()
                        {
                            Name = sCat.Label, Value = BlogEntry.StripeDownTitle(sCat.Label)
                        };
                    }

                    originalEntry.Categories.Add(category);
                }

                this.unitOfWork.Commit();

                return(originalEntry.ConvertToSyndicationItem(this.webOperationContext.BaseUri));
            }
            catch (Exception ex)
            {
                // TODO: add logging
                return(null);
            }
        }