Beispiel #1
0
        public ICollection <string> ValidateRepository(CreateRepositoryInputModel model)
        {
            var errors = new List <string>();

            if (model.Name.Length < 3 || model.Name.Length > 10)
            {
                errors.Add($"Name '{model.Name}' is not valid. It must be between 3 and 10 characters long.");
            }

            return(errors);
        }
Beispiel #2
0
        public void CreateRepository(CreateRepositoryInputModel repositoryModel, string userId)
        {
            var repository = new Repository()
            {
                Name     = repositoryModel.Name,
                IsPublic = repositoryModel.RepositoryType == "Public" ? true : false,
                OwnerId  = userId
            };

            this.db.Repositories.Add(repository);
            this.db.SaveChanges();
        }
        public HttpResponse Create(CreateRepositoryInputModel input)
        {
            var userId = this.GetUserId();

            if (string.IsNullOrEmpty(input.name) || input.name.Length < 3 || input.name.Length > 10)
            {
                return(this.Error("Username has to be between 5 and 20 characters"));
            }

            this.service.Create(input, userId);
            return(this.Redirect("/Repositories/All"));
        }
Beispiel #4
0
        public void CreateRepository(CreateRepositoryInputModel input, string userId)
        {
            var repository = new Repository
            {
                Name      = input.Name,
                IsPublic  = input.Type == "Public",
                CreatedOn = DateTime.UtcNow,
                OwnerId   = userId,
            };

            this.db.Add(repository);
            this.db.SaveChanges();
        }
        public void Create(CreateRepositoryInputModel model)
        {
            var repository = new Repository()
            {
                Name      = model.Name,
                CreatedOn = DateTime.UtcNow,
                IsPublic  = model.RepositoryType == "Public" ? true : false,
                OwnerId   = model.OwnerId,
            };

            this.db.Repositories.Add(repository);
            this.db.SaveChanges();
        }
Beispiel #6
0
        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"));
        }
Beispiel #7
0
        public HttpResponse Create(CreateRepositoryInputModel input)
        {
            if (!IsUserSignedIn())
            {
                return(this.Redirect("/"));
            }

            if (string.IsNullOrEmpty(input.Name) || input.Name.Length < 3 || input.Name.Length > 10)
            {
                return(this.Error("Repository name should be between 3 and 10 characters long."));
            }

            var userId = this.GetUserId();

            this.repositoriesService.CreateRepository(input, userId);
            return(this.Redirect("/"));
        }
        public HttpResponse Create(CreateRepositoryInputModel repositoryModel)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrEmpty(repositoryModel.Name) || repositoryModel.Name.Length < GlobalValidations.RepositoryNameMinLength || repositoryModel.Name.Length > GlobalValidations.RepositoryNameMaxLength)
            {
                return(this.Error(GlobalErrors.invalidRepositoryName));
            }

            var userId = this.GetUserId();

            this.repositoriesService.CreateRepository(repositoryModel, userId);
            return(this.Redirect("/Repositories/All"));
        }
Beispiel #9
0
        public HttpResponse Create(CreateRepositoryInputModel input)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrWhiteSpace(input.Name) || input.Name.Length < 3 || input.Name.Length > 10)
            {
                return(this.Error("Name is required and should be between 3 and 10 character long."));
            }

            string userId = this.GetUserId();

            this.repositoriesService.CreateRepository(input.Name, input.RepositoryType, userId);

            return(this.Redirect("/Repositories/All"));
        }
        public HttpResponse Create(CreateRepositoryInputModel input)
        {
            if (!IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            var userId = this.GetUserId();

            var repoId = this.repositoryService.CreateRepo(input.Name, input.RepositoryType, userId);

            if (repoId == null)
            {
                return(Redirect("/Repositories/Create"));
            }

            return(this.Redirect("/Repositories/All"));
        }
Beispiel #11
0
        public HttpResponse Create(CreateRepositoryInputModel model)
        {
            if (!this.IsUserSignedIn())
            {
                return(this.Redirect("/Users/Login"));
            }

            if (string.IsNullOrEmpty(model.Name) || model.Name.Length < 3 || model.Name.Length > 10)
            {
                return(this.Error("Name is required and should be between 3 and 10 charecters"));
            }

            model.OwnerId = this.GetUserId();



            this.repositoriesService.Create(model);
            return(this.Redirect("/Repositories/All"));
        }
Beispiel #12
0
        public void Create(CreateRepositoryInputModel repo, string userid)
        {
            var IsPublic = false;
            var owner    = this.db.Users.FirstOrDefault(x => x.Id == userid);

            if (repo.repositoryType == "Public")
            {
                IsPublic = true;
            }
            var dbRepo = new Repository
            {
                Name      = repo.name,
                CreatedOn = DateTime.UtcNow,
                IsPublic  = IsPublic,
                Owner     = owner,
                OwnerId   = userid
            };

            this.db.Repositories.Add(dbRepo);
            this.db.SaveChanges();
        }
Beispiel #13
0
        public HttpResponse Create(CreateRepositoryInputModel model)
        {
            var modelErrors = this.validator.ValidateRepository(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.db.Repositories.Add(repository);

            this.db.SaveChanges();

            return(Redirect("/Repositories/All"));
        }