public IActionResult ViewPartyDetails(Int64 Refid)
        {
            ReferralAdvocateDTO lstViewReferralAgentDetails = new ReferralAdvocateDTO();
            string base64String = string.Empty;

            try
            {
                lstViewReferralAgentDetails = obReferralAdvocate.ViewPartyDetails(Refid, Con);
                if (!string.IsNullOrEmpty(lstViewReferralAgentDetails.pContactimagepath))
                {
                    using (System.Drawing.Image image = System.Drawing.Image.FromFile(lstViewReferralAgentDetails.pContactimagepath))
                    {
                        using (System.IO.MemoryStream m = new System.IO.MemoryStream())
                        {
                            image.Save(m, image.RawFormat);
                            byte[] imageBytes1 = m.ToArray();
                            base64String = Convert.ToBase64String(imageBytes1);
                            lstViewReferralAgentDetails.pPhoto = base64String;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FinstaAppException(ex.ToString());
            }
            return(Ok(lstViewReferralAgentDetails));
        }
        public IActionResult UpdatedParty(ReferralAdvocateDTO referralavocatelist)
        {
            //bool isUpdated = false;
            try
            {
                if (!string.IsNullOrEmpty(Convert.ToString(referralavocatelist.documentstorelist)))
                {
                    if (referralavocatelist.documentstorelist.Count > 0)
                    {
                        string OldFolder   = "Upload";
                        string NewFolder   = "Original";
                        string webRootPath = _hostingEnvironment.ContentRootPath;
                        string OldPath     = Path.Combine(webRootPath, OldFolder);
                        string newPath     = Path.Combine(webRootPath, NewFolder);
                        if (!Directory.Exists(newPath))
                        {
                            Directory.CreateDirectory(newPath);
                        }
                        foreach (documentstoreDTO kycDoc in referralavocatelist.documentstorelist)
                        {
                            if (!string.IsNullOrEmpty(kycDoc.pDocStorePath))
                            {
                                string OldFullPath = Path.Combine(OldPath, kycDoc.pDocStorePath);
                                string NewFullPath = Path.Combine(newPath, kycDoc.pDocStorePath);
                                kycDoc.pDocStorePath = NewFullPath;
                                if (System.IO.File.Exists(OldFullPath))
                                {
                                    System.IO.File.Move(OldFullPath, NewFullPath);
                                }
                            }
                        }
                    }
                }
                if (obReferralAdvocate.UpdatedParty(referralavocatelist, Con))
                {
                    return(Ok(true));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status304NotModified));
                }

                //isUpdated = obReferralAdvocate.UpdatedParty(referralavocatelist, Con);
            }
            catch (Exception ex)
            {
                throw new FieldAccessException(ex.ToString());
            }
            //return Ok(isUpdated);
        }
        public List <ReferralAdvocateDTO> GetAllPartyDetails(string Type, string ConnectionString)
        {
            string Query = string.Empty;
            var    lstReferalContactdetails = new List <ReferralAdvocateDTO>();

            if (!string.IsNullOrEmpty(Type))
            {
                Type = Type.ToUpper();
            }
            try
            {
                if (Type == "ALL")
                {
                    Query = "select t1.partiid,t1.contactid,contactreferenceid,(coalesce(t1.name,'')||' '||coalesce(t1.surname,''))  as advocatename,t2.businessentitycontactno,t2.businessentityemailid,contacttype from tblmstparty t1 join tblmstcontact t2 on t1.contactid=t2.contactid where t1.statusid=1 order by advocatename ;";
                }
                else
                {
                    Query = "select t1.partiid,t1.contactid,contactreferenceid,(coalesce(t.name,'')||' '||coalesce(t1.surname,''))  as advocatename,t2.businessentitycontactno,t2.businessentityemailid,contacttype from tblmstparty t1 join tblmstcontact t2 on t1.contactid=t2.contactid   where upper(t1.name) like'%" + Type + "%' or upper(t1.surname) like '%" + Type + "%' or upper(t2.businessentityemailid) like '%" + Type + "%' or upper(businessentitycontactno::text) like '%" + Type + "%' or contacttype like '%" + Type + "%' order by advocatename; ";
                }
                using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, Query))
                {
                    while (dr.Read())
                    {
                        ReferralAdvocateDTO objReferalAgentDetails = new ReferralAdvocateDTO();
                        objReferalAgentDetails.pReferralId              = Convert.ToInt64(dr["partiid"]);
                        objReferalAgentDetails.pContactId               = Convert.ToInt64(dr["contactid"]);
                        objReferalAgentDetails.pAdvocateName            = Convert.ToString(dr["advocatename"]);
                        objReferalAgentDetails.pContactReferanceId      = Convert.ToString(dr["contactreferenceid"]);
                        objReferalAgentDetails.pBusinessEntitycontactNo = Convert.ToString(dr["businessentitycontactno"]);
                        objReferalAgentDetails.pBusinessEntityEmailId   = Convert.ToString(dr["businessentityemailid"]);
                        lstReferalContactdetails.Add(objReferalAgentDetails);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lstReferalContactdetails);
        }
        public IActionResult GetContactDetailsbyId(Int64 ContactId)
        {
            ReferralAdvocateDTO lstReferalContactDetails = new ReferralAdvocateDTO();

            try
            {
                lstReferalContactDetails = obReferralAdvocate.GetContactDetailsbyId(ContactId, Con);
                if (!string.IsNullOrEmpty(lstReferalContactDetails.pContactimagepath))
                {
                    string ThumbnailFolder       = "Upload\\";
                    string webRootPath           = _hostingEnvironment.ContentRootPath;
                    string ThumabnailsFolderpath = Path.Combine(webRootPath, ThumbnailFolder);
                    string ThumbnailFullPath     = Path.Combine(ThumabnailsFolderpath, Convert.ToString(lstReferalContactDetails.pContactimagepath));
                    lstReferalContactDetails.pContactimagepath = ThumbnailFullPath;
                }
            }
            catch (Exception ex)
            {
                throw new FinstaAppException(ex.ToString());
            }
            return(Ok(lstReferalContactDetails));
        }