private List <INVOICE_DETAIL> CopyInvoicedetail(OrderDateModel itemOrder) { List <INVOICE_DETAIL> lstorderDetailDate = new List <INVOICE_DETAIL>(); lstorderDetailDate.Clear(); try { for (int i = 0; i < itemOrder.ListOrderDetail.Count; i++) { INVOICE_DETAIL orderDetaiDate = new INVOICE_DETAIL(); orderDetaiDate.OrderDetailID = itemOrder.ListOrderDetail[i].OrderDetailID; orderDetaiDate.ProductID = itemOrder.ListOrderDetail[i].ProductID; orderDetaiDate.DynId = itemOrder.ListOrderDetail[i].DynID; orderDetaiDate.Seat = itemOrder.ListOrderDetail[i].Seat; orderDetaiDate.Qty = itemOrder.ListOrderDetail[i].Qty; orderDetaiDate.KeyItem = itemOrder.ListOrderDetail[i].KeyItem; orderDetaiDate.Total = itemOrder.ListOrderDetail[i].Total; orderDetaiDate.Price = itemOrder.ListOrderDetail[i].Price; orderDetaiDate.Status = itemOrder.ListOrderDetail[i].Satust; orderDetaiDate.Note = itemOrder.ListOrderDetail[i].Note; orderDetaiDate.CreateBy = itemOrder.ListOrderDetail[i].CreateBy ?? 0; orderDetaiDate.CreateDate = itemOrder.ListOrderDetail[i].CreateDate ?? DateTime.Now; orderDetaiDate.UpdateBy = itemOrder.ListOrderDetail[i].UpdateBy ?? 0; orderDetaiDate.UpdateDate = itemOrder.ListOrderDetail[i].UpdateDate ?? DateTime.Now; lstorderDetailDate.Add(orderDetaiDate); } } catch (Exception ex) { LogPOS.WriteLog("CopyOrderDetailDate:::::::::::::::::::::::::" + ex.Message); } return(lstorderDetailDate); }
public bool Insert(INVOICE_DETAIL invoiceDetail) { try { db.INVOICE_DETAIL.Add(invoiceDetail); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult Checkout(INVOICE invoice) { var sessionCart = (CartModel)Session[Common.CommonConstants.CART_SESSION]; var sessionUser = Session[Common.CommonConstants.USER_SESSION]; invoice.Created_Time = DateTime.Now; invoice.Status = 0; invoice.Total = sessionCart.Total * (100 - sessionCart.DiscountAmount) / 100; if (sessionCart.DiscountCode != null) { invoice.Id_Discount_Code = new DiscountCodeDAO().GetDiscountCodeByCode(sessionCart.DiscountCode).Id; } if (sessionUser != null) { var user = (USER)sessionUser; invoice.Id_User = user.Id; } if (ModelState.IsValid) { var invoiceId = new InvoiceDAO().Insert(invoice); if (invoiceId > 0) { var detailDAO = new InvoiceDetailDAO(); foreach (var item in sessionCart.ListCartItem) { var invoiceDetail = new INVOICE_DETAIL { Id_Invoice = invoiceId, Id_Product = item.Product.Id, Quantity = item.Quantity }; detailDAO.Insert(invoiceDetail); } Session[Common.CommonConstants.CART_SESSION] = null; return(Json(new { result = true })); } } return(PartialView("CheckoutForm", invoice)); }