public CreateProjectResponse CreateProject(CreateProjectRequest request) { CreateProjectResponse response = new CreateProjectResponse(); LogDAL logDAL = new LogDAL(); string projectPath = ProjectBasePath + request.project.ProjectName; string result = null; logDAL.InsertLog(request.project.ToString()); logDAL.InsertLog(projectPath); try { if (!Directory.Exists(projectPath)) { result = Repository.Init(projectPath); if (!string.IsNullOrWhiteSpace(result)) { Repository repo = new Repository(projectPath); //Create README.md file File.WriteAllText(projectPath + "\\README.md", request.project.ProjectName); //Create _Db.config file File.WriteAllText(projectPath + "\\_Db.config", ProjectDomainHelper.ToFileContent(request.project)); //Git add Commands.Stage(repo, "*"); // Create the committer's signature and commit Signature author = new Signature(Properties.AuthorName, Properties.AuthorEmail, DateTime.Now); Signature committer = new Signature(Properties.CommitterName, Properties.CommitterEmail, DateTime.Now); repo.Commit("Project Initialization", author, committer); } else { response.StatusCode = StatusCodes.Status_Error; response.StatusMessage = "Unable to create project"; } } else { logDAL.InsertLog("Project already exists"); response.StatusCode = StatusCodes.Status_Error; response.StatusMessage = "Project already exists"; } } catch (Exception e) { logDAL.InsertLog(e.ToString()); } response.Result = result; return(response); }
public void TestMethod1() { ProjectDomain src = new ProjectDomain(); src.Host = "10.10.10.10"; src.Username = "******"; src.Password = "******"; src.Database = "MyDB"; string actual = ProjectDomainHelper.ToFileContent(src); Assert.AreEqual("", actual); }