public Order CreateOrder(string email, UserProfile userProfile) { Check.Require(!string.IsNullOrEmpty(email)); Check.Require(null != userProfile); var order = new Order(); order.OrderDate = DateTime.Now; var user = _userRepository.GetUserByEmail(email); if (!user.UserProfile.Equals(userProfile)) { var id = user.UserProfile.Id; user.UserProfile = userProfile; user.UserProfile.Id = id; _userRepository.SaveOrUpdate(user); } order.User = user; order.TotalValue = ComputeTotalValue(user.ShoppingCart); foreach (var cartItem in user.ShoppingCart.CartItems) { var orderItem = new OrderItem { Movie = cartItem.Movie, Quantity = cartItem.Quantity }; order.OrderItems.Add(orderItem); _orderItemRepository.SaveOrUpdate(orderItem); } _orderRepository.SaveOrUpdate(order); var cart = user.ShoppingCart; EmptyCart(ref cart); return order; }
public void SaveOrUpdate(OrderItem orderItem) { throw new NotImplementedException(); }
public void SaveOrUpdate(OrderItem orderItem) { Check.Require(orderItem != null, "OrderItem is null"); Session.SaveOrUpdate(orderItem); }