Пример #1
0
        public string Delete(int id)
        {
            try
            {
                IEnumerable <int>  listOfIds    = _salonManager.GetIds();
                List <OrderEntity> listOfOrders = (List <OrderEntity>)_orderManager.GetList();
                if (listOfOrders.Any(c => c.CustomerId == id))
                {
                    return($"Customer can't be deleted because there are orders with this customer");
                }

                if (listOfIds.Contains(id))
                {
                    _salonManager.Delete(id);
                    return($"Customer with id {id} deleted");
                }
                else
                {
                    throw new Exception($"Customer with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        public string Delete(int id)
        {
            try
            {
                IEnumerable <int> listOfIds = _orderManager.GetIds();

                if (listOfIds.Contains(id))
                {
                    _orderManager.Delete(id);
                    return($"Order with id {id} deleted");
                }
                else
                {
                    throw new Exception($"Order with id {id} doesen't found");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }