public HttpResponseMessage getAgentDetails(string UserInfoID)
        {
            AgencyBranchDAL     agentdal                 = new AgencyBranchDAL();
            Response            objResponse              = new Response();
            DataSet             dsResult                 = new DataSet();
            ExistingUserSearch  objAgentExistingDetails  = new ExistingUserSearch();
            List <ExistingUser> objAgentExistingDataList = new List <ExistingUser>();
            string jsonData = string.Empty;

            try
            {
                dsResult = agentdal.GetAgentdetailsByUserinfoID(UserInfoID);
                if (dsResult != null)
                {
                    if (dsResult.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++)
                        {
                            objAgentExistingDataList.Add(new ExistingUser
                            {
                                FirstName    = dsResult.Tables[0].Rows[i]["FirstName"].ToString(),
                                LastName     = dsResult.Tables[0].Rows[i]["LastName"].ToString(),
                                EmployeeCode = dsResult.Tables[0].Rows[i]["EmployeeCode"].ToString(),
                                UserInfoID   = dsResult.Tables[0].Rows[i]["UserInfoID"].ToString(),
                                Mobile       = dsResult.Tables[0].Rows[i]["MobileNo"].ToString(),
                                Email        = dsResult.Tables[0].Rows[i]["EmailAddress"].ToString(),
                            });
                        }
                        objAgentExistingDetails.ExistingUserList = objAgentExistingDataList;
                    }
                }
                objResponse.Success = true;
                objResponse.Data    = objAgentExistingDetails;
                return(Request.CreateResponse(HttpStatusCode.OK, objResponse));
            }
            catch (Exception ex)
            {
                #region set exception response
                string logMsg = Environment.NewLine + DateTime.Now + Environment.NewLine + "Method Name: getAgentDetailsByUserInfoID | Contoller Name: AgencyBranch Controller" + Environment.NewLine;
                logMsg += "UserInfoID:" + UserInfoID + "|" + DateTime.Now + "|" + ex.ToString() + "-" + Environment.NewLine;
                ErrorHandler.ErrorLog(logMsg);
                #endregion
                objResponse.Success = false;
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objResponse));
            }
        }
 public DataSet GetAgent(ExistingUserSearch objExistingUserSearch)
 {
     try
     {
         SqlParameter[] P = new SqlParameter[] {
             new SqlParameter("@AgencyID", String.IsNullOrEmpty(objExistingUserSearch.AgencyID)?"":(object)objExistingUserSearch.AgencyID),
             new SqlParameter("@AgencyBranchID", String.IsNullOrEmpty(objExistingUserSearch.AgencyBranchID)?"":(object)objExistingUserSearch.AgencyBranchID),
             new SqlParameter("@EmailId", String.IsNullOrEmpty(objExistingUserSearch.Email)?"":(object)objExistingUserSearch.Email),
             new SqlParameter("@UserInfoID", String.IsNullOrEmpty(objExistingUserSearch.UserInfoID)?"":(object)objExistingUserSearch.UserInfoID),
             new SqlParameter("@AgentName", String.IsNullOrEmpty(objExistingUserSearch.AgentName)?"":(object)objExistingUserSearch.AgentName),
             //  new SqlParameter("@EmailId",String.IsNullOrEmpty(objExistingUserSearch.Email)?"":(object)objExistingUserSearch.Email),
             new SqlParameter("@MobileNo", String.IsNullOrEmpty(objExistingUserSearch.MobileNo)?"":(object)objExistingUserSearch.MobileNo),
             new SqlParameter("@PageNo", objExistingUserSearch.PageNo),
             new SqlParameter("@UserCategoryID", objExistingUserSearch.UserCategoryID),
             new SqlParameter("@PageSize", objExistingUserSearch.PageSize),
         };
         DataSet dsResult = new DataSet();
         dsResult = DataLib.GetStoredProcData(DataLib.Connection.SetConnectionString, SPKeys.SPGetAgent, P);
         return(dsResult);
     }
     catch { throw; }
 }
        public HttpResponseMessage PostGetagent(ExistingUserSearch _objExistingUserSearch)
        {
            AgencyBranchDAL     objAgencyBranchDal       = new AgencyBranchDAL();
            Response            objResponse              = new Response();
            DataSet             dsResult                 = new DataSet();
            ExistingUserSearch  objAgentExistingDetails  = new ExistingUserSearch();
            List <ExistingUser> objAgentExistingDataList = new List <ExistingUser>();

            try
            {
                dsResult = objAgencyBranchDal.GetAgent(_objExistingUserSearch);

                if (dsResult != null)
                {
                    if (dsResult.Tables.Count > 0)
                    {
                        if (dsResult.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++)
                            {
                                objAgentExistingDataList.Add(new ExistingUser
                                {
                                    IncID        = common.EncodeTo64(dsResult.Tables[0].Rows[i]["UserInfoID"].ToString()),
                                    UserInfoID   = dsResult.Tables[0].Rows[i]["UserInfoID"].ToString(),
                                    FirstName    = dsResult.Tables[0].Rows[i]["FirstName"].ToString(),
                                    LastName     = dsResult.Tables[0].Rows[i]["LastName"].ToString(),
                                    EmployeeCode = dsResult.Tables[0].Rows[i]["EmployeeCode"].ToString(),
                                    Email        = dsResult.Tables[0].Rows[i]["EmailAddress"].ToString(),
                                    Inactive     = dsResult.Tables[0].Rows[i]["Inactive"].ToString(),
                                    Mobile       = dsResult.Tables[0].Rows[i]["MobileNo"].ToString(),
                                });
                            }
                            objAgentExistingDetails.ExistingUserList = objAgentExistingDataList;
                        }
                        if (dsResult.Tables[0].Rows.Count > 0)
                        {
                            objAgentExistingDetails.TotalCount = dsResult.Tables[1].Rows[0]["Column1"].ToString();
                        }
                        else
                        {
                            objAgentExistingDetails.TotalCount = "0";
                        }

                        objResponse.Data    = objAgentExistingDetails;
                        objResponse.Success = true;
                    }
                    else
                    {
                        objResponse.Data    = null;;
                        objResponse.Success = true;
                    }
                }
                else
                {
                    objResponse.Data    = null;;
                    objResponse.Success = true;
                }
                return(Request.CreateResponse(HttpStatusCode.OK, objResponse));
            }
            catch (Exception ex)
            {
                #region set exception response
                string logMsg = Environment.NewLine + DateTime.Now + Environment.NewLine + "Method Name: Getagent | Contoller Name: Agency Branch Controller" + Environment.NewLine;
                ErrorHandler.ErrorLog(logMsg);
                #endregion
                objResponse.ErrorList.Add(new Error {
                    errorCode = "EX", errorMsg = ex.Message
                });
                objResponse.Success = false;
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objResponse));
            }
        }