public void Add(MusteriDAL musteri) { try { ParseMusteriFile(); MusteriList.Add(musteri); using (StreamWriter sw = File.CreateText(@"C:\Users\Yasin\Documents\GitHub\proje2-yetisyagauss\proje2-yetisyagauss\DeuCSC.Proje2.DAL\Data\Musteriler.txt")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(sw, MusteriList); } } catch (Exception e) { Console.WriteLine(e); } }
public void Update(MusteriDAL musteri) { try { ParseMusteriFile(); var result = MusteriList.Where(x => x.Id == musteri.Id).FirstOrDefault(); MusteriList.Remove(result); MusteriList.Add(musteri); using (StreamWriter sw = File.CreateText(@"C:\Users\Yasin\Documents\GitHub\proje2-yetisyagauss\proje2-yetisyagauss\DeuCSC.Proje2.DAL\Data\Musteriler.txt")) { sw.Flush(); JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(sw, MusteriList); } } catch (Exception e) { Console.WriteLine(e); } }