public HttpResponse Create(CreateRepositoryViewModel model) { var checkForErrors = RepositoryService.CreateNewRepository(model, this.User.Id); if (checkForErrors.Count != 0) { return(Error(checkForErrors)); } return(Redirect("/Repositories/All")); }
public ICollection <string> ValidateRepository(CreateRepositoryViewModel model) { var errors = new List <string>(); if (model.Name.Length < RepoNameMinLength || model.Name.Length > RepoNameMaxLength) { errors.Add("Repository name is very short ot vey long."); } if (string.IsNullOrWhiteSpace(model.Name)) { errors.Add("The name is empty;"); } return(errors); }
public ICollection <string> ValidateRepositoryCreation(CreateRepositoryViewModel model) { var errors = new List <string>(); if (model.Name.Length < 3 || model.Name.Length > 10) { errors.Add($"Repository name '{model.Name}' must be between 3 and 10 characters long."); } if (model.RepositoryType != "Public" && model.RepositoryType != "Private") { errors.Add($"Repository must be either public or private. '{model.RepositoryType}' is invalid."); } return(errors); }
public async void CreateRepository() { var dialog = new CreateRepositoryViewModel() { BasePath = this.BasePath, }; if (dialog.ShowDialog() != true) { return; } if (DirectoryUtility.IsEmpty(dialog.BasePath) == false) { if (AppMessageBox.ShowQuestion("대상 폴더는 비어있지 않습니다. 비우고 저장소를 생성하시겠습니까?") == false) { return; } } this.IsProgressing = true; try { var basePath = dialog.BasePath; this.service.RepositoryModule = this.RepositoryModule; await Task.Run(() => { this.Message = "대상 폴더를 비우는 중입니다."; DirectoryUtility.Empty(basePath); this.Message = "저장소를 생성중입니다."; this.service.CreateRepository(basePath, false); }); AppMessageBox.Show("새로운 저장소를 생성했습니다."); this.BasePath = basePath; } catch (Exception e) { AppMessageBox.ShowError(e); } finally { this.Message = string.Empty; this.IsProgressing = false; } }
public HttpResponse Create(CreateRepositoryViewModel input) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (string.IsNullOrEmpty(input.Name)) { return(this.Error("Name is required.")); } if (input.Name.Length < 3 || input.Name.Length > 10) { return(this.Error("Name should be between 3 and 10.")); } this.repositoryService.Add(input); return(this.Redirect("/Repositories/All")); }
public void CreateRepository(CreateRepositoryViewModel input, string userId) { bool Public = false; if (input.repositoryType == "Public") { Public = true; } var Repository = new Repository { Name = input.Name, CreatedOn = DateTime.UtcNow, IsPublic = Public, OwnerId = userId, }; this.db.Repositories.Add(Repository); this.db.SaveChanges(); }
public void Add(CreateRepositoryViewModel repo) { bool isPb = false; if (repo.Type == "Public") { isPb = true; } var dbRepo = new Repository { Name = repo.Name, CreatedOn = DateTime.Now, IsPublic = isPb, OwnerId = user.Id }; this.db.Repositories.Add(dbRepo); this.db.SaveChanges(); }
public HttpResponse Create(CreateRepositoryViewModel input) { if (!this.IsUserSignedIn()) { return(this.Redirect("/")); } if (string.IsNullOrEmpty(input.Name) || string.IsNullOrWhiteSpace(input.Name) || input.Name.Length < 3 || input.Name.Length > 10) { return(this.Error("Name Is Required")); } if (string.IsNullOrEmpty(input.repositoryType) || string.IsNullOrWhiteSpace(input.repositoryType)) { return(this.Error("repositoryType Is Required")); } var userid = this.GetUserId(); this.repositoriesService.CreateRepository(input, userid); return(this.Redirect("/Repositories/All")); }
public ActionResult Create([Bind(Include = "")] CreateRepositoryViewModel createReposirotyViewModel) { try { // TODO: Add insert logic here if (ModelState.IsValid) { var folder = createReposirotyViewModel.CreateFolderName; // tbCreateFolderName.Text; if (string.IsNullOrEmpty(folder)) { return(View()); } string ext = Path.GetExtension(folder); if (string.IsNullOrEmpty(ext) || ext != Git.GIT_EXTENSION) { folder = Path.ChangeExtension(folder, Git.GIT_EXTENSION); } folder = folder.Replace(" ", "-"); if (Directory.Exists(folder)) { return(View()); } var gitBaseDir = ConfigurationManager.AppSettings["GitBaseFolder"]; Git.Run("init --bare " + folder, gitBaseDir); //BindData(); return(RedirectToAction("Index")); } return(View(createReposirotyViewModel)); } catch { return(View()); } }
public HttpResponse Create(CreateRepositoryViewModel model) { var modelErrors = this.validator.ValidateRepository(model); if (modelErrors.Any()) { return(Error(modelErrors)); } var repository = new Repository { Name = model.Name, IsPublic = model.RepositoryType == PublicType, OwnerId = this.User.Id }; this.context.Repositories.Add(repository); this.context.SaveChanges(); return(Redirect("/Repositories/All")); }
public HttpResponse Create(CreateRepositoryViewModel model) { var modelErrors = this.validator.ValidateRepositoryCreation(model); if (modelErrors.Any()) { return(Error(modelErrors)); } var repository = new Repository { Name = model.Name, CreatedOn = DateTime.UtcNow, IsPublic = model.RepositoryType == "Public", OwnerId = this.User.Id }; this.data.Repositories.Add(repository); this.data.SaveChanges(); return(Redirect("/Repositories/All")); }
public List <string> CreateNewRepository(CreateRepositoryViewModel model, string ownerId) { ICollection <string> modelErrors = Validator.ValidateModel(model); if (modelErrors.Count != 0) { return(modelErrors.ToList()); } var repo = new Repository { Name = model.Name, IsPublic = model.RepositoryType == "Public" ? true : false, CreatedOn = DateTime.Now, OwnerId = ownerId }; this.Data.Repositories.Add(repo); this.Data.SaveChanges(); return(modelErrors.ToList()); }