public void SaveRequest(RequestParam requestModel) { var allRequest = GetAllRequest()?.ToList(); var existingRequest = allRequest?.FirstOrDefault(node => node.Guid == requestModel.Guid); allRequest = allRequest ?? new List <RequestParam> { requestModel }; if (existingRequest != null) { RequestParam.CopyObjectDetails(requestModel, existingRequest); } var json = JsonConvert.SerializeObject(allRequest); File.WriteAllText(fileName, json); }