Пример #1
0
        /// <summary>
        /// Authenticates a specified user
        /// </summary>
        /// <returns>Customer id</returns>
        public int Logon(string email, string password)
        {
            try
            {
                int customerId = 0;

                CustomerDS   customerDS   = new CustomerDS();
                CustomerDALC customerDALC = new CustomerDALC();

                customerDALC.GetCustomerByEmail(customerDS, email);

                if (customerDS.Customers.Rows.Count > 0)
                {
                    if ((string)customerDS.Customers[0].Password == password)
                    {
                        customerId = (int)customerDS.Customers[0].CustomerId;
                    }
                }

                return(customerId);
            }
            catch (Exception e)
            {
                throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCantAuthenticateCustomer"), e);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the customer info
        /// </summary>
        /// <param name="customerDS">a dataset that will be used to store the customer info</param>
        /// <param name="email">customer email</param>
        public void GetCustomerByEmail(CustomerDS customerDS, string email)
        {
            try
            {
                SqlDataReader reader = null;
                try
                {
                    reader = SqlHelper.ExecuteReader(this.ConnectionString,
                                                     CommandType.StoredProcedure,
                                                     "SelectCustomerByEmail",
                                                     new SqlParameter[] { new SqlParameter("@EmailAddress", email) });

                    SqlHelperExtension.Fill(reader, customerDS, customerDS.Customers.TableName, 0, 1);
                }
                finally
                {
                    if (reader != null)
                    {
                        ((IDisposable)reader).Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException(String.Format(ResourceManager.GetString("RES_ExceptionCantGetCustomer"), email), e);
            }
        }
Пример #3
0
        public override DataSet Clone()
        {
            CustomerDS cln = ((CustomerDS)(base.Clone()));

            cln.InitVars();
            return(cln);
        }
Пример #4
0
        /// <summary>
        /// Gets customer information
        /// </summary>
        /// <param name="logon">customer logon</param>
        public CustomerDS GetCustomerByLogon(string logon)
        {
            CustomerDS   customerDS   = new CustomerDS();
            CustomerDALC customerDALC = new CustomerDALC();

            customerDALC.GetCustomerByEmail(customerDS, logon);

            return(customerDS);
        }
Пример #5
0
        /// <summary>
        /// Creates a new task for the specified user
        /// </summary>
        public void CreateTask(Guid taskId, string logon)
        {
            try
            {
                CustomerDS   customerDS   = new CustomerDS();
                CustomerDALC customerDALC = new CustomerDALC();
                customerDALC.GetCustomerByEmail(customerDS, logon);

                int customerId = customerDS.Customers[0].CustomerId;

                CartTaskDALC cartTaskDALC = new CartTaskDALC();
                cartTaskDALC.CreateTask(taskId, customerId);
            }
            catch (Exception e)
            {
                throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCreateTask"), e);
            }
        }
Пример #6
0
        /// <summary>
        /// Gets the task related to the specified user
        /// </summary>
        public Guid GetTask(string logon)
        {
            try
            {
                CustomerDS   customerDS   = new CustomerDS();
                CustomerDALC customerDALC = new CustomerDALC();
                customerDALC.GetCustomerByEmail(customerDS, logon);

                int customerId = customerDS.Customers[0].CustomerId;

                CartTaskDALC cartTaskDALC = new CartTaskDALC();
                return(cartTaskDALC.GetTask(customerId));
            }
            catch (Exception e)
            {
                throw new ApplicationException(ResourceManager.GetString("RES_ExceptionGetTask"), e);
            }
        }