public Event AddEvent(Event model) { if (model!=null) { model.Id = _nextId++; model.Time = DateTime.Now; events.Add(model); } return model; }
/// <summary> /// 更新 /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Update(Event item) { if (item ==null) { throw new ArgumentException("item"); } int index = events.FindIndex(e => e.Id == item.Id); if (index ==-1) { return false; } events.RemoveAt(index); events.Add(item); return true; }