public void Save(Address address) { if (address.Id > 0) { var oldAddress = _addresses.SingleOrDefault(a => a.Id == address.Id); _addresses.Remove(oldAddress); } else { address.Id = _addresses.Max(a => a.Id) + 1; } _addresses.Add(address); }
public void Delete(Address address) { _addresses.Remove(address); }
public void Put(int id, Address address) { address.Id = id; _repository.Save(address); }