public ValidationResult UserPayment(string userName, string[] orderDetailsIds) { var result = new ValidationResult(); var userBlance = _userRepository.GetUserFundAccountBalance(userName); var orderDetails = _odRepository.GetOrderDetailByIds(orderDetailsIds); var total = orderDetails.Select(t => t.UnitPrice).Sum(); if (userBlance < total) { result.IsValid = false; result.Message = "对不起,账户余额不足,无法完成购买"; return(result); } _userRepository.UpdateFundAccount(userName, userBlance - total); //设定交易完成 orderDetails.ForEach(t => t.IsClosed = false); _odRepository.UpdateOrderDetails(orderDetails); result.IsValid = true; result.Message = "付款完成!"; return(result); }
public IActionResult Edit(int ProductId, int OrderId) => View(detailRepository.GetOrderDetailByIds(ProductId, OrderId));