public static BeneficiaryProjLocInfo[] GetAllBeneficiaries()
        {
            ArrayList al = new ArrayList();
            int retValue = -1;
            //Generated Code for query : dbo.GetAllVendors
            using (SqlDataReader dr = ProjManagementAdmin.GetAllBeneficiaries(out retValue)) //Initialize and retrieve code for Datareader goes here
            {

                while (dr.Read())
                {
                    BeneficiaryProjLocInfo b = new BeneficiaryProjLocInfo();
                    b.BeneficiaryId = Convert.ToInt32(dr["beneficiary_id"]);
                    b.BeneficiaryName = dr["beneficiary_name"].ToString();
                    b.BeneficiaryAddress = dr["beneficiary_address"].ToString();
                    b.ProjectLocationId = Convert.ToInt32(dr["project_location_id"]);
                    b.ProjectId = Convert.ToInt32(dr["project_id"]);
                   b.ProjectName = dr["project_name"].ToString();
                    // b.ProjectCode = dr["project_code"].ToString();

                    b.LocationId = Convert.ToInt32(dr["location_id"]);
                    b.LocationName = dr["location_name"].ToString();

                    b.IsActive = Convert.ToBoolean(dr["is_active"]);
                    b.CreatedDate = Convert.ToDateTime(dr["created_date"]);
                    b.ChangedDate = Convert.ToDateTime(dr["changed_date"]);
                    b.ChangedBy = dr["changed_by"].ToString();
                    al.Add(b);
                }
                //dr.Close();
            }

            BeneficiaryProjLocInfo[] allInfo = new BeneficiaryProjLocInfo[al.Count];
            al.CopyTo(allInfo);
            return allInfo;
        }
        public static int AddNewBeneficiary(BeneficiaryProjLocInfo bene)
        {
            if (bene == null)
                throw new ArgumentNullException("bene");

            int retValue = -1;
            return ProjManagementAdmin.AddNewBeneficiary(bene, out retValue);
        }
 public static HttpResponseMessage UpdateBeneficiary(BeneficiaryProjLocInfo bene)
 {
     try
     {
         int val = BeneficiaryProjLocDal.UpdateBeneficiary(bene);
         return new HttpResponseMessage(HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         Console.WriteLine("EXCEPTION: " + ex);
         return new HttpResponseMessage(HttpStatusCode.BadRequest);
     }
 }
        public HttpResponseMessage Post(BeneficiaryProjLocInfo bene)
        {
            try
            {

                BeneficiaryProjLocBl.AddNewBeneficiary(bene);
                return new HttpResponseMessage(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
        }
 public static int AddNewBeneficiary(BeneficiaryProjLocInfo bene)
 {
     return BeneficiaryProjLocDal.AddNewBeneficiary(bene);
 }
        private static SqlParameter[] GetAddBeneficiaryParams(BeneficiaryProjLocInfo bene)
        {
            SqlParameter[] sqlParms = new SqlParameter[100];
            sqlParms = SQLHelper.GetCachedParameters(PROC_ADDNEWBENEFICIARY);
            if (sqlParms == null)
            {
                sqlParms = new SqlParameter[]
                            {
                                new SqlParameter(PARAM_RETURN, SqlDbType.Int),
                                new SqlParameter(PARAM_BENEFICIARY_NAME, SqlDbType.NVarChar, 100),
                                new SqlParameter(PARAM_BENEFICIARY_ADDRESS, SqlDbType.NVarChar, 100),
                               new SqlParameter(PARAM_BENEFICIARY_CHANGEDBY, SqlDbType.NVarChar, 50),
                               new SqlParameter(PARAM_PROJECT_ID, SqlDbType.Int),
                               new SqlParameter(PARAM_LOCATION_ID, SqlDbType.Int)

                            };

                sqlParms[0].Direction = ParameterDirection.ReturnValue;
                SQLHelper.CacheParameters(PROC_ADDNEWBENEFICIARY, sqlParms);
            }

            //Assigning values to parameter
            sqlParms[0].Value = -1;
            sqlParms[1].Value = bene.BeneficiaryName;
            sqlParms[2].Value = bene.BeneficiaryAddress;
            sqlParms[3].Value = "sanyam";
            sqlParms[4].Value = bene.ProjectId;
            sqlParms[5].Value = bene.LocationId;

            return sqlParms;
        }
 public static int UpdateBeneficiary(BeneficiaryProjLocInfo bene, out int retValue)
 {
     retValue = -1;
     SqlParameter[] parms = GetUpdateBeneficiaryParams(bene);
     return ExecuteNonQuery(PROC_UPDATEBENEFICIARY, parms, out retValue);
 }
 public static int AddNewBeneficiary(BeneficiaryProjLocInfo bene, out int retValue)
 {
     retValue = -1;
     SqlParameter[] parms = GetAddBeneficiaryParams(bene);
     return ExecuteNonQuery(PROC_ADDNEWBENEFICIARY, parms, out retValue);
 }
 public static int UpdateBeneficiary(BeneficiaryProjLocInfo bene)
 {
     int retValue = -1;
     return ProjManagementAdmin.UpdateBeneficiary(bene, out retValue);
 }
 public HttpResponseMessage Post(BeneficiaryProjLocInfo bene)
 {
     return BeneficiaryProjLocBl.UpdateBeneficiary(bene);
 }