Beispiel #1
0
        /// <summary>
        /// Get Customers
        /// </summary>
        /// <param name="message">return message</param>
        /// <returns>List of Customers</returns>
        public static List <Customer> GetCustomers(out string message)
        {
            try
            {
                DataTable       dt;
                List <Customer> customers = new List <Customer>();

                dt = DBCustomers.GetCustomers(out message);

                // ORM =  Muutetaan datatablen rivit olioiksi
                Customer customer;

                foreach (DataRow row in dt.Rows)
                {
                    customer           = new Customer((int)row[0]);
                    customer.FirstName = row[1].ToString();
                    customer.LastName  = row[2].ToString();
                    customer.Address   = row[3].ToString();
                    customer.ZIP       = row[4].ToString();
                    customer.City      = row[5].ToString();
                    customers.Add(customer);
                }

                // Palautus
                return(customers);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Delete Customer
 /// </summary>
 /// <param name="customer">Customer to Insert</param>
 /// <param name="message">return message</param>
 /// <returns>True id succeeded else false</returns>
 public static bool DeleteCustomer(Customer customer, out string message)
 {
     try
     {
         int c = DBCustomers.DeleteCustomer(customer.Id, out message);
         return(c > 0);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Update Customer
 /// </summary>
 /// <param name="customer">Customer to Update</param>
 /// <param name="message">return message</param>
 /// <returns>Count of affected rows in database</returns>
 public static int UpdateCustomer(Customer customer, out string message)
 {
     try
     {
         int c = DBCustomers.UpdateCustomer(customer, out message);
         return(c);
     }
     catch (Exception)
     {
         throw;
     }
 }