public async Task SaveOrUpdateAsync(TrackBackDto trackBack, ItemType itemType)
		{
			if (trackBack == null)
			{
				throw new ArgumentNullException("trackBack", "The trackback must contains an instance.");
			}

			if (string.IsNullOrEmpty(trackBack.Title))
			{
				throw new ArgumentException("Invalid trackback title.");
			}

			if (trackBack.Url == null)
			{
				throw new ArgumentException("Invalid trackback url.");
			}

			if (string.IsNullOrEmpty(trackBack.Name))
			{
				throw new ArgumentException("Invalid trackback name.");
			}

			if (!string.IsNullOrEmpty(trackBack.Title) && trackBack.ItemId > 0 && !string.IsNullOrEmpty(trackBack.Name) && trackBack.Url != null)
			{
				ItemDto item;
				if (itemType == ItemType.Post)
				{
					item = this.postDataService.GetPostByKey(trackBack.ItemId);
				}
				else
				{
					item = this.pageDataService.GetPageByKey(trackBack.ItemId);
				}

				if (item == null)
				{
					throw new DexterItemNotFoundException(trackBack.ItemId);
				}

				bool firstPingBack = this.trackBackDataService.IsFirstTrackbackBack(trackBack.ItemId, trackBack.Url);

				if (!firstPingBack)
				{
					throw new DuplicateTrackbackException(trackBack.ItemId, trackBack.Url, itemType);
				}

				bool isSpam = await this.IsSpam(trackBack, item);

				if (isSpam)
				{
					throw new SpamException();
				}
			}
		}
		public async Task<ActionResult> Pingback()
		{
			if (!this.BlogConfiguration.Tracking.EnablePingBackReceive)
			{
				this.Logger.Debug("PingBack Receive is disabled, returning 404.");
				throw new HttpException(404, "Page not found");
			}

			XmlDocument doc = this.RetrieveXmlDocument();
			XmlNodeList list = doc.SelectNodes("methodCall/params/param/value/string") ?? doc.SelectNodes("methodCall/params/param/value");

			if (list != null)
			{
				try
				{
					string sourceUrl = list[0].InnerText.Trim();
					string targetUrl = list[1].InnerText.Trim();

					string title = await this.ExamineSourcePage(sourceUrl);

					if (string.IsNullOrEmpty(title))
					{
						this.SendError(16, "The source URI does not exist.");
						return new EmptyResult();
					}

					this.HttpContext.Response.ContentType = "text/xml";

					Uri url = new Uri(targetUrl);

					string postUrl = url.Segments[url.Segments.Length - 1];

					TrackBackDto trackBackDto = new TrackBackDto
						                            {
							                            Url = new Uri(postUrl), 
							                            Title = title, 
						                            };

					await this.trackbackService.SaveOrUpdateAsync(trackBackDto, ItemType.Post);

					this.HttpContext.Response.Write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><response><error>0</error></response>");
					this.HttpContext.Response.End();
				}
				catch (DuplicateTrackbackException)
				{
					this.SendError(48, "The pingback has already been registered.");
				}
				catch (SpamException)
				{
					this.SendError(17, "The source URI does not contain a link to the target URI, and so cannot be used as a source.");
				}
				catch (Exception e)
				{
					this.Logger.Error("Error during saving pingback", e);
					this.SendError(0, "Ops, something wrong");
				}
			}

			this.SendError(0, "Ops, something wrong");

			return new EmptyResult();
		}
		public async Task<ActionResult> Trackback(int id, string title, string excerpt, string blog_name, string url, ItemType itemType = ItemType.Post)
		{
			if (!this.BlogConfiguration.Tracking.EnableTrackBackReceive)
			{
				this.Logger.Debug("Trackback Receive is disabled, returning 404.");
				throw new HttpException(404, "Page not found");
			}

			BlogConfigurationDto configuration = this.configurationService.GetConfiguration();

			if (!configuration.Tracking.EnableTrackBackReceive)
			{
				return this.HttpNotFound();
			}

			if (url != null)
			{
				url = url.Split(',')[0];
			}

			if (url == null)
			{
				return this.HttpNotFound();
			}

			TrackBackDto trackBackDto = new TrackBackDto
				                            {
					                            Url = new Uri(url), 
					                            Title = title, 
					                            Excerpt = excerpt
				                            };

			try
			{
				await this.trackbackService.SaveOrUpdateAsync(trackBackDto, itemType);

				this.HttpContext.Response.Write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><response><error>0</error></response>");
				this.HttpContext.Response.End();
			}
			catch (DuplicateTrackbackException)
			{
				this.HttpContext.Response.Write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><response><error>Trackback already registered</error></response>");
				this.HttpContext.Response.End();
			}
			catch (SpamException)
			{
				this.HttpContext.Response.Write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><response><error>The source page does not contain the link</error></response>");
				this.HttpContext.Response.End();
			}

			return new EmptyResult();
		}
		private async Task<bool> IsSpam(TrackBackDto trackBack, ItemDto item)
		{
			string response;
			using (HttpClient client = new HttpClient())
			{
				response = await client.GetStringAsync(trackBack.Url);
			}

			if (string.IsNullOrEmpty(response))
			{
				return false;
			}

			SiteUrl postUrl = this.urlBuilder.Post.Permalink(item);

			return !response.ToLowerInvariant().Contains(postUrl);
		}
        public void SaveTrackback(TrackBackDto trackBack, int itemId)
        {
            if (trackBack == null)
            {
                throw new ArgumentNullException("trackBack", "The trackBack must be contains a valid instance");
            }

            if (itemId < 1)
            {
                throw new ArgumentException("The Id must be greater than 0", "itemId");
            }

            Post post = this.Session
                            .Include<Post>(x => x.TrackbacksId)
                            .Load<Post>(itemId);

            if (post == null)
            {
                throw new DexterPostNotFoundException(itemId);
            }

            ItemTrackbacks trackbacks = this.Session.Load<ItemTrackbacks>(post.TrackbacksId)
                                        ?? new ItemTrackbacks
                                               {
                                                   Item = new ItemReference
                                                              {
                                                                  Id = post.Id,
                                                                  Status = post.Status,
                                                                  ItemPublishedAt = post.PublishAt
                                                              }
                                               };

            trackbacks.AddTrackback(trackBack.MapTo<Trackback>(), trackBack.Status);

            this.Session.Store(trackbacks);
            post.TrackbacksId = trackbacks.Id;

            this.Session.Store(post);
        }