private void SaveOrder(OrderModel model, Payment payment, string userId) { var order = new Order(); order.OrderNumber = new Random().Next(111111, 999999).ToString(); order.OrderState = EnumOrderState.Completed; order.PaymentType = EnumPaymentTypes.CreditCart; order.PaymentId = payment.PaymentId; order.ConversationId = payment.ConversationId; order.OrderDate = new DateTime(); order.FirstName = model.FirstName; order.LastName = model.LastName; order.UserId = userId; order.Address = model.Address; order.Phone = model.Phone; order.Email = model.Email; order.City = model.City; order.OrderNote = model.OrderNote; order.OrderItems = new List <Entities.OrderItem>(); foreach (var item in model.CartModel.CartItems) { var orderItem = new Entities.OrderItem() { Price = item.Price, Quantity = item.Quantity, ProductId = item.ProductId }; order.OrderItems.Add(orderItem); } orderBusiness.Create(order); }
public IActionResult PostOrder(OrderVO order) { if (order == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } order.TotalValue = order.itens.Sum(s => s.ProductValue); return(new ObjectResult(_orderBusiness.Create(order))); }
public OrderModel CreateItem([FromBody] OrderModel model) { model.ma_hoa_don = Guid.NewGuid().ToString(); if (model.listjson_chitiet != null) { foreach (var item in model.listjson_chitiet) { item.ma_chi_tiet = Guid.NewGuid().ToString(); } } _OrderBusiness.Create(model); return(model); }