public HttpResponse Create(CommitCreateFormModel model)
        {
            var errors = this.commitsService.AddCommit(model, this.User.Id);

            if (errors.Count > 0)
            {
                return(this.Error(errors));
            }

            return(this.Redirect("/Repositories/All"));
        }
Beispiel #2
0
        public ICollection <string> AddCommit(CommitCreateFormModel model, string userId)
        {
            var errors = new List <string>();

            if (model.Description.Length < 5)
            {
                errors.Add("Desciprtion should be with more than 5 symbols");
                return(errors);
            }

            var commit = new Commit
            {
                Description  = model.Description,
                RepositoryId = model.Id,
                CreatorId    = userId,
                CreatedOn    = DateTime.UtcNow,
            };

            this.dbContext.Commits.Add(commit);
            this.dbContext.SaveChanges();

            return(errors);
        }