public string Create(AddRepositoryInputModel repositoryInputModel, string userId) { var dbRepository = new Repository { Name = repositoryInputModel.Name, OwnerId = userId, CreatedOn = DateTime.Now, IsPublic = repositoryInputModel.RepositoryType == "Public" ? true : false, }; this.db.Repositories.Add(dbRepository); this.db.SaveChanges(); return(dbRepository?.Id); }
public HttpResponse Create(AddRepositoryInputModel input) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (string.IsNullOrEmpty(input.Name) || input.Name.Length < 3 || input.Name.Length > 10) { return(this.Error("Name should be between 3 and 10 characters.")); } this.repositoriesService.Create(input, this.GetUserId()); return(this.Redirect("/Repositories/All")); }