public PatientCart Add(PatientCart cart) { //to make a copy of the 'cart' before adding if (cart != null) { lock (_inlock) { cart.Id = ++PatientNumber; data.Add(cart); } } return(cart); }
public bool Delete(int id) { bool isSuccess = false; lock (_inlock) { PatientCart cart = data.Where(c => c.Id == id).First(); if (cart != null) { data.Remove(cart); isSuccess = true; } } return(isSuccess); }
public bool Update(int id, PatientCart cart) { bool isSuccess = false; if (cart != null) { lock (_inlock) { int index = data.ToList().FindIndex(c => c.Id == id); if (cart != null) { cart.Id = id; data[index] = cart; isSuccess = true; } } } return(isSuccess); }