public static List <ProductDiscount> GetProductDiscountsList(DateTime dateTime) { return(ModulesRepository.ModuleExecuteReadList( "Select * From [Module].[" + ModuleName + "] Where ((@dateTime between DateStart and DateExpired) Or (IsRepeat = 1))", CommandType.Text, reader => new ProductDiscount() { ProductId = ModulesRepository.ConvertTo <int>(reader, "ProductId"), Discount = ModulesRepository.ConvertTo <float>(reader, "DiscountInTime"), DateExpired = ModulesRepository.ConvertTo <DateTime>(reader, "DateExpired") }, new SqlParameter("@dateTime", dateTime))); }
private static StoreReview GetStoreReviewFromReader(SqlDataReader reader) { return(new StoreReview { Id = ModulesRepository.ConvertTo <int>(reader, "ID"), ParentId = ModulesRepository.ConvertTo <int>(reader, "ParentID"), Rate = ModulesRepository.ConvertTo <int>(reader, "Rate"), Review = ModulesRepository.ConvertTo <string>(reader, "Review"), ReviewerEmail = ModulesRepository.ConvertTo <string>(reader, "ReviewerEmail"), ReviewerName = ModulesRepository.ConvertTo <string>(reader, "ReviewerName"), DateAdded = ModulesRepository.ConvertTo <DateTime>(reader, "DateAdded"), Moderated = ModulesRepository.ConvertTo <bool>(reader, "Moderated"), HasChild = ModulesRepository.ConvertTo <int>(reader, "ChildsCount") > 0 }); }
public static StoreReview GetStoreReview(int id) { return(ModulesRepository.ModuleExecuteReadOne <StoreReview>( "SELECT *, (SELECT Count(ID) FROM [Module].[StoreReview] WHERE [ParentID] = ParentReview.ID) as ChildsCount FROM [Module].[StoreReview] as ParentReview WHERE [ID] = @ID", CommandType.Text, (reader) => { var review = GetStoreReviewFromReader(reader); review.ChildrenReviews = ModulesRepository.ConvertTo <int>(reader, "ChildsCount") > 0 ? GetStoreReviewsByParentId( ModulesRepository.ConvertTo <int>(reader, "ParentID")) : new List <StoreReview>(); return review; }, new SqlParameter("@ID", id))); }
private static BuyInTimeProductModel GetBuyInTimeProductModelFromReader(SqlDataReader reader) { return(new BuyInTimeProductModel { Id = ModulesRepository.ConvertTo <int>(reader, "Id"), ProductId = ModulesRepository.ConvertTo <int>(reader, "ProductId"), DateStart = ModulesRepository.ConvertTo <DateTime>(reader, "DateStart"), DateExpired = ModulesRepository.ConvertTo <DateTime>(reader, "DateExpired"), DiscountInTime = ModulesRepository.ConvertTo <float>(reader, "DiscountInTime"), ActionText = ModulesRepository.ConvertTo <string>(reader, "ActionText"), ShowMode = ModulesRepository.ConvertTo <int>(reader, "ShowMode"), IsRepeat = ModulesRepository.ConvertTo <bool>(reader, "IsRepeat"), DaysRepeat = ModulesRepository.ConvertTo <int>(reader, "DaysRepeat"), Picture = ModulesRepository.ConvertTo <string>(reader, "Picture"), SortOrder = ModulesRepository.ConvertTo <int>(reader, "SortOrder") }); }
public static List <StoreReview> GetStoreReviewsByParentId(int parentId, bool isModerated) { return(ModulesRepository.ModuleExecuteReadList <StoreReview>( "SELECT *, (SELECT Count(ID) FROM [Module].[StoreReview] WHERE [ParentID] = ParentReview.ID) as ChildsCount FROM [Module].[StoreReview] as ParentReview WHERE " + (parentId == 0 ? "[ParentID] is NULL" : "[ParentID] = " + parentId) + (isModerated ? " AND [Moderated] = 1" : string.Empty) + " ORDER BY [DateAdded]" + (parentId == 0 ? "DESC" : "ASC"), CommandType.Text, (reader) => { var review = GetStoreReviewFromReader(reader); review.ChildrenReviews = ModulesRepository.ConvertTo <int>(reader, "ChildsCount") > 0 ? GetStoreReviewsByParentId( ModulesRepository.ConvertTo <int>(reader, "ID"), isModerated) : new List <StoreReview>(); return review; } )); }