/// <summary> /// Gets a viewed items by customer session GUID /// </summary> /// <param name="CustomerSessionGUID">The customer session identifier</param> /// <param name="Count">count items per page</param> /// <param name="PageIndex">number of page</param> /// <returns>Cart</returns> public static ViewedItemsCollection GetViewedItemsByCustomerSessionGUID(Guid CustomerSessionGUID, int Count, int PageIndex, out int TotalRecords) { DBViewedItemsCollection dbCollection = DBProviderManager <DBViewedItemProvider> .Provider.GetViewedItemByCustomerSessionGUID(CustomerSessionGUID, Count, PageIndex, out TotalRecords); ViewedItemsCollection viewedItemsCollection = DBMapping(dbCollection); return(viewedItemsCollection); }
private static ViewedItemsCollection DBMapping(DBViewedItemsCollection dbCollection) { if (dbCollection == null) { return(null); } ViewedItemsCollection collection = new ViewedItemsCollection(); foreach (DBViewedItem dbItem in dbCollection) { ViewedItem item = DBMapping(dbItem); collection.Add(item); } return(collection); }
/// <summary> /// Gets a viewed by customer session GUID /// </summary> /// <param name="CustomerSessionGUID">The customer session identifier</param> /// <param name="PageSize">pageSize</param> /// <param name="pageIndex">pageIndex</param> /// <returns>Viewed items</returns> public override DBViewedItemsCollection GetViewedItemByCustomerSessionGUID(Guid CustomerSessionGUID, int PageSize, int PageIndex, out int TotalRecords) { DBViewedItemsCollection viewedItems = new DBViewedItemsCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("ViewedItemLoadByCustomerSessionGUID"); db.AddInParameter(dbCommand, "CustomerSessionGUID", DbType.Guid, CustomerSessionGUID); db.AddInParameter(dbCommand, "Count", DbType.Int32, PageSize); db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex); db.AddOutParameter(dbCommand, "TotalRecords", DbType.Int32, 0); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBViewedItem viewedItem = GetViewedItemFromReader(dataReader); viewedItems.Add(viewedItem); } } TotalRecords = Convert.ToInt32(db.GetParameterValue(dbCommand, "@TotalRecords")); return(viewedItems); }