This method is an easy way(i.e with few lines of code) to update an object in a collection. This can be used when you want to update an existing item in a collection with some values read from another object in another collection and all other fields of the existing item remaining same.
Dummy Code:
Real Example:
Dummy Code:
1 2 3 4 5 | Dim existingObject = ExisitngCollection(itemIndex) For Each foo In Foos existingObject.Property1 = foo.Property1 existingObject.Property2 = foo.Property2 Next |
Real Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | Private Function UpdateRoundingValue( ByVal ObjAvailabilityHandlerProcessMergeResponseDom As ClsAvailabilityHandlerProcessMergeResponseDom, ByVal ObjHtlRoundingEntity As ClsHtlRoundingEntity) As ClsAvailabilityHandlerProcessMergeResponseDom Dim hotelCounter As Int16 = 0 Dim roomTypeCounter As Int16 = 0 Dim roomRateCounter As Int16 = 0 Try hotelCounter = 0 For Each RoundingHotel As ClsHtlRoundingHotel In ObjHtlRoundingEntity.ObjHtlRoundingHotels Dim hotelToUpdate = ObjAvailabilityHandlerProcessMergeResponseDom.ObjClsHtlDomAvltRes.ObjHtlDomAvltResHotels(hotelCounter) roomTypeCounter = 0 For Each RoundingRoomType As ClsHtlRoundingRoomType In RoundingHotel.ObjHtlRoundingRoomTypes Dim roomTypeToUpdate = hotelToUpdate.ObjHtlDomAvltResRoomTypes(roomTypeCounter) With roomTypeToUpdate .GrossFare = RoundingRoomType.GrossFare .BaseFare = RoundingRoomType.BaseFare .NetFare = RoundingRoomType.NetFare .SupplierFare = RoundingRoomType.SupplierFare .CustomerFare = RoundingRoomType.CustomerFare roomRateCounter = 0 For Each RoundingRoomRate As ClsHtlRoundingRoomRate In RoundingRoomType.HtlRoundingRoomRates Dim roomRateToUpdate = roomTypeToUpdate.HtlDomAvltResRoomRates(roomRateCounter) With roomRateToUpdate .AdultRate = RoundingRoomRate.AdultRate .ChildRate = RoundingRoomRate.ChildRate .ExtraRate = RoundingRoomRate.ExtraRate .Tax = RoundingRoomRate.Tax .ServiceTax = RoundingRoomRate.ServiceTax .ServiceCharge = RoundingRoomRate.ServiceCharge .OtherCharges = RoundingRoomRate.OtherCharges .TransactionFee = RoundingRoomRate.TransactionFee .Commission = RoundingRoomRate.Commission .TDSOnCommission = RoundingRoomRate.TDSOnCommission .Discount = RoundingRoomRate.Discount .TDSOnDiscount = RoundingRoomRate.TDSOnDiscount .SupplierFare = RoundingRoomRate.SupplierFare .AgentAddOnMarkup = RoundingRoomRate.AgentAddOnMarkup .AgentAddOnDiscount = RoundingRoomRate.AgentAddOnDiscount .AgentTransactionFee = RoundingRoomRate.AgentTransactionFee .AgentMarkup = RoundingRoomRate.AgentMarkup .AgentDiscount = RoundingRoomRate.AgentDiscount .CustomerFare = RoundingRoomRate.CustomerFare End With roomRateCounter += 1 Next End With roomTypeCounter += 1 Next hotelCounter += 1 Next Catch ex As Exception Response.TransRemarks = ex.Message & "-" & ex.StackTrace Response.TransStatus = True Response.TransCode = "1111" LogError(Reflection.MethodBase.GetCurrentMethod.DeclaringType.FullName, Reflection.MethodBase.GetCurrentMethod.Name, ex.Message & "-" & ex.StackTrace) Finally UpdateRoundingValue = ObjAvailabilityHandlerProcessMergeResponseDom End Try End Function |
0 comments:
Post a Comment