public string AvailableUser(UserDetails userDetails)
 {
     try
     {
         objDALComponent.SetParameters("@Username", SqlDbType.VarChar, 50, userDetails.UserName);
         objDALComponent.SqlCommandText = "[AvailableUser]";
         return GetJson(objDALComponent.SelectRecord());
     }
     catch (SqlException sqlEx)
     {
         return sqlEx.Message.ToString();
     }
     catch (Exception ex)
     {
         return ex.Message.ToString();
     }
 }
 public int AddRegistration(UserDetails userDetails)
 {
     try
     {
         objDALComponent.SetParameters("@UserId", SqlDbType.Int, 4, userDetails.UserId);
         objDALComponent.SetParameters("@UserName", SqlDbType.VarChar, 100, userDetails.UserName);
         objDALComponent.SetParameters("@FirstName", SqlDbType.VarChar, 100, userDetails.FirstName);
         objDALComponent.SetParameters("@LastName", SqlDbType.VarChar, 100, userDetails.LastName);
         objDALComponent.SetParameters("@Gender", SqlDbType.Int, 4, userDetails.Gender);
         objDALComponent.SetParameters("@UserPassword", SqlDbType.VarChar, 50, userDetails.UserPassword);
         objDALComponent.SetParameters("@Email", SqlDbType.VarChar, 50, userDetails.Email);
         objDALComponent.SetParameters("@Mobile", SqlDbType.VarChar, 50, userDetails.MobilePhone);
         objDALComponent.SetParameters("@Address", SqlDbType.VarChar, 100, userDetails.Address);
         objDALComponent.SetParameters("@StreetName", SqlDbType.VarChar, 50, userDetails.StreetName);
         objDALComponent.SetParameters("@CityId", SqlDbType.Int, 4, userDetails.CityId);
         objDALComponent.SetParameters("@StateId", SqlDbType.Int, 4, userDetails.StateId);
         objDALComponent.SetParameters("@CountryId", SqlDbType.Int, 4, userDetails.CountryId);
         objDALComponent.SetParameters("@ZipCode", SqlDbType.VarChar, 50, userDetails.ZipCode);
         objDALComponent.SetParameters("@idvalue", SqlDbType.Int, true);
         objDALComponent.SqlCommandText = "CreateUser";
         int x = objDALComponent.CreateRecord();
         object y = objDALComponent.GetParameters("@idvalue");
         if (userDetails.UserId != 0)
             return userDetails.UserId;
         else
             return Int32.Parse(y.ToString());
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
 public void UpdateUserPassword(UserDetails userDetails)
 {
     try
     {
         objDALComponent.SetParameters("@userid", SqlDbType.Int, 4, userDetails.UserId);
         objDALComponent.SetParameters("@userpassword", SqlDbType.VarChar, 50, userDetails.UserPassword);
         objDALComponent.SqlCommandText = "UpdateUserPassword";
         int x = objDALComponent.UpdateRecord();
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
        public string SendMailtoUser(UserDetails userDetails)
        {
            try
            {
                string mUname = ConfigurationManager.AppSettings["mailUsername"].ToString();
                string mPwd = ConfigurationManager.AppSettings["mailPassword"].ToString();
                string mFrom = "";
                string mTo = userDetails.Email;
                string mCC = "";

                string mSubject = "YardeCart Activation mail";
                string serverPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/ActivateUser.aspx?uid=" + UtilityClass.Encrypt(userDetails.UserId.ToString()).ToString();
                string mMsg = "<html><body><form id='form1' runat='server'><div>" +
                "Dear " + userDetails.UserName + ",<br /><br />Thank you for registering at the YardeCart." +
                "Before we can activate your account one last step must be taken to complete your registration." +
                "<br /><br />Please note - you must complete this last step to become a registered member. You will only need to visit this URL once to activate your account." +
                "<br /><br />To complete your registration, please visit this URL:<br />" +
                "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                "<br /><br /><br /><br />All the best,<br />YardeCart.</div></form></body></html>";

                UtilityClass.SendMail(mUname, mPwd, mFrom, mTo, mCC, mSubject, mMsg, true);

                return "true";
            }
            catch (SystemException ex)
            {
                return ex.Message.ToString();
            }
        }
        public string SendMailForgot(UserDetails userDetails)
        {
            try
            {
                string mUname = ConfigurationManager.AppSettings["mailUsername"].ToString();
                string mPwd = ConfigurationManager.AppSettings["mailPassword"].ToString();
                string mFrom = "";
                string mTo = userDetails.Email;
                string mCC = "";

                string mSubject = "YardeCart User password mail";
                string serverPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString() + "/Login.aspx";
                string mMsg = "<html><body><form id='form1' runat='server'><div>" +
                    "Dear " + userDetails.UserName + ",<br /><br />As you request, your username and password is given below:<br><br>" +
                    "<b>UserName : "******"<br>Password : "******"</b>" +
                    "<br /><br />Now you can login with Yard E-Cart<br />" +
                    "<a href='" + serverPath + "' runat='server' >" + serverPath + "</a>" +
                    "<br /><br /><br /><br />All the best,<br />Yard E-Cart.</div></form></body></html>";

                UtilityClass.SendMail(mUname, mPwd, mFrom, mTo, mCC, mSubject, mMsg, true);

                return "true";
            }
            catch (SystemException ex)
            {
                return ex.Message.ToString();
            }
        }
 public DataTable SelectUserProfile(UserDetails userDetails)
 {
     try
     {
         objDALComponent.SetParameters("@userid", SqlDbType.Int, 4, userDetails.UserId);
         objDALComponent.SqlCommandText = "[SelectUserProfile]";
         return objDALComponent.SelectRecord();
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }