public IActionResult NewFile(string description) { RepoMapper.Entry entry; entry = new RepoMapper.Entry() { Key = GenerateUniqueNewName(), Description = description, LastMilestone = 1, LastUpdated = DateTime.Now, IsNew = true }; mapper.InsertEntry(entry); mapper.InsertMilestone(new RepoMapper.EntryMilestone() { Created = entry.LastUpdated, Comments = "", Nr = entry.LastMilestone, EntryKey = entry.Key }); logger.LogInformation("Creating new entry" + entry.Key); return(Json(new HandlerResult() { Result = new { Name = entry.Key, Milestone = entry.LastMilestone, HTML = GetDefaultHTML(), CSS = GetDefaultCSS(), Typescript = GetDefaultTypescript() }, Success = true })); }
private void Save(RepoMapper.Entry entry, string html, string css, string typescript, string output) { var path = System.IO.Path.Combine(repoPath, entry.Key); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string filename; filename = System.IO.Path.Combine(path, "html_" + entry.LastMilestone + ".html"); System.IO.File.WriteAllText(filename, html); filename = System.IO.Path.Combine(path, "css_" + entry.LastMilestone + ".css"); System.IO.File.WriteAllText(filename, css); filename = System.IO.Path.Combine(path, "ts_" + entry.LastMilestone + ".ts"); System.IO.File.WriteAllText(filename, typescript); filename = System.IO.Path.Combine(path, "output_" + entry.LastMilestone + ".html"); System.IO.File.WriteAllText(filename, output); entry.IsNew = false; entry.LastUpdated = DateTime.Now; mapper.UpdateEntry(entry); }