- 89
Hi. Thanks!!
Can you show me a sample, please?
Ivan.
Can you show me a sample, please?
Ivan.
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<Reminder1Service>().As<IReminderRule>().InstancePerHttpRequest();
builder.RegisterType<Reminder2Service>().As<IReminderRule>().InstancePerHttpRequest();
}
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<Reminder1Service>().As<IReminderRule>().InstancePerLifetimeScope();
builder.RegisterType<Reminder2Service>().As<IReminderRule>().InstancePerLifetimeScope();
}
namespace Nop.Plugin.Misc.NewReminderRules
{
public class DependencyRegistrar : IDependencyRegistrar
{
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
builder.RegisterType<MakeCommentRulesService>().As<IReminderRule>().InstancePerHttpRequest();
builder.RegisterType<BuyMoreRulesService>().As<IReminderRule>().InstancePerHttpRequest();
}
public int Order
{
get { return 0; }
}
}
}
public virtual IList<CustomerReminderInfo> GetCustomerReminderInfos(TimeSpan conditionMetDataEarlierThan, TimeSpan conditionMetDateLaterThan, int storeId)
{
try
{
var customerReminderInfos = new List<CustomerReminderInfo>();
var finishedOrders = from a in _orderRepository.Table
join b in _shipmentRepository.Table on a.Id equals b.OrderId
join c in _orderItemRepository.Table on a.Id equals c.OrderId
where b.DeliveryDateUtc != null
&& a.OrderStatusId == 30
&& DateTime.Now > DbFunctions.AddMinutes(b.DeliveryDateUtc, (int)conditionMetDataEarlierThan.TotalMinutes)
&& b.DeliveryDateUtc >= DbFunctions.AddMinutes(DateTime.Now, (int)conditionMetDateLaterThan.TotalMinutes * -1)
&& _productReviewRepository.Table.Where(p => p.CustomerId == a.CustomerId && p.ProductId == c.ProductId).Count() == 0
select new { Order = a, Data = (DateTime)b.DeliveryDateUtc };
foreach (var order in finishedOrders)
{
var customerReminderInfo = new CustomerReminderInfo()
{
Customer = order.Order.Customer,
ReminderMessageId = order.Order.Id,
RuleConditionMetDate = order.Data,
Tokens = new List<Token>(),
StoreId = storeId
};
customerReminderInfos.Add(customerReminderInfo);
}
return customerReminderInfos;
}
catch (Exception ex)
{
_loggerService.InsertLog(LogLevel.Error, ex.Message, ex.StackTrace);
return null;
}
}