public void CreateProject(ProjectInfo model) { try { string contentRootPath = _hostingEnvironment.ContentRootPath; var fileData = System.IO.File.ReadAllText(contentRootPath + "/Files/ProjectDetails.json"); ManagerModel list = JsonConvert.DeserializeObject <ManagerModel>(fileData); var source = model.SourcePath.Replace(@"/", @"\\"); list.data.Add(new ProjectInfo { ProjectName = model.ProjectName, CreatedBy = model.CreatedBy, CreatedOn = DateTime.Now, ModifiedBy = model.CreatedBy, ModifiedOn = DateTime.Now, Comments = model.Comments, SourcePath = source }); CommonClass addObject = new CommonClass(); addObject.AddOrUpdateProject(source, model, list, contentRootPath); } catch (Exception e) { throw e; } finally { } }
public void Put(ProjectInfo model) { string contentRootPath = _hostingEnvironment.ContentRootPath; var fileData = System.IO.File.ReadAllText(contentRootPath + "/Files/ProjectDetails.json"); //string fileName = "ProjectDetails.json"; //string path = String.Format("{0}Files\\", AppDomain.CurrentDomain.BaseDirectory); //string fileData = System.IO.File.ReadAllText(path + fileName); ManagerModel list = JsonConvert.DeserializeObject <ManagerModel>(fileData); var source = model.SourcePath.Replace(@"/", @"\\"); var itemToUpdate = list.data.Single(r => r.ProjectName == model.ProjectName); itemToUpdate.ModifiedBy = model.ModifiedBy; itemToUpdate.ModifiedOn = DateTime.Now; itemToUpdate.SourcePath = model.SourcePath; itemToUpdate.Comments = model.Comments; CommonClass addObject = new CommonClass(); addObject.AddOrUpdateProject(source, model, list, contentRootPath); }