Esempio n. 1
0
        public ActionResult Credentials(string email, string password, string url)
        {
            var tumblr  = MASTERdomain.tumblrSites;
            var cryptor = new AESCrypt();

            if (tumblr == null)
            {
                tumblr = new tumblrSite()
                {
                    subdomainid = subdomainid.Value
                };
                repository.AddTumblr(tumblr);
            }

            tumblr.email    = email;
            tumblr.password = cryptor.Encrypt(password, subdomainid.Value.ToString());

            // need to extract url
            string accountname = "";
            Uri    address;

            try
            {
                if (url.IndexOf('.') == -1)
                {
                    // user only enter store name
                    url = string.Format("{0}.tumblr.com", url);
                }
                if (!url.StartsWith("http"))
                {
                    // user did not enter http
                    url = string.Format("http://{0}", url);
                }
                address = new Uri(url);
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
                return(SendJsonErrorResponse("Please enter a valid blog URL"));
            }

            if (address.Host.Split('.').Length > 2)
            {
                int index = address.Host.IndexOf(".");
                accountname = address.Host.Substring(0, index);
            }
            else
            {
                return(SendJsonErrorResponse("Please enter a valid blog URL"));
            }

            tumblr.accountname = accountname;
            repository.Save();
            return(Json("Credentials saved".ToJsonOKMessage()));
        }
Esempio n. 2
0
 public void DeleteTumblr(tumblrSite tumblr)
 {
     db.tumblrSites.DeleteOnSubmit(tumblr);
     db.SubmitChanges();
 }
Esempio n. 3
0
 public void AddTumblr(tumblrSite tumblr)
 {
     db.tumblrSites.InsertOnSubmit(tumblr);
 }