internal bool Delete(Case Case) { var Cases = JsonConvert.DeserializeObject<List<Case>>(File.ReadAllText(filePath)); var deleted = Cases.Remove(Case); WriteData(Cases); return deleted; }
internal Case Save(Case Case) { var Cases = this.Retrieve(); var maxId = Cases.Max(c => c.CaseId); Case.CaseId = maxId + 1; Cases.Add(Case); //Update the json file WriteData(Cases); return Case; }
internal Case Save(int id, Case Case) { var Cases = this.Retrieve(); var itemIndex = Cases.FindIndex(c => c.CaseId == Case.CaseId); if (itemIndex > 0) { Cases[itemIndex] = Case; } else { return null; } //Update the json file WriteData(Cases); return Case; }