Ejemplo n.º 1
0
 public void DeleteCustomer(int ID)
 {
     Models.DBObjects.Customer customerToDelete = dbContext.Customers.FirstOrDefault(x => x.CustomerID == ID);
     if (customerToDelete != null)
     {
         dbContext.Customers.DeleteOnSubmit(customerToDelete);
         dbContext.SubmitChanges();
     }
 }
Ejemplo n.º 2
0
 public void DeleteCustomer(Guid ID)
 {
     Models.DBObjects.Customer customerToDelete = booksLibraryDataContext.Customers.FirstOrDefault(x => x.IDCustomer == ID);
     if (customerToDelete != null)
     {
         booksLibraryDataContext.Customers.DeleteOnSubmit(customerToDelete);
         booksLibraryDataContext.SubmitChanges();
     }
 }
Ejemplo n.º 3
0
        public void UpdateCustomer(CustomerModel customerModel)
        {
            Models.DBObjects.Customer existingCustomer = dbContext.Customers.FirstOrDefault(x => x.CustomerID == customerModel.CustomerID);
            if (existingCustomer != null)
            {
                existingCustomer.CustomerID = customerModel.CustomerID;
                existingCustomer.FirstName  = customerModel.FirstName;
                existingCustomer.LastName   = customerModel.LastName;
                existingCustomer.Phone      = customerModel.Phone;
                existingCustomer.Email      = customerModel.Email;

                dbContext.SubmitChanges();
            }
        }
Ejemplo n.º 4
0
 public void UpdateCustomer(CustomerModel customerModel)
 {
     Models.DBObjects.Customer existingCustomer = booksLibraryDataContext.Customers.FirstOrDefault(x => x.IDCustomer == customerModel.IDCustomer);
     if (existingCustomer != null)
     {
         existingCustomer.IDCustomer          = customerModel.IDCustomer;
         existingCustomer.Name                = customerModel.Name;
         existingCustomer.EmailAddress        = customerModel.EmailAddress;
         existingCustomer.Address             = customerModel.Address;
         existingCustomer.PhoneNumber         = customerModel.PhoneNumber;
         existingCustomer.CustomerSince       = customerModel.CustomerSince;
         existingCustomer.BooksReturnedOnTime = customerModel.BooksReturnedOnTime;
         existingCustomer.MonthlyFeePayed     = customerModel.MonthlyFeePayed;
         booksLibraryDataContext.SubmitChanges();
     }
 }
Ejemplo n.º 5
0
        private Models.DBObjects.Customer MapModelToDbOject(CustomerModel customerModel)
        {
            Models.DBObjects.Customer dbCustomerModel = new Models.DBObjects.Customer();

            if (customerModel != null)
            {
                dbCustomerModel.CustomerID = customerModel.CustomerID;
                dbCustomerModel.FirstName  = customerModel.FirstName;
                dbCustomerModel.LastName   = customerModel.LastName;
                dbCustomerModel.Phone      = customerModel.Phone;
                dbCustomerModel.Email      = customerModel.Email;
                dbCustomerModel.UserID     = customerModel.UserID;
                dbCustomerModel.AddressId  = customerModel.AddressID;

                return(dbCustomerModel);
            }
            return(null);
        }
Ejemplo n.º 6
0
        private CustomerModel MapDbObjectToModel(Models.DBObjects.Customer dbCustomer)
        {
            CustomerModel customerModel = new CustomerModel();

            if (dbCustomer != null)
            {
                customerModel.CustomerID = dbCustomer.CustomerID;
                customerModel.FirstName  = dbCustomer.FirstName;
                customerModel.LastName   = dbCustomer.LastName;
                customerModel.Phone      = dbCustomer.Phone;
                customerModel.Email      = dbCustomer.Email;
                customerModel.AddressID  = dbCustomer.AddressId;

                return(customerModel);
            }

            return(null);
        }
Ejemplo n.º 7
0
        private Models.DBObjects.Customer MapModelToDbObject(CustomerModel customerModel)
        {
            Models.DBObjects.Customer dbCustomerModel = new Models.DBObjects.Customer();
            if (customerModel != null)
            {
                dbCustomerModel.IDCustomer          = customerModel.IDCustomer;
                dbCustomerModel.Name                = customerModel.Name;
                dbCustomerModel.EmailAddress        = customerModel.EmailAddress;
                dbCustomerModel.Address             = customerModel.Address;
                dbCustomerModel.PhoneNumber         = customerModel.PhoneNumber;
                dbCustomerModel.CustomerSince       = customerModel.CustomerSince;
                dbCustomerModel.BooksReturnedOnTime = customerModel.BooksReturnedOnTime;
                dbCustomerModel.MonthlyFeePayed     = customerModel.MonthlyFeePayed;

                return(dbCustomerModel);
            }
            return(null);
        }
Ejemplo n.º 8
0
        private CustomerModel MapDbObjectToModel(Models.DBObjects.Customer dbCustomer)
        {
            CustomerModel customerModel = new CustomerModel();

            if (dbCustomer != null)
            {
                customerModel.IDCustomer          = dbCustomer.IDCustomer;
                customerModel.Name                = dbCustomer.Name;
                customerModel.EmailAddress        = dbCustomer.EmailAddress;
                customerModel.Address             = dbCustomer.Address;
                customerModel.PhoneNumber         = dbCustomer.PhoneNumber;
                customerModel.CustomerSince       = dbCustomer.CustomerSince;
                customerModel.BooksReturnedOnTime = dbCustomer.BooksReturnedOnTime;
                customerModel.MonthlyFeePayed     = dbCustomer.MonthlyFeePayed;

                return(customerModel);
            }
            return(null);
        }