Ejemplo n.º 1
0
 private static void RemoveInventory(Guid truckId)
 {
     using (var ctx = new OffsiteContext())
     {
         // if truck is found then remove it; otherwise, nothing to see here
         var truckInventory = ctx.Inventory.Where(x => x.Id == truckId).FirstOrDefault();
         if (truckInventory != null)
         {
             ctx.Inventory.Remove(truckInventory);
             ctx.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
 private static void MergeInventory(InventoryItem mergeTruck)
 {
     using (var context = new OffsiteContext())
     {
         // if truck already exists, then perform an update
         if (context.Inventory.Any(x => x.Id == mergeTruck.Id))
         {
             context.Inventory.Attach(mergeTruck);
         }
         // otherwise, insert the new truck
         else
         {
             context.Inventory.Add(mergeTruck);
         }
         context.SaveChanges();
     }
 }