public void OpenAccount(string FirstName,String LastName,String Title,String EmailId,String Country, String DateOfBirth,String UserName,String Password,String AccountBaseCurrency,bool IsPromotionalSubcribed)
 {
     RegisterModel objRegisterModel = new RegisterModel();
     UserAccountModels objUserAccountModels = new UserAccountModels();
     objRegisterModel.FirstName = FirstName;
     objRegisterModel.LastName = LastName;
     objRegisterModel.Title = Title;
     objRegisterModel.Email = EmailId;
     objRegisterModel.Country = Country;
     objRegisterModel.DateOfBirth = DateOfBirth;
     objRegisterModel.UserName = UserName;
     objRegisterModel.Password = Password;
     objRegisterModel.AccountBaseCurrency = AccountBaseCurrency;
     objRegisterModel.IsPromotionalSubcribed = IsPromotionalSubcribed;
     objUserAccountModels.OpenAccount(objRegisterModel);
 }
Пример #2
0
 public RegisterModel OpenAccount(RegisterModel objRegisterModel)
 {
     using (SqlConnection cnn = new SqlConnection(CommonCollection.ConnectionString))
     {
         try
         {
             cnn.Open();
             using (SqlCommand cmd = new SqlCommand("OpenAccount", cnn))
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = objRegisterModel.FirstName;
                 cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = objRegisterModel.LastName;
                 cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = objRegisterModel.Title;
                 cmd.Parameters.Add("@EmailId", SqlDbType.NVarChar).Value = objRegisterModel.Email;
                 cmd.Parameters.Add("@Country", SqlDbType.NVarChar).Value = objRegisterModel.Country;
                 cmd.Parameters.AddWithValue("@DateOfBirth", objRegisterModel.DateOfBirth);
                 cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = objRegisterModel.UserName;
                 cmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = objRegisterModel.Password;
                 cmd.Parameters.Add("@AccountBaseCurrency", SqlDbType.NVarChar).Value = objRegisterModel.AccountBaseCurrency;
                 cmd.Parameters.Add("@IsPromotionalSubcribed", SqlDbType.Bit).Value = objRegisterModel.IsPromotionalSubcribed;
                 cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                 cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                 cmd.Parameters.Add("@GUID", SqlDbType.UniqueIdentifier).Value = "";
                 cmd.Parameters["@GUID"].Direction = ParameterDirection.Output;
                 cmd.ExecuteNonQuery();
                 objRegisterModel.UserId = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString());
                 if (objRegisterModel.UserId > 0)
                 {
                     MEmail.SendConfirmationEmail(objRegisterModel.Email, objRegisterModel.FirstName + " " + objRegisterModel.LastName, cmd.Parameters["@GUID"].Value.ToString());
                 }
             }
         }
         catch (Exception ex)
         {
             throw new Exception(ex.ToString(), ex);
         }
         finally
         {
             cnn.Close();
             cnn.Dispose();
             SqlConnection.ClearPool(cnn);
         }
         return objRegisterModel;
     }
 }
        public Int32 OpenAccount(string FirstName, String LastName, String Title, String EmailId, String Country, String PhoneNo, String DateOfBirth, String UserName, String Password, String AccountBaseCurrency, bool IsPromotionalSubcribed)
        {
            try
            {
                RegisterModel objRegisterModel = new RegisterModel();
                UserAccountModels objUserAccountModels = new UserAccountModels();
                objRegisterModel.FirstName = FirstName;
                objRegisterModel.LastName = LastName;
                objRegisterModel.Title = Title;
                objRegisterModel.Email = EmailId;
                objRegisterModel.Country = Country;
                objRegisterModel.PhoneNo = PhoneNo;
                objRegisterModel.DateOfBirth = DateOfBirth;
                objRegisterModel.UserName = UserName;
                objRegisterModel.Password = Password;
                objRegisterModel.AccountBaseCurrency = AccountBaseCurrency;
                objRegisterModel.IsPromotionalSubcribed = IsPromotionalSubcribed;
                objRegisterModel = objUserAccountModels.OpenAccount(objRegisterModel);

                if (objRegisterModel.UserId > 0)
                {
                    objUserAccountModels.ValidateUser(UserName, Password);
                    Session["username"] = FirstName + " " + LastName;
                    Session["user"] = objRegisterModel.UserId;
                    StockModels objStockModels = new StockModels();
                    Session["TradeBalance"] = Math.Round(Convert.ToDouble(objStockModels.GetUserAccountBalance(Convert.ToInt32(Session["user"].ToString()))), 2);
                    return 1;
                }
                else
                {
                    return -2;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }