/// <summary> /// Remote attribute /// </summary> /// <param name="name"></param> /// <returns></returns> public virtual ActionResult IsNameAvailable(string name) { Repository repository = new Repository(name); RepositoryPath path = new RepositoryPath(repository); if (!path.Exists()) { return(Json(true, JsonRequestBehavior.AllowGet)); } int i = 1; while (path.Exists()) { repository = new Repository(name + i.ToString()); path = new RepositoryPath(repository); } return(Json(string.Format("Duplicate name. Try {1}.", name, repository.Name), JsonRequestBehavior.AllowGet)); }
public virtual Repository Create(string repositoryName, Stream packageStream) { Repository repository = new Repository(repositoryName); RepositoryPath path = new RepositoryPath(repository); if (path.Exists()) { throw new KoobooException("The item is already exists."); } using (ZipFile zipFile = ZipFile.Read(packageStream)) { ExtractExistingFileAction action = ExtractExistingFileAction.OverwriteSilently; zipFile.ExtractAll(path.PhysicalPath, action); baseDir.UpdateFileLink(path.PhysicalPath, null, repositoryName); } return(repository); }