示例#1
0
 public virtual ActionResult IsSiteNameAvailable(string name, string parent)
 {
     Site parentSite = null;
     if (!string.IsNullOrEmpty(parent))
     {
         parentSite = SiteHelper.Parse(parent);
     }
     var site = new Site(parentSite, name);
     if (!site.Exists())
     {
         return Json(true, JsonRequestBehavior.AllowGet);
     }
     int i = 1;
     while (site.Exists())
     {
         site = new Site(parentSite, name + i.ToString());
         i++;
     }
     return Json(string.Format("{0} is not available. Try {1}.", name, site.Name), JsonRequestBehavior.AllowGet);
 }