public HttpResponse Create(CreateCommitModel model, string id) { if (!IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (String.IsNullOrEmpty(model.Description) || model.Description.Length < 5) { return(this.Redirect("/Commits/Create")); } var userId = this.GetUserId(); this.commitsService.CreateCommit(userId, id, model.Description); return(this.Redirect("/Commits/All")); }
public HttpResponse Create(CreateCommitModel model) { if (!this.data.Repositories.Any(r => r.Id == model.Id)) { return(Error("Repository does not exist.")); } if (model.Description.Length < DescriptionMinLength) { return(Error($"Description must be atleast {DescriptionMinLength} symbols long.")); } var commit = new Commit { Description = model.Description, CreatorId = this.User.Id, RepositoryId = model.Id }; this.data.Commits.Add(commit); this.data.SaveChanges(); return(Redirect("/Commits/All")); }