Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }