Try your search with a different keyword or use * as a wildcard.
using FluentMigrator;
using Nop.Core.Domain.Messages;
namespace Nop.Data.Migrations.UpgradeTo480;
[NopUpdateMigration("2023-10-30 12:00:00", "4.80", UpdateMigrationType.Data)]
public class DataMigration : Migration
{
private readonly INopDataProvider _dataProvider;
public DataMigration(INopDataProvider dataProvider)
{
_dataProvider = dataProvider;
}
///
/// Collect the UP migration expressions
///
public override void Up()
{
//#7108 New message template
if (!_dataProvider.GetTable().Any(st => string.Compare(st.Name, MessageTemplateSystemNames.ORDER_CANCELLED_VENDOR_NOTIFICATION, StringComparison.InvariantCultureIgnoreCase) == 0))
{
var eaGeneral = _dataProvider.GetTable().FirstOrDefault() ?? throw new Exception("Default email account cannot be loaded");
_dataProvider.InsertEntity(new MessageTemplate()
{
Name = MessageTemplateSystemNames.ORDER_CANCELLED_VENDOR_NOTIFICATION,
Subject = "%Store.Name%. Order #%Order.OrderNumber% cancelled",
Body = $"{Environment.NewLine}%Store.Name%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}Order #%Order.OrderNumber% has been cancelled.{Environment.NewLine}
{Environment.NewLine}Customer: %Order.CustomerFullName%,{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}Order Number: %Order.OrderNumber%{Environment.NewLine}
{Environment.NewLine}Date Ordered: %Order.CreatedOn%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}%Order.Product(s)%{Environment.NewLine}
{Environment.NewLine}",
IsActive = true,
EmailAccountId = eaGeneral.Id
});
}
//#5898
if (!_dataProvider.GetTable().Any(st => string.Compare(st.Name, MessageTemplateSystemNames.QUANTITY_BELOW_VENDOR_NOTIFICATION, StringComparison.InvariantCultureIgnoreCase) == 0))
{
var eaGeneral = _dataProvider.GetTable().FirstOrDefault() ?? throw new Exception("Default email account cannot be loaded");
_dataProvider.InsertEntity(new MessageTemplate()
{
Name = MessageTemplateSystemNames.QUANTITY_BELOW_VENDOR_NOTIFICATION,
Subject = "%Store.Name%. Quantity below notification. %Product.Name%\"",
Body = $"{Environment.NewLine}%Store.Name%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}%Product.Name% (ID: %Product.ID%) low quantity.{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}Quantity: %Product.StockQuantity%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}",
IsActive = true,
EmailAccountId = eaGeneral.Id
});
}
if (!_dataProvider.GetTable().Any(st => string.Compare(st.Name, MessageTemplateSystemNames.QUANTITY_BELOW_ATTRIBUTE_COMBINATION_VENDOR_NOTIFICATION, StringComparison.InvariantCultureIgnoreCase) == 0))
{
var eaGeneral = _dataProvider.GetTable().FirstOrDefault() ?? throw new Exception("Default email account cannot be loaded");
_dataProvider.InsertEntity(new MessageTemplate()
{
Name = MessageTemplateSystemNames.QUANTITY_BELOW_ATTRIBUTE_COMBINATION_VENDOR_NOTIFICATION,
Subject = "%Store.Name%. Quantity below notification. %Product.Name%\"",
Body = $"{Environment.NewLine}%Store.Name%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}%Product.Name% (ID: %Product.ID%) low quantity.{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}Quantity: %Product.StockQuantity%{Environment.NewLine}
{Environment.NewLine}
{Environment.NewLine}",
IsActive = true,
EmailAccountId = eaGeneral.Id
});
}
}
public override void Down()
{
//add the downgrade logic if necessary
}
}