/// <summary> /// - Faizan Syed - /// add cylinder /// </summary> /// <param name="objCylinder"></param> /// <returns> CustomResponseModel </returns> /// CylinderDAL/InsertCylinder /// public CustomResponseModel <Cylinder> InsertCylinder(Cylinder objCylinder) { _objCommon = new Common(); CustomResponseModel <Cylinder> objCustomResponseModel = null; try { CustomCommandModel objCustomCommandModel = new CustomCommandModel { ProcedureName = "[dbo].[usp_InsertCylinder]", ParamArray = new SqlParameter[] { new SqlParameter("@Code", objCylinder.Code), new SqlParameter("@CylinderName", objCylinder.CylinderName), new SqlParameter("@IsActive", objCylinder.IsActive), }, Type = ProcedureType.Post }; objCustomResponseModel = _objCommon.ExecuteProcedure <Cylinder>(objCustomCommandModel); } catch (Exception ex) { } return(objCustomResponseModel); }
/// <summary> /// - Faizan Syed - /// update requests /// </summary> /// <param name="objRequests"></param> /// <returns> CustomResponseModel </returns> /// RequestsDAL/UpdateRequests /// public CustomResponseModel <Request> UpdateRequest(Request objRequests) { _objCommon = new Common(); CustomResponseModel <Request> objCustomResponseModel = null; try { CustomCommandModel objCustomCommandModel = new CustomCommandModel { ProcedureName = "[dbo].[usp_UpdateRequest]", ParamArray = new SqlParameter[] { new SqlParameter("@RequestId", objRequests.RequestId), new SqlParameter("@PatientName", objRequests.PatientName), new SqlParameter("@PatientMobileNo", objRequests.PatientMobileNo) }, Type = ProcedureType.Post }; objCustomResponseModel = _objCommon.ExecuteProcedure <Request>(objCustomCommandModel); } catch (Exception ex) { } return(objCustomResponseModel); }
public static void UseCustomExceptionMiddleware(this IApplicationBuilder app) { app.UseExceptionHandler(errorApp => { errorApp.Run(async context => { var exceptionHandlerPathFeature = context.Features.Get <IExceptionHandlerPathFeature> (); context.Response.StatusCode = 500; context.Response.ContentType = new MediaTypeHeaderValue("application/json").ToString(); string ErrorContent = exceptionHandlerPathFeature?.Error?.Message + " => " + exceptionHandlerPathFeature?.Error.StackTrace; var bodyContent = new CustomResponseModel { status = 500, title = context.Response.StatusCode.ToString(), errors = ErrorContent }; await context.Response.WriteAsync(JsonSerializer.Serialize(bodyContent), Encoding.UTF8); }); }); }
/// <summary> /// Faizan Syed - /// ExecuteProcedure /// </summary> /// <param name="objCustomCommandModel"></param> /// <returns>CustomResponseModel</returns> /// Common/ExecuteProcedure public CustomResponseModel <T> ExecuteProcedure <T>(CustomCommandModel objCustomCommandModel) { CustomResponseModel <T> objCustomResponseModel = new CustomResponseModel <T>(); try { _objSqlCommand = new SqlCommand { Connection = _objSqlConnection, CommandType = CommandType.StoredProcedure, CommandText = objCustomCommandModel.ProcedureName }; if (objCustomCommandModel.ParamArray != null) { _objSqlCommand.Parameters.AddRange(objCustomCommandModel.ParamArray); } if (objCustomCommandModel.Type == ProcedureType.Get) { SqlDataAdapter objDataAdapter = new SqlDataAdapter(_objSqlCommand); DataTable dtResult = new DataTable(); objDataAdapter.Fill(dtResult); objCustomResponseModel.ResultDataTable = ConvertDataTableToList <T>(dtResult); } else { objCustomResponseModel.Status = _objSqlCommand.ExecuteNonQuery() > 0; } } catch (Exception ex) { } finally { _objSqlCommand.Dispose(); _objSqlConnection.Dispose(); _objConnectionHandler.CloseConnection(); } return(objCustomResponseModel); }
public HttpResponseMessage SaveUnitSam() { CustomResponseModel customResponseModel = new CustomResponseModel(); try { string Name = "Test Name - SAM 2"; string Description = "Test Description - SAM 2"; string SizeName = "Size Name - SAM 2"; string SizeDescription = "Size Desc - SAM 2"; SizeModel _sizeModel = new SizeModel(); List <SizeModel> _sizeModelList = new List <SizeModel>(); _sizeModel.SizeName = SizeName; _sizeModel.SizeDescription = SizeDescription; _sizeModelList.Add(_sizeModel); UnitModel _unitModel = new UnitModel { Name = Name, Description = Description, tblSizes = _sizeModelList }; // _unitModel.tblSizes.Add(_sizeModel); _unit.Save(_unitModel); customResponseModel.type = "success"; customResponseModel.message = "Enquiry Submitted"; // customResponseModel.data = objList; } catch (Exception ex) { customResponseModel.type = "error"; customResponseModel.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, customResponseModel)); } return(Request.CreateResponse(HttpStatusCode.OK, customResponseModel)); }
public HttpResponseMessage SaveUnit([FromBody] JObject data) { CustomResponseModel customResponseModel = new CustomResponseModel(); try { string Name = data["Name"].ToObject <string>(); string Description = data["Description"].ToObject <string>(); string SizeName = data["SizeName"].ToObject <string>(); string SizeDescription = data["SizeDescription"].ToObject <string>(); SizeModel _sizeModel = new SizeModel(); List <SizeModel> _sizeModelList = new List <SizeModel>(); _sizeModel.SizeName = SizeName; _sizeModel.SizeDescription = SizeDescription; _sizeModelList.Add(_sizeModel); UnitModel _unitModel = new UnitModel { Name = Name, Description = Description, // tblSizes= _sizeModelList }; _unitModel.tblSizes.Add(_sizeModel); _unit.Save(_unitModel); customResponseModel.type = "success"; customResponseModel.message = "Enquiry Submitted"; // customResponseModel.data = objList; } catch (Exception ex) { customResponseModel.type = "error"; customResponseModel.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, customResponseModel)); } return(Request.CreateResponse(HttpStatusCode.OK, customResponseModel)); }