public override void Delete(int id) { var list = ModelCollection.ToList(); var modelToRemove = Single(id); list.Remove(modelToRemove); _modelCollection = list; }
public override void Update(T model) { var list = ModelCollection.ToList(); if (model.IsNew) { model.Id = NewId(); list.Add(model); } else { var existing = list.FirstOrDefault( m => m.Id == model.Id); existing = model; } _modelCollection = list; }
public override void Update(T model) { if (model == null) { return; } var list = ModelCollection.ToList(); if (model.IsNew) { model.Id = NewId(); list.Add(model); } else { //trouver le model ayant le même id var existing = list.FirstOrDefault(m => m.Id == model.Id); existing = model; } _modelCollection = list; }
public override void Update(T model) { if (model == null) { return; } var list = ModelCollection.ToList(); if (model.IsNew) { model.Id = NewId(); list.Add(model); } else { // trouver le model ayant le même id // dans la liste var existing = Single(model.Id); list.Remove(existing); list.Add(model); } _modelCollection = list; }