public async Task <IActionResult> GetShareConfigurationReferralDetails(string ShareName, string ShareCode) { ShareconfigReferralDTO ShareconfigReferralDTO = new ShareconfigReferralDTO(); try { ShareconfigReferralDTO = await ObjShareConfig.GetShareConfigReferralDetails(ShareName, ShareCode, Con); return(ShareconfigReferralDTO != null?Ok(ShareconfigReferralDTO) : (IActionResult)StatusCode(StatusCodes.Status204NoContent)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); throw; } }
public IActionResult SaveShareConfigurationReferralDeatils([FromBody] ShareconfigReferralDTO ShareconfigReferralDTO) { try { if (ObjShareConfig.SaveShareConfigReferral(ShareconfigReferralDTO, Con)) { return(Ok(true)); } else { return(StatusCode(StatusCodes.Status304NotModified)); } } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); throw; } }
public async Task <ShareconfigReferralDTO> GetShareConfigReferralDetails(string ShareName, string ShareCode, string ConnectionString) { ShareconfigReferralDTO ShareconfigReferralDTO = new ShareconfigReferralDTO(); await Task.Run(() => { try { using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "select shareconfigid,sharename,sharecode,statusid from tblmstshareconfig where upper(sharecode)='" + ManageQuote(ShareCode.ToUpper()) + "' and upper(sharename)='" + ManageQuote(ShareName.ToUpper()) + "' and statusid = " + Convert.ToInt32(Status.Active) + ";")) { while (dr.Read()) { ShareconfigReferralDTO.pshareconfigid = Convert.ToInt64(dr["shareconfigid"]); ShareconfigReferralDTO.psharename = Convert.ToString(dr["sharename"]); ShareconfigReferralDTO.psharecode = Convert.ToString(dr["sharecode"]); } } using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "SELECT recordid, shareconfigid, sharename, referralcommissiontype, commissionvalue,istdsapplicable, tdsaccountid, tdssection,tdspercentage,isreferralcommissionapplicable FROM tblmstshareconfigreferraldetails where shareconfigid=" + ShareconfigReferralDTO.pshareconfigid + " and upper(sharename)='" + ManageQuote(ShareconfigReferralDTO.psharename.ToUpper()) + "' and statusid = " + Convert.ToInt32(Status.Active) + ";")) { while (dr.Read()) { ShareconfigReferralDTO.precordid = Convert.ToInt64(dr["recordid"]); ShareconfigReferralDTO.pshareconfigid = Convert.ToInt64(dr["shareconfigid"]); ShareconfigReferralDTO.psharename = Convert.ToString(dr["sharename"]); ShareconfigReferralDTO.preferralcommissiontype = Convert.ToString(dr["referralcommissiontype"]); ShareconfigReferralDTO.pcommissionValue = Convert.ToDecimal(dr["commissionvalue"]); ShareconfigReferralDTO.pistdsapplicable = Convert.ToBoolean(dr["istdsapplicable"]); ShareconfigReferralDTO.ptdsaccountid = Convert.ToString(dr["tdsaccountid"]); ShareconfigReferralDTO.ptdssection = Convert.ToString(dr["tdssection"]); ShareconfigReferralDTO.ptdspercentage = Convert.ToInt64(dr["tdspercentage"]); ShareconfigReferralDTO.pisreferralcommissionapplicable = Convert.ToBoolean(dr["isreferralcommissionapplicable"]); } } } catch (Exception) { throw; } }); return(ShareconfigReferralDTO); }
public bool SaveShareConfigReferral(ShareconfigReferralDTO ShareconfigReferralDTO, string ConnectionString) { bool Issaved = false; StringBuilder SbInsert = new StringBuilder(); try { con = new NpgsqlConnection(ConnectionString); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); if (ShareconfigReferralDTO != null) { if (string.IsNullOrEmpty(ShareconfigReferralDTO.preferralcommissiontype)) { ShareconfigReferralDTO.preferralcommissiontype = ""; } if (string.IsNullOrEmpty(ShareconfigReferralDTO.ptdsaccountid)) { ShareconfigReferralDTO.ptdsaccountid = ""; } if (string.IsNullOrEmpty(ShareconfigReferralDTO.ptdssection)) { ShareconfigReferralDTO.ptdssection = ""; } if (string.IsNullOrEmpty(ShareconfigReferralDTO.precordid.ToString()) || ShareconfigReferralDTO.precordid == 0) { SbInsert.Append("INSERT INTO tblmstshareconfigreferraldetails(shareconfigid, sharename, referralcommissiontype, commissionvalue, istdsapplicable, tdsaccountid, tdssection, tdspercentage, statusid,createdby, createddate,isreferralcommissionapplicable) VALUES (" + ShareconfigReferralDTO.pshareconfigid + ",'" + ManageQuote(ShareconfigReferralDTO.psharename) + "','" + ManageQuote(ShareconfigReferralDTO.preferralcommissiontype) + "'," + Convert.ToDecimal(ShareconfigReferralDTO.pcommissionValue) + "," + ShareconfigReferralDTO.pistdsapplicable + ",'" + ManageQuote(ShareconfigReferralDTO.ptdsaccountid) + "','" + ManageQuote(ShareconfigReferralDTO.ptdssection) + "'," + ShareconfigReferralDTO.ptdspercentage + "," + Convert.ToInt32(Status.Active) + "," + ShareconfigReferralDTO.pCreatedby + ",current_timestamp," + ShareconfigReferralDTO.pisreferralcommissionapplicable + ");"); } else { SbInsert.Append("update tblmstshareconfigreferraldetails set shareconfigid=" + ShareconfigReferralDTO.pshareconfigid + ", sharename='" + ManageQuote(ShareconfigReferralDTO.psharename) + "',isreferralcommissionapplicable=" + ShareconfigReferralDTO.pisreferralcommissionapplicable + ", referralcommissiontype='" + ManageQuote(ShareconfigReferralDTO.preferralcommissiontype) + "', commissionvalue=" + Convert.ToDecimal(ShareconfigReferralDTO.pcommissionValue) + ", istdsapplicable=" + ShareconfigReferralDTO.pistdsapplicable + ", tdsaccountid='" + ManageQuote(ShareconfigReferralDTO.ptdsaccountid) + "', tdssection='" + ManageQuote(ShareconfigReferralDTO.ptdssection) + "', tdspercentage=" + ShareconfigReferralDTO.ptdspercentage + " where recordid=" + ShareconfigReferralDTO.precordid + ";"); } } if (Convert.ToString(SbInsert) != string.Empty) { NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, SbInsert.ToString()); } trans.Commit(); Issaved = true; } catch (Exception) { trans.Rollback(); throw; } finally { if (con.State == ConnectionState.Open) { con.Dispose(); con.Close(); con.ClearPool(); trans.Dispose(); } } return(Issaved); }