/// <summary>
        /// Creates a new Registration record
        /// </summary>
        public static int Create(RegistrationDO DO)
        {
            SqlParameter _AccessRoleID = new SqlParameter("AccessRoleID", SqlDbType.VarChar);
            SqlParameter _FirstName = new SqlParameter("FirstName", SqlDbType.VarChar);
            SqlParameter _LastName = new SqlParameter("LastName", SqlDbType.VarChar);
            SqlParameter _Title = new SqlParameter("Title", SqlDbType.VarChar);
            SqlParameter _CompanyID = new SqlParameter("CompanyID", SqlDbType.Int);
            SqlParameter _Address1 = new SqlParameter("Address1", SqlDbType.VarChar);
            SqlParameter _City = new SqlParameter("City", SqlDbType.VarChar);
            SqlParameter _StateID = new SqlParameter("StateID", SqlDbType.VarChar);
            SqlParameter _Zipcode = new SqlParameter("Zipcode", SqlDbType.VarChar);
            SqlParameter _Phone = new SqlParameter("Phone", SqlDbType.VarChar);
            SqlParameter _Email = new SqlParameter("Email", SqlDbType.VarChar);
            SqlParameter _RegistrationDescription = new SqlParameter("RegistrationDescription", SqlDbType.VarChar);
            SqlParameter _UserToken = new SqlParameter("UserToken", SqlDbType.VarChar);
            SqlParameter _TermsOfUse = new SqlParameter("TermsOfUse", SqlDbType.Bit);
            SqlParameter _ActivationDate = new SqlParameter("ActivationDate", SqlDbType.DateTime);
            SqlParameter _ExpirationDate = new SqlParameter("ExpirationDate", SqlDbType.DateTime);

            _AccessRoleID.Value = DO.AccessRoleID;
            _FirstName.Value = DO.FirstName;
            _LastName.Value = DO.LastName;
            _Title.Value = DO.Title;
            _CompanyID.Value = DO.CompanyID;
            _Address1.Value = DO.Address1;
            _City.Value = DO.City;
            _StateID.Value = DO.StateID;
            _Zipcode.Value = DO.Zipcode;
            _Phone.Value = DO.Phone;
            _Email.Value = DO.Email;
            _RegistrationDescription.Value = DO.RegistrationDescription;
            _UserToken.Value = DO.UserToken;
            _TermsOfUse.Value = DO.TermsOfUse;
            _ActivationDate.Value = DO.ActivationDate;
            _ExpirationDate.Value = DO.ExpirationDate;

            SqlParameter[] _params = new SqlParameter[] {
                _AccessRoleID,
                _FirstName,
                _LastName,
                _Title,
                _CompanyID,
                _Address1,
                _City,
                _StateID,
                _Zipcode,
                _Phone,
                _Email,
                _RegistrationDescription,
                _UserToken,
                _TermsOfUse,
                _ActivationDate,
                _ExpirationDate
            };

            return DataCommon.ExecuteScalar("[dbo].[Registration_Insert]", _params, "dbo");
        }
        public ActionResult Register()
        {
            // don't allow users to register twice
            if (RegistrationBLL.IsUserRegistered(myCoalUser.UserToken))
            {
                //myCoalUser.GetInstance().
                return RedirectToAction("RegistrationReceived");
            }

            ViewBag.Message = "Register";
            RegistrationDO reg = new RegistrationDO() { CountryCode = "1" };
            RegistrationVM model = new RegistrationVM() { Registration = reg };
            return View(model);
        }
        /// <summary>
        /// Deletes a Registration record
        /// </summary>
        public static int Delete(RegistrationDO DO)
        {
            SqlParameter _RegistrationID = new SqlParameter("RegistrationID", SqlDbType.Int);

            _RegistrationID.Value = DO.RegistrationID;

            SqlParameter[] _params = new SqlParameter[] {
                _RegistrationID
            };

            return DataCommon.ExecuteScalar("[dbo].[Registration_Delete]", _params, "dbo");
        }
        /// <summary>
        /// Selects Registration records by RegistrationUserToken
        /// </summary>
        public static RegistrationDO[] GetByRegistrationUserToken(String UserToken)
        {
            SqlParameter _UserToken = new SqlParameter("UserToken", SqlDbType.VarChar);

            _UserToken.Value = UserToken;

            SqlParameter[] _params = new SqlParameter[] {
                _UserToken
            };

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[Registration_GetByRegistrationUserToken]", _params, "dbo");

            List<RegistrationDO> objs = new List<RegistrationDO>();

            while(sr.Read())
            {
                RegistrationDO obj = new RegistrationDO();

                obj.RegistrationID = sr.GetInt32(sr.GetOrdinal("RegistrationID"));
                obj.AccessRoleID = sr.GetString(sr.GetOrdinal("AccessRoleID"));
                obj.FirstName = sr.GetString(sr.GetOrdinal("FirstName"));
                obj.LastName = sr.GetString(sr.GetOrdinal("LastName"));
                obj.Title = sr.GetString(sr.GetOrdinal("Title"));
                obj.CompanyID = sr.GetInt32(sr.GetOrdinal("CompanyID"));
                obj.Address1 = sr.GetString(sr.GetOrdinal("Address1"));
                obj.City = sr.GetString(sr.GetOrdinal("City"));
                obj.StateID = sr.GetString(sr.GetOrdinal("StateID"));
                obj.Zipcode = sr.GetString(sr.GetOrdinal("Zipcode"));
                obj.Phone = sr.GetString(sr.GetOrdinal("Phone"));
                obj.Email = sr.GetString(sr.GetOrdinal("Email"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.TermsOfUse = sr.GetBoolean(sr.GetOrdinal("TermsOfUse"));
                if (sr.IsDBNull(sr.GetOrdinal("RegistrationDescription"))) { obj.RegistrationDescription = null; } else { obj.RegistrationDescription = sr.GetString(sr.GetOrdinal("RegistrationDescription")); }
                if (sr.IsDBNull(sr.GetOrdinal("ActivationDate"))) { obj.ActivationDate = null; } else { obj.ActivationDate = sr.GetDateTime(sr.GetOrdinal("ActivationDate")); }
                if (sr.IsDBNull(sr.GetOrdinal("ExpirationDate"))) { obj.ExpirationDate = null; } else { obj.ExpirationDate = sr.GetDateTime(sr.GetOrdinal("ExpirationDate")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }