public static ProductDiscount GetByProduct(int productId, DateTime dateTime)
        {
            var action = ModulesRepository.ModuleExecuteReadOne(
                "Select Top(1) * From [Module].[" + ModuleName + "] " +
                "Where ProductId=@ProductId And ((@dateTime between DateStart and DateExpired) Or (IsRepeat = 1)) Order by SortOrder",
                CommandType.Text, GetBuyInTimeProductModelFromReader,
                new SqlParameter("@ProductId", productId),
                new SqlParameter("@dateTime", dateTime));

            if (action == null)
            {
                return(null);
            }

            if (action.IsRepeat && action.DateExpired < DateTime.Now)
            {
                action.DateExpired = GetExpireDateTime(action.DateExpired, action.DaysRepeat);
            }

            return(new ProductDiscount()
            {
                ProductId = productId,
                Discount = action.DiscountInTime,
                DateExpired = action.DateExpired
            });
        }
Example #2
0
 public static AbandonedCartTemplate GetTemplate(int id)
 {
     return
         (ModulesRepository.ModuleExecuteReadOne(
              "Select * From [Module].[AbandonedCartTemplate] Where Id = @Id", CommandType.Text,
              GetTemplateFromReader,
              new SqlParameter("@Id", id)));
 }
 public static BuyInTimeProductModel GetByShowMode(int showMode, DateTime dateTime)
 {
     return(ModulesRepository.ModuleExecuteReadOne(
                "Select Top(1) * From [Module].[" + ModuleName + "] " +
                "Where ShowMode=@ShowMode And ((@dateTime between DateStart and DateExpired) Or (IsRepeat = 1)) Order by SortOrder",
                CommandType.Text, GetBuyInTimeProductModelFromReader,
                new SqlParameter("@ShowMode", showMode),
                new SqlParameter("@dateTime", dateTime)));
 }
Example #4
0
 public static YaOrder GetOrder(int marketOrderId)
 {
     return(ModulesRepository.ModuleExecuteReadOne(
                "Select * From Module.YaMarketOrder Where MarketOrderId = @MarketOrderId", CommandType.Text,
                reader => new YaOrder()
     {
         MarketOrderId = SQLDataHelper.GetInt(reader, "MarketOrderId"),
         OrderId = SQLDataHelper.GetInt(reader, "OrderId"),
         Status = SQLDataHelper.GetString(reader, "Status"),
     },
                new SqlParameter("@MarketOrderId", marketOrderId)));
 }
Example #5
0
 public static AbandonedCart GetAbondonedCart(Guid customerId)
 {
     return
         (ModulesRepository.ModuleExecuteReadOne(
              "Select *, " +
              "(Select Count(*) From [Module].[AbandonedCartLetter] Where AbandonedCartLetter.CustomerId = OrderConfirmation.CustomerId) as SendingCount, " +
              "(Select Top(1)SendingDate From [Module].[AbandonedCartLetter] Where AbandonedCartLetter.CustomerId = OrderConfirmation.CustomerId Order By SendingDate Desc) as SendingDate " +
              "From [Order].[OrderConfirmation] Where CustomerId = @CustomerId",
              CommandType.Text,
              GetOrderConfirmationFromReader,
              new SqlParameter("@CustomerId", customerId)));
 }
Example #6
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)));
 }
 public static BuyInTimeProductModel Get(int id)
 {
     return(ModulesRepository.ModuleExecuteReadOne("Select * From [Module].[" + ModuleName + "] Where Id=@Id",
                                                   CommandType.Text, GetBuyInTimeProductModelFromReader,
                                                   new SqlParameter("@Id", id)));
 }