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); } }
public List <CustomerNameAndID> GetCustomerPickList() { using (var context = new BAPOCOs()) { return(context.CustomerNameAndIDs.OrderBy(c => c.LastName + c.FirstName).ToList()); } }
public List <Trip> GetUpcomingTrips() { using (BAPOCOs context = new BAPOCOs()) { return(context.Trips.Include("Destination") .Where(t => t.StartDate > DateTime.Today).ToList()); } }
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()); } }
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()); } }
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()); } }
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; } } }
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); } }