Exemple #1
0
        public bool DeleteCustomer(Customer aCustomer)
        {
            try
            {
                var bookingList = GetBookingList().ToList();
                if (bookingList != null)
                {
                    var result = !bookingList.Any(b => b.CustomerId.Equals(aCustomer.Id));
                    if (result)
                    {
                        return Db.DeleteCustomer(aCustomer);
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return Db.DeleteCustomer(aCustomer);
                }

            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
 public bool AddCustomer(Customer customer)
 {
     try
     {
         var isExist = Db.GetCustomer().Any(v => v.Name.Equals(customer.Name));
         if (isExist)
             return false;
         else return Db.AddCustomer(customer);
     }
     catch
     {
         throw;
     }
 }
Exemple #3
0
        public bool UpdateCustomer(Guid key, Customer aCustomer)
        {
            try
            {
                return Db.UpdateCustomer(key, aCustomer);
            }
            catch (Exception)
            {

                throw;
            }
        }
Exemple #4
0
 //Delete Method in Database Class
 public bool DeleteCustomer(Customer aCustomer)
 {
     try
     {
         foreach (KeyValuePair<Guid, Customer> customer in customerList)
         {
             if (customer.Value.Equals(aCustomer))
             {
                 return customerList.Remove(customer.Key);
             }
         }
         return false;
     }
     catch
     {
         throw new VideoRentalException(new Customer() { Name = aCustomer.Name });
     }
 }