Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Add Audit Fields Implementation and Repository Updates (#447)

Krzysztof Pajak406799b5aa58
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs
index 9a72389e4..c05cce808 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs
@@ -32,8 +32,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
public async Task<BrandDto> Handle(AddBrandCommand request, CancellationToken cancellationToken)
{
var brand = request.Model.ToEntity();
- brand.CreatedOnUtc = DateTime.UtcNow;
- brand.UpdatedOnUtc = DateTime.UtcNow;
await _brandService.InsertBrand(brand);
request.Model.SeName = await brand.ValidateSeName(request.Model.SeName, brand.Name, true, _seoSettings, _slugService, _languageService);
brand.SeName = request.Model.SeName;
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs
index 186f8cd59..607287dbf 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs
@@ -39,8 +39,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
public async Task<CategoryDto> Handle(AddCategoryCommand request, CancellationToken cancellationToken)
{
var category = request.Model.ToEntity();
- category.CreatedOnUtc = DateTime.UtcNow;
- category.UpdatedOnUtc = DateTime.UtcNow;
await _categoryService.InsertCategory(category);
request.Model.SeName = await category.ValidateSeName(request.Model.SeName,
category.Name, true, _seoSettings, _slugService, _languageService);
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs
index 3db233741..86458067b 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs
@@ -39,8 +39,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
public async Task<CollectionDto> Handle(AddCollectionCommand request, CancellationToken cancellationToken)
{
var collection = request.Model.ToEntity();
- collection.CreatedOnUtc = DateTime.UtcNow;
- collection.UpdatedOnUtc = DateTime.UtcNow;
await _collectionService.InsertCollection(collection);
request.Model.SeName = await collection.ValidateSeName(request.Model.SeName, collection.Name, true, _seoSettings, _slugService, _languageService);
collection.SeName = request.Model.SeName;
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs
index 747473e03..825243a35 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs
@@ -40,8 +40,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
public async Task<ProductDto> Handle(AddProductCommand request, CancellationToken cancellationToken)
{
var product = request.Model.ToEntity();
- product.CreatedOnUtc = DateTime.UtcNow;
- product.UpdatedOnUtc = DateTime.UtcNow;
await _productService.InsertProduct(product);
request.Model.SeName = await product.ValidateSeName(request.Model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs
index 1ac0274af..e6a0fb1c5 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs
@@ -46,7 +46,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
var brand = await _brandService.GetBrandById(request.Model.Id);
var prevPictureId = brand.PictureId;
brand = request.Model.ToEntity(brand);
- brand.UpdatedOnUtc = DateTime.UtcNow;
request.Model.SeName = await brand.ValidateSeName(request.Model.SeName, brand.Name, true, _seoSettings, _slugService, _languageService);
brand.SeName = request.Model.SeName;
await _brandService.UpdateBrand(brand);
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs
index b581b3a4c..33d122e33 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs
@@ -46,7 +46,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
var category = await _categoryService.GetCategoryById(request.Model.Id);
var prevPictureId = category.PictureId;
category = request.Model.ToEntity(category);
- category.UpdatedOnUtc = DateTime.UtcNow;
request.Model.SeName = await category.ValidateSeName(request.Model.SeName, category.Name, true, _seoSettings, _slugService, _languageService);
category.SeName = request.Model.SeName;
await _categoryService.UpdateCategory(category);
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs
index cf0c7b1da..2bf451444 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs
@@ -46,7 +46,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
var collection = await _collectionService.GetCollectionById(request.Model.Id);
var prevPictureId = collection.PictureId;
collection = request.Model.ToEntity(collection);
- collection.UpdatedOnUtc = DateTime.UtcNow;
request.Model.SeName = await collection.ValidateSeName(request.Model.SeName, collection.Name, true, _seoSettings, _slugService, _languageService);
collection.SeName = request.Model.SeName;
await _collectionService.UpdateCollection(collection);
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs
index 9efdbe72c..9d229ad85 100644
--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs
@@ -56,7 +56,6 @@ namespace Grand.Api.Commands.Handlers.Catalog
var prevPublished = product.Published;
product = request.Model.ToEntity(product);
- product.UpdatedOnUtc = DateTime.UtcNow;
request.Model.SeName = await product.ValidateSeName(request.Model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
product.SeName = request.Model.SeName;
//search engine name
diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerAddressCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerAddressCommandHandler.cs
index 57f32f524..530900f3d 100644
--- a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerAddressCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerAddressCommandHandler.cs
@@ -18,7 +18,6 @@ namespace Grand.Api.Commands.Handlers.Customers
public async Task<AddressDto> Handle(AddCustomerAddressCommand request, CancellationToken cancellationToken)
{
var address = request.Address.ToEntity();
- address.CreatedOnUtc = DateTime.UtcNow;
address.Id = "";
await _customerService.InsertAddress(address, request.Customer.Id);
return address.ToModel();
diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs
index 912375b0e..e380f1b38 100644
--- a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs
+++ b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs
@@ -35,7 +35,6 @@ namespace Grand.Api.Commands.Handlers.Customers
public async Task<CustomerDto> Handle(AddCustomerCommand request, CancellationToken cancellationToken)
{
var customer = request.Model.ToEntity();
- customer.CreatedOnUtc = DateTime.UtcNow;
customer.LastActivityDateUtc = DateTime.UtcNow;
if (string.IsNullOrEmpty(customer.Username))
customer.Username = customer.Email;
diff --git a/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs b/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
index 8ff599c57..b20a152e1 100644
--- a/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
+++ b/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
@@ -124,8 +124,6 @@ namespace Grand.Api.DTOs.Catalog
public int DisplayOrderBrand { get; set; }
public int DisplayOrderCollection { get; set; }
public bool Published { get; set; }
- public DateTime CreatedOnUtc { get; set; }
- public DateTime UpdatedOnUtc { get; set; }
public int Sold { get; set; }
public Int64 Viewed { get; set; }
public int OnSale { get; set; }
diff --git a/src/API/Grand.Api/DTOs/Common/CurrencyDto.cs b/src/API/Grand.Api/DTOs/Common/CurrencyDto.cs
index f586a14a6..48a581f67 100644
--- a/src/API/Grand.Api/DTOs/Common/CurrencyDto.cs
+++ b/src/API/Grand.Api/DTOs/Common/CurrencyDto.cs
@@ -11,7 +11,5 @@ namespace Grand.Api.DTOs.Common
public string CustomFormatting { get; set; }
public bool Published { get; set; }
public int DisplayOrder { get; set; }
- public DateTime CreatedOnUtc { get; set; }
- public DateTime UpdatedOnUtc { get; set; }
}
}
diff --git a/src/API/Grand.Api/DTOs/Customers/AddressDto.cs b/src/API/Grand.Api/DTOs/Customers/AddressDto.cs
index 52dea9b23..ce31fa7ea 100644
--- a/src/API/Grand.Api/DTOs/Customers/AddressDto.cs
+++ b/src/API/Grand.Api/DTOs/Customers/AddressDto.cs
@@ -1,9 +1,9 @@
-using Grand.Api.Models;
-
+
namespace Grand.Api.DTOs.Customers
{
- public class AddressDto : BaseApiEntityModel
+ public class AddressDto
{
+ public string Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
@@ -19,7 +19,5 @@ namespace Grand.Api.DTOs.Customers
public string FaxNumber { get; set; }
public string Note { get; set; }
public int AddressType { get; set; }
- public DateTime CreatedOnUtc { get; set; }
-
}
}
diff --git a/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs b/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs
index 3d0843321..ca93394da 100644
--- a/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs
+++ b/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs
@@ -284,7 +284,6 @@ namespace Grand.Api.Infrastructure
addAddress.Parameter<string>(nameof(AddressDto.PhoneNumber));
addAddress.Parameter<string>(nameof(AddressDto.Note));
addAddress.Parameter<int>(nameof(AddressDto.AddressType));
- addAddress.Parameter<DateTimeOffset>(nameof(AddressDto.CreatedOnUtc));
addAddress.Parameter<string>(nameof(AddressDto.ZipPostalCode));
addAddress.Parameter<string>(nameof(AddressDto.StateProvinceId));
addAddress.Returns<AddressDto>();
@@ -304,7 +303,6 @@ namespace Grand.Api.Infrastructure
updateAddress.Parameter<string>(nameof(AddressDto.PhoneNumber));
updateAddress.Parameter<string>(nameof(AddressDto.Note));
updateAddress.Parameter<int>(nameof(AddressDto.AddressType));
- updateAddress.Parameter<DateTimeOffset>(nameof(AddressDto.CreatedOnUtc));
updateAddress.Parameter<string>(nameof(AddressDto.ZipPostalCode));
updateAddress.Parameter<string>(nameof(AddressDto.StateProvinceId));
updateAddress.Returns<AddressDto>();
diff --git a/src/API/Grand.Api/Infrastructure/Mapper/Profiles/AddressProfile.cs b/src/API/Grand.Api/Infrastructure/Mapper/Profiles/AddressProfile.cs
index 53cfd1012..64b1285b5 100644
--- a/src/API/Grand.Api/Infrastructure/Mapper/Profiles/AddressProfile.cs
+++ b/src/API/Grand.Api/Infrastructure/Mapper/Profiles/AddressProfile.cs
@@ -10,9 +10,7 @@ namespace Grand.Api.Infrastructure.Mapper.Profiles
public AddressProfile()
{
CreateMap<AddressDto, Address>()
- .ForMember(dest => dest.Attributes, mo => mo.Ignore())
- .ForMember(dest => dest.UserFields, mo => mo.Ignore());
-
+ .ForMember(dest => dest.Attributes, mo => mo.Ignore());
CreateMap<Address, AddressDto>();
}
diff --git a/src/API/Grand.Api/Models/BaseApiEntityModel.cs b/src/API/Grand.Api/Models/BaseApiEntityModel.cs
index ec479ce67..3592f2067 100644
--- a/src/API/Grand.Api/Models/BaseApiEntityModel.cs
+++ b/src/API/Grand.Api/Models/BaseApiEntityModel.cs
@@ -6,5 +6,8 @@ namespace Grand.Api.Models
{
[Key]
public string Id { get; set; }
+ public DateTime CreatedOnUtc { get; set; }
+ public DateTime? UpdatedOnUtc { get; set; }
+
}
}
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs
index 09f78ba0d..207c7a971 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/AuctionService.cs
@@ -98,8 +98,6 @@ namespace Grand.Business.Catalog.Services.Products
{
product.HighestBid = bid;
product.HighestBidder = highestBidder;
- product.UpdatedOnUtc = DateTime.UtcNow;
-
await _productRepository.UpdateAsync(product);
await _cacheBase.RemoveAsync(string.Format(CacheKey.PRODUCTS_BY_ID_KEY, product.Id));
@@ -117,7 +115,6 @@ namespace Grand.Business.Catalog.Services.Products
public virtual async Task UpdateAuctionEnded(Product product, bool ended, bool endDate = false)
{
product.AuctionEnded = ended;
- product.UpdatedOnUtc = DateTime.UtcNow;
if (endDate)
product.AvailableEndDateTimeUtc = DateTime.UtcNow;
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs
index 9a12842a7..932f60d10 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/CopyProductService.cs
@@ -147,8 +147,6 @@ namespace Grand.Business.Catalog.Services.Products
AvailableEndDateTimeUtc = product.AvailableEndDateTimeUtc,
DisplayOrder = product.DisplayOrder,
Published = isPublished,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
Locales = product.Locales,
CustomerGroups = product.CustomerGroups,
Stores = product.Stores
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs
index e2233308e..8c8a0bfd8 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductReviewService.cs
@@ -94,7 +94,6 @@ namespace Grand.Business.Catalog.Services.Products
.Set(x => x.ReviewText, productReview.ReviewText)
.Set(x => x.ReplyText, productReview.ReplyText)
.Set(x => x.Signature, productReview.Signature)
- .Set(x => x.UpdatedOnUtc, DateTime.UtcNow)
.Set(x => x.IsApproved, productReview.IsApproved)
.Set(x => x.HelpfulNoTotal, productReview.HelpfulNoTotal)
.Set(x => x.HelpfulYesTotal, productReview.HelpfulYesTotal)
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs
index 646fff2c4..a2cddf3d7 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/ProductService.cs
@@ -201,7 +201,6 @@ namespace Grand.Business.Catalog.Services.Products
.Set(x => x.BasepriceUnitId, product.BasepriceUnitId)
.Set(x => x.CallForPrice, product.CallForPrice)
.Set(x => x.CatalogPrice, product.CatalogPrice)
- .Set(x => x.CreatedOnUtc, product.CreatedOnUtc)
.Set(x => x.EnteredPrice, product.EnteredPrice)
.Set(x => x.CustomerGroups, product.CustomerGroups)
.Set(x => x.DeliveryDateId, product.DeliveryDateId)
@@ -294,11 +293,11 @@ namespace Grand.Business.Catalog.Services.Products
.Set(x => x.Weight, product.Weight)
.Set(x => x.Width, product.Width)
.Set(x => x.UserFields, product.UserFields)
- .Set(x => x.UpdatedOnUtc, DateTime.UtcNow);
+ .Set(x => x.Ticks, DateTime.UtcNow.Ticks);
await _productRepository.UpdateOneAsync(x => x.Id == product.Id, update);
- if (oldProduct.AdditionalShippingCharge != product.AdditionalShippingCharge ||
+ if (!oldProduct.AdditionalShippingCharge.Equals(product.AdditionalShippingCharge) ||
oldProduct.IsFreeShipping != product.IsFreeShipping ||
oldProduct.IsGiftVoucher != product.IsGiftVoucher ||
oldProduct.IsShipEnabled != product.IsShipEnabled ||
diff --git a/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs b/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs
index e11662d4c..8722ad443 100644
--- a/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Products/RecentlyViewedProductsService.cs
@@ -105,11 +105,10 @@ namespace Grand.Business.Catalog.Services.Products
var recentlyViewedProduct = recentlyViewedProducts.FirstOrDefault(x => x.ProductId == productId);
if (recentlyViewedProduct == null)
{
- await _recentlyViewedProducts.InsertAsync(new RecentlyViewedProduct() { CustomerId = customerId, ProductId = productId, CreatedOnUtc = DateTime.UtcNow });
+ await _recentlyViewedProducts.InsertAsync(new RecentlyViewedProduct() { CustomerId = customerId, ProductId = productId });
}
else
{
- recentlyViewedProduct.CreatedOnUtc = DateTime.UtcNow;
await _recentlyViewedProducts.UpdateAsync(recentlyViewedProduct);
}
var maxProducts = _catalogSettings.RecentlyViewedProductsNumber;
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderCommandHandler.cs
index af5911e6f..b85b1af4e 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderCommandHandler.cs
@@ -73,7 +73,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
Note = "Order has been cancelled",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderItemCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderItemCommandHandler.cs
index 9f5b54917..cbf963211 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderItemCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/CancelOrderItemCommandHandler.cs
@@ -55,7 +55,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await _orderService.InsertOrderNote(new OrderNote {
Note = $"Order item has been canceled - {product.Name} - Qty: {request.OrderItem.OpenQty}",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderCommandHandler.cs
index 93343327a..fdf39b87e 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderCommandHandler.cs
@@ -92,7 +92,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
Note = "Order has been deleted",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderItemCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderItemCommandHandler.cs
index 4494d522c..87e353fd3 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderItemCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/DeleteOrderItemCommandHandler.cs
@@ -79,7 +79,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await _orderService.InsertOrderNote(new OrderNote {
Note = $"Order item has been deleted - {product.Name}",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
@@ -87,9 +86,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
//delete item
request.Order.OrderItems.Remove(request.OrderItem);
-
- await _orderService.DeleteOrderItem(request.OrderItem);
-
+
request.Order.OrderSubtotalExclTax -= request.OrderItem.PriceExclTax;
request.Order.OrderSubtotalInclTax -= request.OrderItem.PriceInclTax;
request.Order.OrderTax -= request.OrderItem.PriceInclTax - request.OrderItem.PriceExclTax;
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/InsertOrderItemCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/InsertOrderItemCommandHandler.cs
index 281194a6e..a7c8891cd 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/InsertOrderItemCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/InsertOrderItemCommandHandler.cs
@@ -69,7 +69,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
Note = "A new order item has been added",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
@@ -92,8 +91,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
//SenderName = senderName,
//SenderEmail = senderEmail,
//Message = giftVoucherMessage,
- IsRecipientNotified = false,
- CreatedOnUtc = DateTime.UtcNow
+ IsRecipientNotified = false
};
await _giftVoucherService.InsertGiftVoucher(gc);
}
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MarkAsPaidCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MarkAsPaidCommandHandler.cs
index 4d5f956b6..bc5c8e1a9 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MarkAsPaidCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MarkAsPaidCommandHandler.cs
@@ -53,7 +53,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
{
Note = "Order has been marked as paid",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MaxOrderNumberCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MaxOrderNumberCommandHandler.cs
index a2f077e8f..8ed74f9b1 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MaxOrderNumberCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/MaxOrderNumberCommandHandler.cs
@@ -23,7 +23,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
var max = count > 0 ? _orderRepository.Table.Max(x => x.OrderNumber) : 0;
if (!request.OrderNumber.HasValue) return max;
if (request.OrderNumber.Value <= max) return max;
- await _orderRepository.InsertAsync(new Order() { OrderNumber = request.OrderNumber.Value, Deleted = true, CreatedOnUtc = DateTime.UtcNow });
+ await _orderRepository.InsertAsync(new Order() { OrderNumber = request.OrderNumber.Value, Deleted = true });
max = request.OrderNumber.Value;
return max;
}
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/OrderStatusCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/OrderStatusCommandHandler.cs
index 3d4a6faba..92e3da37b 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/OrderStatusCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/OrderStatusCommandHandler.cs
@@ -56,8 +56,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await _orderService.InsertOrderNote(new OrderNote {
Note = $"Order status has been changed to {request.Os.ToString()}",
DisplayToCustomer = false,
- OrderId = request.Order.Id,
- CreatedOnUtc = DateTime.UtcNow
+ OrderId = request.Order.Id
});
var customer = await _customerService.GetCustomerById(request.Order.CustomerId);
@@ -103,7 +102,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await _orderService.InsertOrderNote(new OrderNote {
Note = "\"Order cancelled\" by customer.",
DisplayToCustomer = true,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
}
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
index 8909501ca..7020c4298 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs
@@ -268,7 +268,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
private async Task<PaymentTransaction> PreparePaymentTransaction(PlaceOrderContainer details)
{
var update = false;
- PaymentTransaction paymentTransaction = new PaymentTransaction { CreatedOnUtc = DateTime.UtcNow };
+ PaymentTransaction paymentTransaction = new PaymentTransaction();
var paymentTransactionId = details.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.PaymentTransaction, _workContext.CurrentStore.Id);
if (!string.IsNullOrEmpty(paymentTransactionId))
{
@@ -276,10 +276,9 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
if (paymentTransaction != null)
{
update = true;
- paymentTransaction.UpdatedOnUtc = DateTime.UtcNow;
}
else
- paymentTransaction = new PaymentTransaction { CreatedOnUtc = DateTime.UtcNow };
+ paymentTransaction = new PaymentTransaction();
}
paymentTransaction.TransactionStatus = TransactionStatus.Pending;
@@ -725,8 +724,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
SenderEmail = giftVoucherSenderEmail,
Message = giftVoucherMessage,
IsRecipientNotified = false,
- StoreId = _orderSettings.GiftVouchers_Assign_StoreId ? _workContext.CurrentStore.Id : string.Empty,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = _orderSettings.GiftVouchers_Assign_StoreId ? _workContext.CurrentStore.Id : string.Empty
};
await _giftVoucherService.InsertGiftVoucher(gc);
}
@@ -855,8 +853,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
DiscountId = discount.DiscountId,
CouponCode = discount.CouponCode,
OrderId = order.Id,
- CustomerId = order.CustomerId,
- CreatedOnUtc = DateTime.UtcNow
+ CustomerId = order.CustomerId
};
await _discountService.InsertDiscountUsageHistory(duh);
}
@@ -953,8 +950,7 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
IsRecurring = details.IsRecurring,
RecurringCycleLength = details.RecurringCycleLength,
RecurringCyclePeriodId = details.RecurringCyclePeriodId,
- RecurringTotalCycles = details.RecurringTotalCycles,
- CreatedOnUtc = DateTime.UtcNow
+ RecurringTotalCycles = details.RecurringTotalCycles
};
foreach (var item in details.Taxes)
@@ -1055,7 +1051,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
Note =
$"Order placed by a store owner ('{originalCustomerIfImpersonated.Email}'. ID = {originalCustomerIfImpersonated.Id}) impersonating the customer.",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
}
@@ -1064,7 +1059,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await orderService.InsertOrderNote(new OrderNote {
Note = "Order placed",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/UpdateOrderItemCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/UpdateOrderItemCommandHandler.cs
index 91da8ea88..60ecc5a70 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/UpdateOrderItemCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/UpdateOrderItemCommandHandler.cs
@@ -79,7 +79,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Orders
await _orderService.InsertOrderNote(new OrderNote {
Note = "Order item has been edited",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = request.Order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/DeliveryCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/DeliveryCommandHandler.cs
index 94ca419c8..89a1d717f 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/DeliveryCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/DeliveryCommandHandler.cs
@@ -58,7 +58,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Shipping
await _orderService.InsertOrderNote(new OrderNote {
Note = $"Shipment #{request.Shipment.ShipmentNumber} has been delivered",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
if (request.NotifyCustomer)
diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/ShipCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/ShipCommandHandler.cs
index 93e42f631..8c2063154 100644
--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/ShipCommandHandler.cs
+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Shipping/ShipCommandHandler.cs
@@ -58,7 +58,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.Shipping
await _orderService.InsertOrderNote(new OrderNote {
Note = $"Shipment #{request.Shipment.ShipmentNumber} has been sent",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs
index 560ff1007..d0310c6d3 100644
--- a/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Orders/LoyaltyPointsService.cs
@@ -83,8 +83,7 @@ namespace Grand.Business.Checkout.Services.Orders
PointsBalance = await GetLoyaltyPointsBalance(customerId, storeId) + points,
UsedAmount = usedAmount,
Message = message,
- StoreId = storeId,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = storeId
};
await _rphRepository.InsertAsync(loyaltyPointsHistory);
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs
index 39ae6affb..079fe54d0 100644
--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderService.cs
@@ -262,23 +262,6 @@ namespace Grand.Business.Checkout.Services.Orders
return Task.FromResult(query.FirstOrDefault());
}
- /// <summary>
- /// Delete an order item
- /// </summary>
- /// <param name="orderItem">The order item</param>
- public virtual async Task DeleteOrderItem(OrderItem orderItem)
- {
- if (orderItem == null)
- throw new ArgumentNullException(nameof(orderItem));
-
- var order = await GetOrderByOrderItemId(orderItem.Id);
-
- await _orderRepository.PullFilter(order.Id, x => x.OrderItems, x => x.Id == orderItem.Id);
-
- //event notification
- await _mediator.EntityDeleted(orderItem);
- }
-
#endregion
#region Orders notes
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs
index eb34f966b..c3346d59b 100644
--- a/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Orders/ShoppingCartService.cs
@@ -222,7 +222,6 @@ namespace Grand.Business.Checkout.Services.Orders
if (update) shoppingCartItem.Quantity += quantity;
else {
- DateTime now = DateTime.UtcNow;
shoppingCartItem = new ShoppingCartItem {
ShoppingCartTypeId = shoppingCartType,
StoreId = storeId,
@@ -238,8 +237,7 @@ namespace Grand.Business.Checkout.Services.Orders
IsShipEnabled = product.IsShipEnabled,
IsTaxExempt = product.IsTaxExempt,
IsGiftVoucher = product.IsGiftVoucher,
- CreatedOnUtc = now,
- UpdatedOnUtc = now,
+ CreatedOnUtc = DateTime.UtcNow,
ReservationId = reservationId,
Parameter = parameter,
Duration = duration
diff --git a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
index b0fcf0cf5..b38f05499 100644
--- a/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
+++ b/src/Business/Grand.Business.Cms/Services/KnowledgebaseService.cs
@@ -68,7 +68,6 @@ namespace Grand.Business.Cms.Services
/// <param name="kc"></param>
public virtual async Task UpdateKnowledgebaseCategory(KnowledgebaseCategory kc)
{
- kc.UpdatedOnUtc = DateTime.UtcNow;
await _knowledgebaseCategoryRepository.UpdateAsync(kc);
await _cacheBase.RemoveByPrefix(CacheKey.ARTICLES_PATTERN_KEY);
await _cacheBase.RemoveByPrefix(CacheKey.KNOWLEDGEBASE_CATEGORIES_PATTERN_KEY);
@@ -130,9 +129,6 @@ namespace Grand.Business.Cms.Services
/// <param name="kc"></param>
public virtual async Task InsertKnowledgebaseCategory(KnowledgebaseCategory kc)
{
- kc.CreatedOnUtc = DateTime.UtcNow;
- kc.UpdatedOnUtc = DateTime.UtcNow;
-
await _knowledgebaseCategoryRepository.InsertAsync(kc);
await _cacheBase.RemoveByPrefix(CacheKey.ARTICLES_PATTERN_KEY);
@@ -195,8 +191,6 @@ namespace Grand.Business.Cms.Services
/// <param name="ka"></param>
public virtual async Task InsertKnowledgebaseArticle(KnowledgebaseArticle ka)
{
- ka.CreatedOnUtc = DateTime.UtcNow;
- ka.UpdatedOnUtc = DateTime.UtcNow;
await _knowledgebaseArticleRepository.InsertAsync(ka);
await _cacheBase.RemoveByPrefix(CacheKey.ARTICLES_PATTERN_KEY);
await _cacheBase.RemoveByPrefix(CacheKey.KNOWLEDGEBASE_CATEGORIES_PATTERN_KEY);
@@ -209,7 +203,6 @@ namespace Grand.Business.Cms.Services
/// <param name="ka"></param>
public virtual async Task UpdateKnowledgebaseArticle(KnowledgebaseArticle ka)
{
- ka.UpdatedOnUtc = DateTime.UtcNow;
await _knowledgebaseArticleRepository.UpdateAsync(ka);
await _cacheBase.RemoveByPrefix(CacheKey.ARTICLES_PATTERN_KEY);
await _cacheBase.RemoveByPrefix(CacheKey.KNOWLEDGEBASE_CATEGORIES_PATTERN_KEY);
diff --git a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs
index 5f420ebc7..0b115c6fd 100644
--- a/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs
+++ b/src/Business/Grand.Business.Common/Services/Directory/HistoryService.cs
@@ -23,7 +23,6 @@ namespace Grand.Business.Common.Services.Directory
throw new ArgumentNullException(nameof(entity));
var history = new HistoryObject
{
- CreatedOnUtc = DateTime.UtcNow,
Object = entity
};
await _historyRepository.InsertAsync(history);
diff --git a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs
index 65275227d..1fb6284d8 100644
--- a/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs
+++ b/src/Business/Grand.Business.Common/Services/Localization/TranslationService.cs
@@ -250,8 +250,6 @@ namespace Grand.Business.Common.Services.Localization
if (string.IsNullOrEmpty(xml))
return;
- var translateResources = new List<TranslationResource>();
-
var xmlDoc = LanguageXmlDocument(xml);
var nodes = xmlDoc.SelectNodes(@"//Language/Resource");
@@ -284,19 +282,16 @@ namespace Grand.Business.Common.Services.Localization
else
{
_ = Enum.TryParse(area, out TranslationResourceArea areaEnum);
-
- translateResources.Add(new TranslationResource {
+ await _translationRepository.InsertAsync(new TranslationResource {
LanguageId = language.Id,
Name = name.ToLowerInvariant(),
Value = value,
- Area = areaEnum
+ Area = areaEnum,
+ CreatedBy = _workContext.CurrentCustomer.Email
});
}
}
- if (translateResources.Any())
- await _translationRepository.InsertManyAsync(translateResources);
-
//clear cache
await _cacheBase.RemoveByPrefix(CacheKey.TRANSLATERESOURCES_PATTERN_KEY);
}
@@ -334,17 +329,15 @@ namespace Grand.Business.Common.Services.Localization
_ = Enum.TryParse(area, out TranslationResourceArea areaEnum);
- translateResources.Add(
- new TranslationResource {
- LanguageId = language.Id,
- Name = name.ToLowerInvariant(),
- Value = value,
- Area = areaEnum
- });
+ await _translationRepository.InsertAsync(new TranslationResource {
+ LanguageId = language.Id,
+ Name = name.ToLowerInvariant(),
+ Value = value,
+ Area = areaEnum,
+ CreatedBy = "System"
+ });
}
- await _translationRepository.InsertManyAsync(translateResources);
-
//clear cache
await _cacheBase.RemoveByPrefix(CacheKey.TRANSLATERESOURCES_PATTERN_KEY);
}
diff --git a/src/Business/Grand.Business.Core/Interfaces/Checkout/Orders/IOrderService.cs b/src/Business/Grand.Business.Core/Interfaces/Checkout/Orders/IOrderService.cs
index f289944c6..a38d735ea 100644
--- a/src/Business/Grand.Business.Core/Interfaces/Checkout/Orders/IOrderService.cs
+++ b/src/Business/Grand.Business.Core/Interfaces/Checkout/Orders/IOrderService.cs
@@ -112,12 +112,6 @@ namespace Grand.Business.Core.Interfaces.Checkout.Orders
/// <returns>Order item</returns>
Task<OrderItem> GetOrderItemByGuid(Guid orderItemGuid);
- /// <summary>
- /// Delete an order item
- /// </summary>
- /// <param name="orderItem">The order item</param>
- Task DeleteOrderItem(OrderItem orderItem);
-
#endregion
#region Order notes
diff --git a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs
index 384a5c05e..80a0549ff 100644
--- a/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs
+++ b/src/Business/Grand.Business.Customers/Services/CustomerHistoryPasswordService.cs
@@ -32,8 +32,7 @@ namespace Grand.Business.Customers.Services
Password = customer.Password,
PasswordFormatId = customer.PasswordFormatId,
PasswordSalt = customer.PasswordSalt,
- CustomerId = customer.Id,
- CreatedOnUtc = DateTime.UtcNow
+ CustomerId = customer.Id
};
await _customerHistoryPasswordProductRepository.InsertAsync(chp);
diff --git a/src/Business/Grand.Business.Customers/Services/CustomerService.cs b/src/Business/Grand.Business.Customers/Services/CustomerService.cs
index 247db9023..a90f166eb 100644
--- a/src/Business/Grand.Business.Customers/Services/CustomerService.cs
+++ b/src/Business/Grand.Business.Customers/Services/CustomerService.cs
@@ -250,7 +250,6 @@ namespace Grand.Business.Customers.Services
CustomerGuid = Guid.NewGuid(),
Active = true,
StoreId = store.Id,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
//add to 'Guests' group
diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
index 919be9828..591d91a15 100644
--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
@@ -334,7 +334,6 @@ namespace Grand.Business.Marketing.Services.Campaigns
email.To = subscription.Email;
email.Subject = subject;
email.Body = body;
- email.CreatedOnUtc = DateTime.UtcNow;
email.EmailAccountId = emailAccount.Id;
email.Reference = Domain.Common.Reference.Campaign;
email.ObjectId = campaign.Id;
diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
index b4f523a03..75a995089 100644
--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
@@ -368,7 +368,6 @@ namespace Grand.Business.Marketing.Services.Newsletters
{
subscription = new NewsLetterSubscription {
Active = isActive,
- CreatedOnUtc = DateTime.UtcNow,
Email = email,
StoreId = storeId,
NewsLetterSubscriptionGuid = Guid.NewGuid()
diff --git a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/InsertContactUsCommandHandler.cs b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/InsertContactUsCommandHandler.cs
index d11707ea4..2f5095dcd 100644
--- a/src/Business/Grand.Business.Messages/Commands/Handlers/Common/InsertContactUsCommandHandler.cs
+++ b/src/Business/Grand.Business.Messages/Commands/Handlers/Common/InsertContactUsCommandHandler.cs
@@ -18,7 +18,6 @@ namespace Grand.Business.Messages.Commands.Handlers.Common
public async Task<bool> Handle(InsertContactUsCommand request, CancellationToken cancellationToken)
{
var contactus = new ContactUs {
- CreatedOnUtc = DateTime.UtcNow,
CustomerId = request.CustomerId,
StoreId = request.StoreId,
VendorId = request.VendorId,
diff --git a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
index f1e11ae64..aec372e61 100644
--- a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
+++ b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
@@ -1966,7 +1966,6 @@ namespace Grand.Business.Messages.Services
email.AttachmentFilePath = attachmentFilePath;
email.AttachmentFileName = attachmentFileName;
email.AttachedDownloads = attachments;
- email.CreatedOnUtc = DateTime.UtcNow;
email.EmailAccountId = emailAccount.Id;
email.DontSendBeforeDateUtc = !messageTemplate.DelayBeforeSend.HasValue ? null
: (DateTime?)(DateTime.UtcNow + TimeSpan.FromHours(messageTemplate.DelayPeriodId.ToHours(messageTemplate.DelayBeforeSend.Value)));
diff --git a/src/Business/Grand.Business.System/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs b/src/Business/Grand.Business.System/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
index 937cc6869..d25021284 100644
--- a/src/Business/Grand.Business.System/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
+++ b/src/Business/Grand.Business.System/Commands/Handlers/Common/GetSitemapXMLCommandHandler.cs
@@ -248,7 +248,7 @@ namespace Grand.Business.System.Commands.Handlers.Common
imageurl = await _pictureService.GetPictureUrl(category.PictureId, showDefaultPicture: false, storeLocation: storeLocation);
}
}
- categories.Add(new SitemapUrl(url, imageurl, UpdateFrequency.Weekly, category.UpdatedOnUtc));
+ categories.Add(new SitemapUrl(url, imageurl, UpdateFrequency.Weekly, category.UpdatedOnUtc.HasValue ? category.UpdatedOnUtc.Value : category.CreatedOnUtc));
categories.AddRange(await GetCategoryUrls(category.Id, language));
}
return categories;
@@ -275,7 +275,7 @@ namespace Grand.Business.System.Commands.Handlers.Common
imageUrl = await _pictureService.GetPictureUrl(brand.PictureId, showDefaultPicture: false, storeLocation: storeLocation);
}
}
- brandUrls.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly, brand.UpdatedOnUtc));
+ brandUrls.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly, brand.UpdatedOnUtc.HasValue ? brand.UpdatedOnUtc.Value : brand.CreatedOnUtc));
}
return brandUrls;
}
@@ -302,7 +302,8 @@ namespace Grand.Business.System.Commands.Handlers.Common
imageUrl = await _pictureService.GetPictureUrl(product.ProductPictures.FirstOrDefault()?.PictureId, showDefaultPicture: false, storeLocation: storeLocation);
}
}
- products.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly, product.UpdatedOnUtc));
+ products.Add(new SitemapUrl(url, imageUrl, UpdateFrequency.Weekly, product.UpdatedOnUtc.HasValue ? product.UpdatedOnUtc.Value : product.CreatedOnUtc));
+
}
return products;
diff --git a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/UpdateExchangeRateScheduleTask.cs b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/UpdateExchangeRateScheduleTask.cs
index 61fcec802..d8935b609 100644
--- a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/UpdateExchangeRateScheduleTask.cs
+++ b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/UpdateExchangeRateScheduleTask.cs
@@ -39,7 +39,6 @@ namespace Grand.Business.System.Services.BackgroundServices.ScheduleTasks
var currency = await _currencyService.GetCurrencyByCode(exchangeRate.CurrencyCode);
if (currency == null) continue;
currency.Rate = exchangeRate.Rate;
- currency.UpdatedOnUtc = DateTime.UtcNow;
await _currencyService.UpdateCurrency(currency);
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataAffiliates.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataAffiliates.cs
index e62a9b6f8..49800806f 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataAffiliates.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataAffiliates.cs
@@ -19,8 +19,7 @@ namespace Grand.Business.System.Services.Installation
ZipPostalCode = "10021",
PhoneNumber = "123456789",
StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "New York")?.Id,
- CountryId = country.Id,
- CreatedOnUtc = DateTime.UtcNow
+ CountryId = country?.Id,
};
var affilate = new Affiliate
{
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataBlogPosts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataBlogPosts.cs
index fd405b184..812a63b20 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataBlogPosts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataBlogPosts.cs
@@ -16,8 +16,7 @@ namespace Grand.Business.System.Services.Installation
Title = "How GrandNode became the real open-source e-Commerce platform?",
BodyOverview = "<p>There are many e-commerce solutions on the market. Is everyone open-source? No, and even if they say yes, it may turn out to be a lie. GrandNode is a true open-source based on .NET Core and MongoDB. No hidden license fees, no additional licensing conditions. Pure open-source and GPL-3 license.</p>",
Body = "<p>There are many e-commerce solutions on the market. Is every open-source? No, and even if they say yes, it may turn out to be a lie. GrandNode is a true open-source platform based on .NET Core and MongoDB. No hidden license fees, no additional licensing conditions. Pure open-source and GPL-3 license.</p><p>An open-source platform shouldn't block your development. Forcing the leaving of information about the platform, paid licenses, obtaining paid license keys is an artificial invention that makes the platform paid and complicated.</p>",
- Tags = "e-commerce, blog, moey",
- CreatedOnUtc = DateTime.UtcNow
+ Tags = "e-commerce, blog, moey"
},
new BlogPost
{
@@ -25,11 +24,11 @@ namespace Grand.Business.System.Services.Installation
Title = "Open-source e-commerce platform GrandNode",
BodyOverview = "<p>GrandNode is one of a kind open-source e-commerce platform. Thanks to most advanced ASP.NET Core framework and out of the box set of features it makes a perfect fit for multiple e-business models.</p>",
Body = "<p>Meet the flexible, the most versatile open-source e-commerce platform on the market. Use GrandNode and its ready-to-use integrations to sell everywhere with a single platform. GrandNode guarantees functionalities for now and for the future. We ensure both, the base needs of each e-commerce, and future features needed for expansion. GrandNode is one platform that suits various business models. It can successfully empower traditional B2C & B2B stores, helping local brands expand globally. Our solution supports booking processes, facilitates the management of the availability calendar and even enables the sale of online courses.</p>",
- Tags = "e-commerce, grandnode, sample tag, money",
- CreatedOnUtc = DateTime.UtcNow.AddSeconds(1)
+ Tags = "e-commerce, grandnode, sample tag, money"
}
};
- await _blogPostRepository.InsertAsync(blogPosts);
+
+ blogPosts.ForEach(x=>_blogPostRepository.Insert(x));
//search engine names
foreach (var blogPost in blogPosts)
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataBrandLayouts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataBrandLayouts.cs
index 9623c730c..b45fb9898 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataBrandLayouts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataBrandLayouts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallBrandLayouts()
+ protected virtual Task InstallBrandLayouts()
{
var brandLayouts = new List<BrandLayout>
{
@@ -15,7 +15,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 1
}
};
- await _brandLayoutRepository.InsertAsync(brandLayouts);
+ brandLayouts.ForEach(x=>_brandLayoutRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataBrands.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataBrands.cs
index 85afeb327..3d124f8e4 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataBrands.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataBrands.cs
@@ -26,9 +26,7 @@ namespace Grand.Business.System.Services.Installation
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
- DisplayOrder = 1,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 1
};
brandXiaomi.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_xiaomi.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Xiaomi"), "", "", false, Domain.Common.Reference.Brand, brandXiaomi.Id)).Id;
await _brandRepository.InsertAsync(brandXiaomi);
@@ -42,9 +40,7 @@ namespace Grand.Business.System.Services.Installation
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
- DisplayOrder = 5,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 5
};
brandDell.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_dell.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Dell"), "", "", false, Domain.Common.Reference.Brand, brandDell.Id)).Id;
@@ -59,9 +55,7 @@ namespace Grand.Business.System.Services.Installation
AllowCustomersToSelectPageSize = true,
PageSizeOptions = "6, 3, 9",
Published = true,
- DisplayOrder = 5,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 5
};
brandAdidas.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "brand_adidas.jpg"), "image/pjpeg", pictureService.GetPictureSeName("Adidas"), "", "", false, Domain.Common.Reference.Brand, brandAdidas.Id)).Id;
await _brandRepository.InsertAsync(brandAdidas);
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCategories.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCategories.cs
index 1ebcc628b..8d785750b 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCategories.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCategories.cs
@@ -35,9 +35,7 @@ namespace Grand.Business.System.Services.Installation
Published = true,
Flag = "New",
FlagStyle = "badge-danger",
- DisplayOrder = 100,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 100
};
categoryComputers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_computers.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Computers"), reference: Domain.Common.Reference.Category, objectId: categoryComputers.Id)).Id;
allCategories.Add(categoryComputers);
@@ -52,9 +50,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryComputers.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryComputers.DisplayOrder + 1,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryComputers.DisplayOrder + 1
};
categoryTablets.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_tablets.jpg"), "image/jpeg", pictureService.GetPictureSeName("Tablets"), reference: Domain.Common.Reference.Category, objectId: categoryTablets.Id)).Id;
allCategories.Add(categoryTablets);
@@ -69,9 +65,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryComputers.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryComputers.DisplayOrder + 2,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryComputers.DisplayOrder + 2
};
categoryNotebooks.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_notebooks.jpg"), "image/jpeg", pictureService.GetPictureSeName("Notebooks"), reference: Domain.Common.Reference.Category, objectId: categoryNotebooks.Id)).Id;
allCategories.Add(categoryNotebooks);
@@ -86,9 +80,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryComputers.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryComputers.DisplayOrder + 3,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryComputers.DisplayOrder + 3
};
categorySmartwatches.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_smartwatches.jpg"), "image/jpeg", pictureService.GetPictureSeName("Smartwatches"), reference: Domain.Common.Reference.Category, objectId: categorySmartwatches.Id)).Id;
allCategories.Add(categorySmartwatches);
@@ -104,9 +96,7 @@ namespace Grand.Business.System.Services.Installation
IncludeInMenu = true,
Published = true,
ShowOnHomePage = false,
- DisplayOrder = 200,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 200
};
categoryElectronics.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_electronics.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Electronics"), reference: Domain.Common.Reference.Category, objectId: categoryElectronics.Id)).Id;
allCategories.Add(categoryElectronics);
@@ -121,9 +111,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryElectronics.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryElectronics.DisplayOrder + 1,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryElectronics.DisplayOrder + 1
};
categoryDisplay.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_display.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Display"), reference: Domain.Common.Reference.Category, objectId: categoryDisplay.Id)).Id;
allCategories.Add(categoryDisplay);
@@ -138,9 +126,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryElectronics.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryElectronics.DisplayOrder + 2,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryElectronics.DisplayOrder + 2
};
categorySmartphones.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_smartphones.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Smartphones"), reference: Domain.Common.Reference.Category, objectId: categorySmartphones.Id)).Id;
allCategories.Add(categorySmartphones);
@@ -156,9 +142,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categoryElectronics.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categoryElectronics.DisplayOrder + 3,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categoryElectronics.DisplayOrder + 3
};
categoryOthers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_accessories.jpg"), "image/jpeg", pictureService.GetPictureSeName("SmAccessoriesartphones"), reference: Domain.Common.Reference.Category, objectId: categoryOthers.Id)).Id;
@@ -175,9 +159,7 @@ namespace Grand.Business.System.Services.Installation
IncludeInMenu = true,
Published = true,
ShowOnHomePage = true,
- DisplayOrder = 300,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 300
};
categorySport.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Sport"), reference: Domain.Common.Reference.Category, objectId: categorySport.Id)).Id;
allCategories.Add(categorySport);
@@ -192,9 +174,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categorySport.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categorySport.DisplayOrder + 1,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categorySport.DisplayOrder + 1
};
categoryShoes.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_shoes.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Shoes"), reference: Domain.Common.Reference.Category, objectId: categoryShoes.Id)).Id;
allCategories.Add(categoryShoes);
@@ -209,9 +189,7 @@ namespace Grand.Business.System.Services.Installation
ParentCategoryId = categorySport.Id,
IncludeInMenu = true,
Published = true,
- DisplayOrder = categorySport.DisplayOrder + 2,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categorySport.DisplayOrder + 2
};
categoryApparel.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_sport.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Apparel"), reference: Domain.Common.Reference.Category, objectId: categoryApparel.Id)).Id;
@@ -227,9 +205,7 @@ namespace Grand.Business.System.Services.Installation
PageSizeOptions = "6, 3, 9",
IncludeInMenu = true,
Published = true,
- DisplayOrder = categorySport.DisplayOrder + 3,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = categorySport.DisplayOrder + 3
};
categoryBalls.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_balls.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Balls"), reference: Domain.Common.Reference.Category, objectId: categoryBalls.Id)).Id;
allCategories.Add(categoryBalls);
@@ -245,9 +221,7 @@ namespace Grand.Business.System.Services.Installation
IncludeInMenu = true,
Published = true,
ShowOnHomePage = false,
- DisplayOrder = 400,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 400
};
categoryDigitalDownloads.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_digital_downloads.jpeg"), "image/jpeg", pictureService.GetPictureSeName("Digital downloads"), reference: Domain.Common.Reference.Category, objectId: categoryDigitalDownloads.Id)).Id;
allCategories.Add(categoryDigitalDownloads);
@@ -267,9 +241,7 @@ namespace Grand.Business.System.Services.Installation
ShowOnHomePage = true,
DisplayOrder = 500,
Flag = "Promo!",
- FlagStyle = "bg-success",
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ FlagStyle = "bg-success"
};
categoryLego.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_lego.jpeg"), "image/jpeg", pictureService.GetPictureSeName(categoryLego.Name), reference: Domain.Common.Reference.Category, objectId: categoryLego.Id)).Id;
allCategories.Add(categoryLego);
@@ -284,14 +256,13 @@ namespace Grand.Business.System.Services.Installation
PageSizeOptions = "6, 3, 9",
IncludeInMenu = true,
Published = true,
- DisplayOrder = 600,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 600
};
categoryGiftVouchers.PictureId = (await pictureService.InsertPicture(File.ReadAllBytes(sampleImagesPath + "category_gift_cards.jpeg"), "image/jpeg", pictureService.GetPictureSeName(categoryGiftVouchers.Name), reference: Domain.Common.Reference.Category, objectId: categoryGiftVouchers.Id)).Id;
allCategories.Add(categoryGiftVouchers);
- await _categoryRepository.InsertAsync(allCategories);
+ allCategories.ForEach(x=>_categoryRepository.Insert(x));
+
//search engine names
foreach (var category in allCategories)
{
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCategoryLayouts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCategoryLayouts.cs
index 3a5b0558c..047af016b 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCategoryLayouts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCategoryLayouts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallCategoryLayouts()
+ protected virtual Task InstallCategoryLayouts()
{
var categoryLayouts = new List<CategoryLayout>
{
@@ -15,7 +15,9 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 1
}
};
- await _categoryLayoutRepository.InsertAsync(categoryLayouts);
+ categoryLayouts.ForEach(x=>_categoryLayoutRepository.Insert(x));
+ return Task.CompletedTask;
+
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCollectionLayouts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCollectionLayouts.cs
index 34242b5d4..19c021587 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCollectionLayouts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCollectionLayouts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallCollectionLayouts()
+ protected virtual Task InstallCollectionLayouts()
{
var collectionLayouts = new List<CollectionLayout>
{
@@ -15,7 +15,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 1
}
};
- await _collectionLayoutRepository.InsertAsync(collectionLayouts);
+ collectionLayouts.ForEach(x=>_collectionLayoutRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCountriesAndStates.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCountriesAndStates.cs
index 25d1c9857..8b24bba13 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCountriesAndStates.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCountriesAndStates.cs
@@ -455,8 +455,6 @@ namespace Grand.Business.System.Services.Installation
});
await _countryRepository.InsertAsync(cUsa);
-
-
var cCanada = new Country
{
Name = "Canada",
@@ -3482,7 +3480,7 @@ namespace Grand.Business.System.Services.Installation
Published = true
}
};
- await _countryRepository.InsertAsync(countries);
+ countries.ForEach(x=>_countryRepository.Insert(x));
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCurrencies.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCurrencies.cs
index ab9306845..bf8bb9747 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCurrencies.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCurrencies.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallCurrencies()
+ protected virtual Task InstallCurrencies()
{
var currencies = new List<Currency>
{
@@ -19,9 +19,7 @@ namespace Grand.Business.System.Services.Installation
Published = true,
DisplayOrder = 1,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.ToEven,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.ToEven
},
new Currency
{
@@ -34,9 +32,7 @@ namespace Grand.Business.System.Services.Installation
Published = true,
DisplayOrder = 2,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.AwayFromZero,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.AwayFromZero
},
new Currency
{
@@ -49,9 +45,7 @@ namespace Grand.Business.System.Services.Installation
Published = false,
DisplayOrder = 3,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.AwayFromZero,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.AwayFromZero
},
new Currency
{
@@ -64,9 +58,7 @@ namespace Grand.Business.System.Services.Installation
Published = false,
DisplayOrder = 4,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.ToEven,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.ToEven
},
new Currency
{
@@ -79,9 +71,7 @@ namespace Grand.Business.System.Services.Installation
Published = false,
DisplayOrder = 5,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.ToEven,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.ToEven
},
new Currency
{
@@ -94,12 +84,11 @@ namespace Grand.Business.System.Services.Installation
Published = false,
DisplayOrder = 6,
RoundingTypeId = RoundingType.Rounding001,
- MidpointRoundId = MidpointRounding.AwayFromZero,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ MidpointRoundId = MidpointRounding.AwayFromZero
}
};
- await _currencyRepository.InsertAsync(currencies);
+ currencies.ForEach(x=>_currencyRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataCustomersAndUsers.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataCustomersAndUsers.cs
index beaadf820..b9ed7e173 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataCustomersAndUsers.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataCustomersAndUsers.cs
@@ -71,7 +71,6 @@ namespace Grand.Business.System.Services.Installation
PasswordFormatId = PasswordFormat.Clear,
PasswordSalt = "",
Active = true,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow,
PasswordChangeDateUtc = DateTime.UtcNow
};
@@ -89,8 +88,7 @@ namespace Grand.Business.System.Services.Installation
City = "New York",
StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "New York")?.Id,
CountryId = country?.Id,
- ZipPostalCode = "10021",
- CreatedOnUtc = DateTime.UtcNow
+ ZipPostalCode = "10021"
};
adminUser.Addresses.Add(defaultAdminUserAddress);
adminUser.BillingAddress = defaultAdminUserAddress;
@@ -111,7 +109,6 @@ namespace Grand.Business.System.Services.Installation
Active = true,
IsSystemAccount = true,
SystemName = SystemCustomerNames.Anonymous,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
anonymousUser.Groups.Add(crGuests.Id);
@@ -127,7 +124,6 @@ namespace Grand.Business.System.Services.Installation
Active = true,
IsSystemAccount = true,
SystemName = SystemCustomerNames.SearchEngine,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
searchEngineUser.Groups.Add(crGuests.Id);
@@ -144,7 +140,6 @@ namespace Grand.Business.System.Services.Installation
Active = true,
IsSystemAccount = true,
SystemName = SystemCustomerNames.BackgroundTask,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
backgroundTaskUser.Groups.Add(crGuests.Id);
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataDeliveryDates.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataDeliveryDates.cs
index 33d87b7e3..9551df816 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataDeliveryDates.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataDeliveryDates.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallDeliveryDates()
+ protected virtual Task InstallDeliveryDates()
{
var deliveryDates = new List<DeliveryDate>
{
@@ -24,7 +24,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 10
}
};
- await _deliveryDateRepository.InsertAsync(deliveryDates);
+ deliveryDates.ForEach(x=>_deliveryDateRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataDiscounts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataDiscounts.cs
index 926934d75..34b4de515 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataDiscounts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataDiscounts.cs
@@ -33,18 +33,19 @@ namespace Grand.Business.System.Services.Installation
CurrencyCode = "USD"
}
};
- await _discountRepository.InsertAsync(discounts);
+ discounts.ForEach(x=>_discountRepository.Insert(x));
+
var coupon1 = new DiscountCoupon
{
CouponCode = "123",
- DiscountId = _discountRepository.Table.Where(x => x.Name == "Sample discount with coupon code").FirstOrDefault().Id
+ DiscountId = _discountRepository.Table.Where(x => x.Name == "Sample discount with coupon code").FirstOrDefault()!.Id
};
await _discountCouponRepository.InsertAsync(coupon1);
var coupon2 = new DiscountCoupon
{
CouponCode = "456",
- DiscountId = _discountRepository.Table.Where(x => x.Name == "'20% order total' discount").FirstOrDefault().Id
+ DiscountId = _discountRepository.Table.Where(x => x.Name == "'20% order total' discount").FirstOrDefault()!.Id
};
await _discountCouponRepository.InsertAsync(coupon2);
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataEmailAccounts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataEmailAccounts.cs
index cfd0b566c..1b6f718fd 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataEmailAccounts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataEmailAccounts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallEmailAccounts()
+ protected virtual Task InstallEmailAccounts()
{
var emailAccounts = new List<EmailAccount>
{
@@ -20,7 +20,8 @@ namespace Grand.Business.System.Services.Installation
UseServerCertificateValidation = true
}
};
- await _emailAccountRepository.InsertAsync(emailAccounts);
+ emailAccounts.ForEach(x=>_emailAccountRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataMeasures.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataMeasures.cs
index 49df94e27..e786a53ba 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataMeasures.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataMeasures.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallMeasures()
+ protected virtual Task InstallMeasures()
{
var measureDimensions = new List<MeasureDimension>
{
@@ -31,7 +31,7 @@ namespace Grand.Business.System.Services.Installation
}
};
- await _measureDimensionRepository.InsertAsync(measureDimensions);
+ measureDimensions.ForEach(x=>_measureDimensionRepository.Insert(x));
var measureWeights = new List<MeasureWeight>
{
@@ -65,7 +65,7 @@ namespace Grand.Business.System.Services.Installation
}
};
- await _measureWeightRepository.InsertAsync(measureWeights);
+ measureWeights.ForEach(x=>_measureWeightRepository.Insert(x));
var measureUnits = new List<MeasureUnit>
{
@@ -85,9 +85,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 3
}
};
-
- await _measureUnitRepository.InsertAsync(measureUnits);
-
+ measureUnits.ForEach(x=>_measureUnitRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnActions.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnActions.cs
index bd8ce3986..c41da4292 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnActions.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnActions.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallMerchandiseReturnActions()
+ protected virtual Task InstallMerchandiseReturnActions()
{
var merchandiseReturnActions = new List<MerchandiseReturnAction>
{
@@ -24,7 +24,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 3
}
};
- await _merchandiseReturnActionRepository.InsertAsync(merchandiseReturnActions);
+ merchandiseReturnActions.ForEach(x=>_merchandiseReturnActionRepository.Insert(x));
+ return Task.CompletedTask;
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnReasons.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnReasons.cs
index ed6e16d71..f00d6a12e 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnReasons.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataMerchandiseReturnReasons.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallMerchandiseReturnReasons()
+ protected virtual Task InstallMerchandiseReturnReasons()
{
var merchandiseReturnReasons = new List<MerchandiseReturnReason>
{
@@ -24,7 +24,9 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 3
}
};
- await _merchandiseReturnReasonRepository.InsertAsync(merchandiseReturnReasons);
+
+ merchandiseReturnReasons.ForEach(x=>_merchandiseReturnReasonRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataMessageTemplates.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataMessageTemplates.cs
index 8ab2939b7..5ea85b7c2 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataMessageTemplates.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataMessageTemplates.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallMessageTemplates()
+ protected virtual Task InstallMessageTemplates()
{
var eaGeneral = _emailAccountRepository.Table.FirstOrDefault();
if (eaGeneral == null)
@@ -574,7 +574,9 @@ namespace Grand.Business.System.Services.Installation
EmailAccountId = eaGeneral.Id
}
};
- await _messageTemplateRepository.InsertAsync(messageTemplates);
+
+ messageTemplates.ForEach(x=>_messageTemplateRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataNews.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataNews.cs
index 87e9cd851..b70ec103e 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataNews.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataNews.cs
@@ -18,7 +18,6 @@ namespace Grand.Business.System.Services.Installation
Short = "It's stable and highly usable. From downloads to documentation, www.grandnode.com offers a comprehensive base of information, resources, and support to the grandnode community.",
Full = "<p>For full feature list go to <a href=\"https://grandnode.com\">grandnode.com</a></p><p>Providing outstanding custom search engine optimization, web development services and e-commerce development solutions to our clients at a fair price in a professional manner.</p>",
Published = true,
- CreatedOnUtc = DateTime.UtcNow
},
new NewsItem
{
@@ -27,7 +26,6 @@ namespace Grand.Business.System.Services.Installation
Short = "grandnode includes everything you need to begin your e-commerce online store. We have thought of everything and it's all included! grandnode is a fully customizable shopping cart",
Full = "<p>Grandnode includes everything you need to begin your e-commerce online store. We have thought of everything and it's all included!</p>",
Published = true,
- CreatedOnUtc = DateTime.UtcNow.AddSeconds(1)
},
new NewsItem
{
@@ -36,11 +34,10 @@ namespace Grand.Business.System.Services.Installation
Short = "The new grandnode store is open now! We are very excited to offer our new range of products. We will be constantly adding to our range so please register on our site.",
Full = "<p>Our online store is officially up and running. Stock up for the holiday season! We have a great selection of items. We will be constantly adding to our range so please register on our site, this will enable you to keep up to date with any new products.</p><p>All shipping is worldwide and will leave the same day an order is placed! Happy Shopping and spread the word!!</p>",
Published = true,
- CreatedOnUtc = DateTime.UtcNow.AddSeconds(2)
}
};
- await _newsItemRepository.InsertAsync(news);
+ news.ForEach(x=>_newsItemRepository.Insert(x));
//search engine names
foreach (var newsItem in news)
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataOrderStatus.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataOrderStatus.cs
index c621e5dd7..26f78886e 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataOrderStatus.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataOrderStatus.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallOrderStatus()
+ protected virtual Task InstallOrderStatus()
{
var statuses = new List<OrderStatus>
{
@@ -37,7 +37,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 3
}
};
- await _orderStatusRepository.InsertManyAsync(statuses);
+ statuses.ForEach(x=> _orderStatusRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataPageLayouts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataPageLayouts.cs
index 64e45140d..f06b68305 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataPageLayouts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataPageLayouts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallPageLayouts()
+ protected virtual Task InstallPageLayouts()
{
var pageLayouts = new List<PageLayout>
{
@@ -15,7 +15,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 1
}
};
- await _pageLayoutRepository.InsertAsync(pageLayouts);
+ pageLayouts.ForEach(x=>_pageLayoutRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataPages.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataPages.cs
index 42b0dd01e..8de41f61b 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataPages.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataPages.cs
@@ -173,7 +173,7 @@ namespace Grand.Business.System.Services.Installation
Published = true
}
};
- await _pageRepository.InsertAsync(pages);
+ pages.ForEach(x=>_pageRepository.Insert(x));
var lpages = from p in _pageRepository.Table
select p;
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataPickupPoints.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataPickupPoints.cs
index 1de102d17..31c8ec4c8 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataPickupPoints.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataPickupPoints.cs
@@ -14,8 +14,7 @@ namespace Grand.Business.System.Services.Installation
City = "New York",
StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "New York")?.Id,
CountryId = country?.Id,
- ZipPostalCode = "10021",
- CreatedOnUtc = DateTime.UtcNow
+ ZipPostalCode = "10021"
};
var point = new PickupPoint()
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataProductAttributes.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataProductAttributes.cs
index 2f8a0efe8..59afe6ecd 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataProductAttributes.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataProductAttributes.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallProductAttributes()
+ protected virtual Task InstallProductAttributes()
{
var productAttributes = new List<ProductAttribute>
{
@@ -49,7 +49,8 @@ namespace Grand.Business.System.Services.Installation
SeName = "software"
}
};
- await _productAttributeRepository.InsertAsync(productAttributes);
+ productAttributes.ForEach(x=>_productAttributeRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataProductLayouts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataProductLayouts.cs
index 0fc7b7908..e7649fd60 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataProductLayouts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataProductLayouts.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallProductLayouts()
+ protected virtual Task InstallProductLayouts()
{
var productLayouts = new List<ProductLayout>
{
@@ -21,7 +21,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 100
}
};
- await _productLayoutRepository.InsertAsync(productLayouts);
+ productLayouts.ForEach(x=>_productLayoutRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
index 0265015cd..eec93b81b 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataProducts.cs
@@ -76,8 +76,6 @@ namespace Grand.Business.System.Services.Installation
OrderMaximumQuantity = 10000,
Published = true,
ShowOnHomePage = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -265,8 +263,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -317,8 +313,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -374,8 +368,6 @@ namespace Grand.Business.System.Services.Installation
OrderMaximumQuantity = 10000,
Published = true,
ShowOnHomePage = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -453,8 +445,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -539,8 +529,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -624,8 +612,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -710,8 +696,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -797,8 +781,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -872,8 +854,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -923,8 +903,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -974,8 +952,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1029,8 +1005,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1080,8 +1054,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1137,8 +1109,6 @@ namespace Grand.Business.System.Services.Installation
Published = true,
ShowOnHomePage = true,
MarkAsNew = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
BrandId = _brandRepository.Table.Single(c => c.Name == "Xiaomi").Id,
ProductCategories =
{
@@ -1184,8 +1154,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
BrandId = _brandRepository.Table.Single(c => c.Name == "Xiaomi").Id,
ProductCategories =
{
@@ -1236,8 +1204,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
BrandId = _brandRepository.Table.Single(c => c.Name == "Xiaomi").Id,
ProductCategories =
{
@@ -1291,8 +1257,6 @@ namespace Grand.Business.System.Services.Installation
OrderMaximumQuantity = 10000,
Published = true,
MarkAsNew = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
BrandId = _brandRepository.Table.Single(c => c.Name == "Xiaomi").Id,
TierPrices =
{
@@ -1363,8 +1327,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1414,8 +1376,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
BrandId = _brandRepository.Table.Single(c => c.Name == "Xiaomi").Id,
ProductCategories =
{
@@ -1471,8 +1431,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -1575,8 +1533,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -1713,8 +1669,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1765,8 +1719,6 @@ namespace Grand.Business.System.Services.Installation
BackorderModeId = BackorderMode.NoBackorders,
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1814,8 +1766,6 @@ namespace Grand.Business.System.Services.Installation
BackorderModeId = BackorderMode.NoBackorders,
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1857,8 +1807,6 @@ namespace Grand.Business.System.Services.Installation
BackorderModeId = BackorderMode.NoBackorders,
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -1902,8 +1850,6 @@ namespace Grand.Business.System.Services.Installation
BackorderModeId = BackorderMode.NoBackorders,
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -1996,8 +1942,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
TierPrices =
{
new TierPrice
@@ -2065,8 +2009,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -2120,8 +2062,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2165,8 +2105,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2211,8 +2149,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
TierPrices =
{
new TierPrice
@@ -2286,8 +2222,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductAttributeMappings =
{
new ProductAttributeMapping
@@ -2369,8 +2303,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2421,8 +2353,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2493,8 +2423,6 @@ namespace Grand.Business.System.Services.Installation
HasSampleDownload = true,
SampleDownloadId = downloadCyberpunk2.Id,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2560,8 +2488,6 @@ namespace Grand.Business.System.Services.Installation
HasSampleDownload = true,
SampleDownloadId = downloadGTA2.Id,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2617,8 +2543,6 @@ namespace Grand.Business.System.Services.Installation
UnlimitedDownloads = true,
HasUserAgreement = false,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2670,8 +2594,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2723,8 +2645,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2774,8 +2694,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2829,8 +2747,6 @@ namespace Grand.Business.System.Services.Installation
OrderMaximumQuantity = 10000,
Published = true,
MarkAsNew = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2876,8 +2792,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2922,8 +2836,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -2968,8 +2880,6 @@ namespace Grand.Business.System.Services.Installation
AllowOutOfStockSubscriptions = false,
Published = true,
ShowOnHomePage = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -3015,8 +2925,6 @@ namespace Grand.Business.System.Services.Installation
AllowOutOfStockSubscriptions = false,
Published = true,
MarkAsNew = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -3060,8 +2968,6 @@ namespace Grand.Business.System.Services.Installation
NotifyAdminForQuantityBelow = 1,
AllowOutOfStockSubscriptions = false,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -3106,8 +3012,6 @@ namespace Grand.Business.System.Services.Installation
OrderMinimumQuantity = 1,
OrderMaximumQuantity = 10000,
Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
ProductCategories =
{
new ProductCategory
@@ -3742,8 +3646,7 @@ namespace Grand.Business.System.Services.Installation
ReviewText = string.Format("This sample review is for the {0}. I've been waiting for this product to be available. It is priced just right.", product.Name),
Rating = rating,
HelpfulYesTotal = 0,
- HelpfulNoTotal = 0,
- CreatedOnUtc = DateTime.UtcNow,
+ HelpfulNoTotal = 0
};
await _productReviewRepository.InsertAsync(productReview);
@@ -3752,7 +3655,7 @@ namespace Grand.Business.System.Services.Installation
product.ApprovedTotalReviews += 1;
product.AvgRating = rating / product.ApprovedTotalReviews;
}
- await _productRepository.UpdateAsync(allProducts);
+ allProducts.ForEach((x=>_productRepository.Update(x)));
}
private async Task AddProductTag(Product product, string tag)
{
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataScheduleTasks.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataScheduleTasks.cs
index 60005350c..733eee379 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataScheduleTasks.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataScheduleTasks.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallScheduleTasks()
+ protected virtual Task InstallScheduleTasks()
{
//these tasks are default - they are created in order to insert them into database
//and nothing above it
@@ -76,7 +76,8 @@ namespace Grand.Business.System.Services.Installation
TimeInterval = 1440
}
};
- await _scheduleTaskRepository.InsertAsync(tasks);
+ tasks.ForEach(x=>_scheduleTaskRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
index df6db2e0c..4bb07c6b6 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
@@ -298,7 +298,7 @@ namespace Grand.Business.System.Services.Installation
NewsletterBlockAllowToUnsubscribe = false,
OnlineCustomerMinutes = 20,
OnlineShoppingCartMinutes = 60,
- StoreLastVisitedPage = true,
+ StoreLastVisitedPage = false,
AllowUsersToDeleteAccount = false,
AllowUsersToExportData = false,
TwoFactorAuthenticationEnabled = false
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataShippingMethods.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataShippingMethods.cs
index 61375423d..92cdf8847 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataShippingMethods.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataShippingMethods.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallShippingMethods()
+ protected virtual Task InstallShippingMethods()
{
var shippingMethods = new List<ShippingMethod>
{
@@ -27,7 +27,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 3
}
};
- await _shippingMethodRepository.InsertAsync(shippingMethods);
+ shippingMethods.ForEach(x=>_shippingMethodRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataTaxCategories.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataTaxCategories.cs
index 61c272bb7..631229d0f 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataTaxCategories.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataTaxCategories.cs
@@ -4,7 +4,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallTaxCategories()
+ protected virtual Task InstallTaxCategories()
{
var taxCategories = new List<TaxCategory>
{
@@ -34,8 +34,8 @@ namespace Grand.Business.System.Services.Installation
DisplayOrder = 20
}
};
- await _taxCategoryRepository.InsertAsync(taxCategories);
-
+ taxCategories.ForEach(x=>_taxCategoryRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataVendors.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataVendors.cs
index 74a3cf78b..34b03cf19 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataVendors.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataVendors.cs
@@ -38,7 +38,7 @@ namespace Grand.Business.System.Services.Installation
}
};
- await _vendorRepository.InsertAsync(vendors);
+ vendors.ForEach(x=>_vendorRepository.Insert(x));
//search engine names
foreach (var vendor in vendors)
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
index 4a65338a0..fa589d17d 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataWarehouses.cs
@@ -5,7 +5,7 @@ namespace Grand.Business.System.Services.Installation
{
public partial class InstallationService
{
- protected virtual async Task InstallWarehouses()
+ protected virtual Task InstallWarehouses()
{
var country = _countryRepository.Table.FirstOrDefault(c => c.ThreeLetterIsoCode == "USA");
var warehouse1address = new Address
@@ -14,18 +14,16 @@ namespace Grand.Business.System.Services.Installation
City = "New York",
StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "New York")?.Id,
CountryId = country?.Id,
- ZipPostalCode = "10021",
- CreatedOnUtc = DateTime.UtcNow
+ ZipPostalCode = "10021"
};
var warehouse2address = new Address
{
Address1 = "300 South Spring Stree",
City = "Los Angeles",
- StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "California").Id,
- CountryId = country.Id,
- ZipPostalCode = "90013",
- CreatedOnUtc = DateTime.UtcNow
+ StateProvinceId = country?.StateProvinces.FirstOrDefault(sp => sp.Name == "California")?.Id,
+ CountryId = country?.Id,
+ ZipPostalCode = "90013"
};
var warehouses = new List<Warehouse>
@@ -46,7 +44,8 @@ namespace Grand.Business.System.Services.Installation
}
};
- await _warehouseRepository.InsertAsync(warehouses);
+ warehouses.ForEach(x=>_warehouseRepository.Insert(x));
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
index 08b05c84c..043749192 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallationService.cs
@@ -360,9 +360,10 @@ namespace Grand.Business.System.Services.Installation
await _versionRepository.InsertAsync(version);
}
- protected virtual async Task InstallMenuAdminSiteMap()
+ protected virtual Task InstallMenuAdminSiteMap()
{
- await _adminRepository.InsertManyAsync(StandardAdminSiteMap.SiteMap);
+ StandardAdminSiteMap.SiteMap.ForEach(x=>_adminRepository.Insert(x));
+ return Task.CompletedTask;
}
protected virtual async Task HashDefaultCustomerPassword(string defaultUserEmail, string defaultUserPassword)
diff --git a/src/Business/Grand.Business.System/Services/Migrations/MigrationProcess.cs b/src/Business/Grand.Business.System/Services/Migrations/MigrationProcess.cs
index b38133698..f0e59e487 100644
--- a/src/Business/Grand.Business.System/Services/Migrations/MigrationProcess.cs
+++ b/src/Business/Grand.Business.System/Services/Migrations/MigrationProcess.cs
@@ -56,7 +56,6 @@ namespace Grand.Business.System.Services.Migrations
Identity = migrationResult.Migration.Identity,
Name = migrationResult.Migration.Name,
Version = migrationResult.Migration.Version.ToString(),
- CreatedOnUtc = DateTime.UtcNow,
InstallApp = install
});
}
diff --git a/src/Core/Grand.Domain/AuditableEntity.cs b/src/Core/Grand.Domain/AuditableEntity.cs
new file mode 100644
index 000000000..58e40a8b1
--- /dev/null
+++ b/src/Core/Grand.Domain/AuditableEntity.cs
@@ -0,0 +1,9 @@
+namespace Grand.Domain;
+
+public interface IAuditableEntity
+{
+ public DateTime CreatedOnUtc { get; set; }
+ public string CreatedBy { get; set; }
+ public DateTime? UpdatedOnUtc { get; set; }
+ public string UpdatedBy { get; set; }
+}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/BaseEntity.cs b/src/Core/Grand.Domain/BaseEntity.cs
index 0e62a7013..8050b3afb 100644
--- a/src/Core/Grand.Domain/BaseEntity.cs
+++ b/src/Core/Grand.Domain/BaseEntity.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain
/// <summary>
/// Base class for entities
/// </summary>
- public abstract partial class BaseEntity : ParentEntity
+ public abstract class BaseEntity : ParentEntity, IAuditableEntity
{
protected BaseEntity()
{
@@ -14,5 +14,9 @@ namespace Grand.Domain
public IList<UserField> UserFields { get; set; }
+ public DateTime CreatedOnUtc { get; set; }
+ public string CreatedBy { get; set; }
+ public DateTime? UpdatedOnUtc { get; set; }
+ public string UpdatedBy { get; set; }
}
}
diff --git a/src/Core/Grand.Domain/Blogs/BlogComment.cs b/src/Core/Grand.Domain/Blogs/BlogComment.cs
index a55779746..0c75160dd 100644
--- a/src/Core/Grand.Domain/Blogs/BlogComment.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogComment.cs
@@ -30,9 +30,5 @@ namespace Grand.Domain.Blogs
/// </summary>
public string BlogPostId { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Blogs/BlogPost.cs b/src/Core/Grand.Domain/Blogs/BlogPost.cs
index 6157a5b91..e181bf8eb 100644
--- a/src/Core/Grand.Domain/Blogs/BlogPost.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogPost.cs
@@ -93,11 +93,6 @@ namespace Grand.Domain.Blogs
/// Gets or sets the sename
/// </summary>
public string SeName { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
+
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Catalog/Brand.cs b/src/Core/Grand.Domain/Catalog/Brand.cs
index ae3245ef1..9bff7e9dd 100644
--- a/src/Core/Grand.Domain/Catalog/Brand.cs
+++ b/src/Core/Grand.Domain/Catalog/Brand.cs
@@ -125,16 +125,6 @@ namespace Grand.Domain.Catalog
/// </summary>
public int DisplayOrder { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Catalog/Category.cs b/src/Core/Grand.Domain/Catalog/Category.cs
index 4860bdc34..b1735e786 100644
--- a/src/Core/Grand.Domain/Catalog/Category.cs
+++ b/src/Core/Grand.Domain/Catalog/Category.cs
@@ -160,17 +160,7 @@ namespace Grand.Domain.Catalog
/// Gets or sets the hide on catalog page (subcategories)
/// </summary>
public bool HideOnCatalog { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
+
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Catalog/Collection.cs b/src/Core/Grand.Domain/Catalog/Collection.cs
index 72d9726b0..af2366360 100644
--- a/src/Core/Grand.Domain/Catalog/Collection.cs
+++ b/src/Core/Grand.Domain/Catalog/Collection.cs
@@ -130,16 +130,6 @@ namespace Grand.Domain.Catalog
/// </summary>
public string ExternalId { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs b/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
index 96d5d454b..e5f4297f4 100644
--- a/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
+++ b/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
@@ -36,12 +36,6 @@ namespace Grand.Domain.Catalog
/// Gets or sets the customer identifier
/// </summary>
public string CustomerId { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
}
}
diff --git a/src/Core/Grand.Domain/Catalog/Product.cs b/src/Core/Grand.Domain/Catalog/Product.cs
index 9491b50c0..40867fa7b 100644
--- a/src/Core/Grand.Domain/Catalog/Product.cs
+++ b/src/Core/Grand.Domain/Catalog/Product.cs
@@ -25,7 +25,7 @@ namespace Grand.Domain.Catalog
private ICollection<RelatedProduct> _relatedProduct;
private ICollection<SimilarProduct> _similarProduct;
private ICollection<BundleProduct> _bundleProduct;
- private ICollection<ProductPrice> _productprices;
+ private ICollection<ProductPrice> _productPrices;
private ICollection<string> _productTags;
public Product()
{
@@ -532,15 +532,6 @@ namespace Grand.Domain.Catalog
/// </summary>
public bool Published { get; set; }
- /// <summary>
- /// Gets or sets the date and time of product creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
- /// <summary>
- /// Gets or sets the date and time of product update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the sold
/// </summary>
@@ -561,6 +552,11 @@ namespace Grand.Domain.Catalog
/// </summary>
public string Flag { get; set; }
+ /// <summary>
+ /// Gets or sets the ticks
+ /// </summary>
+ public long Ticks { get; set; }
+
/// <summary>
/// Gets or sets the coordinates
/// </summary>
@@ -637,8 +633,8 @@ namespace Grand.Domain.Catalog
/// Gets or sets the product prices
/// </summary>
public virtual ICollection<ProductPrice> ProductPrices {
- get { return _productprices ??= new List<ProductPrice>(); }
- protected set { _productprices = value; }
+ get { return _productPrices ??= new List<ProductPrice>(); }
+ protected set { _productPrices = value; }
}
/// <summary>
/// Gets or sets the tier prices
diff --git a/src/Core/Grand.Domain/Catalog/ProductReview.cs b/src/Core/Grand.Domain/Catalog/ProductReview.cs
index 4fee92d24..b395bde1c 100644
--- a/src/Core/Grand.Domain/Catalog/ProductReview.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductReview.cs
@@ -65,17 +65,7 @@ namespace Grand.Domain.Catalog
/// Review not helpful votes total
/// </summary>
public int HelpfulNoTotal { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance updated
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
+
/// <summary>
/// Gets the entries of product review helpfulness
/// </summary>
diff --git a/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs b/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
index 8808fb452..c00e414c2 100644
--- a/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
@@ -4,7 +4,5 @@
{
public string CustomerId { get; set; }
public string ProductId { get; set; }
- public DateTime CreatedOnUtc { get; set; }
-
}
}
diff --git a/src/Core/Grand.Domain/Common/Address.cs b/src/Core/Grand.Domain/Common/Address.cs
index d28175799..fcb76c9a3 100644
--- a/src/Core/Grand.Domain/Common/Address.cs
+++ b/src/Core/Grand.Domain/Common/Address.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Common
{
- public partial class Address : BaseEntity
+ public partial class Address : SubBaseEntity
{
public Address()
{
@@ -92,9 +92,5 @@
/// </summary>
public AddressType AddressType { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
}
}
diff --git a/src/Core/Grand.Domain/Courses/Course.cs b/src/Core/Grand.Domain/Courses/Course.cs
index f4daa59df..b1db23666 100644
--- a/src/Core/Grand.Domain/Courses/Course.cs
+++ b/src/Core/Grand.Domain/Courses/Course.cs
@@ -86,16 +86,6 @@ namespace Grand.Domain.Courses
/// </summary>
public string SeName { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Customers/Customer.cs b/src/Core/Grand.Domain/Customers/Customer.cs
index f04b1139e..a9c2efc44 100644
--- a/src/Core/Grand.Domain/Customers/Customer.cs
+++ b/src/Core/Grand.Domain/Customers/Customer.cs
@@ -140,11 +140,6 @@ namespace Grand.Domain.Customers
/// </summary>
public string LastIpAddress { get; set; }
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the date and time of last login
/// </summary>
diff --git a/src/Core/Grand.Domain/Customers/CustomerExtensions.cs b/src/Core/Grand.Domain/Customers/CustomerExtensions.cs
index 328d98919..59686f7f1 100644
--- a/src/Core/Grand.Domain/Customers/CustomerExtensions.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerExtensions.cs
@@ -122,6 +122,7 @@ namespace Grand.Domain.Customers
/// Gets coupon codes
/// </summary>
/// <param name="customer">Customer</param>
+ /// <param name="key">key</param>
/// <returns>Coupon codes</returns>
public static string[] ParseAppliedCouponCodes(this Customer customer, string key)
{
@@ -152,11 +153,13 @@ namespace Grand.Domain.Customers
var existingCouponCodes = customer.GetUserFieldFromEntity<string>(key);
return string.IsNullOrEmpty(existingCouponCodes) ? couponCode : string.Join(CouponSeparator, existingCouponCodes.Split(CouponSeparator).Append(couponCode).Distinct());
}
+
/// <summary>
/// Adds a coupon codes
/// </summary>
/// <param name="customer">Customer</param>
- /// <param name="couponCode">Coupon code</param>
+ /// <param name="key">key</param>
+ /// <param name="couponCodes">Coupon code</param>
/// <returns>New coupon codes document</returns>
public static string ApplyCouponCode(this Customer customer, string key, string[] couponCodes)
{
diff --git a/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs b/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
index c1077afd0..9a5f5d334 100644
--- a/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
@@ -30,10 +30,5 @@
/// </summary>
public string PasswordSalt { get; set; }
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
}
}
diff --git a/src/Core/Grand.Domain/Customers/CustomerNote.cs b/src/Core/Grand.Domain/Customers/CustomerNote.cs
index 7d9ac2c8a..e38e77e05 100644
--- a/src/Core/Grand.Domain/Customers/CustomerNote.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerNote.cs
@@ -29,12 +29,6 @@ namespace Grand.Domain.Customers
/// Gets or sets a value indicating whether a customer can see a note
/// </summary>
public bool DisplayToCustomer { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of order note creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
}
}
diff --git a/src/Core/Grand.Domain/Data/IAuditInfoProvider.cs b/src/Core/Grand.Domain/Data/IAuditInfoProvider.cs
new file mode 100644
index 000000000..69a5f2bdc
--- /dev/null
+++ b/src/Core/Grand.Domain/Data/IAuditInfoProvider.cs
@@ -0,0 +1,7 @@
+namespace Grand.Domain.Data;
+
+public interface IAuditInfoProvider
+{
+ string GetCurrentUser();
+ DateTime GetCurrentDateTime();
+}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Data/IRepository.cs b/src/Core/Grand.Domain/Data/IRepository.cs
index 6d634caf1..41df15477 100644
--- a/src/Core/Grand.Domain/Data/IRepository.cs
+++ b/src/Core/Grand.Domain/Data/IRepository.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Data
/// <summary>
/// Repository
/// </summary>
- public partial interface IRepository<T> where T : BaseEntity
+ public interface IRepository<T> where T : BaseEntity
{
/// <summary>
@@ -28,12 +28,6 @@ namespace Grand.Domain.Data
/// <returns>Entity</returns>
Task<T> GetByIdAsync(string id);
- /// <summary>
- /// Get all entities in collection
- /// </summary>
- /// <returns>collection of entities</returns>
- Task<List<T>> GetAllAsync();
-
/// <summary>
/// Insert entity
/// </summary>
@@ -46,24 +40,6 @@ namespace Grand.Domain.Data
/// <param name="entity">Entity</param>
Task<T> InsertAsync(T entity);
- /// <summary>
- /// Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- void Insert(IEnumerable<T> entities);
-
- /// <summary>
- /// Async Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- Task<IEnumerable<T>> InsertAsync(IEnumerable<T> entities);
-
- /// <summary>
- /// Async Insert many entities
- /// </summary>
- /// <param name="entities">Entities</param>
- Task InsertManyAsync(IEnumerable<T> entities);
-
/// <summary>
/// Update entity
/// </summary>
@@ -76,12 +52,6 @@ namespace Grand.Domain.Data
/// <param name="entity">Entity</param>
Task<T> UpdateAsync(T entity);
- /// <summary>
- /// Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- void Update(IEnumerable<T> entities);
-
/// <summary>
/// Update field for entity
/// </summary>
@@ -195,29 +165,18 @@ namespace Grand.Domain.Data
/// <returns></returns>
Task Pull(string id, Expression<Func<T, IEnumerable<string>>> field, string element);
- /// <summary>
- /// Async Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- Task<IEnumerable<T>> UpdateAsync(IEnumerable<T> entities);
-
/// <summary>
/// Delete entity
/// </summary>
/// <param name="entity">Entity</param>
void Delete(T entity);
+ /// <summary>
/// Async Delete entity
/// </summary>
/// <param name="entity">Entity</param>
Task<T> DeleteAsync(T entity);
- /// <summary>
- /// Delete entities
- /// </summary>
- /// <param name="entities">Entities</param>
- void Delete(IEnumerable<T> entities);
-
/// <summary>
/// Async Delete entities
/// </summary>
diff --git a/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs b/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
index 2076051a3..ef17cff20 100644
--- a/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
+++ b/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
@@ -8,10 +8,12 @@ namespace Grand.Domain.Data.LiteDb
/// <summary>
/// MongoDB repository
/// </summary>
- public partial class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
+ public class LiteDBRepository<T> : IRepository<T> where T : BaseEntity
{
#region Fields
+ private readonly IAuditInfoProvider _auditInfoProvider;
+
/// <summary>
/// Gets the collection
/// </summary>
@@ -49,8 +51,9 @@ namespace Grand.Domain.Data.LiteDb
/// <summary>
/// Ctor
/// </summary>
- public LiteDBRepository()
+ public LiteDBRepository(IAuditInfoProvider auditInfoProvider)
{
+ _auditInfoProvider = auditInfoProvider;
var connection = DataSettingsManager.LoadSettings();
if (!string.IsNullOrEmpty(connection.ConnectionString))
@@ -59,16 +62,18 @@ namespace Grand.Domain.Data.LiteDb
_collection = _database.GetCollection<T>(typeof(T).Name);
}
}
- public LiteDBRepository(string connectionString)
+ public LiteDBRepository(string connectionString, IAuditInfoProvider auditInfoProvider)
{
+ _auditInfoProvider = auditInfoProvider;
_database = new LiteDatabase(connectionString);
_collection = _database.GetCollection<T>(typeof(T).Name);
}
- public LiteDBRepository(LiteDatabase database)
+ public LiteDBRepository(LiteDatabase database, IAuditInfoProvider auditInfoProvider)
{
_database = database;
+ _auditInfoProvider = auditInfoProvider;
_collection = _database.GetCollection<T>(typeof(T).Name);
}
@@ -95,21 +100,14 @@ namespace Grand.Domain.Data.LiteDb
return await Task.FromResult(GetById(id));
}
- /// <summary>
- /// Get all entities in collection
- /// </summary>
- /// <returns>collection of entities</returns>
- public virtual async Task<List<T>> GetAllAsync()
- {
- return await Task.FromResult(_collection.Query().ToList());
- }
-
/// <summary>
/// Insert entity
/// </summary>
/// <param name="entity">Entity</param>
public virtual T Insert(T entity)
{
+ entity.CreatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.CreatedBy = _auditInfoProvider.GetCurrentUser();
_collection.Insert(entity);
return entity;
}
@@ -124,42 +122,14 @@ namespace Grand.Domain.Data.LiteDb
return await Task.FromResult(entity);
}
- /// <summary>
- /// Async Insert many entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual Task InsertManyAsync(IEnumerable<T> entities)
- {
- Insert(entities);
- return Task.CompletedTask;
- }
-
- /// <summary>
- /// Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Insert(IEnumerable<T> entities)
- {
- _collection.InsertBulk(entities);
- }
-
- /// <summary>
- /// Async Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual async Task<IEnumerable<T>> InsertAsync(IEnumerable<T> entities)
- {
- Insert(entities);
- return await Task.FromResult(entities);
- }
-
-
/// <summary>
/// Update entity
/// </summary>
/// <param name="entity">Entity</param>
public virtual T Update(T entity)
{
+ entity.UpdatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.UpdatedBy = _auditInfoProvider.GetCurrentUser();
_collection.Update(entity);
return entity;
@@ -175,19 +145,6 @@ namespace Grand.Domain.Data.LiteDb
return await Task.FromResult(entity);
}
-
- /// <summary>
- /// Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Update(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- Update(entity);
- }
- }
-
/// <summary>
/// Update field for entity
/// </summary>
@@ -200,6 +157,8 @@ namespace Grand.Domain.Data.LiteDb
var entity = _database.GetCollection(typeof(T).Name).FindById(new(id));
var bsonValue = BsonMapper.Global.Serialize<U>(value);
entity[GetName(expression)] = bsonValue;
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
_database.GetCollection(typeof(T).Name).Update(entity);
return Task.CompletedTask;
@@ -273,6 +232,10 @@ namespace Grand.Domain.Data.LiteDb
propertyInfo?.SetValue(entity, item.Value);
}
+
+ entity.UpdatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.UpdatedBy = _auditInfoProvider.GetCurrentUser();
+
_collection.Update(entity);
return Task.CompletedTask;
}
@@ -297,6 +260,8 @@ namespace Grand.Domain.Data.LiteDb
var list = entity[fieldName].AsArray.ToList();
list.Add(bsonValue);
entity[fieldName] = new BsonArray(list);
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
return Task.CompletedTask;
@@ -335,6 +300,8 @@ namespace Grand.Domain.Data.LiteDb
document[key] = bsonValue[key];
}
entity[fieldName] = new BsonArray(list);
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
@@ -375,6 +342,9 @@ namespace Grand.Domain.Data.LiteDb
var updateList = BsonMapper.Global.Serialize<IList<U>>(list);
entity[fieldName] = updateList;
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
+
collection.Update(entity);
}
return Task.CompletedTask;
@@ -408,6 +378,8 @@ namespace Grand.Domain.Data.LiteDb
list.Add(bsonValue);
list.Remove(oldbsonValue);
entity[fieldName] = new BsonArray(list);
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
}
@@ -464,6 +436,8 @@ namespace Grand.Domain.Data.LiteDb
list.Remove(document);
}
entity[fieldName] = new BsonArray(list);
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
}
@@ -499,6 +473,8 @@ namespace Grand.Domain.Data.LiteDb
var updatelist = BsonMapper.Global.Serialize<IList<U>>(list);
entity[fieldName] = updatelist;
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
return Task.CompletedTask;
@@ -539,6 +515,8 @@ namespace Grand.Domain.Data.LiteDb
{
list.Remove(new BsonValue(element));
entity[fieldName] = new BsonArray(list);
+ entity["UpdatedOnUtc"] = _auditInfoProvider.GetCurrentDateTime();
+ entity["UpdatedBy"] = _auditInfoProvider.GetCurrentUser();
collection.Update(entity);
}
}
@@ -547,18 +525,6 @@ namespace Grand.Domain.Data.LiteDb
return Task.CompletedTask;
}
- /// <summary>
- /// Async Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual async Task<IEnumerable<T>> UpdateAsync(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- await UpdateAsync(entity);
- }
- return entities;
- }
/// <summary>
/// Delete entity
@@ -578,19 +544,6 @@ namespace Grand.Domain.Data.LiteDb
Delete(entity);
return await Task.FromResult(entity);
}
-
- /// <summary>
- /// Delete entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Delete(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- Delete(entity);
- }
- }
-
/// <summary>
/// Async Delete entities
/// </summary>
diff --git a/src/Core/Grand.Domain/Data/MigrationDb.cs b/src/Core/Grand.Domain/Data/MigrationDb.cs
index 96ebaab4a..60c659dcf 100644
--- a/src/Core/Grand.Domain/Data/MigrationDb.cs
+++ b/src/Core/Grand.Domain/Data/MigrationDb.cs
@@ -17,11 +17,6 @@
/// </summary>
public string Version { get; set; }
- /// <summary>
- /// Gets or sets the date and time of migration creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the migration creation from installation
/// </summary>
diff --git a/src/Core/Grand.Domain/Data/Mongo/MongoRepository.cs b/src/Core/Grand.Domain/Data/Mongo/MongoRepository.cs
index 450957ddf..418b93079 100644
--- a/src/Core/Grand.Domain/Data/Mongo/MongoRepository.cs
+++ b/src/Core/Grand.Domain/Data/Mongo/MongoRepository.cs
@@ -8,10 +8,12 @@ namespace Grand.Domain.Data.Mongo
/// <summary>
/// MongoDB repository
/// </summary>
- public partial class MongoRepository<T> : IRepository<T> where T : BaseEntity
+ public class MongoRepository<T> : IRepository<T> where T : BaseEntity
{
#region Fields
+ private readonly IAuditInfoProvider _auditInfoProvider;
+
/// <summary>
/// Gets the collection
/// </summary>
@@ -36,6 +38,7 @@ namespace Grand.Domain.Data.Mongo
/// Mongo Database
/// </summary>
protected IMongoDatabase _database;
+
public IMongoDatabase Database {
get {
return _database;
@@ -49,8 +52,9 @@ namespace Grand.Domain.Data.Mongo
/// <summary>
/// Ctor
/// </summary>
- public MongoRepository()
+ public MongoRepository(IAuditInfoProvider auditInfoProvider)
{
+ _auditInfoProvider = auditInfoProvider;
var connection = DataSettingsManager.LoadSettings();
if (!string.IsNullOrEmpty(connection.ConnectionString))
@@ -61,8 +65,10 @@ namespace Grand.Domain.Data.Mongo
_collection = _database.GetCollection<T>(typeof(T).Name);
}
}
- public MongoRepository(string connectionString)
+
+ public MongoRepository(string connectionString, IAuditInfoProvider auditInfoProvider)
{
+ _auditInfoProvider = auditInfoProvider;
var client = new MongoClient(connectionString);
var databaseName = new MongoUrl(connectionString).DatabaseName;
_database = client.GetDatabase(databaseName);
@@ -70,9 +76,10 @@ namespace Grand.Domain.Data.Mongo
}
- public MongoRepository(IMongoDatabase database)
+ public MongoRepository(IMongoDatabase database, IAuditInfoProvider auditInfoProvider)
{
_database = database;
+ _auditInfoProvider = auditInfoProvider;
_collection = _database.GetCollection<T>(typeof(T).Name);
}
@@ -89,6 +96,7 @@ namespace Grand.Domain.Data.Mongo
{
return _collection.Find(e => e.Id == id).FirstOrDefault();
}
+
/// <summary>
/// Get async entity by identifier
/// </summary>
@@ -99,21 +107,14 @@ namespace Grand.Domain.Data.Mongo
return _collection.Find(e => e.Id == id).FirstOrDefaultAsync();
}
- /// <summary>
- /// Get all entities in collection
- /// </summary>
- /// <returns>collection of entities</returns>
- public virtual Task<List<T>> GetAllAsync()
- {
- return _collection.AsQueryable().ToListAsync();
- }
-
/// <summary>
/// Insert entity
/// </summary>
/// <param name="entity">Entity</param>
public virtual T Insert(T entity)
{
+ entity.CreatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.CreatedBy = _auditInfoProvider.GetCurrentUser();
_collection.InsertOne(entity);
return entity;
}
@@ -124,48 +125,22 @@ namespace Grand.Domain.Data.Mongo
/// <param name="entity">Entity</param>
public virtual async Task<T> InsertAsync(T entity)
{
+ entity.CreatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.CreatedBy = _auditInfoProvider.GetCurrentUser();
await _collection.InsertOneAsync(entity);
return entity;
}
- /// <summary>
- /// Async Insert many entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual async Task InsertManyAsync(IEnumerable<T> entities)
- {
- await _collection.InsertManyAsync(entities);
- }
-
- /// <summary>
- /// Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Insert(IEnumerable<T> entities)
- {
- _collection.InsertMany(entities);
- }
-
- /// <summary>
- /// Async Insert entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual async Task<IEnumerable<T>> InsertAsync(IEnumerable<T> entities)
- {
- await _collection.InsertManyAsync(entities);
- return entities;
- }
-
-
/// <summary>
/// Update entity
/// </summary>
/// <param name="entity">Entity</param>
public virtual T Update(T entity)
{
+ entity.UpdatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.UpdatedBy = _auditInfoProvider?.GetCurrentUser();
_collection.ReplaceOne(x => x.Id == entity.Id, entity, new ReplaceOptions() { IsUpsert = false });
return entity;
-
}
/// <summary>
@@ -174,23 +149,13 @@ namespace Grand.Domain.Data.Mongo
/// <param name="entity">Entity</param>
public virtual async Task<T> UpdateAsync(T entity)
{
- await _collection.ReplaceOneAsync(x => x.Id == entity.Id, entity, new ReplaceOptions() { IsUpsert = false });
+ entity.UpdatedOnUtc = _auditInfoProvider.GetCurrentDateTime();
+ entity.UpdatedBy = _auditInfoProvider.GetCurrentUser();
+ await _collection.ReplaceOneAsync(x => x.Id == entity.Id, entity,
+ new ReplaceOptions() { IsUpsert = false });
return entity;
}
-
- /// <summary>
- /// Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Update(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- Update(entity);
- }
- }
-
/// <summary>
/// Update field for entity
/// </summary>
@@ -203,6 +168,8 @@ namespace Grand.Domain.Data.Mongo
var builder = Builders<T>.Filter;
var filter = builder.Eq(x => x.Id, id);
var update = Builders<T>.Update
+ .Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime())
+ .Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser())
.Set(expression, value);
await _collection.UpdateOneAsync(filter, update);
@@ -231,8 +198,11 @@ namespace Grand.Domain.Data.Mongo
/// <param name="filterexpression"></param>
/// <param name="updateBuilder"></param>
/// <returns></returns>
- public virtual async Task UpdateOneAsync(Expression<Func<T, bool>> filterexpression, UpdateBuilder<T> updateBuilder)
- {
+ public virtual async Task UpdateOneAsync(Expression<Func<T, bool>> filterexpression,
+ UpdateBuilder<T> updateBuilder)
+ {
+ updateBuilder.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ updateBuilder.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
var update = Builders<T>.Update.Combine(updateBuilder.Fields);
await _collection.UpdateOneAsync(filterexpression, update);
}
@@ -243,8 +213,11 @@ namespace Grand.Domain.Data.Mongo
/// <param name="filterexpression"></param>
/// <param name="updateBuilder"></param>
/// <returns></returns>
- public virtual async Task UpdateManyAsync(Expression<Func<T, bool>> filterexpression, UpdateBuilder<T> updateBuilder)
+ public virtual async Task UpdateManyAsync(Expression<Func<T, bool>> filterexpression,
+ UpdateBuilder<T> updateBuilder)
{
+ updateBuilder.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ updateBuilder.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
var update = Builders<T>.Update.Combine(updateBuilder.Fields);
await _collection.UpdateManyAsync(filterexpression, update);
}
@@ -263,8 +236,10 @@ namespace Grand.Domain.Data.Mongo
var filter = builder.Eq(x => x.Id, id);
var update = Builders<T>.Update.AddToSet(field, value);
- await _collection.UpdateOneAsync(filter, update);
-
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
+ await _collection.UpdateOneAsync(filter, combinedUpdate);
}
/// <summary>
@@ -277,16 +252,20 @@ namespace Grand.Domain.Data.Mongo
/// <param name="elemFieldMatch">Subdocument field to match</param>
/// <param name="elemMatch">Subdocument ident value</param>
/// <param name="value">Subdocument - to update (all values)</param>
- public virtual async Task UpdateToSet<U, Z>(string id, Expression<Func<T, IEnumerable<U>>> field, Expression<Func<U, Z>> elemFieldMatch, Z elemMatch, U value)
+ public virtual async Task UpdateToSet<U, Z>(string id, Expression<Func<T, IEnumerable<U>>> field,
+ Expression<Func<U, Z>> elemFieldMatch, Z elemMatch, U value)
{
- var filter = Builders<T>.Filter.Eq(x => x.Id, id)
- & Builders<T>.Filter.ElemMatch(field, Builders<U>.Filter.Eq(elemFieldMatch, elemMatch));
+ var filter = Builders<T>.Filter.Eq(x => x.Id, id)
+ & Builders<T>.Filter.ElemMatch(field, Builders<U>.Filter.Eq(elemFieldMatch, elemMatch));
MemberExpression me = field.Body as MemberExpression;
MemberInfo minfo = me.Member;
var update = Builders<T>.Update.Set($"{minfo.Name}.$", value);
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
- await _collection.UpdateOneAsync(filter, update);
+ await _collection.UpdateOneAsync(filter, combinedUpdate);
}
/// <summary>
@@ -298,25 +277,31 @@ namespace Grand.Domain.Data.Mongo
/// <param name="elemFieldMatch">Subdocument field to match</param>
/// <param name="elemMatch">Subdocument ident value</param>
/// <param name="value">Subdocument - to update (all values)</param>
- public virtual async Task UpdateToSet<U>(string id, Expression<Func<T, IEnumerable<U>>> field, Expression<Func<U, bool>> elemFieldMatch, U value)
+ public virtual async Task UpdateToSet<U>(string id, Expression<Func<T, IEnumerable<U>>> field,
+ Expression<Func<U, bool>> elemFieldMatch, U value)
{
- var filter = string.IsNullOrEmpty(id) ? Builders<T>.Filter.Where(x => true) : Builders<T>.Filter.Eq(x => x.Id, id)
- & Builders<T>.Filter.ElemMatch(field, elemFieldMatch);
+ var filter = string.IsNullOrEmpty(id)
+ ? Builders<T>.Filter.Where(x => true)
+ : Builders<T>.Filter.Eq(x => x.Id, id)
+ & Builders<T>.Filter.ElemMatch(field, elemFieldMatch);
MemberExpression me = field.Body as MemberExpression;
MemberInfo minfo = me.Member;
var update = Builders<T>.Update.Set($"{minfo.Name}.$", value);
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
if (string.IsNullOrEmpty(id))
{
- await _collection.UpdateManyAsync(filter, update);
+ await _collection.UpdateManyAsync(filter, combinedUpdate);
}
else
{
- await _collection.UpdateOneAsync(filter, update);
+ await _collection.UpdateOneAsync(filter, combinedUpdate);
}
-
}
+
/// <summary>
/// Update subdocuments
/// </summary>
@@ -333,15 +318,19 @@ namespace Grand.Domain.Data.Mongo
MemberExpression me = field.Body as MemberExpression;
MemberInfo minfo = me.Member;
- var filter = new BsonDocument
- {
+ var filter = new BsonDocument {
new BsonElement(minfo.Name, elemFieldMatch.ToString())
};
var update = Builders<T>.Update.Set($"{minfo.Name}.$", value);
- await _collection.UpdateManyAsync(filter, update);
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
+
+ await _collection.UpdateManyAsync(filter, combinedUpdate);
}
+
/// <summary>
/// Delete subdocument
/// </summary>
@@ -352,17 +341,25 @@ namespace Grand.Domain.Data.Mongo
/// <param name="elemFieldMatch"></param>
/// <param name="elemMatch"></param>
/// <returns></returns>
- public virtual async Task PullFilter<U, Z>(string id, Expression<Func<T, IEnumerable<U>>> field, Expression<Func<U, Z>> elemFieldMatch, Z elemMatch)
+ public virtual async Task PullFilter<U, Z>(string id, Expression<Func<T, IEnumerable<U>>> field,
+ Expression<Func<U, Z>> elemFieldMatch, Z elemMatch)
{
- var filter = string.IsNullOrEmpty(id) ? Builders<T>.Filter.Where(x => true) : Builders<T>.Filter.Eq(x => x.Id, id);
+ var filter = string.IsNullOrEmpty(id)
+ ? Builders<T>.Filter.Where(x => true)
+ : Builders<T>.Filter.Eq(x => x.Id, id);
var update = Builders<T>.Update.PullFilter(field, Builders<U>.Filter.Eq(elemFieldMatch, elemMatch));
+
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
+
if (string.IsNullOrEmpty(id))
{
- await _collection.UpdateManyAsync(filter, update);
+ await _collection.UpdateManyAsync(filter, combinedUpdate);
}
else
{
- await _collection.UpdateOneAsync(filter, update);
+ await _collection.UpdateOneAsync(filter, combinedUpdate);
}
}
@@ -374,12 +371,19 @@ namespace Grand.Domain.Data.Mongo
/// <param name="field"></param>
/// <param name="elemFieldMatch"></param>
/// <returns></returns>
- public virtual async Task PullFilter<U>(string id, Expression<Func<T, IEnumerable<U>>> field, Expression<Func<U, bool>> elemFieldMatch)
+ public virtual async Task PullFilter<U>(string id, Expression<Func<T, IEnumerable<U>>> field,
+ Expression<Func<U, bool>> elemFieldMatch)
{
var filter = Builders<T>.Filter.Eq(x => x.Id, id);
var update = Builders<T>.Update.PullFilter(field, elemFieldMatch);
- await _collection.UpdateOneAsync(filter, update);
+
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
+
+ await _collection.UpdateOneAsync(filter, combinedUpdate);
}
+
/// <summary>
/// Delete subdocument
/// </summary>
@@ -390,26 +394,19 @@ namespace Grand.Domain.Data.Mongo
public virtual async Task Pull(string id, Expression<Func<T, IEnumerable<string>>> field, string element)
{
var update = Builders<T>.Update.Pull(field, element);
+
+ var updateDate = Builders<T>.Update.Set(x => x.UpdatedOnUtc, _auditInfoProvider.GetCurrentDateTime());
+ var updateUser = Builders<T>.Update.Set(x => x.UpdatedBy, _auditInfoProvider.GetCurrentUser());
+ var combinedUpdate = Builders<T>.Update.Combine(update, updateDate, updateUser);
+
if (string.IsNullOrEmpty(id))
{
- await _collection.UpdateManyAsync(Builders<T>.Filter.Where(x => true), update);
+ await _collection.UpdateManyAsync(Builders<T>.Filter.Where(x => true), combinedUpdate);
}
else
{
- await _collection.UpdateOneAsync(Builders<T>.Filter.Eq(x => x.Id, id), update);
- }
- }
- /// <summary>
- /// Async Update entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual async Task<IEnumerable<T>> UpdateAsync(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- await UpdateAsync(entity);
+ await _collection.UpdateOneAsync(Builders<T>.Filter.Eq(x => x.Id, id), combinedUpdate);
}
- return entities;
}
/// <summary>
@@ -431,18 +428,6 @@ namespace Grand.Domain.Data.Mongo
return entity;
}
- /// <summary>
- /// Delete entities
- /// </summary>
- /// <param name="entities">Entities</param>
- public virtual void Delete(IEnumerable<T> entities)
- {
- foreach (T entity in entities)
- {
- _collection.FindOneAndDeleteAsync(e => e.Id == entity.Id);
- }
- }
-
/// <summary>
/// Async Delete entities
/// </summary>
@@ -453,8 +438,10 @@ namespace Grand.Domain.Data.Mongo
{
await DeleteAsync(entity);
}
+
return entities;
}
+
/// <summary>
/// Delete a many entities
/// </summary>
diff --git a/src/Core/Grand.Domain/Directory/Currency.cs b/src/Core/Grand.Domain/Directory/Currency.cs
index cedc8c4ad..80909e01a 100644
--- a/src/Core/Grand.Domain/Directory/Currency.cs
+++ b/src/Core/Grand.Domain/Directory/Currency.cs
@@ -69,16 +69,6 @@ namespace Grand.Domain.Directory
/// </summary>
public int NumberDecimal { get; set; } = 2;
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Discounts/DiscountUsageHistory.cs b/src/Core/Grand.Domain/Discounts/DiscountUsageHistory.cs
index 6aacc29a0..1de1f5432 100644
--- a/src/Core/Grand.Domain/Discounts/DiscountUsageHistory.cs
+++ b/src/Core/Grand.Domain/Discounts/DiscountUsageHistory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Discounts
/// <summary>
/// Represents a discount usage history entry
/// </summary>
- public partial class DiscountUsageHistory : BaseEntity
+ public class DiscountUsageHistory : BaseEntity
{
/// <summary>
/// Gets or sets the discount identifier
@@ -25,11 +25,6 @@ namespace Grand.Domain.Discounts
/// </summary>
public string CustomerId { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the canceled identifier
/// </summary>
diff --git a/src/Core/Grand.Domain/Documents/Document.cs b/src/Core/Grand.Domain/Documents/Document.cs
index 3fb414eab..f2107cd8a 100644
--- a/src/Core/Grand.Domain/Documents/Document.cs
+++ b/src/Core/Grand.Domain/Documents/Document.cs
@@ -137,21 +137,12 @@ namespace Grand.Domain.Documents
/// </summary>
public int Quantity { get; set; }
- /// <summary>
- /// Gets or sets the date and time of document creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of document update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the date and time of document date
/// </summary>
public DateTime? DocDate { get; set; }
+ /// <summary>
/// Gets or sets the date and time of document due date
/// </summary>
public DateTime? DueDate { get; set; }
diff --git a/src/Core/Grand.Domain/History/HistoryObject.cs b/src/Core/Grand.Domain/History/HistoryObject.cs
index 2439495ce..2740329fa 100644
--- a/src/Core/Grand.Domain/History/HistoryObject.cs
+++ b/src/Core/Grand.Domain/History/HistoryObject.cs
@@ -2,7 +2,6 @@
{
public class HistoryObject: BaseEntity
{
- public DateTime CreatedOnUtc { get; set; }
public BaseEntity Object { get; set; }
}
}
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
index beb818216..61b1a0ee2 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
@@ -40,16 +40,6 @@ namespace Grand.Domain.Knowledgebase
/// </summary>
public bool Published { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
index d1a4073b5..17537c8fc 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
@@ -22,9 +22,5 @@
/// </summary>
public string ArticleId { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
}
}
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
index 722ccd2ca..bd7ee4f2a 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
@@ -39,16 +39,6 @@ namespace Grand.Domain.Knowledgebase
/// </summary>
public bool Published { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
diff --git a/src/Core/Grand.Domain/Messages/Campaign.cs b/src/Core/Grand.Domain/Messages/Campaign.cs
index 4ee2c2338..3055a93b7 100644
--- a/src/Core/Grand.Domain/Messages/Campaign.cs
+++ b/src/Core/Grand.Domain/Messages/Campaign.cs
@@ -45,11 +45,6 @@
public CampaignCondition CustomerHasShoppingCart { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the used email account identifier
/// </summary>
diff --git a/src/Core/Grand.Domain/Messages/ContactUs.cs b/src/Core/Grand.Domain/Messages/ContactUs.cs
index 5f263c02e..4dafeb87e 100644
--- a/src/Core/Grand.Domain/Messages/ContactUs.cs
+++ b/src/Core/Grand.Domain/Messages/ContactUs.cs
@@ -21,13 +21,7 @@ namespace Grand.Domain.Messages
/// Gets or sets the IP address
/// </summary>
public string IpAddress { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
-
+
/// <summary>
/// Gets or sets the email
/// </summary>
diff --git a/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs b/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
index a254652bd..63f611f5d 100644
--- a/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
+++ b/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
@@ -34,11 +34,6 @@ namespace Grand.Domain.Messages
/// </summary>
public string StoreId { get; set; }
- /// <summary>
- /// Gets or sets the date and time when subscription was created
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the categories
/// </summary>
diff --git a/src/Core/Grand.Domain/Messages/QueuedEmail.cs b/src/Core/Grand.Domain/Messages/QueuedEmail.cs
index 9d7206494..1520afc1a 100644
--- a/src/Core/Grand.Domain/Messages/QueuedEmail.cs
+++ b/src/Core/Grand.Domain/Messages/QueuedEmail.cs
@@ -81,11 +81,6 @@ namespace Grand.Domain.Messages
/// </summary>
public IList<string> AttachedDownloads { get; set; }
- /// <summary>
- /// Gets or sets the date and time of item creation in UTC
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the date and time in UTC before which this email should not be sent
/// </summary>
diff --git a/src/Core/Grand.Domain/News/NewsItem.cs b/src/Core/Grand.Domain/News/NewsItem.cs
index af00b7f21..5f0483e8d 100644
--- a/src/Core/Grand.Domain/News/NewsItem.cs
+++ b/src/Core/Grand.Domain/News/NewsItem.cs
@@ -96,12 +96,7 @@ namespace Grand.Domain.News
/// Gets or sets the meta title
/// </summary>
public string MetaTitle { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
+
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/GiftVoucher.cs b/src/Core/Grand.Domain/Orders/GiftVoucher.cs
index fbf576166..74280b40d 100644
--- a/src/Core/Grand.Domain/Orders/GiftVoucher.cs
+++ b/src/Core/Grand.Domain/Orders/GiftVoucher.cs
@@ -74,11 +74,6 @@ namespace Grand.Domain.Orders
/// </summary>
public DateTime? ValidTo { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the gift voucher usage history
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs b/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
index 6cb8dd16c..75b0db394 100644
--- a/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
+++ b/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
@@ -33,12 +33,7 @@ namespace Grand.Domain.Orders
/// Gets or sets the message
/// </summary>
public string Message { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
+
public string UsedWithOrderId { get; set; }
}
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
index 80edd6569..dfe5036f1 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
@@ -69,16 +69,6 @@ namespace Grand.Domain.Orders
/// </summary>
public int MerchandiseReturnStatusId { get; set; }
- /// <summary>
- /// Gets or sets the date and time of entity creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of entity update
- /// </summary>
- public DateTime UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets the return status
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
index 70da0450a..d63c68f02 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
@@ -30,11 +30,6 @@
/// </summary>
public bool DisplayToCustomer { get; set; }
- /// <summary>
- /// Gets or sets the date and time of merchandise return note creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets value indicating whether this merchandise return note was create by customer
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/Order.cs b/src/Core/Grand.Domain/Orders/Order.cs
index 506dba878..920362a39 100644
--- a/src/Core/Grand.Domain/Orders/Order.cs
+++ b/src/Core/Grand.Domain/Orders/Order.cs
@@ -253,11 +253,6 @@ namespace Grand.Domain.Orders
/// </summary>
public bool Deleted { get; set; }
- /// <summary>
- /// Gets or sets the date and time of order creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets a value indicating whether the entity has been imported
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/OrderNote.cs b/src/Core/Grand.Domain/Orders/OrderNote.cs
index 304ee365d..82edb7524 100644
--- a/src/Core/Grand.Domain/Orders/OrderNote.cs
+++ b/src/Core/Grand.Domain/Orders/OrderNote.cs
@@ -25,11 +25,6 @@ namespace Grand.Domain.Orders
/// </summary>
public bool DisplayToCustomer { get; set; }
- /// <summary>
- /// Gets or sets the date and time of order note creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets value indicating whether this order note was create by customer
/// </summary>
diff --git a/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs b/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
index f4f1c386d..67f320ea1 100644
--- a/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
+++ b/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
@@ -65,7 +65,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the date and time of instance update
/// </summary>
- public DateTime UpdatedOnUtc { get; set; }
+ public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets a value indicating whether the shopping cart item is free shipping
diff --git a/src/Core/Grand.Domain/Payments/PaymentTransaction.cs b/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
index 60c5a5644..64b4b608a 100644
--- a/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
+++ b/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
@@ -13,7 +13,6 @@
/// </summary>
public string PaymentMethodSystemName { get; set; }
- /// <summary>
/// <summary>
/// Gets or sets transaction status
/// </summary>
@@ -101,15 +100,6 @@
/// </summary>
public IList<string> Errors { get; set; }
- /// <summary>
- /// Gets or sets the date and time of transaction creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
- /// <summary>
- /// Gets or sets the date and time of transaction updated
- /// </summary>
- public DateTime? UpdatedOnUtc { get; set; }
-
/// <summary>
/// Gets or sets
/// </summary>
diff --git a/src/Core/Grand.Domain/Shipping/Shipment.cs b/src/Core/Grand.Domain/Shipping/Shipment.cs
index 86e9b77a9..3abfd357c 100644
--- a/src/Core/Grand.Domain/Shipping/Shipment.cs
+++ b/src/Core/Grand.Domain/Shipping/Shipment.cs
@@ -52,11 +52,6 @@ namespace Grand.Domain.Shipping
/// </summary>
public string AdminComment { get; set; }
- /// <summary>
- /// Gets or sets the entity creation date
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets the shipment number
/// </summary>
diff --git a/src/Core/Grand.Domain/Shipping/ShipmentNote.cs b/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
index 470bbb045..7bf29fd8d 100644
--- a/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
+++ b/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
@@ -24,12 +24,7 @@ namespace Grand.Domain.Shipping
/// Gets or sets a value indicating whether a customer can see a note
/// </summary>
public bool DisplayToCustomer { get; set; }
-
- /// <summary>
- /// Gets or sets the date and time of shipment note creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
+
/// <summary>
/// Gets or sets value indicating whether this shipment note was create by customer
/// </summary>
diff --git a/src/Core/Grand.Domain/SubBaseEntity.cs b/src/Core/Grand.Domain/SubBaseEntity.cs
index 2ebbab9b3..3f7b0f92e 100644
--- a/src/Core/Grand.Domain/SubBaseEntity.cs
+++ b/src/Core/Grand.Domain/SubBaseEntity.cs
@@ -1,7 +1,7 @@
namespace Grand.Domain
{
- public abstract partial class SubBaseEntity : ParentEntity
+ public abstract class SubBaseEntity : ParentEntity
{
}
diff --git a/src/Core/Grand.Domain/Vendors/VendorReview.cs b/src/Core/Grand.Domain/Vendors/VendorReview.cs
index 92041eea9..4878a5e9f 100644
--- a/src/Core/Grand.Domain/Vendors/VendorReview.cs
+++ b/src/Core/Grand.Domain/Vendors/VendorReview.cs
@@ -47,11 +47,6 @@
/// </summary>
public int HelpfulNoTotal { get; set; }
- /// <summary>
- /// Gets or sets the date and time of instance creation
- /// </summary>
- public DateTime CreatedOnUtc { get; set; }
-
/// <summary>
/// Gets the entries of vendor review helpfulness
/// </summary>
diff --git a/src/Core/Grand.Infrastructure/Models/BaseEntityModel.cs b/src/Core/Grand.Infrastructure/Models/BaseEntityModel.cs
index 46e6d647e..bfa87dd11 100644
--- a/src/Core/Grand.Infrastructure/Models/BaseEntityModel.cs
+++ b/src/Core/Grand.Infrastructure/Models/BaseEntityModel.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents base grandnode entity model
/// </summary>
- public partial class BaseEntityModel : BaseModel
+ public class BaseEntityModel : BaseModel
{
/// <summary>
/// Gets or sets model identifier
diff --git a/src/Core/Grand.Infrastructure/Startup/AuditInfoProvider.cs b/src/Core/Grand.Infrastructure/Startup/AuditInfoProvider.cs
new file mode 100644
index 000000000..37f77a411
--- /dev/null
+++ b/src/Core/Grand.Infrastructure/Startup/AuditInfoProvider.cs
@@ -0,0 +1,25 @@
+using Grand.Domain.Data;
+using Microsoft.AspNetCore.Http;
+using System.Security.Claims;
+
+namespace Grand.Infrastructure.Startup;
+
+public class AuditInfoProvider : IAuditInfoProvider
+{
+ private readonly IHttpContextAccessor _contextAccessor;
+
+ public AuditInfoProvider(IHttpContextAccessor contextAccessor)
+ {
+ _contextAccessor = contextAccessor;
+ }
+
+ public string GetCurrentUser()
+ {
+ return _contextAccessor.HttpContext?.User.FindFirst(ClaimTypes.Name)?.Value;
+ }
+
+ public DateTime GetCurrentDateTime()
+ {
+ return DateTime.UtcNow;
+ }
+}
\ No newline at end of file
diff --git a/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs b/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
index 8c20b06bb..08e74a8dc 100644
--- a/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
+++ b/src/Core/Grand.Infrastructure/Startup/StartupApplication.cs
@@ -30,6 +30,8 @@ namespace Grand.Infrastructure.Startup
private void RegisterDataLayer(IServiceCollection serviceCollection, IConfiguration configuration)
{
+ serviceCollection.AddSingleton<IAuditInfoProvider, AuditInfoProvider>();
+
var dbConfig = new DatabaseConfig();
configuration.GetSection("Database").Bind(dbConfig);
diff --git a/src/Plugins/Payments.PayPalStandard/Controllers/PaymentPayPalStandardController.cs b/src/Plugins/Payments.PayPalStandard/Controllers/PaymentPayPalStandardController.cs
index a9a9332de..9a588f60e 100644
--- a/src/Plugins/Payments.PayPalStandard/Controllers/PaymentPayPalStandardController.cs
+++ b/src/Plugins/Payments.PayPalStandard/Controllers/PaymentPayPalStandardController.cs
@@ -129,7 +129,6 @@ namespace Payments.PayPalStandard.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = sb.ToString(),
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
@@ -145,8 +144,7 @@ namespace Payments.PayPalStandard.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = errorStr,
OrderId = order.Id,
- DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow
+ DisplayToCustomer = false
});
return RedirectToAction("Index", "Home", new { area = "" });
@@ -262,7 +260,6 @@ namespace Payments.PayPalStandard.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = sb.ToString(),
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
var paymentTransaction = await _paymentTransactionService.GetOrderByGuid(order.OrderGuid);
@@ -291,7 +288,6 @@ namespace Payments.PayPalStandard.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = errorStr,
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
}
@@ -322,7 +318,6 @@ namespace Payments.PayPalStandard.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = errorStr,
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
index a3a116bcc..491d1228c 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceTests.cs
@@ -36,7 +36,7 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_casheManagerMock = new Mock<ICacheBase>();
_categoryRepositoryMock = new Mock<IRepository<Category>>();
- _productRepositoryMock = new Mock<MongoRepository<Product>>();
+ _productRepositoryMock = new Mock<MongoRepository<Product>>(Mock.Of<IAuditInfoProvider>());
_workContextMock = new Mock<IWorkContext>();
_mediatorMock = new Mock<IMediator>();
_aclServiceMock = new Mock<IAclService>();
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
index 3626269ee..f251f2a1f 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
@@ -410,7 +410,6 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
@@ -560,7 +559,6 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
@@ -592,14 +590,12 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
};
await _discountUsageHistoryRepository.InsertAsync(discountUsageHistory);
var discountUsageHistory2 = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "124",
CouponCode = "TEST123"
@@ -630,7 +626,6 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
@@ -662,7 +657,6 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
@@ -696,7 +690,6 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
await _discountCouponRepository.InsertAsync(discountCoupon);
var discountUsageHistory = new DiscountUsageHistory() {
- CreatedOnUtc = DateTime.UtcNow,
DiscountId = discount.Id,
OrderId = "123",
CouponCode = "TEST123"
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceFormatterTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceFormatterTests.cs
index 2b1cc5d56..04d64e19a 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceFormatterTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceFormatterTests.cs
@@ -55,9 +55,7 @@ namespace Grand.Business.Catalog.Tests.Services.Prices
DisplayLocale = "",
CustomFormatting = "€0.00",
DisplayOrder = 1,
- Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ Published = true
};
var currency02 = new Currency {
@@ -67,14 +65,12 @@ namespace Grand.Business.Catalog.Tests.Services.Prices
DisplayLocale = "en-US",
CustomFormatting = "",
DisplayOrder = 2,
- Published = true,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ Published = true
};
var tempCurrencyRepo = new Mock<IRepository<Currency>>();
{
- var tempIMongoCollection = new Mock<MongoRepository<Currency>>().Object;
+ var tempIMongoCollection = new Mock<MongoRepository<Currency>>(Mock.Of<IAuditInfoProvider>()).Object;
tempIMongoCollection.Insert(currency01);
tempIMongoCollection.Insert(currency02);
tempCurrencyRepo.Setup(x => x.Table).Returns(tempIMongoCollection.Table);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceServiceTests.cs
index b7658ece4..863477533 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Prices/PriceServiceTests.cs
@@ -96,7 +96,7 @@ namespace Grand.Business.Catalog.Tests.Services.Prices
IRepository<Currency> _currencyRepository;
var tempCurrencyRepository = new Mock<IRepository<Currency>>();
{
- var IMongoCollection = new Mock<MongoRepository<Currency>>().Object;
+ var IMongoCollection = new Mock<MongoRepository<Currency>>(Mock.Of<IAuditInfoProvider>()).Object;
IMongoCollection.Insert(_currency);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/CopyProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/CopyProductServiceTests.cs
index 35013ce5e..c0b6a5c07 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/CopyProductServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/CopyProductServiceTests.cs
@@ -37,7 +37,6 @@ namespace Grand.Business.Catalog.Tests.Services.Products
var product = new Product() {
Name = "name",
Price = 49,
- CreatedOnUtc = DateTime.UtcNow,
ShortDescription = "Desc"
};
var copy = await _copyProductService.CopyProduct(product, "copy-product");
@@ -47,7 +46,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
Assert.AreNotEqual(copy.SeName, product.SeName);
Assert.AreNotEqual(copy.Id, product.Id);
- Assert.AreNotEqual(copy.CreatedOnUtc, product.CreatedOnUtc);
+ Assert.AreNotEqual(copy.Name, product.Name);
_productServiceMock.Verify(c => c.InsertProduct(It.IsAny<Product>()), Times.Once);
}
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs
index 5faf6c835..5b9ff8a97 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs
@@ -44,8 +44,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
var outOfStockSubscription3 = new OutOfStockSubscription() {
CustomerId = "2"
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
-
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
var result = await _outOfStockSubscriptionService.GetAllSubscriptionsByCustomerId("1");
@@ -75,7 +76,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
StoreId = "",
WarehouseId = ""
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
var result = await _outOfStockSubscriptionService.FindSubscription("1", "1", new List<CustomAttribute>(), "", "");
@@ -105,7 +108,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
StoreId = "",
WarehouseId = ""
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
var result = await _outOfStockSubscriptionService.FindSubscription("1", "1", new List<CustomAttribute>(), "1", "");
@@ -135,7 +140,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
StoreId = "",
WarehouseId = ""
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
var result = await _outOfStockSubscriptionService.GetSubscriptionById(outOfStockSubscription1.Id);
@@ -222,7 +229,10 @@ namespace Grand.Business.Catalog.Tests.Services.Products
StoreId = "",
WarehouseId = ""
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
+
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
await _outOfStockSubscriptionService.SendNotificationsToSubscribers(new Product() { Id = "1" }, "");
@@ -255,7 +265,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
StoreId = "",
WarehouseId = ""
};
- await _repository.InsertManyAsync(new[] { outOfStockSubscription1, outOfStockSubscription2, outOfStockSubscription3 });
+ await _repository.InsertAsync(outOfStockSubscription1);
+ await _repository.InsertAsync(outOfStockSubscription2);
+ await _repository.InsertAsync(outOfStockSubscription3);
//Act
await _outOfStockSubscriptionService.SendNotificationsToSubscribers(new Product() { Id = "1" }, new CustomAttribute[] { new CustomAttribute { Key = "MyKey", Value = "1" } }, "");
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
index 64e964bbc..e3bc85654 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
@@ -41,7 +41,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
var pa1 = new ProductAttribute();
var pa2 = new ProductAttribute();
var pa3 = new ProductAttribute();
- await _repositoryproductAttribute.InsertManyAsync(new[] { pa1, pa2, pa3 });
+ await _repositoryproductAttribute.InsertAsync(pa1);
+ await _repositoryproductAttribute.InsertAsync(pa2);
+ await _repositoryproductAttribute.InsertAsync(pa3);
//Act
var result = await _productAttributeService.GetAllProductAttributes();
@@ -57,7 +59,9 @@ namespace Grand.Business.Catalog.Tests.Services.Products
var pa1 = new ProductAttribute();
var pa2 = new ProductAttribute();
var pa3 = new ProductAttribute();
- await _repositoryproductAttribute.InsertManyAsync(new[] { pa1, pa2, pa3 });
+ await _repositoryproductAttribute.InsertAsync(pa1);
+ await _repositoryproductAttribute.InsertAsync(pa2);
+ await _repositoryproductAttribute.InsertAsync(pa3);
//Act
var result = await _productAttributeService.GetProductAttributeById(pa1.Id);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs
index c0febef8c..a066bea13 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductReviewServiceTests.cs
@@ -28,12 +28,11 @@ namespace Grand.Business.Catalog.Tests.Services.Products
public async Task GetAllProductReviewsTest()
{
//Arrange
- await _repository.InsertManyAsync(new[] {
- new ProductReview(){ CustomerId = "1" },
- new ProductReview(){ CustomerId = "1"},
- new ProductReview(){ },
- new ProductReview(){ }
- });
+
+ await _repository.InsertAsync(new ProductReview(){ CustomerId = "1" });
+ await _repository.InsertAsync(new ProductReview(){ CustomerId = "1"});
+ await _repository.InsertAsync(new ProductReview(){ });
+ await _repository.InsertAsync(new ProductReview(){ });
//Act
var result = await _productReviewService.GetAllProductReviews("1", null);
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
index 7ff16ee24..af06e7b6b 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
@@ -106,7 +106,7 @@ namespace Grand.Business.Checkout.Tests.Services.CheckoutAttributes
var tempCheckoutAttributeRepo = new Mock<IRepository<CheckoutAttribute>>();
{
- var IMongoCollection = new Mock<MongoRepository<CheckoutAttribute>>().Object;
+ var IMongoCollection = new Mock<MongoRepository<CheckoutAttribute>>(Mock.Of<IAuditInfoProvider>()).Object;
IMongoCollection.Insert(ca1);
IMongoCollection.Insert(ca2);
IMongoCollection.Insert(ca3);
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs
index aae4ca8f4..e1f2bcc14 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/LoyaltyPointsServiceTests.cs
@@ -28,9 +28,9 @@ namespace Grand.Business.Checkout.Tests.Services.Orders
public async Task GetLoyaltyPointsBalanceTest()
{
//Assert
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 10, CreatedOnUtc = DateTime.UtcNow.AddDays(-3) });
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 20, CreatedOnUtc = DateTime.UtcNow.AddDays(-2) });
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 30, CreatedOnUtc = DateTime.UtcNow.AddDays(-1) });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 10 });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 20 });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 30 });
//Act
var result = await _loyaltyPointsService.GetLoyaltyPointsBalance("1", "");
//Assert
@@ -53,9 +53,9 @@ namespace Grand.Business.Checkout.Tests.Services.Orders
public async Task GetLoyaltyPointsHistoryTest()
{
//Assert
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 10, CreatedOnUtc = DateTime.UtcNow.AddDays(-3) });
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 20, CreatedOnUtc = DateTime.UtcNow.AddDays(-2) });
- await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 30, CreatedOnUtc = DateTime.UtcNow.AddDays(-1) });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 10 });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 20 });
+ await _repository.InsertAsync(new LoyaltyPointsHistory() { CustomerId = "1", StoreId = "", Points = 10, PointsBalance = 30 });
//Act
var result = await _loyaltyPointsService.GetLoyaltyPointsHistory("1");
//Assert
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs
index dc3acc5ef..efc34ebcb 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Addresses/AddressAttributeServiceTests.cs
@@ -1,5 +1,6 @@
using Grand.Business.Common.Services.Addresses;
using Grand.Domain.Common;
+using Grand.Domain.Data;
using Grand.Domain.Data.Mongo;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Events;
@@ -23,7 +24,7 @@ namespace Grand.Business.Common.Tests.Services.Addresses
{
CommonPath.BaseDirectory = "";
_cacheMock = new Mock<ICacheBase>();
- _repositoryMock = new Mock<MongoRepository<AddressAttribute>>();
+ _repositoryMock = new Mock<MongoRepository<AddressAttribute>>(Mock.Of<IAuditInfoProvider>());
_mediatorMock = new Mock<IMediator>();
_service = new AddressAttributeService(_cacheMock.Object, _repositoryMock.Object, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
index 372a7aa68..eb1314228 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
@@ -42,9 +42,7 @@ namespace Grand.Business.Common.Tests.Services.Directory
DisplayLocale = "en-US",
CustomFormatting = "",
Published = true,
- DisplayOrder = 1,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 1
};
currencyEUR = new Currency {
Id = "2",
@@ -54,9 +52,7 @@ namespace Grand.Business.Common.Tests.Services.Directory
DisplayLocale = "",
CustomFormatting = "€0.00",
Published = true,
- DisplayOrder = 2,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 2
};
currencyRUR = new Currency {
Id = "3",
@@ -66,14 +62,12 @@ namespace Grand.Business.Common.Tests.Services.Directory
DisplayLocale = "ru-RU",
CustomFormatting = "",
Published = true,
- DisplayOrder = 3,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow
+ DisplayOrder = 3
};
tempCurrencyRepository = new Mock<IRepository<Currency>>();
{
- var IMongoCollection = new Mock<MongoRepository<Currency>>().Object;
+ var IMongoCollection = new Mock<MongoRepository<Currency>>(Mock.Of<IAuditInfoProvider>()).Object;
IMongoCollection.Insert(currencyUSD);
IMongoCollection.Insert(currencyEUR);
IMongoCollection.Insert(currencyRUR);
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Documents/DocumentTypeServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Documents/DocumentTypeServiceTests.cs
index 6149ce31d..35767f2e6 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Documents/DocumentTypeServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Documents/DocumentTypeServiceTests.cs
@@ -26,7 +26,7 @@ namespace Grand.Business.Marketing.Tests.Services.Documents
_mediatorMock = new Mock<IMediator>();
_documentTypeRepositoryMock = new Mock<IRepository<DocumentType>>();
- var _mongoQueryableMock = new Mock<MongoRepository<DocumentType>>();
+ var _mongoQueryableMock = new Mock<MongoRepository<DocumentType>>(Mock.Of<IAuditInfoProvider>());
_expected = new List<DocumentType>
{
new DocumentType() {Name = "name1", Description = "t1", DisplayOrder = 0},
diff --git a/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs b/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs
new file mode 100644
index 000000000..1d27851c9
--- /dev/null
+++ b/src/Tests/Grand.Data.Tests/AuditInfoProvider.cs
@@ -0,0 +1,20 @@
+using Grand.Domain.Data;
+
+namespace Grand.Data.Tests;
+
+public class AuditInfoProvider : IAuditInfoProvider
+{
+ public AuditInfoProvider()
+ {
+ }
+
+ public string GetCurrentUser()
+ {
+ return "user";
+ }
+
+ public DateTime GetCurrentDateTime()
+ {
+ return DateTime.UtcNow;
+ }
+}
\ No newline at end of file
diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs
index 84c708792..6ae9cfdfa 100644
--- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs
+++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryMock.cs
@@ -5,9 +5,9 @@ using LiteDB;
namespace Grand.Data.Tests.LiteDb
{
- public partial class LiteDBRepositoryMock<T> : LiteDBRepository<T>, IRepository<T> where T : BaseEntity
+ public class LiteDBRepositoryMock<T> : LiteDBRepository<T>, IRepository<T> where T : BaseEntity
{
- public LiteDBRepositoryMock(): base(Guid.NewGuid().ToString())
+ public LiteDBRepositoryMock(): base(Guid.NewGuid().ToString(), new AuditInfoProvider())
{
_database = new LiteDatabase(new MemoryStream());
_database.DropCollection(typeof(T).Name);
diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs
index d1afc0c33..2c25c36df 100644
--- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs
+++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs
@@ -20,33 +20,29 @@ namespace Grand.Data.Tests.LiteDb
[TestMethod()]
public void Insert_LiteRepository_Success()
{
- var product = new SampleCollection();
+ //Arrange
+ var product = new SampleCollection(){Id = "1"};
+ //Act
_myRepository.Insert(product);
-
+ //Assert
Assert.AreEqual(1, _myRepository.Table.Count());
+ Assert.IsTrue(_myRepository.Table.FirstOrDefault(x=>x.Id == "1")!.CreatedBy == "user");
}
[TestMethod()]
public async Task InsertAsync_LiteRepository_Success()
{
- var product = new SampleCollection();
+ //Arrange
+ var product = new SampleCollection(){ Id = "11"};
+ //Act
await _myRepository.InsertAsync(product);
-
+ var p = _myRepository.GetById("11");
+ //Assert
+ Assert.IsNotNull(p);
Assert.AreEqual(1, _myRepository.Table.Count());
+ Assert.IsTrue(p.CreatedBy == "user");
}
- [TestMethod()]
- public async Task InsertManyAsync_LiteRepository_Success()
- {
- var products = new List<SampleCollection>() {
- new SampleCollection(){ Id = "1" },
- new SampleCollection(){ Id = "2" },
- new SampleCollection(){ Id = "3" }
-
- };
- await _myRepository.InsertManyAsync(products);
-
- Assert.IsTrue(_myRepository.Table.Count() == 3);
- }
+
[TestMethod()]
public async Task GetById_LiteRepository_Success()
{
@@ -83,18 +79,23 @@ namespace Grand.Data.Tests.LiteDb
[TestMethod()]
public async Task AddToSet_LiteRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
await _myRepository.AddToSet("1", x => x.UserFields,
new Domain.Common.UserField() { Key = "key", Value = "value", StoreId = "" });
+ //Act
await _myRepository.AddToSet("1", x => x.UserFields,
new Domain.Common.UserField() { Key = "key2", Value = "value2", StoreId = "" });
-
var p = _myRepository.GetById("1");
-
+
+ //Assert
Assert.IsTrue(p.UserFields.Count == 2);
+ Assert.IsTrue(p.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p.UpdatedBy == "user");
+
}
[TestMethod()]
@@ -125,39 +126,19 @@ namespace Grand.Data.Tests.LiteDb
[TestMethod()]
public async Task DeleteManyAsync_LiteRepository_Success()
{
- var products = new List<SampleCollection>() {
- new SampleCollection(){ Id = "1", Name = "Test" },
- new SampleCollection(){ Id = "2", Name = "Test" },
- new SampleCollection(){ Id = "3", Name = "Test2" }
-
- };
- await _myRepository.InsertManyAsync(products);
+ await _myRepository.InsertAsync(new SampleCollection(){ Id = "1", Name = "Test" });
+ await _myRepository.InsertAsync(new SampleCollection(){ Id = "2", Name = "Test" });
+ await _myRepository.InsertAsync(new SampleCollection(){ Id = "3", Name = "Test2" });
await _myRepository.DeleteManyAsync(x => x.Name == "Test");
Assert.IsTrue(_myRepository.Table.Count() == 1);
}
- [TestMethod()]
- public async Task GetAllAsync_LiteRepository_Success()
- {
- var products = new List<SampleCollection>() {
- new SampleCollection(){ Id = "1", Name = "Test" },
- new SampleCollection(){ Id = "2", Name = "Test2" },
- new SampleCollection(){ Id = "3", Name = "Test3" }
-
- };
- await _myRepository.InsertManyAsync(products);
-
- var p = await _myRepository.GetAllAsync();
-
- Assert.IsTrue(p.Count() == 3);
- }
-
-
[TestMethod()]
public async Task Pull_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
Phones = new [] { "Phone1", "Phone2", "Phone3" }
@@ -168,17 +149,20 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.Pull("1", x => x.Phones, "Phone2");
-
var p = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p.Phones.Count() == 2);
+ Assert.IsTrue(p.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p.UpdatedBy == "user");
}
[TestMethod()]
public async Task Pull_Many_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
Phones = new [] { "Phone1", "Phone2", "Phone3" }
@@ -189,20 +173,26 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.Pull(String.Empty, x => x.Phones, "Phone2");
var p1 = _myRepository.GetById("1");
var p2 = _myRepository.GetById("2");
var p3 = _myRepository.GetById("3");
-
+
+ //Assert
Assert.IsTrue(p1.Phones.Count() == 2 && p2.Phones.Count() == 2 && p3.Phones.Count() == 0);
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task PullFilter_1_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -215,18 +205,23 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter("1", x => x.UserFields, x => x.Value == "value");
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 2);
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task PullFilter_2_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -239,17 +234,23 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter("1", x => x.UserFields, x => x.Value, "value");
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 1);
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task PullFilter_2_Many_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -269,20 +270,25 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter(String.Empty, x => x.UserFields, x => x.Value, "value");
var p1 = _myRepository.GetById("1");
var p2 = _myRepository.GetById("2");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 1 && p2.UserFields.Count() == 2);
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
}
[TestMethod()]
- public async Task Update_LiteRepository_Success()
+ public void Update_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -295,20 +301,26 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
var p1_update = products.FirstOrDefault();
p1_update.Name = "update";
+ //Act
_myRepository.Update(p1_update);
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task UpdateAsync_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -321,21 +333,24 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
var p1_update = products.FirstOrDefault();
p1_update.Name = "update";
-
+ //Act
await _myRepository.UpdateAsync(p1_update);
var p1 = _myRepository.GetById("1");
-
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
}
[TestMethod()]
public async Task UpdateField_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -348,13 +363,17 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.UpdateField("1", x => x.Name, "update");
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p1.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task IncField_MongoRepository_Success()
@@ -373,6 +392,7 @@ namespace Grand.Data.Tests.LiteDb
[TestMethod()]
public async Task UpdateManyAsync_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -385,18 +405,25 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+
+ //Act
await _myRepository.UpdateManyAsync(x => x.Name == "Test",
UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));
var pUpdated = _myRepository.Table.Where(x=>x.Name == "UpdateTest");
+ //Asser
Assert.IsTrue(pUpdated.Count() == 2);
+ Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task UpdateOneAsync_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -409,17 +436,23 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.UpdateOneAsync(x => x.Name == "Test",
UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));
var pUpdated = _myRepository.Table.Where(x => x.Name == "UpdateTest");
+ //Assert
Assert.IsTrue(pUpdated.Count() == 1);
+ Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(pUpdated.FirstOrDefault()!.UpdatedBy == "user");
+
}
[TestMethod()]
public async Task UpdateToSet_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -432,18 +465,23 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+
+ //Act
await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key", new Domain.Common.UserField() { Key = "key", Value = "update", StoreId = "1" });
-
var p = _myRepository.GetById("1");
+
+ //Assert
+ Assert.IsTrue(p.UserFields!.FirstOrDefault(x=>x.Key=="key")!.Value == "update");
+ Assert.IsTrue(p.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p.UpdatedBy == "user");
- Assert.IsTrue(p.UserFields.FirstOrDefault(x=>x.Key=="key").Value == "update");
}
[TestMethod()]
public async Task UpdateToSet_2_LiteRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -456,13 +494,17 @@ namespace Grand.Data.Tests.LiteDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key == "key", new Domain.Common.UserField() { Key = "key", Value = "update", StoreId = "1" });
var p = _myRepository.GetById("1");
- Assert.IsTrue(p.UserFields.FirstOrDefault(x => x.Key == "key").Value == "update");
+ //Assert
+ Assert.IsTrue(p.UserFields!.FirstOrDefault(x => x.Key == "key")!.Value == "update");
+ Assert.IsTrue(p.UpdatedOnUtc.HasValue);
+ Assert.IsTrue(p.UpdatedBy == "user");
+
}
}
}
diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
index f1a864505..2158d34e6 100644
--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoDBRepositoryTest.cs
@@ -5,9 +5,9 @@ using MongoDB.Bson.Serialization.Conventions;
namespace Grand.Data.Tests.MongoDb
{
- public partial class MongoDBRepositoryTest<T> : MongoRepository<T>, IRepository<T> where T : BaseEntity
+ public class MongoDBRepositoryTest<T> : MongoRepository<T>, IRepository<T> where T : BaseEntity
{
- public MongoDBRepositoryTest():base(DriverTestConfiguration.Client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName))
+ public MongoDBRepositoryTest():base(DriverTestConfiguration.Client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName), new AuditInfoProvider())
{
var cp = new ConventionPack {
new IgnoreExtraElementsConvention(true)
@@ -22,4 +22,6 @@ namespace Grand.Data.Tests.MongoDb
_collection = _database.GetCollection<T>(typeof(T).Name);
}
}
+
+
}
diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs
index 1c9d4a3a4..6eda51c74 100644
--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs
+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs
@@ -20,53 +20,45 @@ namespace Grand.Data.Tests.MongoDb
[TestMethod()]
public void Insert_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection();
+ //Act
_myRepository.Insert(product);
-
+ //Assert
Assert.AreEqual(1, _myRepository.Table.Count());
+ Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedBy == "user");
+ Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Month == DateTime.UtcNow.Month);
+ Assert.IsTrue(_myRepository.Table.FirstOrDefault()!.CreatedOnUtc.Day == DateTime.UtcNow.Day);
}
- [TestMethod()]
- public async Task InsertAsync_MongoRepository_Success()
- {
- var product = new SampleCollection();
- await _myRepository.InsertAsync(product);
-
- Assert.AreEqual(1, _myRepository.Table.Count());
- }
- [TestMethod()]
- public async Task InsertManyAsync_MongoRepository_Success()
- {
- var products = new List<SampleCollection>() {
- new SampleCollection(){ Id = "1" },
- new SampleCollection(){ Id = "2" },
- new SampleCollection(){ Id = "3" }
-
- };
- await _myRepository.InsertManyAsync(products);
-
- Assert.IsTrue(_myRepository.Table.Count() == 3);
- }
+
[TestMethod()]
public async Task GetById_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
-
+
+ //Act
var p = _myRepository.GetById("1");
-
+
+ //Assert
Assert.IsNotNull(p);
}
[TestMethod()]
public async Task GetByIdAsync_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
-
+ //Act
var p = await _myRepository.GetByIdAsync("1");
-
+ //Assert
Assert.IsNotNull(p);
+ Assert.IsTrue(p!.CreatedBy == "user");
+ Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
}
[TestMethod()]
@@ -83,81 +75,79 @@ namespace Grand.Data.Tests.MongoDb
[TestMethod()]
public async Task AddToSet_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
await _myRepository.AddToSet("1", x => x.UserFields,
new Domain.Common.UserField() { Key = "key", Value = "value", StoreId = "" });
+ //Act
await _myRepository.AddToSet("1", x => x.UserFields,
new Domain.Common.UserField() { Key = "key2", Value = "value2", StoreId = "" });
var p = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p.UserFields.Count == 2);
+ Assert.IsTrue(p!.CreatedBy == "user");
+ Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p!.UpdatedBy == "user");
+ Assert.IsTrue(p!.UpdatedOnUtc.HasValue);
}
[TestMethod()]
public async Task Delete_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
+ //Act
_myRepository.Delete(product);
-
var p = _myRepository.GetById("1");
+ //Assert
Assert.IsNull(p);
}
[TestMethod()]
public async Task DeleteAsync_MongoRepository_Success()
{
+ //Arrange
var product = new SampleCollection() { Id = "1" };
await _myRepository.InsertAsync(product);
+ //Act
await _myRepository.DeleteAsync(product);
-
var p = _myRepository.GetById("1");
+ //Assert
Assert.IsNull(p);
}
[TestMethod()]
public async Task DeleteManyAsync_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test" },
new SampleCollection(){ Id = "2", Name = "Test" },
new SampleCollection(){ Id = "3", Name = "Test2" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.DeleteManyAsync(x => x.Name == "Test");
+ //Assert
Assert.IsTrue(_myRepository.Table.Count() == 1);
}
- [TestMethod()]
- public async Task GetAllAsync_MongoRepository_Success()
- {
- var products = new List<SampleCollection>() {
- new SampleCollection(){ Id = "1", Name = "Test" },
- new SampleCollection(){ Id = "2", Name = "Test2" },
- new SampleCollection(){ Id = "3", Name = "Test3" }
-
- };
- await _myRepository.InsertManyAsync(products);
-
- var p = await _myRepository.GetAllAsync();
-
- Assert.IsTrue(p.Count() == 3);
- }
-
-
[TestMethod()]
public async Task Pull_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
Phones = new [] { "Phone1", "Phone2", "Phone3" }
@@ -168,17 +158,24 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.Pull("1", x => x.Phones, "Phone2");
var p = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p.Phones.Count() == 2);
+ Assert.IsTrue(p!.CreatedBy == "user");
+ Assert.IsTrue(p!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p!.UpdatedBy == "user");
+ Assert.IsTrue(p!.UpdatedOnUtc.HasValue);
}
[TestMethod()]
public async Task Pull_Many_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
Phones = new [] { "Phone1", "Phone2", "Phone3" }
@@ -189,20 +186,27 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.Pull(String.Empty, x => x.Phones, "Phone2");
var p1 = _myRepository.GetById("1");
var p2 = _myRepository.GetById("2");
var p3 = _myRepository.GetById("3");
+ //Assert
Assert.IsTrue(p1.Phones.Count() == 2 && p2.Phones.Count() == 2 && p3.Phones.Count() == 0);
+ Assert.IsTrue(p1!.CreatedBy == "user");
+ Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
}
[TestMethod()]
public async Task PullFilter_1_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -215,18 +219,26 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter("1", x => x.UserFields, x => x.Value == "value");
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 1);
+ Assert.IsTrue(p1!.CreatedBy == "user");
+ Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
public async Task PullFilter_2_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -239,17 +251,25 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter("1", x => x.UserFields, x => x.Value, "value");
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 1);
+ Assert.IsTrue(p1!.CreatedBy == "user");
+ Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
public async Task PullFilter_2_Many_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -269,20 +289,28 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.PullFilter(String.Empty, x => x.UserFields, x => x.Value, "value");
var p1 = _myRepository.GetById("1");
var p2 = _myRepository.GetById("2");
+ //Assert
Assert.IsTrue(p1.UserFields.Count() == 1 && p2.UserFields.Count() == 2);
+ Assert.IsTrue(p1!.CreatedBy == "user");
+ Assert.IsTrue(p1!.CreatedOnUtc.Year == DateTime.UtcNow.Year);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
- public async Task Update_MongoRepository_Success()
+ public void Update_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -295,20 +323,25 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
var p1_update = products.FirstOrDefault();
p1_update.Name = "update";
+ //Act
_myRepository.Update(p1_update);
-
var p1 = _myRepository.GetById("1");
-
+
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
public async Task UpdateAsync_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -321,21 +354,24 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
var p1_update = products.FirstOrDefault();
p1_update.Name = "update";
-
+ //Act
await _myRepository.UpdateAsync(p1_update);
-
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
}
[TestMethod()]
public async Task UpdateField_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -348,13 +384,16 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+
+ //Act
await _myRepository.UpdateField("1", x => x.Name, "update");
-
var p1 = _myRepository.GetById("1");
+ //Assert
Assert.IsTrue(p1.Name == "update");
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
}
[TestMethod()]
@@ -375,6 +414,7 @@ namespace Grand.Data.Tests.MongoDb
[TestMethod()]
public async Task UpdateManyAsync_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -387,18 +427,23 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.UpdateManyAsync(x => x.Name == "Test",
UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));
-
var pUpdated = _myRepository.Table.Where(x=>x.Name == "UpdateTest");
-
+ var p1 = pUpdated.FirstOrDefault();
+ //Assert
Assert.IsTrue(pUpdated.Count() == 2);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
public async Task UpdateOneAsync_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -411,17 +456,24 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
+ products.ForEach(x=>_myRepository.Insert(x));
+
+ //Act
await _myRepository.UpdateOneAsync(x => x.Name == "Test",
UpdateBuilder<SampleCollection>.Create().Set(x => x.Name, "UpdateTest"));
var pUpdated = _myRepository.Table.Where(x => x.Name == "UpdateTest");
-
+ var p1 = pUpdated.FirstOrDefault();
+ //Assert
Assert.IsTrue(pUpdated.Count() == 1);
+ Assert.IsTrue(p1!.UpdatedBy == "user");
+ Assert.IsTrue(p1!.UpdatedOnUtc.HasValue);
+
}
[TestMethod()]
public async Task UpdateToSet_MongoRepository_Success()
{
+ //Arrange
var products = new List<SampleCollection>() {
new SampleCollection(){ Id = "1", Name = "Test",
UserFields = new List<Domain.Common.UserField>()
@@ -434,13 +486,16 @@ namespace Grand.Data.Tests.MongoDb
new SampleCollection(){ Id = "3", Name = "Test3" }
};
- await _myRepository.InsertManyAsync(products);
-
+ products.ForEach(x=>_myRepository.Insert(x));
+ //Act
await _myRepository.UpdateToSet("1", x => x.UserFields, z => z.Key, "key", new Domain.Common.UserField() { Key = "key", Value = "update", StoreId = "1" });
-
var p = _myRepository.GetById("1");
- Assert.IsTrue(p.UserFields.FirstOrDefault(x=>x.Key=="key").Value == "update");
+ //Assert
+ Assert.IsTrue(p.UserFields.FirstOrDefault(x=>x.Key=="key")!.Value == "update");
+ Assert.IsTrue(p!.UpdatedBy == "user");
+ Assert.IsTrue(p!.UpdatedOnUtc.HasValue);
+
}
}
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/CurrencyController.cs b/src/Web/Grand.Web.Admin/Controllers/CurrencyController.cs
index 2f203f72c..cbf3ea66f 100644
--- a/src/Web/Grand.Web.Admin/Controllers/CurrencyController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/CurrencyController.cs
@@ -140,7 +140,6 @@ namespace Grand.Web.Admin.Controllers
if (currency != null)
{
currency.Rate = _rate;
- currency.UpdatedOnUtc = DateTime.UtcNow;
await _currencyService.UpdateCurrency(currency);
}
return Json(new { result = true });
diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
index 95f27ee0e..cd84e0b20 100644
--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
@@ -305,7 +305,6 @@ namespace Grand.Web.Admin.Controllers
{
Note = $"Order status has been edited. New status: {status?.Name}",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
@@ -502,7 +501,6 @@ namespace Grand.Web.Admin.Controllers
{
Note = "Order totals have been edited",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
@@ -531,7 +529,6 @@ namespace Grand.Web.Admin.Controllers
{
Note = "Shipping method has been edited",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
await _orderViewModelService.PrepareOrderDetailsModel(model, order);
diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
index cf5ed1bca..86e8fc183 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
@@ -186,7 +186,7 @@ namespace Grand.Web.Admin.Controllers
}
var model = product.ToModel(_dateTimeService);
- model.Ticks = product.UpdatedOnUtc.Ticks;
+ //model.Ticks = product.UpdatedOnUtc.Ticks;
await _productViewModelService.PrepareProductModel(model, product, false, false);
await AddLocales(_languageService, model.Locales, (locale, languageId) =>
@@ -218,7 +218,7 @@ namespace Grand.Web.Admin.Controllers
return RedirectToAction("Edit", new { id = product.Id });
}
- if (model.Ticks != product.UpdatedOnUtc.Ticks)
+ if (model.Ticks != product.Ticks)
{
Error(_translationService.GetResource("Admin.Catalog.Products.Fields.ChangedWarning"));
return RedirectToAction("Edit", new { id = product.Id });
diff --git a/src/Web/Grand.Web.Admin/Controllers/QueuedEmailController.cs b/src/Web/Grand.Web.Admin/Controllers/QueuedEmailController.cs
index a80a4798e..ae5378933 100644
--- a/src/Web/Grand.Web.Admin/Controllers/QueuedEmailController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/QueuedEmailController.cs
@@ -185,7 +185,6 @@ namespace Grand.Web.Admin.Controllers
AttachmentFilePath = queuedEmail.AttachmentFilePath,
AttachmentFileName = queuedEmail.AttachmentFileName,
AttachedDownloads = queuedEmail.AttachedDownloads,
- CreatedOnUtc = DateTime.UtcNow,
EmailAccountId = queuedEmail.EmailAccountId,
DontSendBeforeDateUtc = queuedEmailModel.SendImmediately || !queuedEmailModel.DontSendBeforeDate.HasValue ?
null : _dateTimeService.ConvertToUtcTime(queuedEmailModel.DontSendBeforeDate.Value)
diff --git a/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs b/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs
index 8e7ca8200..20156f2de 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs
@@ -205,7 +205,6 @@ namespace Grand.Web.Admin.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = $"A shipment #{shipment.ShipmentNumber} has been added",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
@@ -271,7 +270,6 @@ namespace Grand.Web.Admin.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = $"A shipment #{shipment.ShipmentNumber} has been deleted",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
diff --git a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs b/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
index 032a15b6c..66e53b193 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs
@@ -488,7 +488,6 @@ namespace Grand.Web.Admin.Controllers
{
var warehouse = model.ToEntity();
var address = model.Address.ToEntity();
- address.CreatedOnUtc = DateTime.UtcNow;
warehouse.Address = address;
await _warehouseService.InsertWarehouse(warehouse);
diff --git a/src/Web/Grand.Web.Admin/Controllers/ShoppingCartController.cs b/src/Web/Grand.Web.Admin/Controllers/ShoppingCartController.cs
index 05a051121..7c3cf76e3 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ShoppingCartController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ShoppingCartController.cs
@@ -104,7 +104,7 @@ namespace Grand.Web.Admin.Controllers
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes, customer),
UnitPrice = _priceFormatter.FormatPrice((await _taxService.GetProductPrice(product, (await _pricingService.GetUnitPrice(sci, product)).unitprice)).productprice),
Total = _priceFormatter.FormatPrice((await _taxService.GetProductPrice(product, (await _pricingService.GetSubTotal(sci, product)).subTotal)).productprice),
- UpdatedOn = _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc, DateTimeKind.Utc)
+ UpdatedOn = sci.UpdatedOnUtc.HasValue ? _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc.Value, DateTimeKind.Utc) : _dateTimeService.ConvertToUserTime(sci.CreatedOnUtc, DateTimeKind.Utc)
};
items.Add(sciModel);
}
@@ -161,7 +161,7 @@ namespace Grand.Web.Admin.Controllers
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes, customer),
UnitPrice = _priceFormatter.FormatPrice((await _taxService.GetProductPrice(product, (await _pricingService.GetUnitPrice(sci, product)).unitprice)).productprice),
Total = _priceFormatter.FormatPrice((await _taxService.GetProductPrice(product, (await _pricingService.GetSubTotal(sci, product)).subTotal)).productprice),
- UpdatedOn = _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc, DateTimeKind.Utc)
+ UpdatedOn = sci.UpdatedOnUtc.HasValue ? _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc.Value, DateTimeKind.Utc) : _dateTimeService.ConvertToUserTime(sci.CreatedOnUtc, DateTimeKind.Utc)
};
items.Add(sciModel);
}
diff --git a/src/Web/Grand.Web.Admin/Mapper/AddressProfile.cs b/src/Web/Grand.Web.Admin/Mapper/AddressProfile.cs
index f1725610f..c28b956ee 100644
--- a/src/Web/Grand.Web.Admin/Mapper/AddressProfile.cs
+++ b/src/Web/Grand.Web.Admin/Mapper/AddressProfile.cs
@@ -41,7 +41,6 @@ namespace Grand.Web.Admin.Mapper
//address
CreateMap<AddressModel, Address>()
- .ForMember(dest => dest.CreatedOnUtc, mo => mo.Ignore())
.ForMember(dest => dest.Id, mo => mo.Ignore())
.ForMember(dest => dest.Attributes, mo => mo.Ignore());
diff --git a/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs b/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs
index c3839aece..e438f1587 100644
--- a/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/AffiliateViewModelService.cs
@@ -135,7 +135,6 @@ namespace Grand.Web.Admin.Services
var friendlyUrlName = await affiliate.ValidateFriendlyUrlName(_affiliateService, _seoSettings, model.FriendlyUrlName, model.Name);
affiliate.FriendlyUrlName = friendlyUrlName.ToLowerInvariant();
affiliate.Address = model.Address.ToEntity();
- affiliate.Address.CreatedOnUtc = DateTime.UtcNow;
//some validation
await _affiliateService.InsertAffiliate(affiliate);
return affiliate;
diff --git a/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs b/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs
index 39255db98..9ba099e6e 100644
--- a/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs
@@ -75,7 +75,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<BlogPost> InsertBlogPostModel(BlogPostModel model)
{
var blogPost = model.ToEntity(_dateTimeService);
- blogPost.CreatedOnUtc = DateTime.UtcNow;
await _blogService.InsertBlogPost(blogPost);
//search engine name
diff --git a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs
index 6baee2ae1..de2b22a9a 100644
--- a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs
@@ -105,8 +105,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Brand> InsertBrandModel(BrandModel model)
{
var brand = model.ToEntity();
- brand.CreatedOnUtc = DateTime.UtcNow;
- brand.UpdatedOnUtc = DateTime.UtcNow;
//discounts
var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToBrands, showHidden: true);
foreach (var discount in allDiscounts)
@@ -134,7 +132,6 @@ namespace Grand.Web.Admin.Services
{
var prevPictureId = brand.PictureId;
brand = model.ToEntity(brand);
- brand.UpdatedOnUtc = DateTime.UtcNow;
brand.Locales = await model.Locales.ToTranslationProperty(brand, x => x.Name, _seoSettings, _slugService, _languageService);
//discounts
var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToBrands, showHidden: true);
diff --git a/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs
index e1b87fecc..55832f2a6 100644
--- a/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CampaignViewModelService.cs
@@ -172,7 +172,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Campaign> InsertCampaignModel(CampaignModel model)
{
var campaign = model.ToEntity();
- campaign.CreatedOnUtc = DateTime.UtcNow;
await _campaignService.InsertCampaign(campaign);
return campaign;
}
diff --git a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs
index a2b6a035c..154eb241c 100644
--- a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs
@@ -165,8 +165,6 @@ namespace Grand.Web.Admin.Services
public async Task<Category> InsertCategoryModel(CategoryModel model)
{
var category = model.ToEntity();
- category.CreatedOnUtc = DateTime.UtcNow;
- category.UpdatedOnUtc = DateTime.UtcNow;
var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToCategories, showHidden: true);
foreach (var discount in allDiscounts)
{
@@ -193,7 +191,6 @@ namespace Grand.Web.Admin.Services
{
var prevPictureId = category.PictureId;
category = model.ToEntity(category);
- category.UpdatedOnUtc = DateTime.UtcNow;
model.SeName = await category.ValidateSeName(model.SeName, category.Name, true, _seoSettings, _slugService, _languageService);
category.SeName = model.SeName;
//locales
diff --git a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs
index fe299f1de..1b31571ff 100644
--- a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs
@@ -118,8 +118,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Collection> InsertCollectionModel(CollectionModel model)
{
var collection = model.ToEntity();
- collection.CreatedOnUtc = DateTime.UtcNow;
- collection.UpdatedOnUtc = DateTime.UtcNow;
//discounts
var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToCollections, showHidden: true);
foreach (var discount in allDiscounts)
@@ -147,7 +145,6 @@ namespace Grand.Web.Admin.Services
{
var prevPictureId = collection.PictureId;
collection = model.ToEntity(collection);
- collection.UpdatedOnUtc = DateTime.UtcNow;
collection.Locales = await model.Locales.ToTranslationProperty(collection, x => x.Name, _seoSettings, _slugService, _languageService);
//discounts
var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToCollections, showHidden: true);
diff --git a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
index 563d331a5..2cd872665 100644
--- a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
@@ -94,9 +94,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Course> InsertCourseModel(CourseModel model)
{
var course = model.ToEntity();
- course.CreatedOnUtc = DateTime.UtcNow;
- course.UpdatedOnUtc = DateTime.UtcNow;
-
await _courseService.Insert(course);
//locales
@@ -122,7 +119,6 @@ namespace Grand.Web.Admin.Services
var prevProductId = course.ProductId;
course = model.ToEntity(course);
- course.UpdatedOnUtc = DateTime.UtcNow;
model.SeName = await course.ValidateSeName(model.SeName, course.Name, true, _seoSettings, _slugService, _languageService);
course.SeName = model.SeName;
//locales
diff --git a/src/Web/Grand.Web.Admin/Services/CurrencyViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CurrencyViewModelService.cs
index 77d7afaf8..3764b8273 100644
--- a/src/Web/Grand.Web.Admin/Services/CurrencyViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CurrencyViewModelService.cs
@@ -36,8 +36,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Currency> InsertCurrencyModel(CurrencyModel model)
{
var currency = model.ToEntity();
- currency.CreatedOnUtc = DateTime.UtcNow;
- currency.UpdatedOnUtc = DateTime.UtcNow;
await _currencyService.InsertCurrency(currency);
return currency;
@@ -46,7 +44,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Currency> UpdateCurrencyModel(Currency currency, CurrencyModel model)
{
currency = model.ToEntity(currency);
- currency.UpdatedOnUtc = DateTime.UtcNow;
await _currencyService.UpdateCurrency(currency);
return currency;
}
diff --git a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs
index 8e7bcdb5e..59b552e1e 100644
--- a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs
@@ -629,7 +629,6 @@ namespace Grand.Web.Admin.Services
StoreId = _workContext.CurrentStore.Id,
OwnerId = ownerId,
Attributes = model.Attributes,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
@@ -682,8 +681,7 @@ namespace Grand.Web.Admin.Services
CustomerId = customer.Id,
Email = customer.Email,
Active = true,
- StoreId = store.Id,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = store.Id
});
}
}
@@ -825,8 +823,7 @@ namespace Grand.Web.Admin.Services
CustomerId = customer.Id,
Email = customer.Email,
Active = true,
- StoreId = store.Id,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = store.Id
});
}
}
@@ -912,7 +909,6 @@ namespace Grand.Web.Admin.Services
To = customer.Email,
Subject = model.Subject,
Body = model.Body,
- CreatedOnUtc = DateTime.UtcNow,
DontSendBeforeDateUtc = model.SendImmediately || !model.DontSendBeforeDate.HasValue ?
null : _dateTimeService.ConvertToUtcTime(model.DontSendBeforeDate.Value)
};
@@ -943,7 +939,7 @@ namespace Grand.Web.Admin.Services
public virtual async Task<IEnumerable<AddressModel>> PrepareAddressModel(Customer customer)
{
- var addresses = customer.Addresses.OrderByDescending(a => a.CreatedOnUtc).ThenByDescending(a => a.Id).ToList();
+ var addresses = customer.Addresses.ToList();
var addressesListModel = new List<AddressModel>();
foreach (var x in addresses)
{
@@ -985,7 +981,6 @@ namespace Grand.Web.Admin.Services
{
var address = model.Address.ToEntity();
address.Attributes = customAttributes;
- address.CreatedOnUtc = DateTime.UtcNow;
customer.Addresses.Add(address);
await _customerService.UpdateCustomerInAdminPanel(customer);
return address;
@@ -1087,7 +1082,7 @@ namespace Grand.Web.Admin.Services
UnitPrice = priceFormatter.FormatPrice(price),
UnitPriceValue = price,
Total = priceFormatter.FormatPrice((await taxService.GetProductPrice(product, (await priceCalculationService.GetSubTotal(sci, product)).subTotal)).productprice),
- UpdatedOn = _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc, DateTimeKind.Utc)
+ UpdatedOn = sci.UpdatedOnUtc.HasValue ? _dateTimeService.ConvertToUserTime(sci.UpdatedOnUtc.Value, DateTimeKind.Utc) : _dateTimeService.ConvertToUserTime(sci.CreatedOnUtc, DateTimeKind.Utc)
};
items.Add(sciModel);
}
@@ -1315,8 +1310,7 @@ namespace Grand.Web.Admin.Services
Title = title,
Note = message,
DownloadId = downloadId,
- CustomerId = customerId,
- CreatedOnUtc = DateTime.UtcNow
+ CustomerId = customerId
};
await _customerNoteService.InsertCustomerNote(customerNote);
diff --git a/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs b/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs
index 331275f78..73bdf76e5 100644
--- a/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs
@@ -210,7 +210,6 @@ namespace Grand.Web.Admin.Services
model.CustomerId = !string.IsNullOrEmpty(model.CustomerEmail) ? (await _customerService.GetCustomerByEmail(model.CustomerEmail))?.Id : string.Empty;
var document = model.ToEntity();
- document.CreatedOnUtc = DateTime.UtcNow;
await _documentService.Insert(document);
return document;
}
@@ -227,8 +226,6 @@ namespace Grand.Web.Admin.Services
model.CustomerId = string.Empty;
document = model.ToEntity(document);
- document.UpdatedOnUtc = DateTime.UtcNow;
-
await _documentService.Update(document);
//delete an old "attachment" file (if deleted or updated)
diff --git a/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs b/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs
index 1dddd2fc6..48d54b4f8 100644
--- a/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs
@@ -131,7 +131,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<GiftVoucher> InsertGiftVoucherModel(GiftVoucherModel model)
{
var giftVoucher = model.ToEntity(_dateTimeService);
- giftVoucher.CreatedOnUtc = DateTime.UtcNow;
await _giftVoucherService.InsertGiftVoucher(giftVoucher);
return giftVoucher;
}
diff --git a/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs b/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs
index fa94957e8..7466f26a9 100644
--- a/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs
@@ -132,8 +132,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<KnowledgebaseCategory> InsertKnowledgebaseCategoryModel(KnowledgebaseCategoryModel model)
{
var knowledgebaseCategory = model.ToEntity();
- knowledgebaseCategory.CreatedOnUtc = DateTime.UtcNow;
- knowledgebaseCategory.UpdatedOnUtc = DateTime.UtcNow;
knowledgebaseCategory.Locales = await model.Locales.ToTranslationProperty(knowledgebaseCategory, x => x.Name, _seoSettings, _slugService, _languageService);
model.SeName = await knowledgebaseCategory.ValidateSeName(model.SeName, knowledgebaseCategory.Name, true, _seoSettings, _slugService, _languageService);
knowledgebaseCategory.SeName = model.SeName;
@@ -145,7 +143,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<KnowledgebaseCategory> UpdateKnowledgebaseCategoryModel(KnowledgebaseCategory knowledgebaseCategory, KnowledgebaseCategoryModel model)
{
knowledgebaseCategory = model.ToEntity(knowledgebaseCategory);
- knowledgebaseCategory.UpdatedOnUtc = DateTime.UtcNow;
knowledgebaseCategory.Locales = await model.Locales.ToTranslationProperty(knowledgebaseCategory, x => x.Name, _seoSettings, _slugService, _languageService);
model.SeName = await knowledgebaseCategory.ValidateSeName(model.SeName, knowledgebaseCategory.Name, true, _seoSettings, _slugService, _languageService);
knowledgebaseCategory.SeName = model.SeName;
@@ -171,8 +168,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<KnowledgebaseArticle> InsertKnowledgebaseArticleModel(KnowledgebaseArticleModel model)
{
var knowledgebaseArticle = model.ToEntity();
- knowledgebaseArticle.CreatedOnUtc = DateTime.UtcNow;
- knowledgebaseArticle.UpdatedOnUtc = DateTime.UtcNow;
knowledgebaseArticle.Locales = await model.Locales.ToTranslationProperty(knowledgebaseArticle, x => x.Name, _seoSettings, _slugService, _languageService);
model.SeName = await knowledgebaseArticle.ValidateSeName(model.SeName, knowledgebaseArticle.Name, true, _seoSettings, _slugService, _languageService);
knowledgebaseArticle.SeName = model.SeName;
@@ -185,7 +180,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<KnowledgebaseArticle> UpdateKnowledgebaseArticleModel(KnowledgebaseArticle knowledgebaseArticle, KnowledgebaseArticleModel model)
{
knowledgebaseArticle = model.ToEntity(knowledgebaseArticle);
- knowledgebaseArticle.UpdatedOnUtc = DateTime.UtcNow;
knowledgebaseArticle.Locales = await model.Locales.ToTranslationProperty(knowledgebaseArticle, x => x.Name, _seoSettings, _slugService, _languageService);
model.SeName = await knowledgebaseArticle.ValidateSeName(model.SeName, knowledgebaseArticle.Name, true, _seoSettings, _slugService, _languageService);
knowledgebaseArticle.SeName = model.SeName;
diff --git a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
index 9bc296b65..deac80337 100644
--- a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
@@ -265,7 +265,6 @@ namespace Grand.Web.Admin.Services
merchandiseReturn.StaffNotes = model.StaffNotes;
merchandiseReturn.MerchandiseReturnStatusId = model.MerchandiseReturnStatusId;
merchandiseReturn.ExternalId = model.ExternalId;
- merchandiseReturn.UpdatedOnUtc = DateTime.UtcNow;
merchandiseReturn.UserFields = model.UserFields;
if (_orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate)
@@ -317,8 +316,7 @@ namespace Grand.Web.Admin.Services
DisplayToCustomer = displayToCustomer,
Note = message,
DownloadId = downloadId,
- MerchandiseReturnId = merchandiseReturn.Id,
- CreatedOnUtc = DateTime.UtcNow
+ MerchandiseReturnId = merchandiseReturn.Id
};
await _merchandiseReturnService.InsertMerchandiseReturnNote(merchandiseReturnNote);
diff --git a/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs b/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs
index 0f9455bd2..37a94300d 100644
--- a/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/NewsViewModelService.cs
@@ -70,7 +70,6 @@ namespace Grand.Web.Admin.Services
public virtual async Task<NewsItem> InsertNewsItemModel(NewsItemModel model)
{
var newsItem = model.ToEntity(_dateTimeService);
- newsItem.CreatedOnUtc = DateTime.UtcNow;
await _newsService.InsertNews(newsItem);
var seName = await newsItem.ValidateSeName(model.SeName, model.Title, true, _seoSettings, _slugService, _languageService);
diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
index d97fbb602..a05e99d74 100644
--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
@@ -1010,8 +1010,7 @@ namespace Grand.Web.Admin.Services
DisplayToCustomer = displayToCustomer,
Note = message,
DownloadId = downloadId,
- OrderId = order.Id,
- CreatedOnUtc = DateTime.UtcNow
+ OrderId = order.Id
};
await _orderService.InsertOrderNote(orderNote);
@@ -1052,7 +1051,6 @@ namespace Grand.Web.Admin.Services
await _orderService.InsertOrderNote(new OrderNote {
Note = "Address has been edited",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
return address;
diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
index e02b60a5d..a3c68e622 100644
--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
@@ -454,7 +454,7 @@ namespace Grand.Web.Admin.Services
{
//date
model.CreatedOn = _dateTimeService.ConvertToUserTime(product.CreatedOnUtc, DateTimeKind.Utc);
- model.UpdatedOn = _dateTimeService.ConvertToUserTime(product.UpdatedOnUtc, DateTimeKind.Utc);
+ model.UpdatedOn = product.UpdatedOnUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.UpdatedOnUtc.Value, DateTimeKind.Utc) : null;
//parent grouped product
var parentGroupedProduct = await _productService.GetProductById(product.ParentGroupedProductId);
@@ -864,9 +864,6 @@ namespace Grand.Web.Admin.Services
//product
var product = model.ToEntity(_dateTimeService);
- product.CreatedOnUtc = DateTime.UtcNow;
- product.UpdatedOnUtc = DateTime.UtcNow;
-
await _productService.InsertProduct(product);
model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
@@ -909,7 +906,6 @@ namespace Grand.Web.Admin.Services
//product
product = model.ToEntity(product, _dateTimeService);
- product.UpdatedOnUtc = DateTime.UtcNow;
product.AutoAddRequiredProducts = model.AutoAddRequiredProducts;
model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
product.SeName = model.SeName;
diff --git a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
index 28cba8253..5a4ecbc34 100644
--- a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs
@@ -255,8 +255,7 @@ namespace Grand.Web.Admin.Services
DisplayToCustomer = displayToCustomer,
Note = message,
DownloadId = downloadId,
- ShipmentId = shipment.Id,
- CreatedOnUtc = DateTime.UtcNow
+ ShipmentId = shipment.Id
};
await _shipmentService.InsertShipmentNote(shipmentNote);
@@ -601,7 +600,6 @@ namespace Grand.Web.Admin.Services
ShippedDateUtc = null,
DeliveryDateUtc = null,
AdminComment = adminComment,
- CreatedOnUtc = DateTime.UtcNow,
StoreId = order.StoreId
};
}
diff --git a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
index 9c476d7c6..dd68c0e54 100644
--- a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
@@ -199,8 +199,6 @@ namespace Grand.Web.Admin.Services
{
var vendor = model.ToEntity();
vendor.Address = model.Address.ToEntity();
- vendor.Address.CreatedOnUtc = DateTime.UtcNow;
-
await _vendorService.InsertVendor(vendor);
//discounts
diff --git a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
index 71d4e1ebd..a1c5bde71 100644
--- a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
+++ b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs
@@ -76,7 +76,7 @@ namespace Grand.Web.Common.Filters
return;
//update last activity date
- if (_workContext.CurrentCustomer.LastActivityDateUtc.AddMinutes(1.0) < DateTime.UtcNow)
+ if (_workContext.CurrentCustomer.LastActivityDateUtc.AddMinutes(3.0) < DateTime.UtcNow)
{
await _customerService.UpdateCustomerField(_workContext.CurrentCustomer, x => x.LastActivityDateUtc, DateTime.UtcNow);
}
diff --git a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs b/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs
index 84fdc5932..322c48766 100644
--- a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs
@@ -166,7 +166,7 @@ namespace Grand.Web.Vendor.Controllers
return RedirectToAction("List");
var model = product.ToModel(_dateTimeService);
- model.Ticks = product.UpdatedOnUtc.Ticks;
+ //model.Ticks = product.UpdatedOnUtc.Ticks;
await _productViewModelService.PrepareProductModel(model, product, false);
await AddLocales(_languageService, model.Locales, (locale, languageId) =>
@@ -192,7 +192,7 @@ namespace Grand.Web.Vendor.Controllers
//No product found with the specified id
return RedirectToAction("List");
- if (model.Ticks != product.UpdatedOnUtc.Ticks)
+ if (model.Ticks != product.Ticks)
{
Error(_translationService.GetResource("Vendor.Catalog.Products.Fields.ChangedWarning"));
return RedirectToAction("Edit", new { id = product.Id });
diff --git a/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs b/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs
index e43aec910..8f3126379 100644
--- a/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs
+++ b/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs
@@ -175,7 +175,6 @@ namespace Grand.Web.Vendor.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = $"A shipment #{shipment.ShipmentNumber} has been added",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = order.Id
});
Success(_translationService.GetResource("Admin.Orders.Shipments.Added"));
@@ -211,7 +210,6 @@ namespace Grand.Web.Vendor.Controllers
await _orderService.InsertOrderNote(new OrderNote {
Note = $"A shipment #{shipment.ShipmentNumber} has been deleted",
DisplayToCustomer = false,
- CreatedOnUtc = DateTime.UtcNow,
OrderId = shipment.OrderId
});
Success(_translationService.GetResource("Admin.Orders.Shipments.Deleted"));
diff --git a/src/Web/Grand.Web.Vendor/Mapper/AddressProfile.cs b/src/Web/Grand.Web.Vendor/Mapper/AddressProfile.cs
index a4e622fa1..ff220da78 100644
--- a/src/Web/Grand.Web.Vendor/Mapper/AddressProfile.cs
+++ b/src/Web/Grand.Web.Vendor/Mapper/AddressProfile.cs
@@ -41,7 +41,6 @@ namespace Grand.Web.Vendor.Mapper
//address
CreateMap<AddressModel, Address>()
- .ForMember(dest => dest.CreatedOnUtc, mo => mo.Ignore())
.ForMember(dest => dest.Id, mo => mo.Ignore())
.ForMember(dest => dest.Attributes, mo => mo.Ignore());
diff --git a/src/Web/Grand.Web.Vendor/Mapper/ProductProfile.cs b/src/Web/Grand.Web.Vendor/Mapper/ProductProfile.cs
index 4d1eefb74..95cb18d5e 100644
--- a/src/Web/Grand.Web.Vendor/Mapper/ProductProfile.cs
+++ b/src/Web/Grand.Web.Vendor/Mapper/ProductProfile.cs
@@ -41,7 +41,6 @@ namespace Grand.Web.Vendor.Mapper
CreateMap<ProductModel, Product>()
.ForMember(dest => dest.Id, mo => mo.Ignore())
.ForMember(dest => dest.Locales, mo => mo.Ignore())
- .ForMember(dest => dest.CreatedOnUtc, mo => mo.Ignore())
.ForMember(dest => dest.VendorId, mo => mo.Ignore())
.ForMember(dest => dest.UpdatedOnUtc, mo => mo.Ignore())
.ForMember(dest => dest.Coordinates, mo => mo.Ignore())
diff --git a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
index e62de9090..72b286050 100644
--- a/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
+++ b/src/Web/Grand.Web.Vendor/Services/MerchandiseReturnViewModelService.cs
@@ -259,7 +259,6 @@ namespace Grand.Web.Vendor.Services
merchandiseReturn.StaffNotes = model.StaffNotes;
merchandiseReturn.MerchandiseReturnStatusId = model.MerchandiseReturnStatusId;
merchandiseReturn.ExternalId = model.ExternalId;
- merchandiseReturn.UpdatedOnUtc = DateTime.UtcNow;
merchandiseReturn.UserFields = model.UserFields;
if (_orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate)
@@ -307,8 +306,7 @@ namespace Grand.Web.Vendor.Services
{
DisplayToCustomer = displayToCustomer,
Note = message,
- MerchandiseReturnId = merchandiseReturn.Id,
- CreatedOnUtc = DateTime.UtcNow
+ MerchandiseReturnId = merchandiseReturn.Id
};
await _merchandiseReturnService.InsertMerchandiseReturnNote(merchandiseReturnNote);
diff --git a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs
index ad8a6bb23..e55eb6a04 100644
--- a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs
+++ b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs
@@ -62,6 +62,7 @@ namespace Grand.Web.Vendor.Services
private readonly MeasureSettings _measureSettings;
private readonly TaxSettings _taxSettings;
private readonly SeoSettings _seoSettings;
+
public ProductViewModelService(
IProductService productService,
IInventoryManageService inventoryManageService,
@@ -88,7 +89,7 @@ namespace Grand.Web.Vendor.Services
ILanguageService languageService,
IProductAttributeFormatter productAttributeFormatter,
IStockQuantityService stockQuantityService,
- IAuctionService auctionService,
+ IAuctionService auctionService,
IPriceFormatter priceFormatter,
CurrencySettings currencySettings,
MeasureSettings measureSettings,
@@ -371,7 +372,9 @@ namespace Grand.Web.Vendor.Services
{
//date
model.CreatedOn = _dateTimeService.ConvertToUserTime(product.CreatedOnUtc, DateTimeKind.Utc);
- model.UpdatedOn = _dateTimeService.ConvertToUserTime(product.UpdatedOnUtc, DateTimeKind.Utc);
+ model.UpdatedOn = product.UpdatedOnUtc.HasValue
+ ? _dateTimeService.ConvertToUserTime(product.UpdatedOnUtc.Value, DateTimeKind.Utc)
+ : null;
//parent grouped product
var parentGroupedProduct = await _productService.GetProductById(product.ParentGroupedProductId);
@@ -759,12 +762,11 @@ namespace Grand.Web.Vendor.Services
{
//product
var product = model.ToEntity(_dateTimeService);
- product.CreatedOnUtc = DateTime.UtcNow;
- product.UpdatedOnUtc = DateTime.UtcNow;
product.VendorId = _workContext.CurrentVendor!.Id;
await _productService.InsertProduct(product);
- model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
+ model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService,
+ _languageService);
product.SeName = model.SeName;
product.Locales = await model.Locales.ToTranslationProperty(product, x => x.Name,
_seoSettings, _slugService, _languageService);
@@ -789,11 +791,12 @@ namespace Grand.Web.Vendor.Services
//product
product = model.ToEntity(product, _dateTimeService);
- product.UpdatedOnUtc = DateTime.UtcNow;
product.AutoAddRequiredProducts = model.AutoAddRequiredProducts;
- model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService, _languageService);
+ model.SeName = await product.ValidateSeName(model.SeName, product.Name, true, _seoSettings, _slugService,
+ _languageService);
product.SeName = model.SeName;
- product.Locales = await model.Locales.ToTranslationProperty(product, x => x.Name, _seoSettings, _slugService, _languageService);
+ product.Locales = await model.Locales.ToTranslationProperty(product, x => x.Name, _seoSettings,
+ _slugService, _languageService);
//search engine name
await _slugService.SaveSlug(product, model.SeName, "");
@@ -1267,7 +1270,7 @@ namespace Grand.Web.Vendor.Services
//update
var product = await _productService.GetProductById(pModel.Id, true);
if (product == null || product.VendorId != _workContext.CurrentVendor.Id) continue;
-
+
var prevStockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true);
product.Sku = pModel.Sku;
@@ -1299,7 +1302,7 @@ namespace Grand.Web.Vendor.Services
//delete
var product = await _productService.GetProductById(pModel.Id, true);
if (product == null || product.VendorId != _workContext.CurrentVendor.Id) continue;
-
+
await _productService.DeleteProduct(product);
}
}
@@ -1367,7 +1370,8 @@ namespace Grand.Web.Vendor.Services
return model;
}
- public virtual async Task<ProductModel.ProductAttributeMappingModel> PrepareProductAttributeMappingModel(ProductAttributeMapping productAttributeMapping)
+ public virtual async Task<ProductModel.ProductAttributeMappingModel> PrepareProductAttributeMappingModel(
+ ProductAttributeMapping productAttributeMapping)
{
var model = productAttributeMapping.ToModel();
foreach (var attribute in await _productAttributeService.GetAllProductAttributes())
diff --git a/src/Web/Grand.Web.Vendor/Services/ShipmentViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/ShipmentViewModelService.cs
index 7737a9cda..46e1a9a40 100644
--- a/src/Web/Grand.Web.Vendor/Services/ShipmentViewModelService.cs
+++ b/src/Web/Grand.Web.Vendor/Services/ShipmentViewModelService.cs
@@ -245,8 +245,7 @@ namespace Grand.Web.Vendor.Services
var shipmentNote = new ShipmentNote {
DisplayToCustomer = displayToCustomer,
Note = message,
- ShipmentId = shipment.Id,
- CreatedOnUtc = DateTime.UtcNow
+ ShipmentId = shipment.Id
};
await _shipmentService.InsertShipmentNote(shipmentNote);
}
@@ -526,7 +525,6 @@ namespace Grand.Web.Vendor.Services
ShippedDateUtc = null,
DeliveryDateUtc = null,
AdminComment = model.AdminComment,
- CreatedOnUtc = DateTime.UtcNow,
StoreId = order.StoreId,
VendorId = _workContext.CurrentVendor.Id
};
diff --git a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
index 1075acd7a..b4b1a44f1 100644
--- a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
@@ -41,7 +41,6 @@ namespace Grand.Web.Commands.Handler.Blogs
CustomerId = customer.Id,
StoreId = _workContext.CurrentStore.Id,
CommentText = request.Model.CommentText,
- CreatedOnUtc = DateTime.UtcNow,
BlogPostTitle = request.BlogPost.Title
};
await _blogService.InsertBlogComment(comment);
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
index 2ad974ee8..7096aa5a7 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
@@ -137,8 +137,7 @@ namespace Grand.Web.Commands.Handler.Customers
Email = request.Model.Email,
CustomerId = request.Customer.Id,
Active = true,
- StoreId = request.Store.Id,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = request.Store.Id
};
categories?.ForEach(x => newsLetterSubscription.Categories.Add(x));
await _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsLetterSubscription);
@@ -171,8 +170,7 @@ namespace Grand.Web.Commands.Handler.Customers
Address2 = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.StreetAddress2),
ZipPostalCode = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.ZipPostalCode),
PhoneNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Phone),
- FaxNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Fax),
- CreatedOnUtc = request.Customer.CreatedOnUtc
+ FaxNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Fax)
};
if (await IsAddressValid(defaultAddress))
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
index c8734807c..3fe00cc28 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
@@ -47,7 +47,6 @@ namespace Grand.Web.Commands.Handler.Customers
OwnerId = request.Customer.Id,
CustomerGuid = Guid.NewGuid(),
StoreId = request.Store.Id,
- CreatedOnUtc = DateTime.UtcNow,
LastActivityDateUtc = DateTime.UtcNow
};
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
index c8ceedf8a..31223b071 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
@@ -173,8 +173,7 @@ namespace Grand.Web.Commands.Handler.Customers
Email = request.Customer.Email,
CustomerId = request.Customer.Id,
Active = true,
- StoreId = request.Store.Id,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = request.Store.Id
};
categories?.ForEach(x => newsLetterSubscription.Categories.Add(x));
await _newsLetterSubscriptionService.InsertNewsLetterSubscription(newsLetterSubscription);
diff --git a/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
index 1540d6e16..629031fcd 100644
--- a/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
@@ -40,8 +40,7 @@ namespace Grand.Web.Commands.Handler.News
CustomerId = _workContext.CurrentCustomer.Id,
StoreId = _workContext.CurrentStore.Id,
CommentTitle = request.Model.CommentTitle,
- CommentText = request.Model.CommentText,
- CreatedOnUtc = DateTime.UtcNow
+ CommentText = request.Model.CommentText
};
request.NewsItem.NewsComments.Add(comment);
diff --git a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
index 9ca8fb1c1..d2f634b96 100644
--- a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
@@ -71,8 +71,7 @@ namespace Grand.Web.Commands.Handler.Newsletter
Email = email,
CustomerId = _workContext.CurrentCustomer.Id,
Active = false,
- StoreId = _workContext.CurrentStore.Id,
- CreatedOnUtc = DateTime.UtcNow
+ StoreId = _workContext.CurrentStore.Id
};
await _newsLetterSubscriptionService.InsertNewsLetterSubscription(subscription);
diff --git a/src/Web/Grand.Web/Commands/Handler/Orders/InsertOrderNoteCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Orders/InsertOrderNoteCommandHandler.cs
index 00cba0d62..f32c2587a 100644
--- a/src/Web/Grand.Web/Commands/Handler/Orders/InsertOrderNoteCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Orders/InsertOrderNoteCommandHandler.cs
@@ -21,7 +21,6 @@ namespace Grand.Web.Commands.Handler.Orders
{
var orderNote = new OrderNote
{
- CreatedOnUtc = DateTime.UtcNow,
DisplayToCustomer = true,
Note = request.OrderNote.Note,
OrderId = request.OrderNote.OrderId,
diff --git a/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
index 55e816b62..d5700e2dd 100644
--- a/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
@@ -50,8 +50,6 @@ namespace Grand.Web.Commands.Handler.Orders
CustomerComments = request.Model.Comments,
StaffNotes = string.Empty,
MerchandiseReturnStatus = MerchandiseReturnStatus.Pending,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedOnUtc = DateTime.UtcNow,
PickupAddress = request.Address
};
diff --git a/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
index 27b0eb4d3..dfc48757c 100644
--- a/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
@@ -65,8 +65,7 @@ namespace Grand.Web.Commands.Handler.Products
HelpfulYesTotal = 0,
HelpfulNoTotal = 0,
IsApproved = isApproved,
- ConfirmedPurchase = confirmPurchased,
- CreatedOnUtc = DateTime.UtcNow
+ ConfirmedPurchase = confirmPurchased
};
await _productReviewService.InsertProductReview(productReview);
diff --git a/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
index 16dd4a2ae..23dba7815 100644
--- a/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
@@ -48,8 +48,7 @@ namespace Grand.Web.Commands.Handler.Vendors
Rating = rating,
HelpfulYesTotal = 0,
HelpfulNoTotal = 0,
- IsApproved = isApproved,
- CreatedOnUtc = DateTime.UtcNow
+ IsApproved = isApproved
};
await _vendorService.InsertVendorReview(vendorReview);
diff --git a/src/Web/Grand.Web/Controllers/AccountController.cs b/src/Web/Grand.Web/Controllers/AccountController.cs
index 789c9bcfe..357f3e68c 100644
--- a/src/Web/Grand.Web/Controllers/AccountController.cs
+++ b/src/Web/Grand.Web/Controllers/AccountController.cs
@@ -707,7 +707,6 @@ namespace Grand.Web.Controllers
{
var address = model.Address.ToEntity(_workContext.CurrentCustomer, addressSettings);
address.Attributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.Address.SelectedAttributes });
- address.CreatedOnUtc = DateTime.UtcNow;
customer.Addresses.Add(address);
await _customerService.InsertAddress(address, customer.Id);
diff --git a/src/Web/Grand.Web/Controllers/CheckoutController.cs b/src/Web/Grand.Web/Controllers/CheckoutController.cs
index a7d3d773f..f0c4309ad 100644
--- a/src/Web/Grand.Web/Controllers/CheckoutController.cs
+++ b/src/Web/Grand.Web/Controllers/CheckoutController.cs
@@ -462,9 +462,7 @@ namespace Grand.Web.Controllers
: model.BillingNewAddress.ToEntity(_workContext.CurrentCustomer, addressSettings);
address.Attributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.BillingNewAddress.SelectedAttributes });
- address.CreatedOnUtc = DateTime.UtcNow;
- address.AddressType =
- _addressSettings.AddressTypeEnabled ? AddressType.Billing : AddressType.Any;
+ address.AddressType = _addressSettings.AddressTypeEnabled ? AddressType.Billing : AddressType.Any;
_workContext.CurrentCustomer.Addresses.Add(address);
await _customerService.InsertAddress(address, _workContext.CurrentCustomer.Id);
@@ -614,7 +612,6 @@ namespace Grand.Web.Controllers
: model.ShippingNewAddress.ToEntity(_workContext.CurrentCustomer, addressSettings);
address.Attributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.ShippingNewAddress.SelectedAttributes });
- address.CreatedOnUtc = DateTime.UtcNow;
address.AddressType = _addressSettings.AddressTypeEnabled
? model.BillToTheSameAddress ? AddressType.Any : AddressType.Shipping
: AddressType.Any;
diff --git a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs b/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
index 0386fa512..bbca42125 100644
--- a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
+++ b/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
@@ -267,7 +267,6 @@ namespace Grand.Web.Controllers
ArticleId = article.Id,
CustomerId = customer.Id,
CommentText = model.AddNewComment.CommentText,
- CreatedOnUtc = DateTime.UtcNow,
ArticleTitle = article.Name
};
await _knowledgebaseService.InsertArticleComment(comment);
diff --git a/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs b/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
index f47a6a105..bf6512347 100644
--- a/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
+++ b/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
@@ -94,7 +94,6 @@ namespace Grand.Web.Controllers
address = model.MerchandiseReturnNewAddress.ToEntity(_workContext.CurrentCustomer, _addressSettings);
model.NewAddressPreselected = true;
address.Attributes = customAttributes;
- address.CreatedOnUtc = DateTime.UtcNow;
}
return address;
diff --git a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
index 11cd2bc6d..eed002aea 100644
--- a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
+++ b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
@@ -137,8 +137,7 @@ namespace Grand.Web.Controllers
CustomerId = customer.Id,
ProductId = product.Id,
StoreId = _workContext.CurrentStore.Id,
- WarehouseId = warehouseId,
- CreatedOnUtc = DateTime.UtcNow
+ WarehouseId = warehouseId
};
await _outOfStockSubscriptionService.InsertSubscription(subscription);
return Json(new {
@@ -181,8 +180,7 @@ namespace Grand.Web.Controllers
? ""
: await _productAttributeFormatter.FormatAttributes(product, attributes),
StoreId = _workContext.CurrentStore.Id,
- WarehouseId = warehouseId,
- CreatedOnUtc = DateTime.UtcNow
+ WarehouseId = warehouseId
};
await _outOfStockSubscriptionService.InsertSubscription(subscriptionAttributes);