public ActionResult TransactionSuccessful(string trxref, string reference) { Transaction Transaction = new Transaction(); string UserId = LoggedInUser.Id.ToString(); List <Cart> CartTransactions = CartRepo.GetAll(x => x.CustomerId == UserId).ToList(); foreach (var item in CartTransactions) { TransactionRepo.Add(new Transaction() { AuctioneeId = UserId, BatchId = item.Auction.BatchId, BulkPurchase = false, DateOfTransaction = DateTime.Now, Quantity = item.Quantity, TransactionType = TransactionType.Auction, TotalCost = item.Auction.AuctionPrice * item.Quantity, }); Batch batch = BatchRepo.Get(x => x.Id == item.Auction.BatchId); batch.QuantityAuctioned += item.Quantity; BatchRepo.Update(batch); } Guid[] ids = CartTransactions.Select(x => x.Id).ToArray(); foreach (var item in ids) { CartRepo.Delete(item); } return(View()); }
private void deleteButton_Click(object sender, EventArgs e) { Button currButton = (Button)sender; int selectedRowIndex = 0; if (int.TryParse(currButton.ID.Substring(0, currButton.ID.Length - 2), out selectedRowIndex)) { int CartId = int.Parse(((Label)ListCart.Rows[selectedRowIndex].Cells[1].Controls[0]).Text); CartRepo.Delete(CartId); Response.Redirect("./Cart.aspx"); } }
public ActionResult RemoveProductFromCart(Guid id) { CartRepo.Delete(id); return(RedirectToAction("MyCart")); }