public bool UpdateCar(String id, String vin, int repairingsCount, int driveWeight, bool searched, DateTime stkEndDate, DateTime ekEndDate) { AddressedID searchObj = new AddressedID(); searchObj.ID = id; Block <AddressedID> block = IDCarTree.Find(searchObj); if (block != null) { Record <AddressedID>[] records = block.RecordsArray.Records; for (int i = 0; i < records.Length; i++) { if (records[i].Data.CompareTo(searchObj) == 0) { Block <Vehicle> vehicleBlock = CarHeapFile.FindBlock(records[i].Data.Address); Vehicle vehicle = null; int recordIndex = 0; for (int j = 0; j < vehicleBlock.RecordsArray.Records.Length; j++) { if (vehicleBlock.RecordsArray.Records[j].Data.ID.Equals(id)) { vehicle = vehicleBlock.RecordsArray.Records[j].Data; recordIndex = j; break; } } vehicle.RepairingsCount = repairingsCount; vehicle.DriveWeight = driveWeight; vehicle.Searched = searched; vehicle.STKEndDate = stkEndDate; vehicle.EKEndDate = ekEndDate; vehicleBlock.RecordsArray.Records[recordIndex] = new Record <Vehicle>(vehicle); CarHeapFile.WriteBlock(vehicleBlock); return(true); } } } return(false); }
private Vehicle GetCarByIDAsObject(String id) { AddressedID searchObj = new AddressedID(); searchObj.ID = id; Block <AddressedID> block = IDCarTree.Find(searchObj); if (block != null) { Record <AddressedID>[] records = block.RecordsArray.Records; foreach (Record <AddressedID> record in records) { if (record.Data.CompareTo(searchObj) == 0) { return(CarHeapFile.FindData(record.Data.Address)); } } } return(null); }