Ejemplo n.º 1
0
 public static void DeleteOrder()
 {
     using (var dbContext = new EntityFrameworkPlusDbContext())
     {
         var audit = new Audit {
             CreatedBy = "david"
         };
         var orderAsync = dbContext.Orders.FirstAsync();
         var order      = orderAsync.Result;
         dbContext.Entry(order).State = EntityState.Deleted;
         dbContext.SaveChanges(audit);
     }
 }
Ejemplo n.º 2
0
 public static void UpdateOrder()
 {
     using (var dbContext = new EntityFrameworkPlusDbContext())
     {
         var audit = new Audit {
             CreatedBy = "david"
         };
         var orderAsync = dbContext.Orders.FirstAsync();
         var order      = orderAsync.Result;
         order.LastModifier         = "davidzhou";
         order.LastModifiedDateTime = DateTime.Now;
         order.OrderStatus          = "已完成";
         dbContext.Entry(order);
         dbContext.SaveChanges(audit);
     }
 }
Ejemplo n.º 3
0
 public static void AddOrder()
 {
     using (var dbContext = new EntityFrameworkPlusDbContext())
     {
         var audit = new Audit {
             CreatedBy = "david"
         };
         dbContext.Orders.Add(new OrderModel
         {
             OrderNo        = "ORDER0001",
             OrderCreator   = "david",
             OrderDateTime  = DateTime.Now,
             OrderStatus    = "已出库",
             Creator        = "david",
             CreateDateTime = DateTime.Now
         });
         dbContext.SaveChanges(audit);
     }
 }