public void DeleteCartWithValidId() { // Act var resultRaw = _controller.DeleteCart(1); NegotiatedContentResult <ResponseDto> result = (NegotiatedContentResult <ResponseDto>)resultRaw; ////// Assert Assert.IsNotNull(result); Assert.IsNotNull(result.Content); Assert.AreEqual(HttpStatusCode.OK, result.Content.StatusCode); Assert.AreEqual("Cart with id: 1 successfully deleted.", result.Content.MessageDetail); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string userId = Session["id"].ToString(); int rowIndex = e.RowIndex; string productId = GridView1.Rows[rowIndex].Cells[2].Text; CartController.DeleteCart(int.Parse(userId), int.Parse(productId)); Response.Redirect("ViewCart.aspx"); }
private void DeleteBtn_Click(object sender, EventArgs e) { Button currentButton = (Button)sender; int selectedindex = 0; int.TryParse(currentButton.ID.Substring(0, currentButton.ID.Length - 3), out selectedindex); int productID = 0; productID = int.Parse(((Label)CartTable.Rows[selectedindex].Cells[1].Controls[0]).Text); Response response = CartController.DeleteCart(productID, u.ID); if (response.successStatus) { Response.Redirect(Request.RawUrl); } else { ErrorLabel.Visible = true; ErrorLabel.Text = response.message; } }