public HttpResponse Create(CreateRepositoryInputModel model) { if (!IsUserSignedIn()) { return(Redirect("/Users/Login")); } if (string.IsNullOrWhiteSpace(model.Name) || model.Name.Length < 3 || model.Name.Length > 10) { return(Error("Name should be between 3 and 10 characters.")); } service.Create(model.Name, model.RepositoryType, this.GetUserId()); return(Redirect("/Repositories/All")); }
public HttpResponse Create(string name, string repositoryType) { if (string.IsNullOrEmpty(name) || name.Length < 3 || name.Length > 10) { return(this.Error("Invalid name")); } bool isPublic = false; if (repositoryType == "Public") { isPublic = true; } string userId = this.GetUserId(); repositoriesService.Create(name, isPublic, userId); return(Redirect("/Repositories/All")); }
public HttpResponse Create(RepositoryInputModel repositoryInput) { if (!this.IsUserSignedIn()) { return(this.Redirect("/")); } if (repositoryInput.Name.Length < 3 || repositoryInput.Name.Length > 10 || string.IsNullOrWhiteSpace(repositoryInput.Name)) { return(this.Error("Repository name should be between 3 and 10 symbols!")); } if (string.IsNullOrWhiteSpace(repositoryInput.RepositoryType)) { return(this.Error("Repository type is required!")); } repositoriesService.Create(repositoryInput.Name, repositoryInput.RepositoryType, this.GetUserId()); return(this.Redirect("/Repositories/All")); }