public string DeleteEmpDataBQ(string Id) { //var id = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["Id"]; string query = "delete from spEmpData where EmpId = '" + Id + "'"; try { int res = lib.ExecuteNonQuery(query); return(res.ToString()); } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public string RegEmp([FromBody] string Id, string Name, string Dob, string Gender, string Email, string Post, long MobileNo, string Image, string ImageName) { { string query = "insert into spEmpData values ('" + Id + "','" + Name + "','" + Dob + "','" + Gender + "','" + Email + "','" + Post + "','" + MobileNo + "','" + Image + "','" + ImageName + "')"; try { int res = lib.ExecuteNonQuery(query); return(res.ToString()); } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } } }
public string DeleteEmpData(string Id) { string query = "delete from spEmpData where EmpId = '" + Id + "'"; try { int res = lib.ExecuteNonQuery(query); return(res.ToString()); } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public string UpdateEmpData(string Id, string Name, string Dob, string Gender, string Email, string Post, long MobileNo, string Image, string ImageName) { string updateQuery = "Update spEmpData set Name='" + Name + "', Dob = '" + Dob + "', Gender='" + Gender + "', Email = '" + Email + "', Post='" + Post + "', MobileNo='" + MobileNo + "', Image='" + Image + "',ImageName='" + ImageName + "' where EmpId='" + Id + "'"; try { int res = lib.ExecuteNonQuery(updateQuery); return(res.ToString()); } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public string test(string Dbname, string userId) { string query = "SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'" + Dbname + "_Acm'"; try { string res = lib.ExecuteScalar(query); if (Convert.ToInt32(res) == 1) { string userqry = "SELECT count(*) FROM WebLogins WHERE DbName = '" + userId + "'"; try { string ures = lib.ExecuteScalar(userqry); if (Convert.ToInt32(ures) == 1) { token = Guid.NewGuid().ToString(); //string inserttoken = "SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'" + Dbname + "_Acm'"; //con.Open(); //SqlCommand insertcmd = new SqlCommand(inserttoken, con); //int insertres = inserttoken.ExecuteNonQuery(); return(token); } else { token = "No User Data Exist"; return(token); } } catch (Exception ex) { throw ex; } } else { token = "No User Data Exist"; return(token); } } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public List <EmpData> GetEmpById(string Id) { List <EmpData> dataList = new List <EmpData>(); try { //var eId = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["Id"]; string tblqry = "select * from spEmpData where EmpId = '" + Id + "'"; dr = lib.GetDataReader(tblqry); if (dr.HasRows) { while (dr.Read()) { dataList.Add(new EmpData { Id = dr["EmpId"].ToString(), Name = dr["Name"].ToString(), Dob = Convert.ToDateTime(dr["Dob"]).ToString("yyyy-MM-dd"), Gender = dr["Gender"].ToString(), Email = dr["Email"].ToString(), Post = dr["Post"].ToString(), MobileNo = (long)dr["MobileNo"], Image = dr["Image"].ToString(), ImageName = dr["ImageName"].ToString(), }); } return(dataList); } else { return(dataList); } } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public void Post([FromBody] EmployeeMasterModel employeeMasterBusinessEntity) { try { employeeMasterService.CreateEmployee(employeeMasterBusinessEntity); Request.CreateResponse(HttpStatusCode.OK); } catch { var message = new System.Web.Http.HttpError("OOPS !! Something went wrong . Please contract [email protected]") { { "ErrorCode", 500 } }; throw new HttpResponseException(Request.CreateErrorResponse (HttpStatusCode.InternalServerError, message)); } }
public void Post([FromBody] IList<EmployeeSurveyModel> employeeSurveyBusinessEntity) { try { employeeSurveyService.CreateEmployeeSurvey(employeeSurveyBusinessEntity); Request.CreateResponse(HttpStatusCode.OK); } catch { var message = new System.Web.Http.HttpError("OOPS !! Something went wrong . Please contract [email protected]") { { "ErrorCode", 500 } }; throw new HttpResponseException(Request.CreateErrorResponse (HttpStatusCode.InternalServerError, message)); } }
public List <EmpData> GetAllEmployees() { List <EmpData> dataList = new List <EmpData>(); try { string tblqry = "select * from spEmpData"; dr = lib.GetDataReader(tblqry); if (dr.HasRows) { while (dr.Read()) { dataList.Add(new EmpData { Id = dr["EmpId"].ToString(), Name = dr["Name"].ToString(), Dob = Convert.ToDateTime(dr["Dob"]).ToString("yyyy-MM-dd"), Gender = dr["Gender"].ToString(), Email = dr["Email"].ToString(), Post = dr["Post"].ToString(), }); } return(dataList); } else { return(dataList); } } catch (HttpResponseException ex) { throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, ex)); } catch (Exception ex) { var errorMessagError = new System.Web.Http.HttpError(ex.Message) { { "ErrorCode", HttpStatusCode.InternalServerError } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.InternalServerError, errorMessagError)); } }
public HttpResponseMessage PostData([FromBody] RequestBody requestBody) { try { if (requestBody != null && requestBody.payload != null && requestBody.payload.Count > 0) { ResponseBody responseBody = new ResponseBody(); List<Response> lstResponse = new List<Response>(); foreach(TVChannelDetails channelDetails in requestBody.payload) { if (channelDetails.drm == true && channelDetails.episodeCount > 0) { Response responseObj = new Response(); responseObj.image = channelDetails.image.showImage; responseObj.slug = channelDetails.slug; responseObj.title = channelDetails.title; lstResponse.Add(responseObj); } } responseBody.response = lstResponse; JavaScriptSerializer serializer = new JavaScriptSerializer(); return Request.CreateResponse(HttpStatusCode.OK, responseBody); } else { var error = new System.Web.Http.HttpError { { "error", "Could not decode request: JSON parsing failed" } }; //var error = new HttpError("Could not decode request: JSON parsing failed"); return Request.CreateErrorResponse(HttpStatusCode.BadRequest, error); } } catch (Exception ex) { var error = new System.Web.Http.HttpError { { "error", "Could not decode request: JSON parsing failed" } }; return Request.CreateErrorResponse(HttpStatusCode.BadRequest, error); } }
private static ODataInnerError ToODataInnerError(this HttpError httpError) { string innerErrorMessage = httpError.GetPropertyValue <string>(HttpErrorKeys.ExceptionMessageKey); if (innerErrorMessage == null) { string messageDetail = httpError.GetPropertyValue <string>(HttpErrorKeys.MessageDetailKey); if (messageDetail == null) { HttpError modelStateError = httpError.GetPropertyValue <HttpError>(HttpErrorKeys.ModelStateKey); return(modelStateError == null ? null : new ODataInnerError { Message = ConvertModelStateErrors(modelStateError) }); } else { return(new ODataInnerError() { Message = messageDetail }); } } else { ODataInnerError innerError = new ODataInnerError(); innerError.Message = innerErrorMessage; innerError.TypeName = httpError.GetPropertyValue <string>(HttpErrorKeys.ExceptionTypeKey); innerError.StackTrace = httpError.GetPropertyValue <string>(HttpErrorKeys.StackTraceKey); HttpError innerExceptionError = httpError.GetPropertyValue <HttpError>(HttpErrorKeys.InnerExceptionKey); if (innerExceptionError != null) { innerError.InnerError = innerExceptionError.ToODataInnerError(); } return(innerError); } }
public static ODataError ToODataError(this HttpError httpError) { return(HttpErrorExtensions.CreateODataError(httpError)); }
internal static HttpError AddAndReturn(this HttpError httpError, string key, object value) { httpError.Add(key, value); return(httpError); }
public HttpResponseMessage UpdateBlobDataToDB(BlobData blobData) { try { SqlConnection conn = null; SqlCommand command = null; var connectionString = string.Empty; var json = string.Empty; connectionString = ConfigurationManager.AppSettings["ConnectionString"]; conn = new SqlConnection(connectionString); command = new SqlCommand("BlobStorageIns", conn); command.CommandTimeout = 0; command.CommandType = CommandType.StoredProcedure; conn.Open(); command.Parameters.Add("@filePath", SqlDbType.VarChar, 255); command.Parameters.Add("@fileExt", SqlDbType.VarChar, 10); command.Parameters.Add("@senderNumber", SqlDbType.VarChar, 30); command.Parameters.Add("@senderLat", SqlDbType.Decimal); command.Parameters.Add("@senderLong", SqlDbType.Decimal); command.Parameters.Add("@adminArea", SqlDbType.VarChar, 50); command.Parameters.Add("@countryCode", SqlDbType.VarChar, 50); command.Parameters.Add("@countryName", SqlDbType.VarChar, 50); command.Parameters.Add("@featureName", SqlDbType.VarChar, 50); command.Parameters.Add("@locality", SqlDbType.VarChar, 50); command.Parameters.Add("@postalCode", SqlDbType.VarChar, 50); command.Parameters.Add("@subAdminArea", SqlDbType.VarChar, 50); command.Parameters.Add("@subLocality", SqlDbType.VarChar, 50); command.Parameters.Add("@subThoroughFare", SqlDbType.VarChar, 50); command.Parameters.Add("@thoroughFare", SqlDbType.VarChar, 50); command.Parameters.Add("@createdOn", SqlDbType.DateTime); command.Parameters["@filePath"].Value = blobData.filePath; command.Parameters["@fileExt"].Value = blobData.fileExt; command.Parameters["@senderNumber"].Value = blobData.senderNumber; command.Parameters["@senderLat"].Value = blobData.senderLat; command.Parameters["@senderLong"].Value = blobData.senderLong; command.Parameters["@adminArea"].Value = blobData.adminArea; command.Parameters["@countryCode"].Value = blobData.countryCode; command.Parameters["@countryName"].Value = blobData.countryName; command.Parameters["@featureName"].Value = blobData.featureName; command.Parameters["@locality"].Value = blobData.locality; command.Parameters["@postalCode"].Value = blobData.postalCode; command.Parameters["@subAdminArea"].Value = blobData.subAdminArea; command.Parameters["@subLocality"].Value = blobData.subLocality; command.Parameters["@subThoroughFare"].Value = blobData.subThoroughFare; command.Parameters["@thoroughFare"].Value = blobData.thoroughFare; command.Parameters["@createdOn"].Value = DateTime.UtcNow; command.ExecuteNonQuery(); conn.Close(); conn.Dispose(); HttpResponseMessage response = Request.CreateResponse <BlobData>(HttpStatusCode.Created, blobData); return(response); } catch (Exception exception) { { var errorMessagError = new System.Web.Http.HttpError(exception.Message) { { "ErrorCode", 405 } }; throw new HttpResponseException (ControllerContext.Request.CreateErrorResponse(HttpStatusCode.MethodNotAllowed, errorMessagError)); } } }