/// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool Delete(int id)
        {
            var item = new OrderDetailPO {
                Id = id
            };

            return(Delete(item));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Delete(OrderDetailPO item)
 {
     using (var context = new SchoolContext())
     {
         context.OrderDetails.Attach(item);
         context.OrderDetails.Remove(item);
         context.SaveChanges();
     }
     return(true);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Save(OrderDetailPO item)
 {
     using (var context = new SchoolContext())
     {
         if (item.Id == 0)
         {
             context.OrderDetails.Add(item);
         }
         else
         {
             context.Entry(item).State = EntityState.Modified;
         }
         context.SaveChanges();
     }
     return(true);
 }
 public static OrderDetailModel ToModel(this OrderDetailPO item)
 {
     if (item == null)
     {
         return(null);
     }
     return(new OrderDetailModel
     {
         Id = item.Id,
         OrderId = item.OrderId,
         ProductId = item.ProductId,
         ProductsizeId = item.ProductsizeId,
         Unitprice = item.Unitprice,
         Quantity = item.Quantity,
         Status = item.Status,
         Createtime = item.Createtime,
         Updatetime = item.Updatetime,
     });
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static OrderDetailPO GetDataForSave(int id)
        {
            OrderDetailPO item;

            if (id == 0)
            {
                item = new OrderDetailPO()
                {
                    OrderId       = 0,
                    ProductId     = 0,
                    ProductsizeId = 0,
                    Unitprice     = 0,
                    Quantity      = 0,
                    Status        = 0,
                    Createtime    = DateTime.Now,
                    Updatetime    = DateTime.Now,
                };
            }
            else
            {
                item = GetItem(id);
            }
            return(item);
        }