public HttpResponse Create(string name, string repositoryType) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (name.Length < 3 || name.Length > 10) { return(this.Error(GlobalConstants.RepositoryNameLenghtError)); } var repository = new CreteRepositoryInputModel { Name = name, OwnerId = this.GetUserId(), IsPublic = repositoryType == "Public" }; var isCreate = this.repositoryService.CreateRepository(repository); if (!isCreate) { return(this.Error(GlobalConstants.RepositoryNameAvaivable)); } return(this.Redirect("All")); }
public bool CreateRepository(CreteRepositoryInputModel repositoryInputModel) { if (db.Repositories.Any(x => x.Name == repositoryInputModel.Name)) { return(false); } db.Repositories .Add(new Repository { Name = repositoryInputModel.Name, CreatedOn = DateTime.UtcNow, IsPublic = repositoryInputModel.IsPublic, OwnerId = repositoryInputModel.OwnerId }); db.SaveChanges(); return(true); }