public JObject CreateAccountProducts(string sConnString, byte productId, string accountUrl, string mobileNumber) { bool success = false; decimal accountId = 0, accountProductID = 0; bool isFirstTime = false; JObject userObj; Orders.DataAccessLayer.Accounts accountsObj = new DataAccessLayer.Accounts(sConnString); //if (!success) //{ //if (_ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0) //{ responseObj = GetAccountDetailApi(accountUrl, mobileNumber); isFirstTime = true; //} //else //{ // responseObj = new JObject(new JProperty("Success", false), // new JProperty("Message", "No User details Found")); // return responseObj; //} //} if (Convert.ToBoolean(responseObj.SelectToken("Success").ToString()) == true) { AccountProducts accountProductProperties = new AccountProducts(); accountProductProperties.ProductAccountName = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("NickName").ToString(); accountProductProperties.MobileNo = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("MobileNumber").ToString(); accountProductProperties.Email = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("EmailID").ToString(); accountProductProperties.Address = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("Address").ToString(); accountProductProperties.Gstin = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("GSTIN").ToString(); accountProductProperties.Company = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("Company").ToString(); accountProductProperties.StateId = Convert.ToInt32(responseObj.SelectToken(Label.USER_DETAILS).SelectToken("StateId").ToString()); accountProductProperties.Country = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("Country").ToString(); accountProductProperties.ProductAccountId = Convert.ToInt32(responseObj.SelectToken(Label.USER_DETAILS).SelectToken("UserId").ToString()); accountProductProperties.ProductId = productId; accountProductProperties.OwnerShipEmail = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("OwnerShip").ToString();; accountProductProperties.RegisteredDate = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("RegisteredDate").ToString(); accountProductProperties.AccessToken = responseObj.SelectToken(Label.USER_DETAILS).SelectToken("AccessToken").ToString(); accountProductProperties.BillingDay = Convert.ToInt32(responseObj.SelectToken(Label.USER_DETAILS).SelectToken("BillingDay")); accountProductProperties.BillingMode = Convert.ToInt32(responseObj.SelectToken(Label.USER_DETAILS).SelectToken("BillingModeId")); Orders.DataAccessLayer.Accounts account = new Orders.DataAccessLayer.Accounts(sConnString); account.CreateAccountProduct(accountProductProperties, out accountId, out accountProductID); responseObj[Label.USER_DETAILS][Label.ACCOUNT_ID] = Convert.ToInt64(accountId); responseObj[Label.USER_DETAILS][Label.ACCOUNT_PRODUCT_ID] = Convert.ToInt64(accountProductID); } responseObj = accountsObj.GetAccountProductDetails(productId, mobileNumber, out success); responseObj.Add(new JProperty(Label.ISFIRSTTIME, isFirstTime)); return(responseObj); }
public dynamic CreateAccountProduct(AccountProducts accountProperty, out decimal accountId, out decimal accountProductID) { try { _sqlConnection = Connection; this._sqlCommand = new SqlCommand(StoredProcedure.CREATE_ACCOUNT_PRODUCT, this._sqlConnection); this._sqlCommand.Parameters.Add(ProcedureParameters.NAME, SqlDbType.NVarChar, 50).Value = accountProperty.ProductAccountName; this._sqlCommand.Parameters.Add(ProcedureParameters.PRODUCT_ID, SqlDbType.TinyInt).Value = accountProperty.ProductId; this._sqlCommand.Parameters.Add(ProcedureParameters.MODE, SqlDbType.TinyInt).Value = 1; this._sqlCommand.Parameters.Add(ProcedureParameters.MOBILE, SqlDbType.VarChar, 15).Value = accountProperty.MobileNo; this._sqlCommand.Parameters.Add(ProcedureParameters.EMAIL, SqlDbType.VarChar, 100).Value = accountProperty.Email; this._sqlCommand.Parameters.Add(ProcedureParameters.PRODUCT_USER_ID, SqlDbType.BigInt).Value = accountProperty.ProductAccountId; this._sqlCommand.Parameters.Add(ProcedureParameters.ADDRESS, SqlDbType.NVarChar, -1).Value = accountProperty.Address; this._sqlCommand.Parameters.Add(ProcedureParameters.GSTIN, SqlDbType.VarChar, 15).Value = accountProperty.Gstin; this._sqlCommand.Parameters.Add(ProcedureParameters.STATE_ID, SqlDbType.Int).Value = accountProperty.StateId; this._sqlCommand.Parameters.Add(ProcedureParameters.COMPANY, SqlDbType.VarChar, 100).Value = accountProperty.Company; this._sqlCommand.Parameters.Add(ProcedureParameters.REGISTERED_DATE, SqlDbType.DateTime).Value = accountProperty.RegisteredDate; this._sqlCommand.Parameters.Add(ProcedureParameters.COUNTRY, SqlDbType.VarChar, 50).Value = accountProperty.Country; this._sqlCommand.Parameters.Add(ProcedureParameters.ACCESS_TOKEN, SqlDbType.VarChar, 64).Value = accountProperty.AccessToken; this._sqlCommand.Parameters.Add(ProcedureParameters.BILLING_DAY, SqlDbType.Int).Value = accountProperty.BillingDay; this._sqlCommand.Parameters.Add(ProcedureParameters.BILLING_MODE_ID, SqlDbType.Int).Value = accountProperty.BillingMode; if (accountProperty.OwnerShipEmail != null) { this._sqlCommand.Parameters.Add(ProcedureParameters.OWNER_EMAIL, SqlDbType.VarChar, 100).Value = accountProperty.OwnerShipEmail; } else { this._sqlCommand.Parameters.Add(ProcedureParameters.OWNER_EMAIL, SqlDbType.VarChar, 100).Value = ""; } this.PopulateCommonOutputParameters(ref this._sqlCommand); this._sqlCommand.Parameters.Add(ProcedureParameters.ACCOUNT_ID, System.Data.SqlDbType.Decimal).Direction = System.Data.ParameterDirection.Output; this._sqlCommand.Parameters.Add(ProcedureParameters.PRODUCT_ACCOUNT_ID, System.Data.SqlDbType.Decimal).Direction = System.Data.ParameterDirection.Output; _da = new SqlDataAdapter(_sqlCommand); _ds = new DataSet(); _da.Fill(_ds); this._ds.Tables.Add(this.ConvertOutputParametersToDataTable(this._sqlCommand.Parameters)); this._helper.ParseDataSet(_ds, null); } catch (Exception e) { //Logger.Error(string.Format("Unable to fetch QuotationStatuses. {0}", e.ToString())); //throw new QuotationException(string.Format("Unable to fetch QuotationStatuses. {0}", e.Message)); } finally { } accountId = Convert.ToDecimal(_sqlCommand.Parameters[ProcedureParameters.ACCOUNT_ID].Value); accountProductID = Convert.ToDecimal(_sqlCommand.Parameters[ProcedureParameters.PRODUCT_ACCOUNT_ID].Value); return(this._helper.GetResponse()); }
public dynamic UpdateAccountProduct(AccountProducts accountProperty, int quotationId) { try { _sqlConnection = Connection; this._sqlCommand = new SqlCommand(StoredProcedure.CREATE_ACCOUNT_PRODUCT, this._sqlConnection); this._sqlCommand.Parameters.Add(ProcedureParameters.NAME, SqlDbType.NVarChar, 50).Value = accountProperty.ProductAccountName; this._sqlCommand.Parameters.Add(ProcedureParameters.PRODUCT_ID, SqlDbType.TinyInt).Value = accountProperty.ProductId; this._sqlCommand.Parameters.Add(ProcedureParameters.MODE, SqlDbType.TinyInt).Value = 2; this._sqlCommand.Parameters.Add(ProcedureParameters.MOBILE, SqlDbType.VarChar, 20).Value = accountProperty.MobileNo; this._sqlCommand.Parameters.Add(ProcedureParameters.EMAIL, SqlDbType.VarChar, 100).Value = accountProperty.Email; this._sqlCommand.Parameters.Add(ProcedureParameters.PRODUCT_USER_ID, SqlDbType.BigInt).Value = accountProperty.ProductAccountId; this._sqlCommand.Parameters.Add(ProcedureParameters.ADDRESS, SqlDbType.NVarChar, -1).Value = accountProperty.Address; this._sqlCommand.Parameters.Add(ProcedureParameters.GSTIN, SqlDbType.VarChar, 15).Value = accountProperty.Gstin; this._sqlCommand.Parameters.Add(ProcedureParameters.STATE_ID, SqlDbType.Int).Value = accountProperty.StateId; this._sqlCommand.Parameters.Add(ProcedureParameters.COMPANY, SqlDbType.VarChar, 100).Value = accountProperty.Company; this._sqlCommand.Parameters.Add(ProcedureParameters.COUNTRY, SqlDbType.VarChar, 50).Value = accountProperty.Country; this._sqlCommand.Parameters.Add(ProcedureParameters.OWNER_EMAILID, SqlDbType.Int).Value = accountProperty.OwnerShipId; this._sqlCommand.Parameters.Add(ProcedureParameters.QUOTATION_ID, SqlDbType.BigInt).Value = quotationId; this.PopulateCommonOutputParameters(ref this._sqlCommand); this._sqlCommand.Parameters.Add(ProcedureParameters.ACCOUNT_ID, System.Data.SqlDbType.Decimal).Direction = System.Data.ParameterDirection.Output; _da = new SqlDataAdapter(_sqlCommand); _ds = new DataSet(); _da.Fill(_ds); this._ds.Tables.Add(this.ConvertOutputParametersToDataTable(this._sqlCommand.Parameters)); this._helper.ParseDataSet(_ds, null); } catch (Exception e) { //Logger.Error(string.Format("Unable to fetch QuotationStatuses. {0}", e.ToString())); //throw new QuotationException(string.Format("Unable to fetch QuotationStatuses. {0}", e.Message)); } finally { } return(this._helper.GetResponse()); }