public AuctionItemDetail GetAuctionItemDetail(string connstring, string auctionDetailNo) { AuctionItemDetail auctionItemDetail = new AuctionItemDetail(); string query = "SELECT [AuctionDetailNo], [AuctionRefNo], [Item], [Description], [Quantity], [UnitOfMeasure], [DateCreated], [Status], [CategoryId], [SubCategoryId] FROM [tblAuctionItemDetails] WHERE [AuctionDetailNo] = " + auctionDetailNo; SqlParameter[] sqlParams = new SqlParameter[1]; sqlParams[0] = new SqlParameter("@query", SqlDbType.NText); sqlParams[0].Value = query; DataSet dataSet = new DataSet(); dataSet = SqlHelper.ExecuteDataset(connstring, CommandType.StoredProcedure, "[s3p_EBid_GenericQueryProcedure]", sqlParams); if (dataSet.Tables[0].Rows.Count > 0) { auctionItemDetail.AuctionDetailNo = Int32.Parse(dataSet.Tables[0].Rows[0]["AuctionDetailNo"].ToString()); auctionItemDetail.AuctionRefNo = Int32.Parse(dataSet.Tables[0].Rows[0]["AuctionRefNo"].ToString()); auctionItemDetail.CategoryId = dataSet.Tables[0].Rows[0]["CategoryId"].ToString(); auctionItemDetail.DateCreated = dataSet.Tables[0].Rows[0]["DateCreated"].ToString(); auctionItemDetail.Description = dataSet.Tables[0].Rows[0]["Description"].ToString(); auctionItemDetail.Item = dataSet.Tables[0].Rows[0]["Item"].ToString(); auctionItemDetail.Quantity = Int32.Parse(dataSet.Tables[0].Rows[0]["Quantity"].ToString()); auctionItemDetail.Status = Int32.Parse(dataSet.Tables[0].Rows[0]["Status"].ToString()); auctionItemDetail.SubCategoryId = Int32.Parse(dataSet.Tables[0].Rows[0]["SubCategoryId"].ToString()); auctionItemDetail.UnitOfMeasure = dataSet.Tables[0].Rows[0]["UnitOfMeasure"].ToString(); } return(auctionItemDetail); }
public async Task <IActionResult> Details(int?id) { var auctionItemDetail = new AuctionItemDetail(); if (id == null) { return(NotFound()); } auctionItemDetail.Item = await _context.AuctionItem.SingleOrDefaultAsync(m => m.ID == id); if (auctionItemDetail.Item == null) { return(NotFound()); } string query = "SELECT * FROM Offer WHERE AuctionItemID = {0}"; auctionItemDetail.Offers = await _context.Offer.FromSql(query, auctionItemDetail.Item.ID).AsNoTracking().ToListAsync(); if (auctionItemDetail.Offers == null) { auctionItemDetail.Offers = new List <Offer>(); } return(View(auctionItemDetail)); }
public void InsertAuctionItemDetail(AuctionItemDetail auctionItemDetail) { string query = "INSERT INTO [tblAuctionItemDetails] " + "([AuctionRefNo], [Item], [Description], [Quantity], [UnitOfMeasure], [DateCreated], [Status]) " + "VALUES (" + auctionItemDetail.AuctionRefNo + ", '" + auctionItemDetail.Item + "', '" + auctionItemDetail.Description + "', " + auctionItemDetail.Quantity + ", '" + auctionItemDetail.UnitOfMeasure + "', '" + auctionItemDetail.DateCreated + "', " + auctionItemDetail.Status + ")"; SqlParameter[] sqlparam = new SqlParameter[1]; sqlparam[0] = new SqlParameter("@query", SqlDbType.NText); sqlparam[0].Value = query; SqlHelper.ExecuteNonQuery(connstring, CommandType.StoredProcedure, "[s3p_EBid_GenericQueryProcedure]", sqlparam); }