public IHttpActionResult GettblProduct(int id) { vProduct tblProduct = db.vProducts.Find(id); if (tblProduct == null) { return(NotFound()); } return(Ok(tblProduct)); }
protected void Page_Load(object sender, EventArgs e) { if (!AddToCartController.checkIsAMember()) { userWarnLbl.Text = "You are not logged in as member."; addBtn.Visible = false; qtyBox.Enabled = false; } else { int id = Convert.ToInt32(Request.QueryString["id"]); vProduct currentProduct = AddToCartController.findProductDetail(id); productNameLbl.Text = currentProduct.Name; productPriceLbl.Text = currentProduct.Price.ToString(); productStockLbl.Text = currentProduct.Stock.ToString(); productTypeLbl.Text = currentProduct.Type; } }
protected void Page_Load(object sender, EventArgs e) { if (UpdateProductController.isUserLoggedIn()) { if (UpdateProductController.isUserAnAdmin(Request.Cookies["user_email"].Value)) { if (!IsPostBack) { int id = Convert.ToInt32(Request.QueryString["Id"]); vProduct currentProduct = UpdateProductController.getProductObject(id); typeDD.DataSource = UpdateProductController.getProductType(); typeDD.DataBind(); nameBox.Text = currentProduct.Name; stockBox.Text = currentProduct.Stock.ToString(); priceBox.Text = currentProduct.Price.ToString(); typeDD.SelectedValue = currentProduct.Type; } } else { userWarnLbl.Text = "403. You're not an admin."; nameBox.Enabled = false; priceBox.Enabled = false; stockBox.Enabled = false; updateBtn.Visible = false; } } else { userWarnLbl.Text = "403. You're not logged in"; nameBox.Enabled = false; priceBox.Enabled = false; stockBox.Enabled = false; updateBtn.Visible = false; logoutBtn.Visible = false; } }