public static async Task <bool> updateAsync(string contentRootPath, TaskOpj mod) { try { var opj = await getAsync(contentRootPath, mod.guid); if (opj == null) { return(false); } var fold = Path.Combine(contentRootPath, rootPathA); var date = DateTime.UtcNow; opj.Note = mod.Note; opj.modfiledAt = date; var file_path = Path.Combine(fold, opj.guid + ".json"); var json = JsonConvert.SerializeObject(opj, Formatting.Indented); await System.IO.File.WriteAllTextAsync(file_path, json); return(true); } catch (Exception) { return(false); } }
public static async Task <TaskOpj> createAsync(string contentRootPath, TaskOpj mod) { var fold = Path.Combine(contentRootPath, rootPathA); System.IO.Directory.CreateDirectory(fold); var date = DateTime.UtcNow; var opj = new TaskOpj(); opj.guid = Guid.NewGuid().ToString(); opj.Note = mod.Note; opj.createdAt = date; opj.modfiledAt = date; var file_path = Path.Combine(fold, opj.guid + ".json"); var json = JsonConvert.SerializeObject(opj, Formatting.Indented); await System.IO.File.WriteAllTextAsync(file_path, json); return(opj); }