コード例 #1
0
        public void AddRepo(AddRepoInputModel model, string id)
        {
            var repo = new Repository
            {
                CreatedOn = DateTime.Now,
                IsPublic  = model.RepositoryType == "Public" ? true : false,
                OwnerId   = id,
                Name      = model.Name
            };

            this.db.Repositories.Add(repo);
            this.db.SaveChanges();
        }
コード例 #2
0
        public HttpResponse Create(AddRepoInputModel 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 should be between 3 and 10 characters long."));
            }

            if (string.IsNullOrWhiteSpace(model.RepositoryType))
            {
                return(this.Error("RepositoryType is required ."));
            }
            var userId = this.GetUserId();

            this.repositoriesService.AddRepo(model, userId);

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