Beispiel #1
0
        public string SaveCustomer(Customer customer)
        {
            try
            {
                using (var context = new BAPOCOs())
                {
                    context.ContextOptions.LazyLoadingEnabled = false;
                    //Add the customer graph into the context

                    context.Contacts.Attach(customer);

                    context.ObjectStateManager.ChangeObjectState(customer, StateHelpers.GetEquivalentEntityState(customer.State));

                    foreach (Reservation reservation in customer.Reservations.ToList())
                    {
                        context.ObjectStateManager.ChangeObjectState(reservation, StateHelpers.GetEquivalentEntityState(reservation.State));
                    }
                    context.SaveChanges();
                    return("OK");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #2
0
 public List <CustomerNameAndID> GetCustomerPickList()
 {
     using (var context = new BAPOCOs())
     {
         return(context.CustomerNameAndIDs.OrderBy(c => c.LastName + c.FirstName).ToList());
     }
 }
Beispiel #3
0
 public List <Trip> GetUpcomingTrips()
 {
     using (BAPOCOs context = new BAPOCOs())
     {
         return(context.Trips.Include("Destination")
                .Where(t => t.StartDate > DateTime.Today).ToList());
     }
 }
Beispiel #4
0
 public List <Trip> GetUpcomingTrips()
 {
     using (var context = new BAPOCOs())
     {
         //lazyloading & ProxyCreation will create major problems during serialization
         //but in our POCOs, there is no virtual keyword and therefore we don't have to worry about thiese
         return(context.Trips.Include("Destination")
                .Where(t => t.StartDate > DateTime.Today).ToList());
     }
 }
Beispiel #5
0
 public Customer GetCustomer(int custID)
 {
     using (BAPOCOs context = new BAPOCOs())
     {
         var cust =
             from c in context.Contacts.OfType <Customer>()
             .Include("Reservations.Trip.Destination")
             where c.ContactID == custID
             select c;
         return(cust.Single());
     }
 }
Beispiel #6
0
        public Customer GetCustomer(int customerId)
        {
            using (var context = new BAPOCOs())
            {
                //lazyloading & ProxyCreation will create major problems during serialization
                //but in our POCOs, there is no virtual keyword and therefore we don't have to worry about thiese
                var cust =
                    from c in context.Contacts.OfType <Customer>()
                    .Include("Reservations.Trip.Destination")
                    where c.ContactID == customerId
                    select c;

                return(cust.Single());
            }
        }
Beispiel #7
0
 public List <CustomerNameAndID> GetCustomerPickList()
 {
     using (var context = new BAPOCOs())
     {
         try
         {
             var clist = context.CustomerNameAndIDs.OrderBy(c => c.LastName + c.FirstName).ToList();
             return(clist);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Beispiel #8
0
        public string SaveCustomer(Customer cust)
        {
            try
            {
                using (BAPOCOs context = new BAPOCOs())
                {
                    // context.ContextOptions.LazyLoadingEnabled = false;

                    context.Contacts.ApplyChanges(cust);
                    context.SaveChanges();
                    return("");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }