public HttpResponseMessage PostAddnewagent(NewAgentADD _objNewAgentADD) { AgencyBranchDAL objAgencyBranchDal = new AgencyBranchDAL(); Response objResponse = new Response(); try { var jsonResult = new StringBuilder(); jsonResult = objAgencyBranchDal.AddnewAgent(_objNewAgentADD); objResponse.Data = jsonResult.ToString(); if (!string.IsNullOrEmpty(jsonResult.ToString()) && jsonResult.ToString() != "-1") { objResponse.Success = true; } else { objResponse.Success = false; } return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } catch (Exception ex) { #region set exception response string logMsg = Environment.NewLine + DateTime.Now + Environment.NewLine + "Method Name: Addnewagent | Contoller Name: Agency Branch Controller" + Environment.NewLine; logMsg += "UserCategoryID:" + _objNewAgentADD.UserCategory + "|" + DateTime.Now + "|" + ex.ToString() + "-" + 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)); } }
public StringBuilder AddnewAgent(NewAgentADD objNewAgentADD) { try { SqlParameter[] P = new SqlParameter[] { new SqlParameter("@UserInfoID", objNewAgentADD.UserInfoID), new SqlParameter("@FirstName", objNewAgentADD.FirstName), new SqlParameter("@LastName", objNewAgentADD.LastName), new SqlParameter("@MobileNo", objNewAgentADD.Mobile), new SqlParameter("@EmployeeCode", objNewAgentADD.EmpCode), new SqlParameter("@UserCategoryID", objNewAgentADD.UserCategory), new SqlParameter("@EmailId", objNewAgentADD.Email), new SqlParameter("@CreatedBy", objNewAgentADD.CreatedBy), new SqlParameter("@AgencyID", objNewAgentADD.AgencyID), new SqlParameter("@AgencyBranchID", objNewAgentADD.AgencyBranchID), }; var jsonResult = new StringBuilder(); jsonResult = DataLib.JsonStringExecuteReader(DataLib.Connection.SetConnectionString, SPKeys.SPAddNewAgent, P); return(jsonResult); } catch { throw; } }