public void DeleteVehicleMaintenanceLogEntry(VehicleMaintenanceLogEntry vehicleMaintenanceLogEntry)
        {
            if ((vehicleMaintenanceLogEntry.EntityState == EntityState.Detached))
                this.ObjectContext.VehicleMaintenanceLog.Attach(vehicleMaintenanceLogEntry);

            vehicleMaintenanceLogEntry.Vehicle = null;

            vehicleMaintenanceLogEntry.LineItems.Load();
            var lineItemsToRemove = vehicleMaintenanceLogEntry.LineItems.ToArray();
            foreach (var lineItem in lineItemsToRemove)
                this.DeleteVehicleMaintenanceLineItem(lineItem);

            if ((vehicleMaintenanceLogEntry.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(vehicleMaintenanceLogEntry, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.VehicleMaintenanceLog.DeleteObject(vehicleMaintenanceLogEntry);
            }
        }
        public void UpdateVehicleMaintenanceLogEntry(VehicleMaintenanceLogEntry currentVehicleMaintenanceLogEntry)
        {
            currentVehicleMaintenanceLogEntry.LastModified = DateTime.UtcNow;
            currentVehicleMaintenanceLogEntry.LastModifyingUserId = CurrentUserAccount().Id;

            this.ObjectContext.VehicleMaintenanceLog.AttachAsModified(currentVehicleMaintenanceLogEntry);
        }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the VehicleMaintenanceLog EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVehicleMaintenanceLog(VehicleMaintenanceLogEntry vehicleMaintenanceLogEntry)
 {
     base.AddObject("VehicleMaintenanceLog", vehicleMaintenanceLogEntry);
 }
 public void InsertVehicleMaintenanceLogEntry(VehicleMaintenanceLogEntry vehicle)
 {
     if ((vehicle.EntityState != EntityState.Detached))
     {
         this.ObjectContext.ObjectStateManager.ChangeObjectState(vehicle, EntityState.Added);
     }
     else
     {
         this.ObjectContext.VehicleMaintenanceLog.AddObject(vehicle);
     }
 }
Example #5
0
 /// <summary>
 /// Create a new VehicleMaintenanceLogEntry object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="vehicleId">Initial value of the VehicleId property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static VehicleMaintenanceLogEntry CreateVehicleMaintenanceLogEntry(global::System.Guid id, global::System.Guid vehicleId, global::System.DateTime createdDate)
 {
     VehicleMaintenanceLogEntry vehicleMaintenanceLogEntry = new VehicleMaintenanceLogEntry();
     vehicleMaintenanceLogEntry.Id = id;
     vehicleMaintenanceLogEntry.VehicleId = vehicleId;
     vehicleMaintenanceLogEntry.CreatedDate = createdDate;
     return vehicleMaintenanceLogEntry;
 }