コード例 #1
0
        public override void Delete(int id)
        {
            var list          = ModelCollection.ToList();
            var modelToRemove = Single(id);

            list.Remove(modelToRemove);
            _modelCollection = list;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }