public ActionResult PaymentUserLogin(int total) { var username = Session["UsernameMember"];//lấy session gáng giá trị vào order var model = new USERdao().findByUsername(username.ToString()); var order = new Bill(); order.Date = DateTime.Now; order.Fullname = model.Fullname; order.Address = model.Address; order.Email = model.Email; order.Phonenumber = model.PhoneNumber; order.Status = "Chờ xử lý"; order.TotalPrice = total.ToString(); order.AccountID = model.ID; //insert order var id = new BILLdao().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new BILLdetailsdao(); foreach (var item in cart) { var orderDetail = new BillDetails(); orderDetail.ProductID = (int)item.ProductModel.ID; orderDetail.BillID = (int)id; orderDetail.Price = (int)item.ProductModel.Price; orderDetail.Amount = item.Quantity; db.Create(orderDetail); Session[CartSession] = null; } } catch (Exception) { throw; } return(RedirectToAction("Success", "Test")); }
public ActionResult Payment(string shipName, string shipPhone, string shipAddress, string shipEmail, int total) { var order = new Bill(); order.Date = DateTime.Now; order.Fullname = shipName; order.Address = shipAddress; order.Email = shipEmail; order.Phonenumber = shipPhone; order.Status = "Chờ xử lý"; order.TotalPrice = total.ToString(); order.AccountID = 2; //insert order var id = new BILLdao().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new BILLdetailsdao(); foreach (var item in cart) { var orderDetail = new BillDetails(); orderDetail.ProductID = (int)item.ProductModel.ID; orderDetail.BillID = (int)id; orderDetail.Price = (int)item.ProductModel.Price; orderDetail.Amount = item.Quantity; db.Create(orderDetail); Session[CartSession] = null; } } catch (Exception) { throw; } return(RedirectToAction("Success", "Test")); }