public async Task <List <GstDTo> > GetGstPercentages(string ConnectionString)
        {
            await Task.Run(() =>
            {
                GstList = new List <GstDTo>();
                try
                {
                    using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "select recordid, coalesce(gstpercentage,0) gstpercentage,coalesce( cgstpercentage,0)cgstpercentage,coalesce( sgstpercentage,0)sgstpercentage,coalesce( utgstpercentage,0) utgstpercentage from tblmstgsttaxpercentage where statusid=" + Convert.ToInt32(Status.Active) + " order by gstpercentage;"))
                    {
                        while (dr.Read())
                        {
                            GstDTo GstDTO = new GstDTo
                            {
                                pRecordId        = Convert.ToInt64(dr["recordid"]),
                                pgstpercentage   = Convert.ToDecimal(dr["gstpercentage"]),
                                pigstpercentage  = Convert.ToDecimal(dr["gstpercentage"]),
                                psgstpercentage  = Convert.ToDecimal(dr["cgstpercentage"]),
                                pcgstpercentage  = Convert.ToDecimal(dr["sgstpercentage"]),
                                putgstpercentage = Convert.ToDecimal(dr["utgstpercentage"])
                            };
                            GstList.Add(GstDTO);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            });

            return(GstList);
        }
        public async Task <List <GstDTo> > getStatesbyPartyid(long ppartyid, string ConnectionString, int id)
        {
            await Task.Run(() =>
            {
                statelist    = new List <GstDTo>();
                string query = "";
                try
                {
                    if (Convert.ToBoolean(NPGSqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, "select count(*) from tblmstparty t1 join  tblmstpartytaxdetails  t2 on t1.partiid =t2.partiid where isgstapplicable =true and  contactid =" + ppartyid + "; ")))
                    {
                        query = "select stateid,state,case when statecode<>branchstatcode and sgsttype='SGST' then 'IGST' else 'CGST,'||sgsttype end as gsttype from (select t1.stateid,t1.state,t1.statecode,case when isstateunionterritory=false then 'SGST' else 'UTGST' end as sgsttype,t2.statecode as branchstatcode from (select t1.statusid,t3.stateid,t3.state||'-'|| gstno state,statecode,isstateunionterritory from tblmstparty t1 join tblmstpartytaxdetails  t2 on t1.partiid=t2.partiid join tblmststate t3 on t3.state=t2.statename  where t1.contactid =" + ppartyid + ") t1,tblmstbranch t2 where t1.statusid  =" + Convert.ToInt32(Status.Active) + ")x order by state;";
                    }
                    else
                    {
                        query = "select stateid,state,case when statecode<>branchstatcode and sgsttype='SGST' then 'IGST' else 'CGST,'||sgsttype end as gsttype from (select t1.stateid,t1.state,t1.statecode,case when isstateunionterritory=false then 'SGST' else 'UTGST' end as sgsttype,t2.statecode as branchstatcode from tblmststate t1,tblmstbranch t2 where t1.statusid  =" + Convert.ToInt32(Status.Active) + ")x order by state;";
                    }
                    using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, query))
                    {
                        while (dr.Read())
                        {
                            GstDTo obGstDTo   = new GstDTo();
                            obGstDTo.pState   = dr["state"].ToString();
                            obGstDTo.pStateId = Convert.ToInt32(dr["stateid"]);
                            obGstDTo.pgsttype = Convert.ToString(dr["gsttype"]);
                            statelist.Add(obGstDTo);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            });

            return(statelist);
        }