public ICollection <string> ValidateCommit(CommitsCreateModel model)
        {
            var errors = new List <string>();

            if (model.Description.Length < 5)
            {
                errors.Add($"Description '{model.Description}' is not valid. It must be more than 5 characters long.");
            }

            return(errors);
        }
Esempio n. 2
0
        public HttpResponse Create(CommitsCreateModel model, string id)
        {
            var modelErrors = validator.ValidateCommit(model);

            if (modelErrors.Any())
            {
                return(Error(modelErrors));
            }

            var commit = new Commit()
            {
                Description  = model.Description,
                CreatedOn    = DateTime.UtcNow,
                RepositoryId = id,
                CreatorId    = User.Id,
            };

            this.data.Commits.Add(commit);

            this.data.SaveChanges();

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