using System.Configuration;
using LeafWeb.Core.Entities;
using Umbraco.Core.Models;
using Umbraco.Web.PublishedCache;

namespace LeafWeb.WebCms.Services
{
	public class UrlService
	{
		private readonly string _downloadUrl;
		private readonly string _verifyEmailUrl;

		public UrlService()
		{
			_downloadUrl =
				ConfigurationManager.AppSettings["LeafWebUrl"]
				+ ConfigurationManager.AppSettings["ResultsDownloadPath"];
		}

		public string GetDownloadUrl(LeafInput leafInput)
		{
			return string.Format(_downloadUrl, leafInput.UniqueToken);
		}

        public string GetVerifyEmailURl(IMember member)
        {
            var memberEmail = member.Email;
            var token = member.GetValue("VerificationToken") as string;
            var verifyEmailToken = _downloadUrl + "/verify?email={0}&token={1}";
            return string.Format(verifyEmailToken, memberEmail, token);
        }
    }
}