public async Task <IList <SurveyDetail> > GetSurveyDetails(string username)
        {
            string spName = "GetSurveyDetails_NewAPI";

            dbConnector         objConn          = new dbConnector();
            SqlConnection       Conn             = objConn.GetConnection;
            List <SurveyDetail> getSurveyDetails = new List <SurveyDetail>();

            Conn.Open();
            try
            {
                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@Soochnapreneur", username);
                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    getSurveyDetails.Add(new SurveyDetail
                    {
                        Id                = Convert.ToInt32(_Reader["Id"]),
                        SurveyId          = Convert.ToInt32(_Reader["SurveyId"]),
                        Question          = _Reader["Question"].ToString(),
                        InputTypes        = _Reader["InputTypes"].ToString(),
                        HasSubQuestion    = Convert.ToBoolean(_Reader["HasSubQuestion"]),
                        SectionId         = Convert.ToInt32(_Reader["SectionId"]),
                        Condition         = _Reader["Condition"].ToString(),
                        ValidationMessage = _Reader["ValidationMessage"].ToString(),
                        isMandatory       = Convert.ToBoolean(_Reader["isMandatory"]),
                        isAvailable       = Convert.ToBoolean(_Reader["isAvailable"]),
                        isSearchable      = Convert.ToBoolean(_Reader["isSearchable"]),
                        SelectValues      = _Reader["SelectValues"].ToString(),
                        LangId            = Convert.ToInt32(_Reader["LangId"]),
                        LinkQuestion      = Convert.ToInt32(_Reader["LinkQuestion"]),
                        ClientId          = _Reader["ClientId"].ToString(),
                        Size              = Convert.ToInt32(_Reader["Size"])
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(getSurveyDetails);
        }
        public async Task <IList <SoochnaPreneur> > GetSoochnaPrenuer(string state)
        {
            string spName = "GetDEFSoochnaPreneur";

            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();

            try
            {
                List <SoochnaPreneur> SoochnaPreneurs = new List <SoochnaPreneur>();

                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    Conn.Open();
                }

                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@State", state);

                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    SoochnaPreneurs.Add(new SoochnaPreneur
                    {
                        UserName  = _Reader["UserName"].ToString(),
                        Name      = _Reader["Name"].ToString(),
                        StateName = _Reader["StateName"].ToString(),
                        Mobile    = _Reader["MobileNumber"].ToString(),
                        Email     = _Reader["Email"].ToString()
                    });
                }

                return(SoochnaPreneurs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
        }
        public async Task <bool> SyncBeneficiary(IList <Beneficiary> Beneficiaries)
        {
            bool          result  = true;
            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();
            try
            {
                foreach (var Ben in Beneficiaries)
                {
                    if (Conn.State != System.Data.ConnectionState.Open)
                    {
                        Conn.Open();
                    }

                    string spName = "GetBeneficiaryById";

                    if (Conn.State != System.Data.ConnectionState.Open)
                    {
                        Conn.Open();
                    }


                    SqlCommand objCommand = new SqlCommand(spName, Conn);
                    objCommand.CommandType = CommandType.StoredProcedure;
                    objCommand.Parameters.AddWithValue("@ID", Ben.Id);


                    int count = Convert.ToInt32(await objCommand.ExecuteScalarAsync());
                    if (count > 0)
                    {
                        result = await UpdateBeneficiary(Ben);
                    }
                    else
                    {
                        result = await AddBeneficiary(Ben);
                    }
                }
            }
            catch (Exception)
            {
                result = false;
                throw;
            }
            finally
            {
            }
            return(result);
        }
        public async Task <IList <SurveyData> > GetSurveyData(string username)
        {
            string spName = "GetSurveyData_NewAPI";

            dbConnector       objConn       = new dbConnector();
            SqlConnection     Conn          = objConn.GetConnection;
            List <SurveyData> getSurveyData = new List <SurveyData>();

            Conn.Open();
            try
            {
                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@Soochnapreneur", username);
                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    getSurveyData.Add(new SurveyData
                    {
                        Id             = Convert.ToInt32(_Reader["Id"]),
                        SurveyId       = Convert.ToInt32(_Reader["SurveyId"]),
                        SurveyDataId   = _Reader["SurveyDataId"].ToString(),
                        BeneficiaryId  = Convert.ToInt32(_Reader["BeneficiaryId"]),
                        SoochnaPrenuer = _Reader["SoochnaPrenuer"].ToString(),
                        Latitude       = _Reader["Latitude"].ToString(),
                        Longitude      = _Reader["Longitude"].ToString(),
                        Timestamp      = _Reader["Timestamp"].ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(getSurveyData);
        }
        public async Task <IList <SurveyDataDetail> > GetSurveyDataDetails(string username)
        {
            string spName = "GetSurveyDataDetails_NewAPI";

            dbConnector             objConn = new dbConnector();
            SqlConnection           Conn    = objConn.GetConnection;
            List <SurveyDataDetail> getSurveyDataDetails = new List <SurveyDataDetail>();

            Conn.Open();
            try
            {
                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@Soochnapreneur", username);
                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    getSurveyDataDetails.Add(new SurveyDataDetail
                    {
                        Id                = Convert.ToInt32(_Reader["Id"]),
                        SurveyDataId      = _Reader["SurveyDataId"].ToString(),
                        SurveyDetailsId   = _Reader["SurveyDetailsId"].ToString(),
                        SurveyDetailsData = _Reader["SurveyDetailsData"].ToString(),
                        InputType         = _Reader["InputType"].ToString(),
                        SurveyId          = Convert.ToInt32(_Reader["SurveyId"]),
                        SurveyDataIdFK    = Convert.ToInt64(_Reader["SurveyDataId_FK"])
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(getSurveyDataDetails);
        }
        public async Task <IList <SurveySection> > GetSurveySections(string username)
        {
            string spName = "GetSurveySections_NewAPI";

            dbConnector          objConn           = new dbConnector();
            SqlConnection        Conn              = objConn.GetConnection;
            List <SurveySection> getSurveySections = new List <SurveySection>();

            Conn.Open();
            try
            {
                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@Soochnapreneur", username);
                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    getSurveySections.Add(new SurveySection
                    {
                        Id            = Convert.ToInt32(_Reader["Id"]),
                        SurveyId      = Convert.ToInt32(_Reader["SurveyId"]),
                        SectionHeader = _Reader["SectionHeader"].ToString(),
                        IsAvailable   = Convert.ToBoolean(_Reader["IsAvailable"]),
                        ClientId      = Convert.ToInt32(_Reader["ClientId"]),
                        SectionId     = Convert.ToInt16(_Reader["SectionId"])
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(getSurveySections);
        }
        public async Task <Sync> GetSyncStatus(string syncFunctionName, string userName)
        {
            string spName = "GetSyncStatus";

            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;
            var           sync    = new Sync();

            Conn.Open();
            try
            {
                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@SyncName", syncFunctionName);
                objCommand.Parameters.AddWithValue("@UserName", userName);
                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    sync.Id = Convert.ToInt32(_Reader["Id"]);
                    sync.SyncFunctionName = _Reader["SyncFunctionName"].ToString();
                    sync.SyncStatus       = Convert.ToBoolean(_Reader["SyncStatus"]);
                    sync.TimeStamp        = Convert.ToDateTime(_Reader["Timestamp"]);
                    sync.User             = _Reader["Users"].ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(sync);
        }
        public async Task <bool> InsertSurveyDataDetails(IList <SurveyDataDetail> surveyData)
        {
            string        spName    = "UpsertSurveyDataDetails_NewAPI";
            bool          retResult = true;
            dbConnector   objConn   = new dbConnector();
            SqlConnection Conn      = objConn.GetConnection;

            Conn.Open();
            try
            {
                foreach (var sData in surveyData)
                {
                    SqlCommand objCommand = new SqlCommand(spName, Conn);
                    objCommand.CommandType = CommandType.StoredProcedure;
                    objCommand.Parameters.AddWithValue("@Id", sData.Id);
                    objCommand.Parameters.AddWithValue("@SurveyDataId", sData.SurveyDataId);
                    objCommand.Parameters.AddWithValue("@SurveyDetailsId", sData.SurveyDetailsId);
                    objCommand.Parameters.AddWithValue("@SurveyDetailsData", sData.SurveyDetailsData);
                    objCommand.Parameters.AddWithValue("@InputType", sData.InputType);
                    objCommand.Parameters.AddWithValue("@SurveyId", sData.SurveyId);
                    objCommand.Parameters.AddWithValue("@SurveyDataId_FK", sData.SurveyDataFK);

                    await(objCommand.ExecuteNonQueryAsync());
                }
            }
            catch (Exception ex)
            {
                retResult = false;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(retResult);
        }
        public async Task <bool> InsertSurveyData(IList <SurveyData> surveyData)
        {
            string        spName    = "UpsertSurveyData_NewAPI";
            bool          retResult = true;
            dbConnector   objConn   = new dbConnector();
            SqlConnection Conn      = objConn.GetConnection;

            Conn.Open();
            try
            {
                foreach (var sData in surveyData)
                {
                    SqlCommand objCommand = new SqlCommand(spName, Conn);
                    objCommand.CommandType = CommandType.StoredProcedure;
                    objCommand.Parameters.AddWithValue("@SurveyId", sData.SurveyId);
                    objCommand.Parameters.AddWithValue("@SurveyDataId", sData.SurveyDataId);
                    objCommand.Parameters.AddWithValue("@SoochnaPrenuer", sData.SoochnaPrenuer);
                    objCommand.Parameters.AddWithValue("@BeneficiaryId", sData.BeneficiaryId);
                    objCommand.Parameters.AddWithValue("@Latitude", sData.Latitude);
                    objCommand.Parameters.AddWithValue("@Longitude", sData.Longitude);

                    await(objCommand.ExecuteNonQueryAsync());
                }
            }
            catch (Exception ex)
            {
                retResult = false;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
            return(retResult);
        }
        public async Task <int> AddBeneficiary_LCAsync(LCBeneficiary beneficiary)
        {
            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();

            int result = 0;

            try
            {
                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    Conn.Open();
                }

                SqlCommand objCommand = new SqlCommand("AddBeneficiary_LC", Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@BeneficiaryId", beneficiary.Id);
                objCommand.Parameters.AddWithValue("@FirstName", !string.IsNullOrEmpty(beneficiary.FirstName) ? beneficiary.FirstName : string.Empty);
                objCommand.Parameters.AddWithValue("@LastName", !string.IsNullOrEmpty(beneficiary.LastName) ? beneficiary.LastName : string.Empty);
                objCommand.Parameters.AddWithValue("@FathersName", !string.IsNullOrEmpty(beneficiary.FathersName) ? beneficiary.FathersName : string.Empty);
                objCommand.Parameters.AddWithValue("@DOB", Convert.ToDateTime(beneficiary.DOB));
                objCommand.Parameters.AddWithValue("@State", beneficiary.State);
                objCommand.Parameters.AddWithValue("@LCGenderCode", beneficiary.Gender);
                objCommand.Parameters.AddWithValue("@Age", beneficiary.Age);
                objCommand.Parameters.AddWithValue("@LCMaritalStatus", beneficiary.MaritalStatus);
                objCommand.Parameters.AddWithValue("@LCEmpStatus", beneficiary.EmpStatus);
                objCommand.Parameters.AddWithValue("@LCDisability", beneficiary.Disability);
                objCommand.Parameters.AddWithValue("@SoochnaPreneur", beneficiary.SoochnaPreneur);
                objCommand.Parameters.AddWithValue("@Address", beneficiary.Address);
                objCommand.Parameters.AddWithValue("@EMail", beneficiary.EMail);
                objCommand.Parameters.AddWithValue("@Phone", beneficiary.Phone);
                objCommand.Parameters.AddWithValue("@LCQualification", beneficiary.Qualification);

                if (beneficiary.DateOfRegistration != null)
                {
                    objCommand.Parameters.AddWithValue("@DateOfRegistration", beneficiary.DateOfRegistration);
                }
                else
                {
                    objCommand.Parameters.AddWithValue("@DateOfRegistration", DBNull.Value);
                }

                var response = Convert.ToInt32(await objCommand.ExecuteScalarAsync());

                return(response);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
        }
        public async Task <bool> AddBeneficiary(Beneficiary Beneficiary)
        {
            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();

            int result = 0;

            try
            {
                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    Conn.Open();
                }

                SqlCommand objCommand = new SqlCommand("AddBeneficiaryNew", Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@BeneficiaryId", Beneficiary.Id);
                objCommand.Parameters.AddWithValue("@Beneficiary ", Beneficiary.ParentId);
                objCommand.Parameters.AddWithValue("@FirstName", !string.IsNullOrEmpty(Beneficiary.FirstName) ? Beneficiary.FirstName : string.Empty);
                objCommand.Parameters.AddWithValue("@LastName", !string.IsNullOrEmpty(Beneficiary.LastName) ? Beneficiary.LastName : string.Empty);
                objCommand.Parameters.AddWithValue("@FathersName", !string.IsNullOrEmpty(Beneficiary.FathersName) ? Beneficiary.FathersName : string.Empty);
                objCommand.Parameters.AddWithValue("@HusbandsName", !string.IsNullOrEmpty(Beneficiary.HusbandsName) ? Beneficiary.HusbandsName : string.Empty);
                objCommand.Parameters.AddWithValue("@DOB", Convert.ToDateTime(Beneficiary.DOB));
                objCommand.Parameters.AddWithValue("@IDProof", Beneficiary.IDProof);
                objCommand.Parameters.AddWithValue("@IDDetails ", !string.IsNullOrEmpty(Beneficiary.IDDetails) ? Beneficiary.IDDetails : string.Empty);
                objCommand.Parameters.AddWithValue("@State", Beneficiary.State);
                objCommand.Parameters.AddWithValue("@District", Beneficiary.District);
                objCommand.Parameters.AddWithValue("@Sex", Beneficiary.Sex);
                objCommand.Parameters.AddWithValue("@Age", Beneficiary.Age);
                objCommand.Parameters.AddWithValue("@Religion", Beneficiary.Religion);
                objCommand.Parameters.AddWithValue("@Socio", Beneficiary.Socio);
                objCommand.Parameters.AddWithValue("@Occupation", Beneficiary.Occupation);
                objCommand.Parameters.AddWithValue("@MaritalStatus ", Beneficiary.MaritalStatus);
                objCommand.Parameters.AddWithValue("@Category", Beneficiary.Category);
                objCommand.Parameters.AddWithValue("@Department", Beneficiary.Department);
                objCommand.Parameters.AddWithValue("@EmpStatus", Beneficiary.EmploymentStatus);
                objCommand.Parameters.AddWithValue("@VulGroup", Beneficiary.VulGroup);
                objCommand.Parameters.AddWithValue("@AnnualIncome", Beneficiary.AnnualIncome);
                objCommand.Parameters.AddWithValue("@Disability", Beneficiary.Disabilty);
                objCommand.Parameters.AddWithValue("@SoochnaPreneur", Beneficiary.SoochnaPreneur);
                objCommand.Parameters.AddWithValue("@Photo", Beneficiary.Photo);
                objCommand.Parameters.AddWithValue("@Relationship", Beneficiary.Relationship);
                objCommand.Parameters.AddWithValue("@Sickness", Beneficiary.Sickness);
                objCommand.Parameters.AddWithValue("@Address", Beneficiary.Address);
                objCommand.Parameters.AddWithValue("@EMail", Beneficiary.EMail);
                objCommand.Parameters.AddWithValue("@Phone", Beneficiary.Phone);
                objCommand.Parameters.AddWithValue("@PercentageDisability", Beneficiary.PercentageDisablity);
                objCommand.Parameters.AddWithValue("@Qualification", Beneficiary.Qualification);
                objCommand.Parameters.AddWithValue("@Block", Beneficiary.Block);
                objCommand.Parameters.AddWithValue("@Village", Beneficiary.Village);
                objCommand.Parameters.AddWithValue("@Panchayat", Beneficiary.Panchayat);

                if (Beneficiary.DateOfRegistration != null)
                {
                    objCommand.Parameters.AddWithValue("@DateOfRegistration", Beneficiary.DateOfRegistration);
                }
                else
                {
                    objCommand.Parameters.AddWithValue("@DateOfRegistration", DBNull.Value);
                }

                result = Convert.ToInt32(await objCommand.ExecuteScalarAsync());

                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
        }
        public async Task <bool> UpdateBeneficiary(Beneficiary Ben)
        {
            bool          result  = true;
            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();
            try
            {
                //bool status = false;
                //DBParameterCollection paramCollection = new DBParameterCollection();
                string spName = "UpdateBeneficiaryNew";
                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    Conn.Open();
                }


                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@ID", Ben.Id);

                objCommand.Parameters.AddWithValue("@BeneficiaryId ", Ben.Id);
                objCommand.Parameters.AddWithValue("@Beneficiary ", Ben.ParentId);
                objCommand.Parameters.AddWithValue("@FirstName", !string.IsNullOrEmpty(Ben.FirstName) ? Ben.FirstName : string.Empty);
                objCommand.Parameters.AddWithValue("@LastName", !string.IsNullOrEmpty(Ben.LastName) ? Ben.LastName : string.Empty);
                objCommand.Parameters.AddWithValue("@FathersName", !string.IsNullOrEmpty(Ben.FathersName) ? Ben.FathersName : string.Empty);
                objCommand.Parameters.AddWithValue("@HusbandsName", !string.IsNullOrEmpty(Ben.HusbandsName) ? Ben.HusbandsName : string.Empty);
                objCommand.Parameters.AddWithValue("@DOB", Convert.ToDateTime(Ben.DOB));
                objCommand.Parameters.AddWithValue("@IDProof", Ben.IDProof);
                objCommand.Parameters.AddWithValue("@IDDetails ", !string.IsNullOrEmpty(Ben.IDDetails) ? Ben.IDDetails : string.Empty);
                objCommand.Parameters.AddWithValue("@State", Ben.State);
                objCommand.Parameters.AddWithValue("@District", Ben.District);
                objCommand.Parameters.AddWithValue("@Sex", Ben.Sex);
                objCommand.Parameters.AddWithValue("@Age", Ben.Age);
                objCommand.Parameters.AddWithValue("@Religion", Ben.Religion);
                objCommand.Parameters.AddWithValue("@Socio", Ben.Socio);
                objCommand.Parameters.AddWithValue("@Occupation", Ben.Occupation);
                objCommand.Parameters.AddWithValue("@MaritalStatus ", Ben.MaritalStatus);
                objCommand.Parameters.AddWithValue("@Category", Ben.Category);
                objCommand.Parameters.AddWithValue("@Department", Ben.Department);
                objCommand.Parameters.AddWithValue("@EmpStatus", Ben.EmploymentStatus);
                objCommand.Parameters.AddWithValue("@VulGroup", Ben.VulGroup);
                objCommand.Parameters.AddWithValue("@AnnualIncome", Ben.AnnualIncome);
                objCommand.Parameters.AddWithValue("@Disability", Ben.Disabilty);
                objCommand.Parameters.AddWithValue("@SoochnaPreneur ", Ben.SoochnaPreneur);
                objCommand.Parameters.AddWithValue("@Photo", Ben.Photo);
                objCommand.Parameters.AddWithValue("@Relationship", Ben.Relationship);
                objCommand.Parameters.AddWithValue("@Sickness", Ben.Sickness);
                objCommand.Parameters.AddWithValue("@Address", Ben.Address);
                objCommand.Parameters.AddWithValue("@EMail", Ben.EMail);
                objCommand.Parameters.AddWithValue("@Phone", Ben.Phone);
                objCommand.Parameters.AddWithValue("@PercentageDisability", Ben.PercentageDisablity);
                objCommand.Parameters.AddWithValue("@Qualification", Ben.Qualification);
                objCommand.Parameters.AddWithValue("@Block", Ben.Block);
                objCommand.Parameters.AddWithValue("@Village", Ben.Village);
                objCommand.Parameters.AddWithValue("@Panchayat", Ben.Panchayat);

                int count = Convert.ToInt32(await objCommand.ExecuteScalarAsync());

                if (count == 2)
                {
                    result = true;
                }
                else if (count == 0)
                {
                    result = true;
                }

                else
                {
                    result = false;
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }

            return(result);
        }
        public async Task <IList <Beneficiary> > ListOfBeneficiaries(string SoochnaPreneur, int Beneficiary)
        {
            string spName = "GetBeneficiariesNew";

            dbConnector   objConn = new dbConnector();
            SqlConnection Conn    = objConn.GetConnection;

            Conn.Open();

            try
            {
                List <Beneficiary> getBeneficiary = new List <Beneficiary>();

                if (Conn.State != System.Data.ConnectionState.Open)
                {
                    Conn.Open();
                }

                SqlCommand objCommand = new SqlCommand(spName, Conn);
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.Parameters.AddWithValue("@SoochnaPreneur", SoochnaPreneur);
                objCommand.Parameters.AddWithValue("@Beneficiary", Beneficiary);

                SqlDataReader _Reader = await objCommand.ExecuteReaderAsync();

                while (_Reader.Read())
                {
                    getBeneficiary.Add(new Beneficiary
                    {
                        Id           = Convert.ToInt64(_Reader["Id"]),
                        ParentId     = Beneficiary,
                        FirstName    = _Reader["FirstName"].ToString(),
                        LastName     = _Reader["LastName"].ToString(),
                        FathersName  = _Reader["FathersName"].ToString(),
                        HusbandsName = _Reader["HusbandsName"].ToString(),
                        //DateOfBirth = (_Reader["DateOfBirth"] != DBNull.Value && !_Reader["DateOfBirth"].ToString().Contains("1/1/0001")) ? _Reader["DateOfBirth"].ToString() : string.Empty,
                        DOB           = _Reader["DOB"] != DBNull.Value && _Reader["DOB"].ToString() != string.Empty ? Convert.ToDateTime(_Reader["DOB"].ToString()) : (DateTime?)null,
                        IDProof       = Convert.ToInt64(_Reader["IDProof"] != DBNull.Value ? Convert.ToInt64(_Reader["IDProof"]) : 0),
                        IDDetails     = _Reader["IDDetails"].ToString(),
                        State         = Convert.ToInt64(_Reader["State"]),
                        District      = Convert.ToInt64(_Reader["District"]),
                        EngDistrictId = _Reader["EngDistrictId"] != DBNull.Value && _Reader["EngDistrictId"] != "" ? Convert.ToInt64(_Reader["EngDistrictId"]) : 0,

                        Sex                 = Convert.ToInt16(_Reader["Sex"] != DBNull.Value ? _Reader["Sex"] : 0),
                        Age                 = Convert.ToInt16(_Reader["Age"] != DBNull.Value ? _Reader["Age"] : 0),
                        Religion            = Convert.ToInt16(_Reader["Religion"] != DBNull.Value ? _Reader["Religion"] : 0),
                        Department          = Convert.ToInt16(_Reader["Department"] != DBNull.Value ? _Reader["Department"] : 0),
                        EmploymentStatus    = Convert.ToInt16(_Reader["EmpStatus"] != DBNull.Value ? _Reader["EmpStatus"] : 0),
                        VulGroup            = Convert.ToInt16(_Reader["VulGroup"] != DBNull.Value ? _Reader["VulGroup"] : 0),
                        AnnualIncome        = Convert.ToDouble(_Reader["AnnualIncome"] != DBNull.Value ? _Reader["AnnualIncome"] : 0),
                        Disabilty           = Convert.ToInt16(_Reader["Disablity"] != DBNull.Value ? _Reader["Disablity"] : 0),
                        Photo               = _Reader["Photo"].ToString(),
                        SoochnaPreneur      = SoochnaPreneur,
                        Relationship        = Convert.ToInt16(_Reader["Relationship"] != DBNull.Value ? _Reader["Relationship"] : 0),
                        Sickness            = Convert.ToInt16(_Reader["Sickness"] != DBNull.Value ? _Reader["Sickness"] : 0),
                        Occupation          = Convert.ToInt16(_Reader["Occupation"] != DBNull.Value ? _Reader["Occupation"] : 0),
                        BeneficiaryId       = Convert.ToInt16(_Reader["Beneficiary"] != DBNull.Value ? _Reader["Beneficiary"] : 0),
                        PercentageDisablity = _Reader["PercentageDisability"] != DBNull.Value ? Convert.ToInt64(_Reader["PercentageDisability"]) : 0,
                        Address             = _Reader["Address"].ToString(),
                        EMail               = _Reader["EMail"].ToString(),
                        Phone               = _Reader["Phone"].ToString(),
                        Qualification       = _Reader["Qualification"].ToString(),
                        DateOfRegistration  = _Reader["DateOfRegistration"] != DBNull.Value && _Reader["DateOfRegistration"].ToString() != string.Empty ? Convert.ToDateTime(_Reader["DateOfRegistration"].ToString()) : (DateTime?)null,
                        Socio               = Convert.ToInt16(_Reader["Socio"] != DBNull.Value ? _Reader["Socio"] : 0),
                        MaritalStatus       = Convert.ToInt16(_Reader["MaritulStatus"] != DBNull.Value ? _Reader["MaritulStatus"] : 0),
                        Category            = Convert.ToInt16(_Reader["Category"] != DBNull.Value ? _Reader["Category"] : 0),
                        Block               = _Reader["Block"].ToString(),
                        Village             = _Reader["Village"].ToString(),
                        Panchayat           = _Reader["Panchayat"].ToString()
                    });
                }

                return(getBeneficiary);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Conn != null)
                {
                    if (Conn.State == ConnectionState.Open)
                    {
                        Conn.Close();
                        Conn.Dispose();
                    }
                }
            }
        }