public static void AddNew(Contact c) { if (c.Id != 0) { throw new ApplicationException("Customer should not have id assigned yet"); } int maxID = _contacts.Max(cust => cust.Id); c.Id = maxID + 1; _contacts.Add(c); }
public static void UpdateContact(Contact c) { Contact current = _contacts.Where(t => t.Id == c.Id).First(); if (current != null) { _contacts.Remove(current); _contacts.Add(c); } else { throw new ApplicationException("Customer " + c.Id + " does not exist"); } }