Esempio n. 1
0
        /// <summary>
        /// Map the basic fields for the RatePlanView view to the RatePlanView model object
        /// </summary>
        /// <param name="record">The SqlDataReader with the executed query result</param>
        /// <param name="prefix">a prefix used to identify fields for the RatePlanView model  in the resultset if required</param>        
        /// <returns>An instance of Model.Room.RatePlanView</returns>
        internal static RatePlanView MapRecord(IDataRecord record, string prefix = "")
        {
            var ratePlanView = new RatePlanView
            {
                RatePlanId = DbHelper.ConvertValue<int>(record[prefix + Parameters.RatePlanId]),
                BusinessId = DbHelper.ConvertValue<long>(record[prefix + Parameters.BusinessId]),
                RatePlanName = DbHelper.ConvertValue<string>(record[prefix + Parameters.RatePlanName]),
                RoomTypeName = DbHelper.ConvertValue<string>(record[prefix + Parameters.RoomTypeName]),
                RatePlanTypeCode = DbHelper.ConvertValue<string>(record[prefix + Parameters.RatePlanTypeCode]),
                IsActive = DbHelper.ConvertValue<bool>(record[prefix + Parameters.IsActive])
            };

            return ratePlanView;
        }
Esempio n. 2
0
            public void GetRatePlansByBusinessIdCallsCache()
            {
                // Arrange
                long businessId = 1;
                int ratePlanId = 1;
                string cultureCode = "en-GB";

                var ratePlan = new RatePlanView
                    {
                        RatePlanId = ratePlanId,
                        BusinessId = businessId,
                        RatePlanName = "RatePlan",
                        RoomTypeName = "RoomType",
                        IsActive = true
                    };

                CacheHelper.StubRatePlanViewCacheWithRatePlanViews(businessId, new List<RatePlanView> { ratePlan });
                // Invalidate the cache so it refreshes
                Business.Cache.Cache.RatePlanViewCache.Invalidate(businessId);

                var ratePlanManager = new RatePlanManager();

                // Act
                var result = ratePlanManager.GetRatePlanViewsByBusinessId(businessId, cultureCode);

                // Assert
                Assert.AreEqual(1, result.Count, "Number of rate plans returned was incorrect");
                
                CacheHelper.ReAssignRatePlanDaoToRatePlanViewCache();
            }