Ejemplo n.º 1
0
 public List <book_order_detail> Mapping(List <BookOrderDetailModel> bslist)
 {
     try
     {
         if (bslist != null && bslist.Count > 0)
         {
             List <book_order_detail> bsmlist = new List <book_order_detail>();
             foreach (BookOrderDetailModel bs in bslist)
             {
                 book_order_detail bsm = new book_order_detail();
                 bsm.book_order_detail_id    = bs.book_order_detail_id;
                 bsm.book_order_id           = bs.book_order_id;
                 bsm.book_product_id         = bs.book_product_id;
                 bsm.book_order_detail_price = bs.book_order_detail_price;
                 bsm.book_order_detail_qty   = bs.book_order_detail_qty;
                 bsmlist.Add(bsm);
             }
             return(bsmlist);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public bool AddBookOrderDetail(List <BookOrderDetailModel> bookOrderDetailModels, int orderId)
 {
     try
     {
         if (bookOrderDetailModels.Count > 0 && orderId != 0)
         {
             foreach (BookOrderDetailModel brd in bookOrderDetailModels)
             {
                 book_order_detail bod = new book_order_detail();
                 bod.book_order_id           = orderId;
                 bod.book_product_id         = brd.book_product_id;
                 bod.book_order_detail_price = brd.book_order_detail_price;
                 bod.book_order_detail_qty   = brd.book_order_detail_qty;
                 db.book_order_detail.Add(bod);
                 db.SaveChanges();
             }
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        public bool AddOrderDetail(int id, List <BookOrderDetailModel> bookDetail)
        {
            try
            {
                List <BookOrderDetailModel> detailList = new List <BookOrderDetailModel>();
                foreach (BookOrderDetailModel de in bookDetail)
                {
                    BookOrderDetailModel detail = new BookOrderDetailModel();
                    detail.book_product_id       = de.book_product_id;
                    detail.book_order_detail_qty = de.book_order_detail_qty;
                    detailList.Add(detail);

                    UpdateStockBookProduct(detailList);
                }

                List <book_order_detail> deList = new List <book_order_detail>();
                foreach (BookOrderDetailModel d in bookDetail)
                {
                    book_order_detail detail = new book_order_detail();
                    detail.book_order_detail_id    = d.book_order_detail_id;
                    detail.book_order_id           = id;
                    detail.book_product_id         = d.book_product_id;
                    detail.book_order_detail_price = d.book_order_detail_price;
                    detail.book_order_detail_qty   = d.book_order_detail_qty;
                    deList.Add(detail);
                }

                foreach (book_order_detail o in deList)
                {
                    db.book_order_detail.Add(o);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }