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:
Dim existingObject = ExisitngCollection(itemIndex) For Each foo In Foos existingObject.Property1 = foo.Property1 existingObject.Property2 = foo.Property2 Next
Real Example:
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