コード例 #1
0
        public bool UpdateStockBookProduct(List <BookOrderDetailModel> bookDetail)
        {
            try
            {
                if (bookDetail != null && bookDetail.Count > 0)
                {
                    List <book_product> deList = new List <book_product>();
                    foreach (BookOrderDetailModel d in bookDetail)
                    {
                        book_product product = IQueryableBookProduct().FirstOrDefault(o => o.book_product_id == d.book_product_id);

                        product.book_product_id  = d.book_product_id;
                        product.book_product_qty = (product.book_product_qty - d.book_order_detail_qty);
                        deList.Add(product);
                    }
                    db.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 public bool UpdateBookProduct(BookProductModel m)
 {
     try
     {
         book_product bp = IQueryable().FirstOrDefault(o => o.book_product_id == m.book_product_id);
         bp.book_product_name  = m.book_product_name;
         bp.book_product_price = m.book_product_price;
         dbh.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
 public bool UpdateStockBookProduct(List <BookProductModel> newQty)
 {
     try
     {
         if (newQty != null && newQty.Count > 0)
         {
             List <book_product> qList = new List <book_product>();
             book_product        bpDB  = new book_product();
             foreach (BookProductModel qty in newQty)
             {
                 book_product q = new book_product();
                 q.book_product_qty = qty.book_product_qty;
                 dbh.SaveChanges();
             }
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
        public bool AddBookProduct(BookProductModel m)
        {
            try
            {
                if (IQueryable().Where(o => o.book_product_name == m.book_product_name).ToList().Count == 0)
                {
                    book_product _obj = Mapping(m);
                    dbh.book_product.Add(_obj);
                    dbh.SaveChanges();
                    // book_product bp = IQueryable().FirstOrDefault(o => o.book_product_id == m.book_product_id);

                    // bp = Mapping(m);

                    //dbh.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
 internal BookProductModel Mapping(book_product o)
 {
     try
     {
         if (o != null)
         {
             return(new BookProductModel()
             {
                 book_product_id = o.book_product_id,
                 book_product_name = o.book_product_name,
                 book_product_price = o.book_product_price,
                 book_product_qty = o.book_product_qty,
                 book_type_id = o.book_type_id,
                 book_category_id = o.book_category_id
             });
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }