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.

Minor code improvements

support489a666c4b06
diff --git a/src/API/Grand.Api/DTOs/Catalog/ProductAttributeDto.cs b/src/API/Grand.Api/DTOs/Catalog/ProductAttributeDto.cs
index 340e3cef9..9d0250656 100644
--- a/src/API/Grand.Api/DTOs/Catalog/ProductAttributeDto.cs
+++ b/src/API/Grand.Api/DTOs/Catalog/ProductAttributeDto.cs
@@ -4,13 +4,9 @@ namespace Grand.Api.DTOs.Catalog
{
public class ProductAttributeDto : BaseApiEntityModel
{
- public ProductAttributeDto()
- {
- PredefinedProductAttributeValues = new List<PredefinedProductAttributeValueDto>();
- }
public string Name { get; set; }
public string Description { get; set; }
- public IList<PredefinedProductAttributeValueDto> PredefinedProductAttributeValues { get; set; }
+ public IList<PredefinedProductAttributeValueDto> PredefinedProductAttributeValues { get; set; } = new List<PredefinedProductAttributeValueDto>();
}
public class PredefinedProductAttributeValueDto : BaseApiEntityModel
diff --git a/src/API/Grand.Api/DTOs/Catalog/ProductAttributeMappingDto.cs b/src/API/Grand.Api/DTOs/Catalog/ProductAttributeMappingDto.cs
index 9139b1bf0..9fbc568bd 100644
--- a/src/API/Grand.Api/DTOs/Catalog/ProductAttributeMappingDto.cs
+++ b/src/API/Grand.Api/DTOs/Catalog/ProductAttributeMappingDto.cs
@@ -5,10 +5,6 @@ namespace Grand.Api.DTOs.Catalog
{
public class ProductAttributeMappingDto : BaseApiEntityModel
{
- public ProductAttributeMappingDto()
- {
- ProductAttributeValues = new List<ProductAttributeValueDto>();
- }
public string ProductAttributeId { get; set; }
public string TextPrompt { get; set; }
public bool IsRequired { get; set; }
@@ -21,9 +17,7 @@ namespace Grand.Api.DTOs.Catalog
public string ConditionAttributeXml { get; set; }
public AttributeControlType AttributeControlTypeId { get; set; }
- public IList<ProductAttributeValueDto> ProductAttributeValues { get; set; }
-
-
+ public IList<ProductAttributeValueDto> ProductAttributeValues { get; set; } = new List<ProductAttributeValueDto>();
}
public class ProductAttributeValueDto: BaseApiEntityModel
{
diff --git a/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs b/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
index b20a152e1..344248144 100644
--- a/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
+++ b/src/API/Grand.Api/DTOs/Catalog/ProductDto.cs
@@ -5,19 +5,6 @@ namespace Grand.Api.DTOs.Catalog
{
public class ProductDto : BaseApiEntityModel
{
- public ProductDto()
- {
- ProductCategories = new List<ProductCategoryDto>();
- ProductCollections = new List<ProductCollectionDto>();
- ProductPictures = new List<ProductPictureDto>();
- ProductSpecificationAttributes = new List<ProductSpecificationAttributeDto>();
- TierPrices = new List<ProductTierPriceDto>();
- ProductWarehouseInventory = new List<ProductWarehouseInventoryDto>();
- ProductAttributeMappings = new List<ProductAttributeMappingDto>();
- ProductAttributeCombinations = new List<ProductAttributeCombinationDto>();
- ProductTags = new List<string>();
- AppliedDiscounts = new List<string>();
- }
public ProductType ProductTypeId { get; set; }
public string ParentGroupedProductId { get; set; }
public bool VisibleIndividually { get; set; }
@@ -128,15 +115,15 @@ namespace Grand.Api.DTOs.Catalog
public Int64 Viewed { get; set; }
public int OnSale { get; set; }
public string Flag { get; set; }
- public IList<ProductCategoryDto> ProductCategories { get; set; }
- public IList<ProductCollectionDto> ProductCollections { get; set; }
- public IList<ProductPictureDto> ProductPictures { get; set; }
- public IList<ProductSpecificationAttributeDto> ProductSpecificationAttributes { get; set; }
- public IList<ProductTierPriceDto> TierPrices { get; set; }
- public IList<ProductWarehouseInventoryDto> ProductWarehouseInventory { get; set; }
- public IList<ProductAttributeMappingDto> ProductAttributeMappings { get; set; }
- public IList<ProductAttributeCombinationDto> ProductAttributeCombinations { get; set; }
- public IList<string> ProductTags { get; set; }
- public IList<string> AppliedDiscounts { get; set; }
+ public IList<ProductCategoryDto> ProductCategories { get; set; } = new List<ProductCategoryDto>();
+ public IList<ProductCollectionDto> ProductCollections { get; set; } = new List<ProductCollectionDto>();
+ public IList<ProductPictureDto> ProductPictures { get; set; } = new List<ProductPictureDto>();
+ public IList<ProductSpecificationAttributeDto> ProductSpecificationAttributes { get; set; } = new List<ProductSpecificationAttributeDto>();
+ public IList<ProductTierPriceDto> TierPrices { get; set; } = new List<ProductTierPriceDto>();
+ public IList<ProductWarehouseInventoryDto> ProductWarehouseInventory { get; set; } = new List<ProductWarehouseInventoryDto>();
+ public IList<ProductAttributeMappingDto> ProductAttributeMappings { get; set; } = new List<ProductAttributeMappingDto>();
+ public IList<ProductAttributeCombinationDto> ProductAttributeCombinations { get; set; } = new List<ProductAttributeCombinationDto>();
+ public IList<string> ProductTags { get; set; } = new List<string>();
+ public IList<string> AppliedDiscounts { get; set; } = new List<string>();
}
}
diff --git a/src/API/Grand.Api/DTOs/Catalog/SpecificationAttributeDto.cs b/src/API/Grand.Api/DTOs/Catalog/SpecificationAttributeDto.cs
index 24346cc2f..0a109b52b 100644
--- a/src/API/Grand.Api/DTOs/Catalog/SpecificationAttributeDto.cs
+++ b/src/API/Grand.Api/DTOs/Catalog/SpecificationAttributeDto.cs
@@ -4,14 +4,9 @@ namespace Grand.Api.DTOs.Catalog
{
public class SpecificationAttributeDto : BaseApiEntityModel
{
- public SpecificationAttributeDto()
- {
- SpecificationAttributeOptions = new List<SpecificationAttributeOptionDto>();
- }
public string Name { get; set; }
public int DisplayOrder { get; set; }
- public IList<SpecificationAttributeOptionDto> SpecificationAttributeOptions { get; set; }
-
+ public IList<SpecificationAttributeOptionDto> SpecificationAttributeOptions { get; set; } = new List<SpecificationAttributeOptionDto>();
}
public class SpecificationAttributeOptionDto : BaseApiEntityModel
{
diff --git a/src/API/Grand.Api/DTOs/Customers/CustomerDto.cs b/src/API/Grand.Api/DTOs/Customers/CustomerDto.cs
index 25ecea32e..eaa07179e 100644
--- a/src/API/Grand.Api/DTOs/Customers/CustomerDto.cs
+++ b/src/API/Grand.Api/DTOs/Customers/CustomerDto.cs
@@ -5,13 +5,7 @@ namespace Grand.Api.DTOs.Customers
{
public class CustomerDto : BaseApiEntityModel
{
- public CustomerDto()
- {
- CustomerGuid = Guid.NewGuid();
- Groups = new List<string>();
- Addresses = new List<AddressDto>();
- }
- public Guid CustomerGuid { get; set; }
+ public Guid CustomerGuid { get; set; } = Guid.NewGuid();
public string Username { get; set; }
[Key]
public string Email { get; set; }
@@ -38,7 +32,7 @@ namespace Grand.Api.DTOs.Customers
public string Fax { get; set; }
public string VatNumber { get; set; }
public string VatNumberStatusId { get; set; }
- public IList<string> Groups { get; set; }
- public IList<AddressDto> Addresses { get; set; }
+ public IList<string> Groups { get; set; } = new List<string>();
+ public IList<AddressDto> Addresses { get; set; } = new List<AddressDto>();
}
}
diff --git a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs
index afc0b91de..a2e3286a3 100644
--- a/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs
+++ b/src/Business/Grand.Business.Catalog/Services/Prices/PricingService.cs
@@ -72,13 +72,9 @@ namespace Grand.Business.Catalog.Services.Prices
protected class ProductPrice
{
- public ProductPrice()
- {
- AppliedDiscounts = new List<ApplyDiscount>();
- }
public double Price { get; set; }
public double AppliedDiscountAmount { get; set; }
- public IList<ApplyDiscount> AppliedDiscounts { get; set; }
+ public IList<ApplyDiscount> AppliedDiscounts { get; set; } = new List<ApplyDiscount>();
public TierPrice PreferredTierPrice { get; set; }
}
diff --git a/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs b/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs
index ea75b331d..c0a37ff7e 100644
--- a/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Orders/OrderCalculationService.cs
@@ -541,7 +541,6 @@ namespace Grand.Business.Checkout.Services.Orders
public virtual async Task<(double? shoppingCartShippingTotal, double taxRate, List<ApplyDiscount> appliedDiscounts)> GetShoppingCartShippingTotal(IList<ShoppingCartItem> cart, bool includingTax)
{
double? shippingTotal = null;
- double? shippingTotalTaxed = null;
var appliedDiscounts = new List<ApplyDiscount>();
double taxRate = 0;
@@ -616,7 +615,7 @@ namespace Grand.Business.Checkout.Services.Orders
shippingTotal = RoundingHelper.RoundPrice(shippingTotal.Value, currency);
var shippingPrice = await _taxService.GetShippingPrice(shippingTotal.Value, includingTax, customer);
- shippingTotalTaxed = shippingPrice.shippingPrice;
+ double? shippingTotalTaxed = shippingPrice.shippingPrice;
taxRate = shippingPrice.taxRate;
//round
diff --git a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs
index c9156daf8..cb4cb259d 100644
--- a/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs
+++ b/src/Business/Grand.Business.Checkout/Services/Shipping/ShippingService.cs
@@ -181,7 +181,7 @@ namespace Grand.Business.Checkout.Services.Shipping
foreach (var shippingRateMethod in shippingRateMethods)
{
//request shipping options (separately for each package-request)
- IList<ShippingOption> shippingRateMethodOptions = null;
+ IList<ShippingOption> shippingRateMethodOptions;
var getShippingOptionResponse = await shippingRateMethod.GetShippingOptions(shippingOptionRequest);
if (getShippingOptionResponse.Success)
diff --git a/src/Business/Grand.Business.Core/Commands/Customers/ActiveVendorCommand.cs b/src/Business/Grand.Business.Core/Commands/Customers/ActiveVendorCommand.cs
index fb6ebfc07..ce4324ed8 100644
--- a/src/Business/Grand.Business.Core/Commands/Customers/ActiveVendorCommand.cs
+++ b/src/Business/Grand.Business.Core/Commands/Customers/ActiveVendorCommand.cs
@@ -5,12 +5,8 @@ namespace Grand.Business.Core.Commands.Customers
{
public class ActiveVendorCommand : IRequest<bool>
{
- public ActiveVendorCommand()
- {
- CustomerIds = new List<string>();
- }
public Vendor Vendor { get; set; }
public bool Active { get; set; }
- public IList<string> CustomerIds { get; set; }
+ public IList<string> CustomerIds { get; set; } = new List<string>();
}
}
diff --git a/src/Business/Grand.Business.Core/Utilities/Authentication/ExternalAuthParam.cs b/src/Business/Grand.Business.Core/Utilities/Authentication/ExternalAuthParam.cs
index 9f66ce93e..51241bc1e 100644
--- a/src/Business/Grand.Business.Core/Utilities/Authentication/ExternalAuthParam.cs
+++ b/src/Business/Grand.Business.Core/Utilities/Authentication/ExternalAuthParam.cs
@@ -7,11 +7,6 @@ namespace Grand.Business.Core.Utilities.Authentication
/// </summary>
public class ExternalAuthParam
{
- public ExternalAuthParam()
- {
- Claims = new List<Claim>();
- }
-
/// <summary>
/// Gets or sets the external authentication provider's system name
/// </summary>
@@ -40,7 +35,7 @@ namespace Grand.Business.Core.Utilities.Authentication
/// <summary>
/// Gets or sets the additional user info as a list of a custom claims
/// </summary>
- public IList<Claim> Claims { get; set; }
+ public IList<Claim> Claims { get; set; } = new List<Claim>();
}
}
\ No newline at end of file
diff --git a/src/Business/Grand.Business.Core/Utilities/Authentication/TwoFactorCodeSetup.cs b/src/Business/Grand.Business.Core/Utilities/Authentication/TwoFactorCodeSetup.cs
index a2157772a..945ca3e33 100644
--- a/src/Business/Grand.Business.Core/Utilities/Authentication/TwoFactorCodeSetup.cs
+++ b/src/Business/Grand.Business.Core/Utilities/Authentication/TwoFactorCodeSetup.cs
@@ -2,10 +2,6 @@
{
public class TwoFactorCodeSetup
{
- public TwoFactorCodeSetup()
- {
- CustomValues = new Dictionary<string, string>();
- }
- public IDictionary<string, string> CustomValues { get; set; }
+ public IDictionary<string, string> CustomValues { get; set; } = new Dictionary<string, string>();
}
}
diff --git a/src/Business/Grand.Business.Core/Utilities/Checkout/GetShippingOptionRequest.cs b/src/Business/Grand.Business.Core/Utilities/Checkout/GetShippingOptionRequest.cs
index 33c9e7264..0cb0c0b64 100644
--- a/src/Business/Grand.Business.Core/Utilities/Checkout/GetShippingOptionRequest.cs
+++ b/src/Business/Grand.Business.Core/Utilities/Checkout/GetShippingOptionRequest.cs
@@ -12,11 +12,6 @@ namespace Grand.Business.Core.Utilities.Checkout
{
#region Ctor
- public GetShippingOptionRequest()
- {
- Items = new List<PackageItem>();
- }
-
#endregion
#region Properties
@@ -29,7 +24,7 @@ namespace Grand.Business.Core.Utilities.Checkout
/// <summary>
/// Gets or sets a shopping cart items
/// </summary>
- public IList<PackageItem> Items { get; set; }
+ public IList<PackageItem> Items { get; set; } = new List<PackageItem>();
/// <summary>
/// Gets or sets a shipping address (where we ship to)
diff --git a/src/Business/Grand.Business.Core/Utilities/Checkout/PlaceOrderContainer.cs b/src/Business/Grand.Business.Core/Utilities/Checkout/PlaceOrderContainer.cs
index 33b66e034..0028d8430 100644
--- a/src/Business/Grand.Business.Core/Utilities/Checkout/PlaceOrderContainer.cs
+++ b/src/Business/Grand.Business.Core/Utilities/Checkout/PlaceOrderContainer.cs
@@ -12,15 +12,6 @@ namespace Grand.Business.Core.Utilities.Checkout
{
public class PlaceOrderContainer
{
- public PlaceOrderContainer()
- {
- Cart = new List<ShoppingCartItem>();
- Taxes = new List<OrderTax>();
- AppliedDiscounts = new List<ApplyDiscount>();
- AppliedGiftVouchers = new List<AppliedGiftVoucher>();
- CheckoutAttributes = new List<CustomAttribute>();
- }
-
public Customer Customer { get; set; }
public Language Language { get; set; }
public Currency Currency { get; set; }
@@ -37,11 +28,11 @@ namespace Grand.Business.Core.Utilities.Checkout
public bool PickUpInStore { get; set; }
public PickupPoint PickupPoint { get; set; }
public string CheckoutAttributeDescription { get; set; }
- public IList<CustomAttribute> CheckoutAttributes { get; set; }
- public IList<ShoppingCartItem> Cart { get; set; }
- public IList<OrderTax> Taxes { get; set; }
- public List<ApplyDiscount> AppliedDiscounts { get; set; }
- public List<AppliedGiftVoucher> AppliedGiftVouchers { get; set; }
+ public IList<CustomAttribute> CheckoutAttributes { get; set; } = new List<CustomAttribute>();
+ public IList<ShoppingCartItem> Cart { get; set; } = new List<ShoppingCartItem>();
+ public IList<OrderTax> Taxes { get; set; } = new List<OrderTax>();
+ public List<ApplyDiscount> AppliedDiscounts { get; set; } = new();
+ public List<AppliedGiftVoucher> AppliedGiftVouchers { get; set; } = new();
public bool IsRecurring { get; set; }
public int RecurringCycleLength { get; set; }
public RecurringCyclePeriod RecurringCyclePeriodId { get; set; }
diff --git a/src/Business/Grand.Business.Core/Utilities/System/InstallationLanguage.cs b/src/Business/Grand.Business.Core/Utilities/System/InstallationLanguage.cs
index d91e0c8fe..95e8d067e 100644
--- a/src/Business/Grand.Business.Core/Utilities/System/InstallationLanguage.cs
+++ b/src/Business/Grand.Business.Core/Utilities/System/InstallationLanguage.cs
@@ -5,16 +5,12 @@
/// </summary>
public class InstallationLanguage
{
- public InstallationLanguage()
- {
- Resources = new List<InstallationLocaleResource>();
- }
public string Name { get; set; }
public string Code { get; set; }
public bool IsDefault { get; set; }
public bool IsRightToLeft { get; set; }
- public List<InstallationLocaleResource> Resources { get; protected set; }
+ public List<InstallationLocaleResource> Resources { get; protected set; } = new();
}
public class InstallationLocaleResource
diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
index f1d7bf74e..b4e1fb644 100644
--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs
@@ -13,42 +13,19 @@ using MediatR;
namespace Grand.Business.Marketing.Services.Campaigns
{
- public class CampaignService : ICampaignService
+ public class CampaignService(
+ IRepository<Campaign> campaignRepository,
+ IRepository<CampaignHistory> campaignHistoryRepository,
+ IRepository<NewsLetterSubscription> newsLetterSubscriptionRepository,
+ IRepository<Customer> customerRepository,
+ IEmailSender emailSender,
+ IQueuedEmailService queuedEmailService,
+ IStoreService storeService,
+ IMediator mediator,
+ ILanguageService languageService,
+ IWorkContext workContext)
+ : ICampaignService
{
- private readonly IRepository<Campaign> _campaignRepository;
- private readonly IRepository<CampaignHistory> _campaignHistoryRepository;
- private readonly IRepository<NewsLetterSubscription> _newsLetterSubscriptionRepository;
- private readonly IRepository<Customer> _customerRepository;
- private readonly IEmailSender _emailSender;
- private readonly IQueuedEmailService _queuedEmailService;
- private readonly IStoreService _storeService;
- private readonly IMediator _mediator;
- private readonly ILanguageService _languageService;
- private readonly IWorkContext _workContext;
-
- public CampaignService(IRepository<Campaign> campaignRepository,
- IRepository<CampaignHistory> campaignHistoryRepository,
- IRepository<NewsLetterSubscription> newsLetterSubscriptionRepository,
- IRepository<Customer> customerRepository,
- IEmailSender emailSender,
- IQueuedEmailService queuedEmailService,
- IStoreService storeService,
- IMediator mediator,
- ILanguageService languageService,
- IWorkContext workContext)
- {
- _campaignRepository = campaignRepository;
- _campaignHistoryRepository = campaignHistoryRepository;
- _newsLetterSubscriptionRepository = newsLetterSubscriptionRepository;
- _customerRepository = customerRepository;
- _emailSender = emailSender;
- _queuedEmailService = queuedEmailService;
- _storeService = storeService;
- _mediator = mediator;
- _languageService = languageService;
- _workContext = workContext;
- }
-
/// <summary>
/// Inserts a campaign
/// </summary>
@@ -58,10 +35,10 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (campaign == null)
throw new ArgumentNullException(nameof(campaign));
- await _campaignRepository.InsertAsync(campaign);
+ await campaignRepository.InsertAsync(campaign);
//event notification
- await _mediator.EntityInserted(campaign);
+ await mediator.EntityInserted(campaign);
}
/// <summary>
@@ -73,7 +50,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (campaignHistory == null)
throw new ArgumentNullException(nameof(campaignHistory));
- await _campaignHistoryRepository.InsertAsync(campaignHistory);
+ await campaignHistoryRepository.InsertAsync(campaignHistory);
}
@@ -86,10 +63,10 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (campaign == null)
throw new ArgumentNullException(nameof(campaign));
- await _campaignRepository.UpdateAsync(campaign);
+ await campaignRepository.UpdateAsync(campaign);
//event notification
- await _mediator.EntityUpdated(campaign);
+ await mediator.EntityUpdated(campaign);
}
/// <summary>
@@ -101,10 +78,10 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (campaign == null)
throw new ArgumentNullException(nameof(campaign));
- await _campaignRepository.DeleteAsync(campaign);
+ await campaignRepository.DeleteAsync(campaign);
//event notification
- await _mediator.EntityDeleted(campaign);
+ await mediator.EntityDeleted(campaign);
}
/// <summary>
@@ -114,7 +91,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
/// <returns>Campaign</returns>
public virtual Task<Campaign> GetCampaignById(string campaignId)
{
- return _campaignRepository.GetByIdAsync(campaignId);
+ return campaignRepository.GetByIdAsync(campaignId);
}
@@ -125,7 +102,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
public virtual async Task<IList<Campaign>> GetAllCampaigns()
{
- var query = from c in _campaignRepository.Table
+ var query = from c in campaignRepository.Table
orderby c.CreatedOnUtc
select c;
return await Task.FromResult(query.ToList());
@@ -136,7 +113,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (campaign == null)
throw new ArgumentNullException(nameof(campaign));
- var query = from c in _campaignHistoryRepository.Table
+ var query = from c in campaignHistoryRepository.Table
where c.CampaignId == campaign.Id
orderby c.CreatedDateUtc descending
select c;
@@ -155,9 +132,9 @@ namespace Grand.Business.Marketing.Services.Campaigns
campaign.CustomerTags.Count > 0 || campaign.CustomerGroups.Count > 0)
{
- var query = from o in _newsLetterSubscriptionRepository.Table
+ var query = from o in newsLetterSubscriptionRepository.Table
where o.Active && o.CustomerId != "" && (o.StoreId == campaign.StoreId || string.IsNullOrEmpty(campaign.StoreId))
- join c in _customerRepository.Table on o.CustomerId equals c.Id into joined
+ join c in customerRepository.Table on o.CustomerId equals c.Id into joined
from customers in joined
select new CampaignCustomerHelp {
CustomerEmail = customers.Email,
@@ -241,7 +218,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
}
else
{
- var query = from o in _newsLetterSubscriptionRepository.Table
+ var query = from o in newsLetterSubscriptionRepository.Table
where o.Active && (o.StoreId == campaign.StoreId || string.IsNullOrEmpty(campaign.StoreId))
select o;
@@ -260,10 +237,6 @@ namespace Grand.Business.Marketing.Services.Campaigns
private class CampaignCustomerHelp
{
- public CampaignCustomerHelp()
- {
- CustomerGroups = new List<string>();
- }
public string CustomerId { get; set; }
public string CustomerEmail { get; set; }
public string Email { get; set; }
@@ -274,7 +247,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
public bool IsHasOrders { get; set; }
public ICollection<string> CustomerTags { get; set; }
public ICollection<string> NewsletterCategories { get; set; }
- public ICollection<string> CustomerGroups { get; set; }
+ public ICollection<string> CustomerGroups { get; set; } = new List<string>();
public Guid NewsLetterSubscriptionGuid { get; set; }
}
@@ -295,28 +268,28 @@ namespace Grand.Business.Marketing.Services.Campaigns
throw new ArgumentNullException(nameof(emailAccount));
var totalEmailsSent = 0;
- var language = await _languageService.GetLanguageById(campaign.LanguageId) ?? (await _languageService.GetAllLanguages()).FirstOrDefault();
+ var language = await languageService.GetLanguageById(campaign.LanguageId) ?? (await languageService.GetAllLanguages()).FirstOrDefault();
foreach (var subscription in subscriptions)
{
Customer customer = null;
- if (!string.IsNullOrEmpty(subscription.CustomerId)) customer = await _customerRepository.GetByIdAsync(subscription.CustomerId);
- customer ??= _customerRepository.Table.FirstOrDefault(x => x.Email == subscription.Email.ToLowerInvariant());
+ if (!string.IsNullOrEmpty(subscription.CustomerId)) customer = await customerRepository.GetByIdAsync(subscription.CustomerId);
+ customer ??= customerRepository.Table.FirstOrDefault(x => x.Email == subscription.Email.ToLowerInvariant());
//ignore deleted or inactive customers when sending newsletter campaigns
if (customer != null && (!customer.Active || customer.Deleted))
continue;
- var builder = new LiquidObjectBuilder(_mediator);
- var store = await _storeService.GetStoreById(campaign.StoreId) ?? (await _storeService.GetAllStores()).FirstOrDefault();
+ var builder = new LiquidObjectBuilder(mediator);
+ var store = await storeService.GetStoreById(campaign.StoreId) ?? (await storeService.GetAllStores()).FirstOrDefault();
builder.AddStoreTokens(store, language, emailAccount)
- .AddNewsLetterSubscriptionTokens(subscription, store, _workContext.CurrentHost);
+ .AddNewsLetterSubscriptionTokens(subscription, store, workContext.CurrentHost);
if (customer != null)
{
- builder.AddCustomerTokens(customer, store, _workContext.CurrentHost, language)
+ builder.AddCustomerTokens(customer, store, workContext.CurrentHost, language)
.AddShoppingCartTokens(customer, store, language);
}
@@ -338,7 +311,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
email.Reference = Domain.Common.Reference.Campaign;
email.ObjectId = campaign.Id;
- await _queuedEmailService.InsertQueuedEmail(email);
+ await queuedEmailService.InsertQueuedEmail(email);
await InsertCampaignHistory(new CampaignHistory { CampaignId = campaign.Id, CustomerId = subscription.CustomerId, Email = subscription.Email, CreatedDateUtc = DateTime.UtcNow, StoreId = campaign.StoreId });
totalEmailsSent++;
@@ -360,16 +333,16 @@ namespace Grand.Business.Marketing.Services.Campaigns
if (emailAccount == null)
throw new ArgumentNullException(nameof(emailAccount));
- var language = await _languageService.GetLanguageById(campaign.LanguageId) ?? (await _languageService.GetAllLanguages()).FirstOrDefault();
+ var language = await languageService.GetLanguageById(campaign.LanguageId) ?? (await languageService.GetAllLanguages()).FirstOrDefault();
- var store = await _storeService.GetStoreById(campaign.StoreId) ?? (await _storeService.GetAllStores()).FirstOrDefault();
+ var store = await storeService.GetStoreById(campaign.StoreId) ?? (await storeService.GetAllStores()).FirstOrDefault();
- var builder = new LiquidObjectBuilder(_mediator);
+ var builder = new LiquidObjectBuilder(mediator);
builder.AddStoreTokens(store, language, emailAccount);
- var customer = _customerRepository.Table.FirstOrDefault(x => x.Email == email.ToLowerInvariant());
+ var customer = customerRepository.Table.FirstOrDefault(x => x.Email == email.ToLowerInvariant());
if (customer != null)
{
- builder.AddCustomerTokens(customer, store, _workContext.CurrentHost, language)
+ builder.AddCustomerTokens(customer, store, workContext.CurrentHost, language)
.AddShoppingCartTokens(customer, store, language);
}
@@ -377,7 +350,7 @@ namespace Grand.Business.Marketing.Services.Campaigns
var body = LiquidExtensions.Render(liquidObject, campaign.Body);
var subject = LiquidExtensions.Render(liquidObject, campaign.Subject);
- await _emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName, email, null);
+ await emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName, email, null);
}
}
}
\ No newline at end of file
diff --git a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
index bf282afa5..d417d354c 100644
--- a/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Newsletters/NewsLetterSubscriptionService.cs
@@ -295,7 +295,7 @@ namespace Grand.Business.Marketing.Services.Newsletters
continue;
var tmp = line.Split(',');
- var email = "";
+ string email;
var isActive = true;
var categories = new List<string>();
var isCategories = false;
diff --git a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
index cbdb18d7d..f1b042c32 100644
--- a/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
+++ b/src/Business/Grand.Business.Messages/Services/MessageProviderService.cs
@@ -1825,8 +1825,8 @@ namespace Grand.Business.Messages.Services
throw new ArgumentNullException(nameof(product));
var builder = new LiquidObjectBuilder(_mediator);
- MessageTemplate messageTemplate = null;
- EmailAccount emailAccount = null;
+ MessageTemplate messageTemplate;
+ EmailAccount emailAccount;
if (bid != null)
{
diff --git a/src/Business/Grand.Business.System/Services/Migrations/MigrationUpdateResource.cs b/src/Business/Grand.Business.System/Services/Migrations/MigrationUpdateResource.cs
index 3da149fba..45fe74f70 100644
--- a/src/Business/Grand.Business.System/Services/Migrations/MigrationUpdateResource.cs
+++ b/src/Business/Grand.Business.System/Services/Migrations/MigrationUpdateResource.cs
@@ -18,10 +18,7 @@ namespace Grand.Business.System.Services.Migrations
try
{
- var language = langRepository.Table.FirstOrDefault(l => l.Name == "English");
-
- if (language == null)
- language = langRepository.Table.FirstOrDefault();
+ var language = langRepository.Table.FirstOrDefault(l => l.Name == "English") ?? langRepository.Table.FirstOrDefault();
var filePath = CommonPath.MapPath(filename);
var localesXml = File.ReadAllText(filePath);
diff --git a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs
index 082673176..cf7ae99e6 100644
--- a/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs
+++ b/src/Business/Grand.Business.System/Services/Reports/OrderReportService.cs
@@ -482,9 +482,7 @@ namespace Grand.Business.System.Services.Reports
&& (string.IsNullOrEmpty(salesEmployeeId) || o.SeId == salesEmployeeId)
group o by 1 into g
select new ReportPeriodOrder { Amount = g.Sum(x => x.OrderTotal / x.CurrencyRate), Count = g.Count() };
- var report = query.ToList()?.FirstOrDefault();
- if (report == null)
- report = new ReportPeriodOrder();
+ var report = query.ToList()?.FirstOrDefault() ?? new ReportPeriodOrder();
report.Date = date;
return await Task.FromResult(report);
}
diff --git a/src/Core/Grand.Data/DataSettingsManager.cs b/src/Core/Grand.Data/DataSettingsManager.cs
index ace6dff90..2007340f7 100644
--- a/src/Core/Grand.Data/DataSettingsManager.cs
+++ b/src/Core/Grand.Data/DataSettingsManager.cs
@@ -74,7 +74,7 @@ namespace Grand.Data
var filePath = CommonPath.SettingsPath;
if (!File.Exists(filePath))
{
- using FileStream fs = File.Create(filePath);
+ await using FileStream fs = File.Create(filePath);
}
var data = JsonSerializer.Serialize(settings, new JsonSerializerOptions { WriteIndented = true });
await File.WriteAllTextAsync(filePath, data);
diff --git a/src/Core/Grand.Data/Mongo/MongoDBContext.cs b/src/Core/Grand.Data/Mongo/MongoDBContext.cs
index 98e46e801..c964a3f09 100644
--- a/src/Core/Grand.Data/Mongo/MongoDBContext.cs
+++ b/src/Core/Grand.Data/Mongo/MongoDBContext.cs
@@ -113,25 +113,15 @@ namespace Grand.Data.Mongo
{
if (item.selector != null)
{
- if (item.value)
- {
- keys.Add(Builders<T>.IndexKeys.Ascending(item.selector));
- }
- else
- {
- keys.Add(Builders<T>.IndexKeys.Descending(item.selector));
- }
+ keys.Add(item.value
+ ? Builders<T>.IndexKeys.Ascending(item.selector)
+ : Builders<T>.IndexKeys.Descending(item.selector));
}
else
{
- if (item.value)
- {
- keys.Add(Builders<T>.IndexKeys.Ascending(item.fieldName));
- }
- else
- {
- keys.Add(Builders<T>.IndexKeys.Descending(item.fieldName));
- }
+ keys.Add(item.value
+ ? Builders<T>.IndexKeys.Ascending(item.fieldName)
+ : Builders<T>.IndexKeys.Descending(item.fieldName));
}
}
diff --git a/src/Core/Grand.Domain/Admin/AdminSiteMap.cs b/src/Core/Grand.Domain/Admin/AdminSiteMap.cs
index 712c4af89..230c36d5b 100644
--- a/src/Core/Grand.Domain/Admin/AdminSiteMap.cs
+++ b/src/Core/Grand.Domain/Admin/AdminSiteMap.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents an admin menu
/// </summary>
- public partial class AdminSiteMap : BaseEntity
+ public class AdminSiteMap : BaseEntity
{
public AdminSiteMap()
{
diff --git a/src/Core/Grand.Domain/Affiliates/Affiliate.cs b/src/Core/Grand.Domain/Affiliates/Affiliate.cs
index ea0171ce4..94f028ec0 100644
--- a/src/Core/Grand.Domain/Affiliates/Affiliate.cs
+++ b/src/Core/Grand.Domain/Affiliates/Affiliate.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Affiliates
/// <summary>
/// Represents an affiliate
/// </summary>
- public partial class Affiliate : BaseEntity
+ public class Affiliate : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/BaseEntity.cs b/src/Core/Grand.Domain/BaseEntity.cs
index 8050b3afb..e27a362c5 100644
--- a/src/Core/Grand.Domain/BaseEntity.cs
+++ b/src/Core/Grand.Domain/BaseEntity.cs
@@ -7,12 +7,7 @@ namespace Grand.Domain
/// </summary>
public abstract class BaseEntity : ParentEntity, IAuditableEntity
{
- protected BaseEntity()
- {
- UserFields = new List<UserField>();
- }
-
- public IList<UserField> UserFields { get; set; }
+ public IList<UserField> UserFields { get; set; } = new List<UserField>();
public DateTime CreatedOnUtc { get; set; }
public string CreatedBy { get; set; }
diff --git a/src/Core/Grand.Domain/Blogs/BlogCategory.cs b/src/Core/Grand.Domain/Blogs/BlogCategory.cs
index 37c880760..6b0c2c25e 100644
--- a/src/Core/Grand.Domain/Blogs/BlogCategory.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogCategory.cs
@@ -3,15 +3,8 @@ using Grand.Domain.Stores;
namespace Grand.Domain.Blogs
{
- public partial class BlogCategory : BaseEntity, IStoreLinkEntity, ITranslationEntity
+ public class BlogCategory : BaseEntity, IStoreLinkEntity, ITranslationEntity
{
- public BlogCategory()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- BlogPosts = new List<BlogCategoryPost>();
- }
-
/// <summary>
/// Gets or sets the blog category name
/// </summary>
@@ -30,15 +23,14 @@ namespace Grand.Domain.Blogs
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
-
- public IList<BlogCategoryPost> BlogPosts { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
+ public IList<BlogCategoryPost> BlogPosts { get; set; } = new List<BlogCategoryPost>();
}
}
diff --git a/src/Core/Grand.Domain/Blogs/BlogCategoryPost.cs b/src/Core/Grand.Domain/Blogs/BlogCategoryPost.cs
index b4b3933a0..0fa14d0c2 100644
--- a/src/Core/Grand.Domain/Blogs/BlogCategoryPost.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogCategoryPost.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Blogs
{
- public partial class BlogCategoryPost : SubBaseEntity
+ public class BlogCategoryPost : SubBaseEntity
{
public string BlogPostId { get; set; }
}
diff --git a/src/Core/Grand.Domain/Blogs/BlogComment.cs b/src/Core/Grand.Domain/Blogs/BlogComment.cs
index 0c75160dd..4833e9261 100644
--- a/src/Core/Grand.Domain/Blogs/BlogComment.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogComment.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Blogs
/// <summary>
/// Represents a blog comment
/// </summary>
- public partial class BlogComment : BaseEntity
+ public class BlogComment : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Blogs/BlogPost.cs b/src/Core/Grand.Domain/Blogs/BlogPost.cs
index e181bf8eb..b6d27d1ae 100644
--- a/src/Core/Grand.Domain/Blogs/BlogPost.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogPost.cs
@@ -7,14 +7,8 @@ namespace Grand.Domain.Blogs
/// <summary>
/// Represents a blog post
/// </summary>
- public partial class BlogPost : BaseEntity, ISlugEntity, IStoreLinkEntity, ITranslationEntity
+ public class BlogPost : BaseEntity, ISlugEntity, IStoreLinkEntity, ITranslationEntity
{
- public BlogPost()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the blog post title
/// </summary>
@@ -82,12 +76,12 @@ namespace Grand.Domain.Blogs
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public virtual bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the sename
diff --git a/src/Core/Grand.Domain/Blogs/BlogPostTag.cs b/src/Core/Grand.Domain/Blogs/BlogPostTag.cs
index f35d8eb05..7a21c3726 100644
--- a/src/Core/Grand.Domain/Blogs/BlogPostTag.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogPostTag.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Blogs
/// <summary>
/// Represents a blog post tag
/// </summary>
- public partial class BlogPostTag
+ public class BlogPostTag
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Blogs/BlogProduct.cs b/src/Core/Grand.Domain/Blogs/BlogProduct.cs
index aa3f93057..3e17ba9f3 100644
--- a/src/Core/Grand.Domain/Blogs/BlogProduct.cs
+++ b/src/Core/Grand.Domain/Blogs/BlogProduct.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Blogs
{
- public partial class BlogProduct : BaseEntity
+ public class BlogProduct : BaseEntity
{
public string BlogPostId { get; set; }
public string ProductId { get; set; }
diff --git a/src/Core/Grand.Domain/Catalog/Bid.cs b/src/Core/Grand.Domain/Catalog/Bid.cs
index 08a585d92..470605fa0 100644
--- a/src/Core/Grand.Domain/Catalog/Bid.cs
+++ b/src/Core/Grand.Domain/Catalog/Bid.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a auction bid
/// </summary>
- public partial class Bid : BaseEntity
+ public class Bid : BaseEntity
{
/// <summary>
/// Gets or sets the product identifier
diff --git a/src/Core/Grand.Domain/Catalog/Brand.cs b/src/Core/Grand.Domain/Catalog/Brand.cs
index 9bff7e9dd..e657ab7d2 100644
--- a/src/Core/Grand.Domain/Catalog/Brand.cs
+++ b/src/Core/Grand.Domain/Catalog/Brand.cs
@@ -8,16 +8,10 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a brand
/// </summary>
- public partial class Brand : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
+ public class Brand : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
private ICollection<string> _appliedDiscounts;
- public Brand()
- {
- CustomerGroups = new List<string>();
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -102,13 +96,13 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the ExternalId
@@ -128,7 +122,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the collection of applied discounts
diff --git a/src/Core/Grand.Domain/Catalog/BrandLayout.cs b/src/Core/Grand.Domain/Catalog/BrandLayout.cs
index bdb08e232..44ade71eb 100644
--- a/src/Core/Grand.Domain/Catalog/BrandLayout.cs
+++ b/src/Core/Grand.Domain/Catalog/BrandLayout.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a brand layout
/// </summary>
- public partial class BrandLayout : BaseEntity
+ public class BrandLayout : BaseEntity
{
/// <summary>
/// Gets or sets the layout name
diff --git a/src/Core/Grand.Domain/Catalog/BundleProduct.cs b/src/Core/Grand.Domain/Catalog/BundleProduct.cs
index 08cb05bef..b62852bd9 100644
--- a/src/Core/Grand.Domain/Catalog/BundleProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/BundleProduct.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a bundle product
/// </summary>
- public partial class BundleProduct : SubBaseEntity
+ public class BundleProduct : SubBaseEntity
{
/// <summary>
/// Gets or sets the product identifier
diff --git a/src/Core/Grand.Domain/Catalog/CatalogSettings.cs b/src/Core/Grand.Domain/Catalog/CatalogSettings.cs
index 19dea8f2e..aeaacde6b 100644
--- a/src/Core/Grand.Domain/Catalog/CatalogSettings.cs
+++ b/src/Core/Grand.Domain/Catalog/CatalogSettings.cs
@@ -4,12 +4,6 @@ namespace Grand.Domain.Catalog
{
public class CatalogSettings : ISettings
{
- public CatalogSettings()
- {
- ProductSortingEnumDisabled = new List<int>();
- ProductSortingEnumDisplayOrder = new Dictionary<int, int>();
- }
-
/// <summary>
/// Gets or sets a value indicating details pages of unpublished product details pages could be open (for SEO optimization)
/// </summary>
@@ -403,12 +397,12 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets a list of disabled values of ProductSortingEnum
/// </summary>
- public List<int> ProductSortingEnumDisabled { get; set; }
+ public List<int> ProductSortingEnumDisabled { get; set; } = new();
/// <summary>
/// Gets or sets a display order of ProductSortingEnum values
/// </summary>
- public Dictionary<int, int> ProductSortingEnumDisplayOrder { get; set; }
+ public Dictionary<int, int> ProductSortingEnumDisplayOrder { get; set; } = new();
/// <summary>
/// Gets or sets a sorting by availability
diff --git a/src/Core/Grand.Domain/Catalog/Category.cs b/src/Core/Grand.Domain/Catalog/Category.cs
index b1735e786..10a1302a7 100644
--- a/src/Core/Grand.Domain/Catalog/Category.cs
+++ b/src/Core/Grand.Domain/Catalog/Category.cs
@@ -8,16 +8,10 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a category
/// </summary>
- public partial class Category : BaseEntity, ISlugEntity, IGroupLinkEntity, ITranslationEntity, IStoreLinkEntity
+ public class Category : BaseEntity, ISlugEntity, IGroupLinkEntity, ITranslationEntity, IStoreLinkEntity
{
private ICollection<string> _appliedDiscounts;
- public Category()
- {
- CustomerGroups = new List<string>();
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -108,13 +102,13 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the name
@@ -164,7 +158,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the collection of applied discounts
diff --git a/src/Core/Grand.Domain/Catalog/CategoryLayout.cs b/src/Core/Grand.Domain/Catalog/CategoryLayout.cs
index bf25d7cac..9a53ff84f 100644
--- a/src/Core/Grand.Domain/Catalog/CategoryLayout.cs
+++ b/src/Core/Grand.Domain/Catalog/CategoryLayout.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a category layout
/// </summary>
- public partial class CategoryLayout : BaseEntity
+ public class CategoryLayout : BaseEntity
{
/// <summary>
/// Gets or sets the layout name
diff --git a/src/Core/Grand.Domain/Catalog/Collection.cs b/src/Core/Grand.Domain/Catalog/Collection.cs
index af2366360..2e5c7dd4c 100644
--- a/src/Core/Grand.Domain/Catalog/Collection.cs
+++ b/src/Core/Grand.Domain/Catalog/Collection.cs
@@ -8,16 +8,10 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a collection
/// </summary>
- public partial class Collection : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
+ public class Collection : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
private ICollection<string> _appliedDiscounts;
- public Collection()
- {
- CustomerGroups = new List<string>();
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -107,13 +101,13 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is published
@@ -133,7 +127,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the collection of applied discounts
diff --git a/src/Core/Grand.Domain/Catalog/CollectionLayout.cs b/src/Core/Grand.Domain/Catalog/CollectionLayout.cs
index 9449efa20..0f099e085 100644
--- a/src/Core/Grand.Domain/Catalog/CollectionLayout.cs
+++ b/src/Core/Grand.Domain/Catalog/CollectionLayout.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a collection layout
/// </summary>
- public partial class CollectionLayout : BaseEntity
+ public class CollectionLayout : BaseEntity
{
/// <summary>
/// Gets or sets the layout name
diff --git a/src/Core/Grand.Domain/Catalog/CrossSellProduct.cs b/src/Core/Grand.Domain/Catalog/CrossSellProduct.cs
index 25bbab582..f5e42ef3a 100644
--- a/src/Core/Grand.Domain/Catalog/CrossSellProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/CrossSellProduct.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a cross-sell product
/// </summary>
- public partial class CrossSellProduct : BaseEntity
+ public class CrossSellProduct : BaseEntity
{
/// <summary>
/// Gets or sets the first product identifier
diff --git a/src/Core/Grand.Domain/Catalog/CustomerReservationsHelper.cs b/src/Core/Grand.Domain/Catalog/CustomerReservationsHelper.cs
index fa6a474dc..cc54686e9 100644
--- a/src/Core/Grand.Domain/Catalog/CustomerReservationsHelper.cs
+++ b/src/Core/Grand.Domain/Catalog/CustomerReservationsHelper.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a customer reservation helper to the product
/// </summary>
- public partial class CustomerReservationsHelper : BaseEntity
+ public class CustomerReservationsHelper : BaseEntity
{
/// <summary>
/// Gets or sets customer identifier
diff --git a/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs b/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
index e5f4297f4..f68a247a1 100644
--- a/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
+++ b/src/Core/Grand.Domain/Catalog/OutOfStockSubscription.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a out of stock subscription
/// </summary>
- public partial class OutOfStockSubscription : BaseEntity
+ public class OutOfStockSubscription : BaseEntity
{
/// <summary>
/// Gets or sets the store identifier
diff --git a/src/Core/Grand.Domain/Catalog/PredefinedProductAttributeValue.cs b/src/Core/Grand.Domain/Catalog/PredefinedProductAttributeValue.cs
index d3e3dde65..fef4cd8fa 100644
--- a/src/Core/Grand.Domain/Catalog/PredefinedProductAttributeValue.cs
+++ b/src/Core/Grand.Domain/Catalog/PredefinedProductAttributeValue.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a predefined (default) product attribute value
/// </summary>
- public partial class PredefinedProductAttributeValue : SubBaseEntity, ITranslationEntity
+ public class PredefinedProductAttributeValue : SubBaseEntity, ITranslationEntity
{
- public PredefinedProductAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the product attribute name
/// </summary>
@@ -45,6 +40,6 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Catalog/Product.cs b/src/Core/Grand.Domain/Catalog/Product.cs
index 40867fa7b..8dc52e1df 100644
--- a/src/Core/Grand.Domain/Catalog/Product.cs
+++ b/src/Core/Grand.Domain/Catalog/Product.cs
@@ -9,7 +9,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product
/// </summary>
- public partial class Product : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
+ public class Product : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
private ICollection<ProductCategory> _productCategories;
private ICollection<ProductCollection> _productCollections;
@@ -27,12 +27,6 @@ namespace Grand.Domain.Catalog
private ICollection<BundleProduct> _bundleProduct;
private ICollection<ProductPrice> _productPrices;
private ICollection<string> _productTags;
- public Product()
- {
- CustomerGroups = new List<string>();
- Locales = new List<TranslationEntity>();
- Stores = new List<string>();
- }
/// <summary>
/// Gets or sets the product type identifier
@@ -139,12 +133,14 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
+
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
+
/// <summary>
/// Gets or sets the ExternalId
/// </summary>
@@ -565,8 +561,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
+
/// <summary>
/// Gets or sets the collection of ProductCategory
/// </summary>
diff --git a/src/Core/Grand.Domain/Catalog/ProductAlsoPurchased.cs b/src/Core/Grand.Domain/Catalog/ProductAlsoPurchased.cs
index 555347fb3..70224ffc4 100644
--- a/src/Core/Grand.Domain/Catalog/ProductAlsoPurchased.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductAlsoPurchased.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product also purchased
/// </summary>
- public partial class ProductAlsoPurchased : BaseEntity
+ public class ProductAlsoPurchased : BaseEntity
{
public string ProductId { get; set; }
public string ProductId2 { get; set; }
diff --git a/src/Core/Grand.Domain/Catalog/ProductAttribute.cs b/src/Core/Grand.Domain/Catalog/ProductAttribute.cs
index 7f88f60f9..687060b7c 100644
--- a/src/Core/Grand.Domain/Catalog/ProductAttribute.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductAttribute.cs
@@ -6,14 +6,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product attribute
/// </summary>
- public partial class ProductAttribute : BaseEntity, IStoreLinkEntity, ITranslationEntity
+ public class ProductAttribute : BaseEntity, IStoreLinkEntity, ITranslationEntity
{
- public ProductAttribute()
- {
- Locales = new List<TranslationEntity>();
- Stores = new List<string>();
- PredefinedProductAttributeValues = new List<PredefinedProductAttributeValue>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -33,12 +27,13 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
- public IList<PredefinedProductAttributeValue> PredefinedProductAttributeValues { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
+
+ public IList<PredefinedProductAttributeValue> PredefinedProductAttributeValues { get; set; } = new List<PredefinedProductAttributeValue>();
}
}
diff --git a/src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs b/src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs
index d8e7e57ed..b503066cd 100644
--- a/src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductAttributeCombination.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product attribute combination
/// </summary>
- public partial class ProductAttributeCombination : SubBaseEntity, ICloneable
+ public class ProductAttributeCombination : SubBaseEntity, ICloneable
{
private ICollection<ProductCombinationWarehouseInventory> _warehouseInventory;
private ICollection<ProductCombinationTierPrices> _tierPrices;
diff --git a/src/Core/Grand.Domain/Catalog/ProductAttributeMapping.cs b/src/Core/Grand.Domain/Catalog/ProductAttributeMapping.cs
index 10db1d82c..c819462c1 100644
--- a/src/Core/Grand.Domain/Catalog/ProductAttributeMapping.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductAttributeMapping.cs
@@ -6,16 +6,10 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product attribute mapping
/// </summary>
- public partial class ProductAttributeMapping : SubBaseEntity, ITranslationEntity
+ public class ProductAttributeMapping : SubBaseEntity, ITranslationEntity
{
private ICollection<ProductAttributeValue> _productAttributeValues;
- public ProductAttributeMapping()
- {
- Locales = new List<TranslationEntity>();
- ConditionAttribute = new List<CustomAttribute>();
- }
-
/// <summary>
/// Gets or sets the product attribute identifier
/// </summary>
@@ -79,12 +73,12 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the custom attributes (see "ProductAttribute" entity for more info)
/// </summary>
- public IList<CustomAttribute> ConditionAttribute { get; set; }
+ public IList<CustomAttribute> ConditionAttribute { get; set; } = new List<CustomAttribute>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets the product attribute values
diff --git a/src/Core/Grand.Domain/Catalog/ProductAttributeValue.cs b/src/Core/Grand.Domain/Catalog/ProductAttributeValue.cs
index 0f6b6bad8..3059371cb 100644
--- a/src/Core/Grand.Domain/Catalog/ProductAttributeValue.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductAttributeValue.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product attribute value
/// </summary>
- public partial class ProductAttributeValue : SubBaseEntity, ITranslationEntity
+ public class ProductAttributeValue : SubBaseEntity, ITranslationEntity
{
- public ProductAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the attribute value type identifier
/// </summary>
@@ -75,7 +70,6 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Catalog/ProductCategory.cs b/src/Core/Grand.Domain/Catalog/ProductCategory.cs
index 10809c8c5..f59d6f574 100644
--- a/src/Core/Grand.Domain/Catalog/ProductCategory.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductCategory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product category mapping
/// </summary>
- public partial class ProductCategory : SubBaseEntity
+ public class ProductCategory : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Catalog/ProductCollection.cs b/src/Core/Grand.Domain/Catalog/ProductCollection.cs
index caead0c97..fd7c428c9 100644
--- a/src/Core/Grand.Domain/Catalog/ProductCollection.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductCollection.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product collection mapping
/// </summary>
- public partial class ProductCollection : SubBaseEntity
+ public class ProductCollection : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Catalog/ProductCombinationTierPrices.cs b/src/Core/Grand.Domain/Catalog/ProductCombinationTierPrices.cs
index 2bff05103..7f95ef4ac 100644
--- a/src/Core/Grand.Domain/Catalog/ProductCombinationTierPrices.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductCombinationTierPrices.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Manage product combination tier prices
/// </summary>
- public partial class ProductCombinationTierPrices : SubBaseEntity
+ public class ProductCombinationTierPrices : SubBaseEntity
{
/// <summary>
/// Gets or sets the store identifier
diff --git a/src/Core/Grand.Domain/Catalog/ProductCombinationWarehouseInventory.cs b/src/Core/Grand.Domain/Catalog/ProductCombinationWarehouseInventory.cs
index b169dc0ce..75042b722 100644
--- a/src/Core/Grand.Domain/Catalog/ProductCombinationWarehouseInventory.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductCombinationWarehouseInventory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Manage product inventory per warehouse
/// </summary>
- public partial class ProductCombinationWarehouseInventory : SubBaseEntity
+ public class ProductCombinationWarehouseInventory : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Catalog/ProductDeleted.cs b/src/Core/Grand.Domain/Catalog/ProductDeleted.cs
index 80a85b91f..b8cdd2400 100644
--- a/src/Core/Grand.Domain/Catalog/ProductDeleted.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductDeleted.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Catalog
{
- public partial class ProductDeleted: Product
+ public class ProductDeleted: Product
{
public DateTime DeletedOnUtc { get; set; }
}
diff --git a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs b/src/Core/Grand.Domain/Catalog/ProductExtensions.cs
index 0efc4d823..052326f4a 100644
--- a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductExtensions.cs
@@ -182,7 +182,7 @@ namespace Grand.Domain.Catalog
{
if (!string.IsNullOrEmpty(valueStr))
{
- if (attribute.ProductAttributeValues.Where(x => x.Id == valueStr).Count() > 0)
+ if (attribute.ProductAttributeValues.Any(x => x.Id == valueStr))
{
var value = attribute.ProductAttributeValues.FirstOrDefault(x => x.Id == valueStr);
if (value != null)
diff --git a/src/Core/Grand.Domain/Catalog/ProductLayout.cs b/src/Core/Grand.Domain/Catalog/ProductLayout.cs
index 607cf4867..3b4e63cc3 100644
--- a/src/Core/Grand.Domain/Catalog/ProductLayout.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductLayout.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product layout
/// </summary>
- public partial class ProductLayout : BaseEntity
+ public class ProductLayout : BaseEntity
{
/// <summary>
/// Gets or sets the layout name
diff --git a/src/Core/Grand.Domain/Catalog/ProductPicture.cs b/src/Core/Grand.Domain/Catalog/ProductPicture.cs
index 59a2b7e0b..513e7f85b 100644
--- a/src/Core/Grand.Domain/Catalog/ProductPicture.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductPicture.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product picture mapping
/// </summary>
- public partial class ProductPicture : SubBaseEntity
+ public class ProductPicture : SubBaseEntity
{
/// <summary>
/// Gets or sets the picture identifier
diff --git a/src/Core/Grand.Domain/Catalog/ProductReservation.cs b/src/Core/Grand.Domain/Catalog/ProductReservation.cs
index 26eb45849..c8ed41835 100644
--- a/src/Core/Grand.Domain/Catalog/ProductReservation.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductReservation.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a product reservation
/// </summary>
- public partial class ProductReservation : BaseEntity
+ public class ProductReservation : BaseEntity
{
/// <summary>
/// Gets or sets the product identifier
diff --git a/src/Core/Grand.Domain/Catalog/ProductReview.cs b/src/Core/Grand.Domain/Catalog/ProductReview.cs
index b395bde1c..33fd659e3 100644
--- a/src/Core/Grand.Domain/Catalog/ProductReview.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductReview.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product review
/// </summary>
- public partial class ProductReview : BaseEntity
+ public class ProductReview : BaseEntity
{
private ICollection<ProductReviewHelpfulness> _productReviewHelpfulnessEntries;
diff --git a/src/Core/Grand.Domain/Catalog/ProductReviewHelpfulness.cs b/src/Core/Grand.Domain/Catalog/ProductReviewHelpfulness.cs
index a89fa7db1..eee786dc0 100644
--- a/src/Core/Grand.Domain/Catalog/ProductReviewHelpfulness.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductReviewHelpfulness.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product review helpfulness
/// </summary>
- public partial class ProductReviewHelpfulness : SubBaseEntity
+ public class ProductReviewHelpfulness : SubBaseEntity
{
/// <summary>
/// Gets or sets the product review identifier
diff --git a/src/Core/Grand.Domain/Catalog/ProductSpecificationAttribute.cs b/src/Core/Grand.Domain/Catalog/ProductSpecificationAttribute.cs
index c9c64c74e..555ac4910 100644
--- a/src/Core/Grand.Domain/Catalog/ProductSpecificationAttribute.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductSpecificationAttribute.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product specification attribute
/// </summary>
- public partial class ProductSpecificationAttribute : SubBaseEntity
+ public class ProductSpecificationAttribute : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Catalog/ProductTag.cs b/src/Core/Grand.Domain/Catalog/ProductTag.cs
index badb33447..2bf3a0193 100644
--- a/src/Core/Grand.Domain/Catalog/ProductTag.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductTag.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a product tag
/// </summary>
- public partial class ProductTag : BaseEntity, ITranslationEntity
+ public class ProductTag : BaseEntity, ITranslationEntity
{
- public ProductTag()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -30,6 +25,6 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Catalog/ProductWarehouseInventory.cs b/src/Core/Grand.Domain/Catalog/ProductWarehouseInventory.cs
index 0ee56629a..2ae28b151 100644
--- a/src/Core/Grand.Domain/Catalog/ProductWarehouseInventory.cs
+++ b/src/Core/Grand.Domain/Catalog/ProductWarehouseInventory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Manage product inventory per warehouse
/// </summary>
- public partial class ProductWarehouseInventory : SubBaseEntity
+ public class ProductWarehouseInventory : SubBaseEntity
{
/// <summary>
/// Gets or sets the warehouse identifier
diff --git a/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs b/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
index c00e414c2..332dd24a9 100644
--- a/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/RecentlyViewedProduct.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Catalog
{
- public partial class RecentlyViewedProduct: BaseEntity
+ public class RecentlyViewedProduct: BaseEntity
{
public string CustomerId { get; set; }
public string ProductId { get; set; }
diff --git a/src/Core/Grand.Domain/Catalog/RelatedProduct.cs b/src/Core/Grand.Domain/Catalog/RelatedProduct.cs
index 1024a7565..c63de35ce 100644
--- a/src/Core/Grand.Domain/Catalog/RelatedProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/RelatedProduct.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a related product
/// </summary>
- public partial class RelatedProduct : SubBaseEntity
+ public class RelatedProduct : SubBaseEntity
{
/// <summary>
/// Gets or sets the second product identifier
diff --git a/src/Core/Grand.Domain/Catalog/SimilarProduct.cs b/src/Core/Grand.Domain/Catalog/SimilarProduct.cs
index a5356f187..9cc889ee8 100644
--- a/src/Core/Grand.Domain/Catalog/SimilarProduct.cs
+++ b/src/Core/Grand.Domain/Catalog/SimilarProduct.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a similar product
/// </summary>
- public partial class SimilarProduct : SubBaseEntity
+ public class SimilarProduct : SubBaseEntity
{
/// <summary>
/// Gets or sets the first product identifier
diff --git a/src/Core/Grand.Domain/Catalog/SpecificationAttribute.cs b/src/Core/Grand.Domain/Catalog/SpecificationAttribute.cs
index 0d382773f..27c45ddb5 100644
--- a/src/Core/Grand.Domain/Catalog/SpecificationAttribute.cs
+++ b/src/Core/Grand.Domain/Catalog/SpecificationAttribute.cs
@@ -6,16 +6,10 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a specification attribute
/// </summary>
- public partial class SpecificationAttribute : BaseEntity, IStoreLinkEntity, ITranslationEntity
+ public class SpecificationAttribute : BaseEntity, IStoreLinkEntity, ITranslationEntity
{
private ICollection<SpecificationAttributeOption> _specificationAttributeOptions;
- public SpecificationAttribute()
- {
- Locales = new List<TranslationEntity>();
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -35,12 +29,12 @@ namespace Grand.Domain.Catalog
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the specification attribute options
diff --git a/src/Core/Grand.Domain/Catalog/SpecificationAttributeOption.cs b/src/Core/Grand.Domain/Catalog/SpecificationAttributeOption.cs
index 5a97069cf..6262760b5 100644
--- a/src/Core/Grand.Domain/Catalog/SpecificationAttributeOption.cs
+++ b/src/Core/Grand.Domain/Catalog/SpecificationAttributeOption.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a specification attribute option
/// </summary>
- public partial class SpecificationAttributeOption : SubBaseEntity, ITranslationEntity
+ public class SpecificationAttributeOption : SubBaseEntity, ITranslationEntity
{
- public SpecificationAttributeOption()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -35,6 +30,6 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Catalog/TierPrice.cs b/src/Core/Grand.Domain/Catalog/TierPrice.cs
index b746d2230..ea529d79a 100644
--- a/src/Core/Grand.Domain/Catalog/TierPrice.cs
+++ b/src/Core/Grand.Domain/Catalog/TierPrice.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Catalog
/// <summary>
/// Represents a tier price
/// </summary>
- public partial class TierPrice : SubBaseEntity
+ public class TierPrice : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Cms/WidgetSettings.cs b/src/Core/Grand.Domain/Cms/WidgetSettings.cs
index 879a80dc0..c05cb46a3 100644
--- a/src/Core/Grand.Domain/Cms/WidgetSettings.cs
+++ b/src/Core/Grand.Domain/Cms/WidgetSettings.cs
@@ -4,14 +4,9 @@ namespace Grand.Domain.Cms
{
public class WidgetSettings : ISettings
{
- public WidgetSettings()
- {
- ActiveWidgetSystemNames = new List<string>();
- }
-
/// <summary>
/// Gets or sets a system names of active widgets
/// </summary>
- public List<string> ActiveWidgetSystemNames { get; set; }
+ public List<string> ActiveWidgetSystemNames { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Common/Address.cs b/src/Core/Grand.Domain/Common/Address.cs
index fcb76c9a3..e9031da17 100644
--- a/src/Core/Grand.Domain/Common/Address.cs
+++ b/src/Core/Grand.Domain/Common/Address.cs
@@ -1,12 +1,7 @@
namespace Grand.Domain.Common
{
- public partial class Address : SubBaseEntity
+ public class Address : SubBaseEntity
{
- public Address()
- {
- Attributes = new List<CustomAttribute>();
- }
-
/// <summary>
/// Gets or sets the name of address
/// </summary>
@@ -85,7 +80,7 @@
/// <summary>
/// Gets or sets the custom attributes (see "AddressAttribute" entity for more info)
/// </summary>
- public IList<CustomAttribute> Attributes { get; set; }
+ public IList<CustomAttribute> Attributes { get; set; } = new List<CustomAttribute>();
/// <summary>
/// Gets or sets the address type
diff --git a/src/Core/Grand.Domain/Common/AddressAttribute.cs b/src/Core/Grand.Domain/Common/AddressAttribute.cs
index 3288efbcb..fe71512ae 100644
--- a/src/Core/Grand.Domain/Common/AddressAttribute.cs
+++ b/src/Core/Grand.Domain/Common/AddressAttribute.cs
@@ -6,14 +6,10 @@ namespace Grand.Domain.Common
/// <summary>
/// Represents an address attribute
/// </summary>
- public partial class AddressAttribute : BaseEntity, ITranslationEntity
+ public class AddressAttribute : BaseEntity, ITranslationEntity
{
private ICollection<AddressAttributeValue> _addressAttributeValues;
- public AddressAttribute()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -38,7 +34,7 @@ namespace Grand.Domain.Common
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets the attribute control type
diff --git a/src/Core/Grand.Domain/Common/AddressAttributeValue.cs b/src/Core/Grand.Domain/Common/AddressAttributeValue.cs
index 17817c706..35846098d 100644
--- a/src/Core/Grand.Domain/Common/AddressAttributeValue.cs
+++ b/src/Core/Grand.Domain/Common/AddressAttributeValue.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Common
/// <summary>
/// Represents an address attribute value
/// </summary>
- public partial class AddressAttributeValue : BaseEntity, ITranslationEntity
+ public class AddressAttributeValue : BaseEntity, ITranslationEntity
{
- public AddressAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the address attribute identifier
/// </summary>
@@ -36,7 +31,7 @@ namespace Grand.Domain.Common
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Common/CommonSettings.cs b/src/Core/Grand.Domain/Common/CommonSettings.cs
index 5da120fbd..a0286b386 100644
--- a/src/Core/Grand.Domain/Common/CommonSettings.cs
+++ b/src/Core/Grand.Domain/Common/CommonSettings.cs
@@ -4,11 +4,6 @@ namespace Grand.Domain.Common
{
public class CommonSettings : ISettings
{
- public CommonSettings()
- {
- IgnoreLogWordlist = new List<string>();
- SitemapCustomUrls = new List<string>();
- }
public bool StoreInDatabaseContactUsForm { get; set; }
public bool SubjectFieldOnContactUsForm { get; set; }
public bool UseSystemEmailForContactUsForm { get; set; }
@@ -22,14 +17,14 @@ namespace Grand.Domain.Common
/// <summary>
/// A list of custom URLs to be added to sitemap.xml (include page names only)
/// </summary>
- public List<string> SitemapCustomUrls { get; set; }
+ public List<string> SitemapCustomUrls { get; set; } = new();
/// <summary>
/// Gets or sets a ignore words (phrases) to be ignored when logging errors/messages
/// </summary>
- public List<string> IgnoreLogWordlist { get; set; }
+ public List<string> IgnoreLogWordlist { get; set; } = new();
- /// <summary>
+ /// <summary>
/// Gets or sets a value indicating whether "accept terms of service" links should be open in popup window. If disabled, then they'll be open on a new page.
/// </summary>
public bool PopupForTermsOfServiceLinks { get; set; }
diff --git a/src/Core/Grand.Domain/Common/GrandNodeVersion.cs b/src/Core/Grand.Domain/Common/GrandNodeVersion.cs
index f8101f7cc..c6e0d613a 100644
--- a/src/Core/Grand.Domain/Common/GrandNodeVersion.cs
+++ b/src/Core/Grand.Domain/Common/GrandNodeVersion.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Common
{
- public partial class GrandNodeVersion: BaseEntity
+ public class GrandNodeVersion: BaseEntity
{
public string DataBaseVersion { get; set; }
}
diff --git a/src/Core/Grand.Domain/Common/RobotsTxt.cs b/src/Core/Grand.Domain/Common/RobotsTxt.cs
index 3917d7e10..ba5da8dad 100644
--- a/src/Core/Grand.Domain/Common/RobotsTxt.cs
+++ b/src/Core/Grand.Domain/Common/RobotsTxt.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Common
{
- public partial class RobotsTxt : BaseEntity
+ public class RobotsTxt : BaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Common/SearchTerm.cs b/src/Core/Grand.Domain/Common/SearchTerm.cs
index 8e385db48..9d3bad2d4 100644
--- a/src/Core/Grand.Domain/Common/SearchTerm.cs
+++ b/src/Core/Grand.Domain/Common/SearchTerm.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Search term (only for statistics)
/// </summary>
- public partial class SearchTerm : BaseEntity
+ public class SearchTerm : BaseEntity
{
/// <summary>
/// Gets or sets the keyword
diff --git a/src/Core/Grand.Domain/Common/UserField.cs b/src/Core/Grand.Domain/Common/UserField.cs
index 117e7a30d..17aa13997 100644
--- a/src/Core/Grand.Domain/Common/UserField.cs
+++ b/src/Core/Grand.Domain/Common/UserField.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Common
/// <summary>
/// Represents a user field
/// </summary>
- public partial class UserField
+ public class UserField
{
/// <summary>
/// Gets or sets the key
diff --git a/src/Core/Grand.Domain/Common/UserFieldBaseEntity.cs b/src/Core/Grand.Domain/Common/UserFieldBaseEntity.cs
index c7e98c86c..72a0022da 100644
--- a/src/Core/Grand.Domain/Common/UserFieldBaseEntity.cs
+++ b/src/Core/Grand.Domain/Common/UserFieldBaseEntity.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Common
{
- public partial class UserFieldBaseEntity : BaseEntity
+ public class UserFieldBaseEntity : BaseEntity
{
}
}
diff --git a/src/Core/Grand.Domain/Configuration/Setting.cs b/src/Core/Grand.Domain/Configuration/Setting.cs
index 421da34c2..60c4cd5af 100644
--- a/src/Core/Grand.Domain/Configuration/Setting.cs
+++ b/src/Core/Grand.Domain/Configuration/Setting.cs
@@ -4,7 +4,7 @@ namespace Grand.Domain.Configuration
/// <summary>
/// Represents a setting
/// </summary>
- public partial class Setting : BaseEntity
+ public class Setting : BaseEntity
{
public Setting()
{
diff --git a/src/Core/Grand.Domain/Courses/Course.cs b/src/Core/Grand.Domain/Courses/Course.cs
index b1db23666..96e97e75f 100644
--- a/src/Core/Grand.Domain/Courses/Course.cs
+++ b/src/Core/Grand.Domain/Courses/Course.cs
@@ -7,13 +7,6 @@ namespace Grand.Domain.Courses
{
public class Course : BaseEntity, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
- public Course()
- {
- CustomerGroups = new List<string>();
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -58,13 +51,13 @@ namespace Grand.Domain.Courses
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the meta keywords
@@ -89,7 +82,6 @@ namespace Grand.Domain.Courses
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Customers/Customer.cs b/src/Core/Grand.Domain/Customers/Customer.cs
index a9c2efc44..90ff5dd26 100644
--- a/src/Core/Grand.Domain/Customers/Customer.cs
+++ b/src/Core/Grand.Domain/Customers/Customer.cs
@@ -6,7 +6,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer
/// </summary>
- public partial class Customer : BaseEntity
+ public class Customer : BaseEntity
{
private ICollection<ShoppingCartItem> _shoppingCartItems;
private ICollection<Address> _addresses;
diff --git a/src/Core/Grand.Domain/Customers/CustomerAttribute.cs b/src/Core/Grand.Domain/Customers/CustomerAttribute.cs
index e4d8f1166..35363949e 100644
--- a/src/Core/Grand.Domain/Customers/CustomerAttribute.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerAttribute.cs
@@ -6,14 +6,10 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer attribute
/// </summary>
- public partial class CustomerAttribute : BaseEntity, ITranslationEntity
+ public class CustomerAttribute : BaseEntity, ITranslationEntity
{
private ICollection<CustomerAttributeValue> _customerAttributeValues;
- public CustomerAttribute()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -42,7 +38,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets the customer attribute values
diff --git a/src/Core/Grand.Domain/Customers/CustomerAttributeValue.cs b/src/Core/Grand.Domain/Customers/CustomerAttributeValue.cs
index cd6862527..df6d712c0 100644
--- a/src/Core/Grand.Domain/Customers/CustomerAttributeValue.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerAttributeValue.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer attribute value
/// </summary>
- public partial class CustomerAttributeValue : SubBaseEntity, ITranslationEntity
+ public class CustomerAttributeValue : SubBaseEntity, ITranslationEntity
{
- public CustomerAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the customer attribute identifier
/// </summary>
@@ -34,8 +30,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Customers/CustomerGroup.cs b/src/Core/Grand.Domain/Customers/CustomerGroup.cs
index 688fb8a46..2c11eff71 100644
--- a/src/Core/Grand.Domain/Customers/CustomerGroup.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerGroup.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer group
/// </summary>
- public partial class CustomerGroup : BaseEntity
+ public class CustomerGroup : BaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Customers/CustomerGroupProduct.cs b/src/Core/Grand.Domain/Customers/CustomerGroupProduct.cs
index d008c1653..9bf2233a5 100644
--- a/src/Core/Grand.Domain/Customers/CustomerGroupProduct.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerGroupProduct.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer group products
/// </summary>
- public partial class CustomerGroupProduct : BaseEntity
+ public class CustomerGroupProduct : BaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs b/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
index 9a5f5d334..0570b7172 100644
--- a/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerHistoryPassword.cs
@@ -3,13 +3,8 @@
/// <summary>
/// Represents a Customer History Password
/// </summary>
- public partial class CustomerHistoryPassword : BaseEntity
+ public class CustomerHistoryPassword : BaseEntity
{
- public CustomerHistoryPassword()
- {
- PasswordFormatId = PasswordFormat.Clear;
- }
-
/// <summary>
/// Gets or sets the customer identifier
/// </summary>
@@ -23,7 +18,7 @@
/// <summary>
/// Gets or sets the password format identifier
/// </summary>
- public PasswordFormat PasswordFormatId { get; set; }
+ public PasswordFormat PasswordFormatId { get; set; } = PasswordFormat.Clear;
/// <summary>
/// Gets or sets the password salt
diff --git a/src/Core/Grand.Domain/Customers/CustomerNote.cs b/src/Core/Grand.Domain/Customers/CustomerNote.cs
index e38e77e05..dfff7bd43 100644
--- a/src/Core/Grand.Domain/Customers/CustomerNote.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerNote.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents an customer note
/// </summary>
- public partial class CustomerNote : BaseEntity
+ public class CustomerNote : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Customers/CustomerTag.cs b/src/Core/Grand.Domain/Customers/CustomerTag.cs
index 239199ce7..76f234abe 100644
--- a/src/Core/Grand.Domain/Customers/CustomerTag.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerTag.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a product tag
/// </summary>
- public partial class CustomerTag : BaseEntity
+ public class CustomerTag : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Customers/CustomerTagProduct.cs b/src/Core/Grand.Domain/Customers/CustomerTagProduct.cs
index 48576ebed..ea7103c76 100644
--- a/src/Core/Grand.Domain/Customers/CustomerTagProduct.cs
+++ b/src/Core/Grand.Domain/Customers/CustomerTagProduct.cs
@@ -4,7 +4,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents a customer tag product
/// </summary>
- public partial class CustomerTagProduct : BaseEntity
+ public class CustomerTagProduct : BaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Customers/ExternalAuthentication.cs b/src/Core/Grand.Domain/Customers/ExternalAuthentication.cs
index 9e3394a2a..3d2c221f1 100644
--- a/src/Core/Grand.Domain/Customers/ExternalAuthentication.cs
+++ b/src/Core/Grand.Domain/Customers/ExternalAuthentication.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Customers
/// <summary>
/// Represents an external authentication
/// </summary>
- public partial class ExternalAuthentication : BaseEntity
+ public class ExternalAuthentication : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Customers/SystemCustomerFieldNames.cs b/src/Core/Grand.Domain/Customers/SystemCustomerFieldNames.cs
index cf7f16fbc..b13433866 100644
--- a/src/Core/Grand.Domain/Customers/SystemCustomerFieldNames.cs
+++ b/src/Core/Grand.Domain/Customers/SystemCustomerFieldNames.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Customers
{
- public static partial class SystemCustomerFieldNames
+ public static class SystemCustomerFieldNames
{
//Form fields
public static string FirstName { get { return "FirstName"; } }
diff --git a/src/Core/Grand.Domain/Customers/SystemCustomerGroupNames.cs b/src/Core/Grand.Domain/Customers/SystemCustomerGroupNames.cs
index d0b66d3a6..12ec67261 100644
--- a/src/Core/Grand.Domain/Customers/SystemCustomerGroupNames.cs
+++ b/src/Core/Grand.Domain/Customers/SystemCustomerGroupNames.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Customers
{
- public static partial class SystemCustomerGroupNames
+ public static class SystemCustomerGroupNames
{
public const string Administrators = "Administrators";
diff --git a/src/Core/Grand.Domain/Customers/SystemCustomerNames.cs b/src/Core/Grand.Domain/Customers/SystemCustomerNames.cs
index 3b501352e..48c8d0db9 100644
--- a/src/Core/Grand.Domain/Customers/SystemCustomerNames.cs
+++ b/src/Core/Grand.Domain/Customers/SystemCustomerNames.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Customers
{
- public static partial class SystemCustomerNames
+ public static class SystemCustomerNames
{
public static string Anonymous { get { return "Anonymous"; } }
public static string SearchEngine { get { return "SearchEngine"; } }
diff --git a/src/Core/Grand.Domain/Customers/UserApi.cs b/src/Core/Grand.Domain/Customers/UserApi.cs
index 040a5e649..a8d1c82c0 100644
--- a/src/Core/Grand.Domain/Customers/UserApi.cs
+++ b/src/Core/Grand.Domain/Customers/UserApi.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Customers
{
- public partial class UserApi : BaseEntity
+ public class UserApi : BaseEntity
{
public string Email { get; set; }
public string Password { get; set; }
diff --git a/src/Core/Grand.Domain/Directory/Country.cs b/src/Core/Grand.Domain/Directory/Country.cs
index 9f5feda05..a331d6215 100644
--- a/src/Core/Grand.Domain/Directory/Country.cs
+++ b/src/Core/Grand.Domain/Directory/Country.cs
@@ -6,15 +6,10 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a country
/// </summary>
- public partial class Country : BaseEntity, ITranslationEntity, IStoreLinkEntity
+ public class Country : BaseEntity, ITranslationEntity, IStoreLinkEntity
{
private ICollection<StateProvince> _stateProvinces;
- public Country()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -64,12 +59,12 @@ namespace Grand.Domain.Directory
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the state/provinces
diff --git a/src/Core/Grand.Domain/Directory/Currency.cs b/src/Core/Grand.Domain/Directory/Currency.cs
index 80909e01a..efc0d2764 100644
--- a/src/Core/Grand.Domain/Directory/Currency.cs
+++ b/src/Core/Grand.Domain/Directory/Currency.cs
@@ -6,13 +6,8 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a currency
/// </summary>
- public partial class Currency : BaseEntity, ITranslationEntity, IStoreLinkEntity
+ public class Currency : BaseEntity, ITranslationEntity, IStoreLinkEntity
{
- public Currency()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -42,7 +37,7 @@ namespace Grand.Domain.Directory
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is published
@@ -72,7 +67,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Directory/ExchangeRate.cs b/src/Core/Grand.Domain/Directory/ExchangeRate.cs
index 7b5f6ac6b..efbb55c51 100644
--- a/src/Core/Grand.Domain/Directory/ExchangeRate.cs
+++ b/src/Core/Grand.Domain/Directory/ExchangeRate.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents an exchange rate
/// </summary>
- public partial class ExchangeRate
+ public class ExchangeRate
{
/// <summary>
/// Creates a new instance of the ExchangeRate class
diff --git a/src/Core/Grand.Domain/Directory/MeasureDimension.cs b/src/Core/Grand.Domain/Directory/MeasureDimension.cs
index 370691456..33228cbaf 100644
--- a/src/Core/Grand.Domain/Directory/MeasureDimension.cs
+++ b/src/Core/Grand.Domain/Directory/MeasureDimension.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a measure dimension
/// </summary>
- public partial class MeasureDimension : BaseEntity
+ public class MeasureDimension : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Directory/MeasureUnit.cs b/src/Core/Grand.Domain/Directory/MeasureUnit.cs
index bf6551f13..ac232b196 100644
--- a/src/Core/Grand.Domain/Directory/MeasureUnit.cs
+++ b/src/Core/Grand.Domain/Directory/MeasureUnit.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a measure weight
/// </summary>
- public partial class MeasureUnit : BaseEntity
+ public class MeasureUnit : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Directory/MeasureWeight.cs b/src/Core/Grand.Domain/Directory/MeasureWeight.cs
index 19ee51388..82c7b28a4 100644
--- a/src/Core/Grand.Domain/Directory/MeasureWeight.cs
+++ b/src/Core/Grand.Domain/Directory/MeasureWeight.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a measure weight
/// </summary>
- public partial class MeasureWeight : BaseEntity
+ public class MeasureWeight : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Directory/StateProvince.cs b/src/Core/Grand.Domain/Directory/StateProvince.cs
index c43bc4b3b..71251a45d 100644
--- a/src/Core/Grand.Domain/Directory/StateProvince.cs
+++ b/src/Core/Grand.Domain/Directory/StateProvince.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Directory
/// <summary>
/// Represents a state/province
/// </summary>
- public partial class StateProvince : SubBaseEntity, ITranslationEntity
+ public class StateProvince : SubBaseEntity, ITranslationEntity
{
- public StateProvince()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -35,7 +30,7 @@ namespace Grand.Domain.Directory
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Discounts/Discount.cs b/src/Core/Grand.Domain/Discounts/Discount.cs
index a8503b301..c7ba86da0 100644
--- a/src/Core/Grand.Domain/Discounts/Discount.cs
+++ b/src/Core/Grand.Domain/Discounts/Discount.cs
@@ -5,15 +5,10 @@ namespace Grand.Domain.Discounts
/// <summary>
/// Represents a discount
/// </summary>
- public partial class Discount : BaseEntity, IStoreLinkEntity
+ public class Discount : BaseEntity, IStoreLinkEntity
{
private ICollection<DiscountRule> _discountRules;
- public Discount()
- {
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -110,7 +105,7 @@ namespace Grand.Domain.Discounts
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the discount requirement
diff --git a/src/Core/Grand.Domain/Discounts/DiscountRule.cs b/src/Core/Grand.Domain/Discounts/DiscountRule.cs
index bc4a9e573..43ae4f68b 100644
--- a/src/Core/Grand.Domain/Discounts/DiscountRule.cs
+++ b/src/Core/Grand.Domain/Discounts/DiscountRule.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a discount requirement
/// </summary>
- public partial class DiscountRule : SubBaseEntity
+ public class DiscountRule : SubBaseEntity
{
/// <summary>
/// Gets or sets the discount requirement rule system name
diff --git a/src/Core/Grand.Domain/Documents/Document.cs b/src/Core/Grand.Domain/Documents/Document.cs
index f2107cd8a..6f5ef5f68 100644
--- a/src/Core/Grand.Domain/Documents/Document.cs
+++ b/src/Core/Grand.Domain/Documents/Document.cs
@@ -7,14 +7,8 @@ namespace Grand.Domain.Documents
/// <summary>
/// Represents a document
/// </summary>
- public partial class Document : BaseEntity, IGroupLinkEntity, IStoreLinkEntity
+ public class Document : BaseEntity, IGroupLinkEntity, IStoreLinkEntity
{
- public Document()
- {
- CustomerGroups = new List<string>();
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets the document number
/// </summary>
@@ -74,13 +68,13 @@ namespace Grand.Domain.Documents
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Documents/DocumentType.cs b/src/Core/Grand.Domain/Documents/DocumentType.cs
index 86946c249..a5ac9e84b 100644
--- a/src/Core/Grand.Domain/Documents/DocumentType.cs
+++ b/src/Core/Grand.Domain/Documents/DocumentType.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a document type
/// </summary>
- public partial class DocumentType : BaseEntity
+ public class DocumentType : BaseEntity
{
public string Name { get; set; }
public string Description { get; set; }
diff --git a/src/Core/Grand.Domain/History/IHistory.cs b/src/Core/Grand.Domain/History/IHistory.cs
index 402d55e64..1f3ef29b1 100644
--- a/src/Core/Grand.Domain/History/IHistory.cs
+++ b/src/Core/Grand.Domain/History/IHistory.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Interface for History of changes object
/// </summary>
- public partial interface IHistory
+ public interface IHistory
{
}
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
index 61b1a0ee2..a89f8df59 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticle.cs
@@ -7,14 +7,6 @@ namespace Grand.Domain.Knowledgebase
{
public class KnowledgebaseArticle : BaseEntity, ITreeNode, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
- public KnowledgebaseArticle()
- {
- CustomerGroups = new List<string>();
- Locales = new List<TranslationEntity>();
- RelatedArticles = new List<string>();
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets title of the article
/// </summary>
@@ -43,13 +35,13 @@ namespace Grand.Domain.Knowledgebase
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the name
@@ -79,7 +71,7 @@ namespace Grand.Domain.Knowledgebase
/// <summary>
/// Gets or sets list of related articles ids
/// </summary>
- public IList<string> RelatedArticles { get; set; }
+ public IList<string> RelatedArticles { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the comments are allowed
@@ -90,6 +82,6 @@ namespace Grand.Domain.Knowledgebase
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
}
}
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
index 17537c8fc..6decd394c 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseArticleComment.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Knowledgebase
{
- public partial class KnowledgebaseArticleComment : BaseEntity
+ public class KnowledgebaseArticleComment : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
index bd7ee4f2a..43fee9ad3 100644
--- a/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
+++ b/src/Core/Grand.Domain/Knowledgebase/KnowledgebaseCategory.cs
@@ -7,13 +7,6 @@ namespace Grand.Domain.Knowledgebase
{
public class KnowledgebaseCategory : BaseEntity, ITreeNode, ITranslationEntity, ISlugEntity, IGroupLinkEntity, IStoreLinkEntity
{
- public KnowledgebaseCategory()
- {
- CustomerGroups = new List<string>();
- Locales = new List<TranslationEntity>();
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets name of the category
/// </summary>
@@ -42,13 +35,13 @@ namespace Grand.Domain.Knowledgebase
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the name
@@ -74,6 +67,6 @@ namespace Grand.Domain.Knowledgebase
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
}
}
diff --git a/src/Core/Grand.Domain/Localization/Language.cs b/src/Core/Grand.Domain/Localization/Language.cs
index dd7073f49..a8000e880 100644
--- a/src/Core/Grand.Domain/Localization/Language.cs
+++ b/src/Core/Grand.Domain/Localization/Language.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Localization
/// <summary>
/// Represents a language
/// </summary>
- public partial class Language : BaseEntity, IStoreLinkEntity
+ public class Language : BaseEntity, IStoreLinkEntity
{
- public Language()
- {
- Stores = new List<string>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -41,7 +36,7 @@ namespace Grand.Domain.Localization
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the identifier of the default currency for this language; 0 is set when we use the default currency display order
diff --git a/src/Core/Grand.Domain/Localization/TranslationEntity.cs b/src/Core/Grand.Domain/Localization/TranslationEntity.cs
index ccdcd76c1..a9806878f 100644
--- a/src/Core/Grand.Domain/Localization/TranslationEntity.cs
+++ b/src/Core/Grand.Domain/Localization/TranslationEntity.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Localization
/// <summary>
/// Represents a translation property
/// </summary>
- public partial class TranslationEntity : SubBaseEntity
+ public class TranslationEntity : SubBaseEntity
{
/// <summary>
/// Gets or sets the language identifier
diff --git a/src/Core/Grand.Domain/Localization/TranslationResource.cs b/src/Core/Grand.Domain/Localization/TranslationResource.cs
index 2df7a6f5a..3c52ed9bc 100644
--- a/src/Core/Grand.Domain/Localization/TranslationResource.cs
+++ b/src/Core/Grand.Domain/Localization/TranslationResource.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Localization
/// <summary>
/// Represents a locale string resource
/// </summary>
- public partial class TranslationResource : BaseEntity
+ public class TranslationResource : BaseEntity
{
/// <summary>
/// Gets or sets the language identifier
diff --git a/src/Core/Grand.Domain/Media/Download.cs b/src/Core/Grand.Domain/Media/Download.cs
index 939161115..53c36c237 100644
--- a/src/Core/Grand.Domain/Media/Download.cs
+++ b/src/Core/Grand.Domain/Media/Download.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Media
/// <summary>
/// Represents a download
/// </summary>
- public partial class Download : BaseEntity
+ public class Download : BaseEntity
{
/// <summary>
/// Gets or sets a customer identifier
diff --git a/src/Core/Grand.Domain/Media/Picture.cs b/src/Core/Grand.Domain/Media/Picture.cs
index 019f48098..fe5d5e1c2 100644
--- a/src/Core/Grand.Domain/Media/Picture.cs
+++ b/src/Core/Grand.Domain/Media/Picture.cs
@@ -6,13 +6,8 @@ namespace Grand.Domain.Media
/// <summary>
/// Represents a picture
/// </summary>
- public partial class Picture : BaseEntity, ITranslationEntity
+ public class Picture : BaseEntity, ITranslationEntity
{
- public Picture()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the picture binary
/// </summary>
@@ -66,7 +61,6 @@ namespace Grand.Domain.Media
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Messages/Campaign.cs b/src/Core/Grand.Domain/Messages/Campaign.cs
index 3055a93b7..3fc9b8799 100644
--- a/src/Core/Grand.Domain/Messages/Campaign.cs
+++ b/src/Core/Grand.Domain/Messages/Campaign.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a campaign
/// </summary>
- public partial class Campaign : BaseEntity
+ public class Campaign : BaseEntity
{
private ICollection<string> _customerTags;
private ICollection<string> _customerGroups;
diff --git a/src/Core/Grand.Domain/Messages/CampaignCustomerSubscription.cs b/src/Core/Grand.Domain/Messages/CampaignCustomerSubscription.cs
index 18d3e3f5a..42de5d39e 100644
--- a/src/Core/Grand.Domain/Messages/CampaignCustomerSubscription.cs
+++ b/src/Core/Grand.Domain/Messages/CampaignCustomerSubscription.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Messages
{
- public partial class CampaignCustomerSubscription
+ public class CampaignCustomerSubscription
{
public string CustomerId { get; set; }
public string Email { get; set; }
diff --git a/src/Core/Grand.Domain/Messages/CampaignHistory.cs b/src/Core/Grand.Domain/Messages/CampaignHistory.cs
index ae11ba49d..a37355aae 100644
--- a/src/Core/Grand.Domain/Messages/CampaignHistory.cs
+++ b/src/Core/Grand.Domain/Messages/CampaignHistory.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a campaign history
/// </summary>
- public partial class CampaignHistory : BaseEntity
+ public class CampaignHistory : BaseEntity
{
public string CampaignId { get; set; }
diff --git a/src/Core/Grand.Domain/Messages/ContactAttribute.cs b/src/Core/Grand.Domain/Messages/ContactAttribute.cs
index daff53101..3e7e55063 100644
--- a/src/Core/Grand.Domain/Messages/ContactAttribute.cs
+++ b/src/Core/Grand.Domain/Messages/ContactAttribute.cs
@@ -9,17 +9,10 @@ namespace Grand.Domain.Messages
/// <summary>
/// Represents a contact attribute
/// </summary>
- public partial class ContactAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity, IGroupLinkEntity
+ public class ContactAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity, IGroupLinkEntity
{
private ICollection<ContactAttributeValue> _contactAttributeValues;
- public ContactAttribute()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- CustomerGroups = new List<string>();
- ConditionAttribute = new List<CustomAttribute>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -50,13 +43,13 @@ namespace Grand.Domain.Messages
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
//validation fields
@@ -85,14 +78,13 @@ namespace Grand.Domain.Messages
/// </summary>
public string DefaultValue { get; set; }
- public IList<CustomAttribute> ConditionAttribute { get; set; }
+ public IList<CustomAttribute> ConditionAttribute { get; set; } = new List<CustomAttribute>();
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
-
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
diff --git a/src/Core/Grand.Domain/Messages/ContactAttributeValue.cs b/src/Core/Grand.Domain/Messages/ContactAttributeValue.cs
index 1c78da814..0765c2b31 100644
--- a/src/Core/Grand.Domain/Messages/ContactAttributeValue.cs
+++ b/src/Core/Grand.Domain/Messages/ContactAttributeValue.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Messages
/// <summary>
/// Represents a contact attribute value
/// </summary>
- public partial class ContactAttributeValue : SubBaseEntity, ITranslationEntity
+ public class ContactAttributeValue : SubBaseEntity, ITranslationEntity
{
- public ContactAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the checkout attribute mapping identifier
/// </summary>
@@ -40,7 +35,7 @@ namespace Grand.Domain.Messages
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Messages/ContactUs.cs b/src/Core/Grand.Domain/Messages/ContactUs.cs
index 4dafeb87e..40a4057fa 100644
--- a/src/Core/Grand.Domain/Messages/ContactUs.cs
+++ b/src/Core/Grand.Domain/Messages/ContactUs.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Messages
/// <summary>
/// Search term record (for statistics)
/// </summary>
- public partial class ContactUs : BaseEntity
+ public class ContactUs : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Messages/EmailAccount.cs b/src/Core/Grand.Domain/Messages/EmailAccount.cs
index 85d515b20..11e4501ec 100644
--- a/src/Core/Grand.Domain/Messages/EmailAccount.cs
+++ b/src/Core/Grand.Domain/Messages/EmailAccount.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents an email account
/// </summary>
- public partial class EmailAccount : BaseEntity
+ public class EmailAccount : BaseEntity
{
/// <summary>
/// Gets or sets an email address
diff --git a/src/Core/Grand.Domain/Messages/LiquidObject.cs b/src/Core/Grand.Domain/Messages/LiquidObject.cs
index 283e89262..346f46d98 100644
--- a/src/Core/Grand.Domain/Messages/LiquidObject.cs
+++ b/src/Core/Grand.Domain/Messages/LiquidObject.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Messages
/// <summary>
/// An object that acumulates all DotLiquid Drops
/// </summary>
- public partial class LiquidObject
+ public class LiquidObject
{
- public LiquidObject()
- {
- AdditionalTokens = new Dictionary<string, string>();
- }
-
public Drop AttributeCombination { get; set; }
public Drop Auctions { get; set; }
@@ -60,6 +55,6 @@ namespace Grand.Domain.Messages
public Drop Email { get; set; }
- public IDictionary<string, string> AdditionalTokens { get; set; }
+ public IDictionary<string, string> AdditionalTokens { get; set; } = new Dictionary<string, string>();
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Messages/MessageTemplate.cs b/src/Core/Grand.Domain/Messages/MessageTemplate.cs
index 99a4fe07d..6ee0e1ce6 100644
--- a/src/Core/Grand.Domain/Messages/MessageTemplate.cs
+++ b/src/Core/Grand.Domain/Messages/MessageTemplate.cs
@@ -6,13 +6,8 @@ namespace Grand.Domain.Messages
/// <summary>
/// Represents a message template
/// </summary>
- public partial class MessageTemplate : BaseEntity, ITranslationEntity, IStoreLinkEntity
+ public class MessageTemplate : BaseEntity, ITranslationEntity, IStoreLinkEntity
{
- public MessageTemplate()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -62,13 +57,12 @@ namespace Grand.Domain.Messages
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
+
-
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs b/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
index 63f611f5d..d662680b6 100644
--- a/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
+++ b/src/Core/Grand.Domain/Messages/NewsLetterSubscription.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Messages
/// <summary>
/// Represents NewsLetterSubscription entity
/// </summary>
- public partial class NewsLetterSubscription : BaseEntity, IHistory
+ public class NewsLetterSubscription : BaseEntity, IHistory
{
private ICollection<string> _categories;
diff --git a/src/Core/Grand.Domain/Messages/NewsletterCategory.cs b/src/Core/Grand.Domain/Messages/NewsletterCategory.cs
index a66aa932f..c34649ecf 100644
--- a/src/Core/Grand.Domain/Messages/NewsletterCategory.cs
+++ b/src/Core/Grand.Domain/Messages/NewsletterCategory.cs
@@ -3,14 +3,8 @@ using Grand.Domain.Stores;
namespace Grand.Domain.Messages
{
- public partial class NewsletterCategory : BaseEntity, ITranslationEntity, IStoreLinkEntity
+ public class NewsletterCategory : BaseEntity, ITranslationEntity, IStoreLinkEntity
{
- public NewsletterCategory()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -30,10 +24,10 @@ namespace Grand.Domain.Messages
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
public int DisplayOrder { get; set; }
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Messages/QueuedEmail.cs b/src/Core/Grand.Domain/Messages/QueuedEmail.cs
index 1520afc1a..8f982f66a 100644
--- a/src/Core/Grand.Domain/Messages/QueuedEmail.cs
+++ b/src/Core/Grand.Domain/Messages/QueuedEmail.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Messages
/// <summary>
/// Represents an email item
/// </summary>
- public partial class QueuedEmail : BaseEntity
+ public class QueuedEmail : BaseEntity
{
- public QueuedEmail()
- {
- AttachedDownloads = new List<string>();
- }
/// <summary>
/// Gets or sets the priority
/// </summary>
@@ -79,7 +75,7 @@ namespace Grand.Domain.Messages
/// <summary>
/// Gets or sets the download identifiers of attached file
/// </summary>
- public IList<string> AttachedDownloads { get; set; }
+ public IList<string> AttachedDownloads { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the date and time in UTC before which this email should not be sent
diff --git a/src/Core/Grand.Domain/News/NewsComment.cs b/src/Core/Grand.Domain/News/NewsComment.cs
index cc6b49220..c90b139c4 100644
--- a/src/Core/Grand.Domain/News/NewsComment.cs
+++ b/src/Core/Grand.Domain/News/NewsComment.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.News
/// <summary>
/// Represents a news comment
/// </summary>
- public partial class NewsComment : SubBaseEntity
+ public class NewsComment : SubBaseEntity
{
/// <summary>
/// Gets or sets the comment title
diff --git a/src/Core/Grand.Domain/News/NewsItem.cs b/src/Core/Grand.Domain/News/NewsItem.cs
index 5f0483e8d..31e1d742b 100644
--- a/src/Core/Grand.Domain/News/NewsItem.cs
+++ b/src/Core/Grand.Domain/News/NewsItem.cs
@@ -8,17 +8,10 @@ namespace Grand.Domain.News
/// <summary>
/// Represents a news item
/// </summary>
- public partial class NewsItem : BaseEntity, ISlugEntity, IStoreLinkEntity, ITranslationEntity, IGroupLinkEntity
+ public class NewsItem : BaseEntity, ISlugEntity, IStoreLinkEntity, ITranslationEntity, IGroupLinkEntity
{
private ICollection<NewsComment> _newsComments;
- public NewsItem()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- CustomerGroups = new List<string>();
- }
-
/// <summary>
/// Gets or sets the news title
/// </summary>
@@ -76,12 +69,13 @@ namespace Grand.Domain.News
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
+
/// <summary>
/// Gets or sets the meta keywords
/// </summary>
@@ -101,7 +95,7 @@ namespace Grand.Domain.News
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the news comments
diff --git a/src/Core/Grand.Domain/Orders/CheckoutAttribute.cs b/src/Core/Grand.Domain/Orders/CheckoutAttribute.cs
index dc784f24e..b0f0471b6 100644
--- a/src/Core/Grand.Domain/Orders/CheckoutAttribute.cs
+++ b/src/Core/Grand.Domain/Orders/CheckoutAttribute.cs
@@ -9,17 +9,10 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a checkout attribute
/// </summary>
- public partial class CheckoutAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity, IGroupLinkEntity
+ public class CheckoutAttribute : BaseEntity, ITranslationEntity, IStoreLinkEntity, IGroupLinkEntity
{
private ICollection<CheckoutAttributeValue> _checkoutAttributeValues;
- public CheckoutAttribute()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- CustomerGroups = new List<string>();
- ConditionAttribute = new List<CustomAttribute>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -64,13 +57,13 @@ namespace Grand.Domain.Orders
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
//validation fields
@@ -102,13 +95,13 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets a condition (depending on other attribute) when this attribute should be enabled (visible).
/// </summary>
- public IList<CustomAttribute> ConditionAttribute { get; set; }
-
+ public IList<CustomAttribute> ConditionAttribute { get; set; } = new List<CustomAttribute>();
+
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets the checkout attribute values
diff --git a/src/Core/Grand.Domain/Orders/CheckoutAttributeValue.cs b/src/Core/Grand.Domain/Orders/CheckoutAttributeValue.cs
index d8747cd99..540c619cf 100644
--- a/src/Core/Grand.Domain/Orders/CheckoutAttributeValue.cs
+++ b/src/Core/Grand.Domain/Orders/CheckoutAttributeValue.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a checkout attribute value
/// </summary>
- public partial class CheckoutAttributeValue : SubBaseEntity, ITranslationEntity
+ public class CheckoutAttributeValue : SubBaseEntity, ITranslationEntity
{
- public CheckoutAttributeValue()
- {
- Locales = new List<TranslationEntity>();
- }
-
/// <summary>
/// Gets or sets the checkout attribute mapping identifier
/// </summary>
@@ -50,7 +45,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Orders/GiftVoucher.cs b/src/Core/Grand.Domain/Orders/GiftVoucher.cs
index 74280b40d..a34e09d42 100644
--- a/src/Core/Grand.Domain/Orders/GiftVoucher.cs
+++ b/src/Core/Grand.Domain/Orders/GiftVoucher.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a gift voucher
/// </summary>
- public partial class GiftVoucher : BaseEntity
+ public class GiftVoucher : BaseEntity
{
private ICollection<GiftVoucherUsageHistory> _giftVoucherUsageHistory;
diff --git a/src/Core/Grand.Domain/Orders/GiftVoucherUsageHistory.cs b/src/Core/Grand.Domain/Orders/GiftVoucherUsageHistory.cs
index b0a7b9a97..eeec11d65 100644
--- a/src/Core/Grand.Domain/Orders/GiftVoucherUsageHistory.cs
+++ b/src/Core/Grand.Domain/Orders/GiftVoucherUsageHistory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a gift voucher usage history entry
/// </summary>
- public partial class GiftVoucherUsageHistory : SubBaseEntity
+ public class GiftVoucherUsageHistory : SubBaseEntity
{
/// <summary>
/// Gets or sets the gift voucher identifier
diff --git a/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs b/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
index 75b0db394..b2715bd25 100644
--- a/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
+++ b/src/Core/Grand.Domain/Orders/LoyaltyPointsHistory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a loyalty point history entry
/// </summary>
- public partial class LoyaltyPointsHistory : BaseEntity
+ public class LoyaltyPointsHistory : BaseEntity
{
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
index dfe5036f1..44f58e681 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturn.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a merchandise return
/// </summary>
- public partial class MerchandiseReturn : BaseEntity
+ public class MerchandiseReturn : BaseEntity
{
- public MerchandiseReturn()
- {
- MerchandiseReturnItems = new List<MerchandiseReturnItem>();
- }
-
public int ReturnNumber { get; set; }
/// <summary>
@@ -42,7 +37,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the merchandise return items
/// </summary>
- public IList<MerchandiseReturnItem> MerchandiseReturnItems { get; set; }
+ public IList<MerchandiseReturnItem> MerchandiseReturnItems { get; set; } = new List<MerchandiseReturnItem>();
/// <summary>
/// Gets or sets the customer identifier
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturnAction.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturnAction.cs
index 03da8dee2..36458aeba 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturnAction.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturnAction.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a merchandise return action
/// </summary>
- public partial class MerchandiseReturnAction : BaseEntity, ITranslationEntity
+ public class MerchandiseReturnAction : BaseEntity, ITranslationEntity
{
- public MerchandiseReturnAction()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -23,6 +19,6 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
index d63c68f02..72de10e4e 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturnNote.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a merchandise return note
/// </summary>
- public partial class MerchandiseReturnNote : BaseEntity
+ public class MerchandiseReturnNote : BaseEntity
{
/// <summary>
/// Gets or sets the merchandise return identifier
diff --git a/src/Core/Grand.Domain/Orders/MerchandiseReturnReason.cs b/src/Core/Grand.Domain/Orders/MerchandiseReturnReason.cs
index bba92dd7a..eb05a4d36 100644
--- a/src/Core/Grand.Domain/Orders/MerchandiseReturnReason.cs
+++ b/src/Core/Grand.Domain/Orders/MerchandiseReturnReason.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a merchandise return reason
/// </summary>
- public partial class MerchandiseReturnReason : BaseEntity, ITranslationEntity
+ public class MerchandiseReturnReason : BaseEntity, ITranslationEntity
{
- public MerchandiseReturnReason()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -24,6 +20,6 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Orders/Order.cs b/src/Core/Grand.Domain/Orders/Order.cs
index 920362a39..b494dd512 100644
--- a/src/Core/Grand.Domain/Orders/Order.cs
+++ b/src/Core/Grand.Domain/Orders/Order.cs
@@ -9,7 +9,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents an order
/// </summary>
- public partial class Order : BaseEntity
+ public class Order : BaseEntity
{
private ICollection<OrderItem> _orderItems;
private ICollection<OrderTax> _orderTaxes;
diff --git a/src/Core/Grand.Domain/Orders/OrderItem.cs b/src/Core/Grand.Domain/Orders/OrderItem.cs
index dc4f6df4c..e1f9078d8 100644
--- a/src/Core/Grand.Domain/Orders/OrderItem.cs
+++ b/src/Core/Grand.Domain/Orders/OrderItem.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents an order item
/// </summary>
- public partial class OrderItem : SubBaseEntity
+ public class OrderItem : SubBaseEntity
{
/// <summary>
/// Gets or sets the order item identifier
diff --git a/src/Core/Grand.Domain/Orders/OrderNote.cs b/src/Core/Grand.Domain/Orders/OrderNote.cs
index 82edb7524..3c2d41b2f 100644
--- a/src/Core/Grand.Domain/Orders/OrderNote.cs
+++ b/src/Core/Grand.Domain/Orders/OrderNote.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents an order note
/// </summary>
- public partial class OrderNote : BaseEntity
+ public class OrderNote : BaseEntity
{
/// <summary>
/// Gets or sets the order identifier
diff --git a/src/Core/Grand.Domain/Orders/OrderTag.cs b/src/Core/Grand.Domain/Orders/OrderTag.cs
index 18c5fc285..2fe7e6d8c 100644
--- a/src/Core/Grand.Domain/Orders/OrderTag.cs
+++ b/src/Core/Grand.Domain/Orders/OrderTag.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Orders
{
- public partial class OrderTag : BaseEntity
+ public class OrderTag : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs b/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
index 67f320ea1..c624d7983 100644
--- a/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
+++ b/src/Core/Grand.Domain/Orders/ShoppingCartItem.cs
@@ -5,13 +5,8 @@ namespace Grand.Domain.Orders
/// <summary>
/// Represents a shopping cart item
/// </summary>
- public partial class ShoppingCartItem : SubBaseEntity
+ public class ShoppingCartItem : SubBaseEntity
{
-
- public ShoppingCartItem()
- {
- Attributes = new List<CustomAttribute>();
- }
/// <summary>
/// Gets or sets the store identifier
/// </summary>
@@ -35,7 +30,7 @@ namespace Grand.Domain.Orders
/// <summary>
/// Gets or sets the custom attributes (see "ProductAttribute" entity for more info)
/// </summary>
- public IList<CustomAttribute> Attributes { get; set; }
+ public IList<CustomAttribute> Attributes { get; set; } = new List<CustomAttribute>();
/// <summary>
/// Gets or sets the price enter by a customer
diff --git a/src/Core/Grand.Domain/PagedList.cs b/src/Core/Grand.Domain/PagedList.cs
index bb67f68b4..fe2c504d4 100644
--- a/src/Core/Grand.Domain/PagedList.cs
+++ b/src/Core/Grand.Domain/PagedList.cs
@@ -5,7 +5,7 @@
/// </summary>
/// <typeparam name="T">T</typeparam>
[Serializable]
- public partial class PagedList<T> : List<T>, IPagedList<T>
+ public class PagedList<T> : List<T>, IPagedList<T>
{
private void Initialize(IEnumerable<T> source, int pageIndex, int pageSize, int? totalCount = null)
diff --git a/src/Core/Grand.Domain/Pages/Page.cs b/src/Core/Grand.Domain/Pages/Page.cs
index fa4c78073..631728dd2 100644
--- a/src/Core/Grand.Domain/Pages/Page.cs
+++ b/src/Core/Grand.Domain/Pages/Page.cs
@@ -8,14 +8,8 @@ namespace Grand.Domain.Pages
/// <summary>
/// Represents a page
/// </summary>
- public partial class Page : BaseEntity, ITranslationEntity, ISlugEntity, IStoreLinkEntity, IGroupLinkEntity
+ public class Page : BaseEntity, ITranslationEntity, ISlugEntity, IStoreLinkEntity, IGroupLinkEntity
{
- public Page()
- {
- Locales = new List<TranslationEntity>();
- Stores = new List<string>();
- CustomerGroups = new List<string>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -104,18 +98,18 @@ namespace Grand.Domain.Pages
/// Gets or sets a value indicating whether the entity is limited/restricted to certain stores
/// </summary>
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to ACL
/// </summary>
public bool LimitedToGroups { get; set; }
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
/// <summary>
/// Gets or sets a value indicating whether the entity is published
diff --git a/src/Core/Grand.Domain/Pages/PageLayout.cs b/src/Core/Grand.Domain/Pages/PageLayout.cs
index cb382a27a..32a5cee57 100644
--- a/src/Core/Grand.Domain/Pages/PageLayout.cs
+++ b/src/Core/Grand.Domain/Pages/PageLayout.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Pages
/// <summary>
/// Represents a page layout
/// </summary>
- public partial class PageLayout : BaseEntity
+ public class PageLayout : BaseEntity
{
/// <summary>
/// Gets or sets the layout name
diff --git a/src/Core/Grand.Domain/ParentEntity.cs b/src/Core/Grand.Domain/ParentEntity.cs
index 8b0661d96..3f8e2af2d 100644
--- a/src/Core/Grand.Domain/ParentEntity.cs
+++ b/src/Core/Grand.Domain/ParentEntity.cs
@@ -13,13 +13,7 @@ namespace Grand.Domain
public string Id
{
get { return _id; }
- set
- {
- if (string.IsNullOrEmpty(value))
- _id = UniqueIdentifier.New;
- else
- _id = value;
- }
+ set { _id = string.IsNullOrEmpty(value) ? UniqueIdentifier.New : value; }
}
private string _id;
diff --git a/src/Core/Grand.Domain/Payments/PaymentRestrictedSettings.cs b/src/Core/Grand.Domain/Payments/PaymentRestrictedSettings.cs
index a49e4a43e..70de4216b 100644
--- a/src/Core/Grand.Domain/Payments/PaymentRestrictedSettings.cs
+++ b/src/Core/Grand.Domain/Payments/PaymentRestrictedSettings.cs
@@ -4,10 +4,6 @@ namespace Grand.Domain.Payments
{
public class PaymentRestrictedSettings : ISettings
{
- public PaymentRestrictedSettings()
- {
- Ids = new List<string>();
- }
- public IList<string> Ids { get; set; }
+ public IList<string> Ids { get; set; } = new List<string>();
}
}
diff --git a/src/Core/Grand.Domain/Payments/PaymentSettings.cs b/src/Core/Grand.Domain/Payments/PaymentSettings.cs
index d3c99a5c9..7f4203337 100644
--- a/src/Core/Grand.Domain/Payments/PaymentSettings.cs
+++ b/src/Core/Grand.Domain/Payments/PaymentSettings.cs
@@ -4,15 +4,10 @@ namespace Grand.Domain.Payments
{
public class PaymentSettings : ISettings
{
- public PaymentSettings()
- {
- ActivePaymentProviderSystemNames = new List<string>();
- }
-
/// <summary>
/// Gets or sets a system names of active payment methods
/// </summary>
- public List<string> ActivePaymentProviderSystemNames { get; set; }
+ public List<string> ActivePaymentProviderSystemNames { get; set; } = new();
/// <summary>
/// Gets or sets a value indicating whether customers are allowed to repost (complete) payments for redirection payment methods
diff --git a/src/Core/Grand.Domain/Payments/PaymentTransaction.cs b/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
index 64b4b608a..b5b03befa 100644
--- a/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
+++ b/src/Core/Grand.Domain/Payments/PaymentTransaction.cs
@@ -2,12 +2,6 @@
{
public class PaymentTransaction : BaseEntity
{
- public PaymentTransaction()
- {
- CustomValues = new Dictionary<string, object>();
- Errors = new List<string>();
- }
-
/// <summary>
/// Gets or sets payment method system name
/// </summary>
@@ -93,12 +87,12 @@
/// <summary>
/// Gets or sets custom values
/// </summary>
- public Dictionary<string, object> CustomValues { get; set; }
+ public Dictionary<string, object> CustomValues { get; set; } = new();
/// <summary>
/// gets or sets errors
/// </summary>
- public IList<string> Errors { get; set; }
+ public IList<string> Errors { get; set; } = new List<string>();
/// <summary>
/// Gets or sets
diff --git a/src/Core/Grand.Domain/Permissions/DefaultPermission.cs b/src/Core/Grand.Domain/Permissions/DefaultPermission.cs
index 8bc5a3cc3..15c06c0dc 100644
--- a/src/Core/Grand.Domain/Permissions/DefaultPermission.cs
+++ b/src/Core/Grand.Domain/Permissions/DefaultPermission.cs
@@ -5,11 +5,6 @@
/// </summary>
public class DefaultPermission
{
- public DefaultPermission()
- {
- Permissions = new List<Permission>();
- }
-
/// <summary>
/// Gets or sets the customer group system name
/// </summary>
@@ -18,6 +13,6 @@
/// <summary>
/// Gets or sets the permissions
/// </summary>
- public IEnumerable<Permission> Permissions { get; set; }
+ public IEnumerable<Permission> Permissions { get; set; } = new List<Permission>();
}
}
diff --git a/src/Core/Grand.Domain/Permissions/IGroupLinkEntity.cs b/src/Core/Grand.Domain/Permissions/IGroupLinkEntity.cs
index 9e3ab0529..cb62d8b0b 100644
--- a/src/Core/Grand.Domain/Permissions/IGroupLinkEntity.cs
+++ b/src/Core/Grand.Domain/Permissions/IGroupLinkEntity.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Permissions
/// <summary>
/// Represents an entity which entity group linking
/// </summary>
- public partial interface IGroupLinkEntity
+ public interface IGroupLinkEntity
{
/// <summary>
/// Gets or sets a value indicating whether the entity is subject to group
diff --git a/src/Core/Grand.Domain/Permissions/Permission.cs b/src/Core/Grand.Domain/Permissions/Permission.cs
index 77653413b..7b45dbf75 100644
--- a/src/Core/Grand.Domain/Permissions/Permission.cs
+++ b/src/Core/Grand.Domain/Permissions/Permission.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a permission
/// </summary>
- public partial class Permission : BaseEntity
+ public class Permission : BaseEntity
{
private ICollection<string> _customerGroups;
private ICollection<string> _actions;
diff --git a/src/Core/Grand.Domain/Permissions/PermissionAction.cs b/src/Core/Grand.Domain/Permissions/PermissionAction.cs
index 70d9bd0c5..830cc269c 100644
--- a/src/Core/Grand.Domain/Permissions/PermissionAction.cs
+++ b/src/Core/Grand.Domain/Permissions/PermissionAction.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents permission for action denied
/// </summary>
- public partial class PermissionAction : BaseEntity
+ public class PermissionAction : BaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Seo/EntityUrl.cs b/src/Core/Grand.Domain/Seo/EntityUrl.cs
index 5f5d2144d..9ed2a5e40 100644
--- a/src/Core/Grand.Domain/Seo/EntityUrl.cs
+++ b/src/Core/Grand.Domain/Seo/EntityUrl.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Seo
/// <summary>
/// Represents an URL
/// </summary>
- public partial class EntityUrl : BaseEntity
+ public class EntityUrl : BaseEntity
{
/// <summary>
/// Gets or sets the entity identifier
diff --git a/src/Core/Grand.Domain/Seo/SeoSettings.cs b/src/Core/Grand.Domain/Seo/SeoSettings.cs
index ef74a532e..2492d9540 100644
--- a/src/Core/Grand.Domain/Seo/SeoSettings.cs
+++ b/src/Core/Grand.Domain/Seo/SeoSettings.cs
@@ -7,11 +7,6 @@ namespace Grand.Domain.Seo
/// </summary>
public class SeoSettings : ISettings
{
- public SeoSettings()
- {
- ReservedEntityUrlSlugs = new List<string>();
- }
-
/// <summary>
/// Page title separator
/// </summary>
@@ -77,7 +72,7 @@ namespace Grand.Domain.Seo
/// <summary>
/// Slugs (sename) reserved for some other needs
/// </summary>
- public List<string> ReservedEntityUrlSlugs { get; set; }
+ public List<string> ReservedEntityUrlSlugs { get; set; } = new();
/// <summary>
/// Custom tags in the head section
diff --git a/src/Core/Grand.Domain/Shipping/DeliveryDate.cs b/src/Core/Grand.Domain/Shipping/DeliveryDate.cs
index 596f891fb..0c27c7d6d 100644
--- a/src/Core/Grand.Domain/Shipping/DeliveryDate.cs
+++ b/src/Core/Grand.Domain/Shipping/DeliveryDate.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a delivery date
/// </summary>
- public partial class DeliveryDate : BaseEntity, ITranslationEntity
+ public class DeliveryDate : BaseEntity, ITranslationEntity
{
- public DeliveryDate()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -29,6 +25,6 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Domain/Shipping/PickupPoints.cs b/src/Core/Grand.Domain/Shipping/PickupPoints.cs
index 71556fd1f..a12e0f730 100644
--- a/src/Core/Grand.Domain/Shipping/PickupPoints.cs
+++ b/src/Core/Grand.Domain/Shipping/PickupPoints.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipment
/// </summary>
- public partial class PickupPoint : BaseEntity
+ public class PickupPoint : BaseEntity
{
/// <summary>
/// Gets or sets the point name
diff --git a/src/Core/Grand.Domain/Shipping/Shipment.cs b/src/Core/Grand.Domain/Shipping/Shipment.cs
index 3abfd357c..a78a6dd31 100644
--- a/src/Core/Grand.Domain/Shipping/Shipment.cs
+++ b/src/Core/Grand.Domain/Shipping/Shipment.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipment
/// </summary>
- public partial class Shipment : BaseEntity
+ public class Shipment : BaseEntity
{
private ICollection<ShipmentItem> _shipmentItems;
diff --git a/src/Core/Grand.Domain/Shipping/ShipmentItem.cs b/src/Core/Grand.Domain/Shipping/ShipmentItem.cs
index 4af0f7035..ceb1cdd93 100644
--- a/src/Core/Grand.Domain/Shipping/ShipmentItem.cs
+++ b/src/Core/Grand.Domain/Shipping/ShipmentItem.cs
@@ -5,7 +5,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipment item
/// </summary>
- public partial class ShipmentItem : SubBaseEntity
+ public class ShipmentItem : SubBaseEntity
{
/// <summary>
/// Gets or sets the order item identifier
diff --git a/src/Core/Grand.Domain/Shipping/ShipmentNote.cs b/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
index 7bf29fd8d..73f997a4e 100644
--- a/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
+++ b/src/Core/Grand.Domain/Shipping/ShipmentNote.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents an shipment note
/// </summary>
- public partial class ShipmentNote : BaseEntity
+ public class ShipmentNote : BaseEntity
{
/// <summary>
/// Gets or sets the shipment identifier
diff --git a/src/Core/Grand.Domain/Shipping/ShippingMethod.cs b/src/Core/Grand.Domain/Shipping/ShippingMethod.cs
index 4fa149e31..7dba04c2d 100644
--- a/src/Core/Grand.Domain/Shipping/ShippingMethod.cs
+++ b/src/Core/Grand.Domain/Shipping/ShippingMethod.cs
@@ -6,15 +6,11 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipping method (used for offline Shipping rate methods)
/// </summary>
- public partial class ShippingMethod : BaseEntity, ITranslationEntity
+ public class ShippingMethod : BaseEntity, ITranslationEntity
{
private ICollection<Country> _restrictedCountries;
private ICollection<string> _restrictedGroups;
- public ShippingMethod()
- {
- Locales = new List<TranslationEntity>();
- }
/// <summary>
/// Gets or sets the name
/// </summary>
@@ -33,7 +29,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
/// <summary>
/// Gets or sets the restricted countries
diff --git a/src/Core/Grand.Domain/Shipping/ShippingOption.cs b/src/Core/Grand.Domain/Shipping/ShippingOption.cs
index 80dbacb75..aa077b94a 100644
--- a/src/Core/Grand.Domain/Shipping/ShippingOption.cs
+++ b/src/Core/Grand.Domain/Shipping/ShippingOption.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipping option
/// </summary>
- public partial class ShippingOption
+ public class ShippingOption
{
/// <summary>
/// Gets or sets the system name of shipping rate provider
diff --git a/src/Core/Grand.Domain/Shipping/ShippingProviderSettings.cs b/src/Core/Grand.Domain/Shipping/ShippingProviderSettings.cs
index c55cd5e22..16831c045 100644
--- a/src/Core/Grand.Domain/Shipping/ShippingProviderSettings.cs
+++ b/src/Core/Grand.Domain/Shipping/ShippingProviderSettings.cs
@@ -4,14 +4,9 @@ namespace Grand.Domain.Shipping
{
public class ShippingProviderSettings : ISettings
{
- public ShippingProviderSettings()
- {
- ActiveSystemNames = new List<string>();
- }
-
/// <summary>
/// Gets or sets system names of active Shipping rate methods
/// </summary>
- public List<string> ActiveSystemNames { get; set; }
+ public List<string> ActiveSystemNames { get; set; } = new();
}
}
diff --git a/src/Core/Grand.Domain/Shipping/Warehouse.cs b/src/Core/Grand.Domain/Shipping/Warehouse.cs
index 2568a09c3..f5c33a63e 100644
--- a/src/Core/Grand.Domain/Shipping/Warehouse.cs
+++ b/src/Core/Grand.Domain/Shipping/Warehouse.cs
@@ -5,12 +5,8 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Represents a shipment
/// </summary>
- public partial class Warehouse : BaseEntity
+ public class Warehouse : BaseEntity
{
- public Warehouse()
- {
- Address = new Address();
- }
/// <summary>
/// Gets or sets the warehouse code
/// </summary>
@@ -38,7 +34,7 @@ namespace Grand.Domain.Shipping
/// <summary>
/// Gets or sets the address identifier of the warehouse
/// </summary>
- public Address Address { get; set; }
+ public Address Address { get; set; } = new();
/// <summary>
/// Gets or sets the display order
diff --git a/src/Core/Grand.Domain/Stores/IStoreLinkEntity.cs b/src/Core/Grand.Domain/Stores/IStoreLinkEntity.cs
index 3fe882833..cae3bb25b 100644
--- a/src/Core/Grand.Domain/Stores/IStoreLinkEntity.cs
+++ b/src/Core/Grand.Domain/Stores/IStoreLinkEntity.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Stores
/// <summary>
/// Represents an entity which user store linking
/// </summary>
- public partial interface IStoreLinkEntity
+ public interface IStoreLinkEntity
{
/// <summary>
/// Gets or sets a value indicating whether the entity is limited to some stores
diff --git a/src/Core/Grand.Domain/Stores/Store.cs b/src/Core/Grand.Domain/Stores/Store.cs
index f08037f0e..e4520d6e4 100644
--- a/src/Core/Grand.Domain/Stores/Store.cs
+++ b/src/Core/Grand.Domain/Stores/Store.cs
@@ -5,15 +5,8 @@ namespace Grand.Domain.Stores
/// <summary>
/// Represents a store
/// </summary>
- public partial class Store : BaseEntity, ITranslationEntity
+ public class Store : BaseEntity, ITranslationEntity
{
- public Store()
- {
- Locales = new List<TranslationEntity>();
- Domains = new List<DomainHost>();
- BankAccount = new BankAccount();
- }
-
/// <summary>
/// Gets or sets the store name
/// </summary>
@@ -42,7 +35,7 @@ namespace Grand.Domain.Stores
/// <summary>
/// Gets or sets the list of domains
/// </summary>
- public IList<DomainHost> Domains { get; set; }
+ public IList<DomainHost> Domains { get; set; } = new List<DomainHost>();
/// <summary>
/// Gets or sets the identifier of the default language for this store; "" is set when we use the default language display order
@@ -109,12 +102,11 @@ namespace Grand.Domain.Stores
/// </summary>
public string DefaultAdminTheme { get; set; }
- public BankAccount BankAccount { get; set; }
+ public BankAccount BankAccount { get; set; } = new();
/// <summary>
/// Gets or sets the collection of locales
/// </summary>
- public IList<TranslationEntity> Locales { get; set; }
-
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
}
}
diff --git a/src/Core/Grand.Domain/Tasks/ScheduleTask.cs b/src/Core/Grand.Domain/Tasks/ScheduleTask.cs
index 89d7e10df..0bd25d5a9 100644
--- a/src/Core/Grand.Domain/Tasks/ScheduleTask.cs
+++ b/src/Core/Grand.Domain/Tasks/ScheduleTask.cs
@@ -1,6 +1,6 @@
namespace Grand.Domain.Tasks
{
- public partial class ScheduleTask : BaseEntity
+ public class ScheduleTask : BaseEntity
{
public string ScheduleTaskName { get; set; }
public string Type { get; set; }
diff --git a/src/Core/Grand.Domain/Tax/TaxCategory.cs b/src/Core/Grand.Domain/Tax/TaxCategory.cs
index af83d1ecb..64e0e1f91 100644
--- a/src/Core/Grand.Domain/Tax/TaxCategory.cs
+++ b/src/Core/Grand.Domain/Tax/TaxCategory.cs
@@ -3,7 +3,7 @@ namespace Grand.Domain.Tax
/// <summary>
/// Represents a tax category
/// </summary>
- public partial class TaxCategory : BaseEntity
+ public class TaxCategory : BaseEntity
{
/// <summary>
/// Gets or sets the name
diff --git a/src/Core/Grand.Domain/Vendors/Vendor.cs b/src/Core/Grand.Domain/Vendors/Vendor.cs
index 55ffbb98d..144d366f5 100644
--- a/src/Core/Grand.Domain/Vendors/Vendor.cs
+++ b/src/Core/Grand.Domain/Vendors/Vendor.cs
@@ -7,7 +7,7 @@ namespace Grand.Domain.Vendors
/// <summary>
/// Represents a vendor
/// </summary>
- public partial class Vendor : BaseEntity, ITranslationEntity, ISlugEntity
+ public class Vendor : BaseEntity, ITranslationEntity, ISlugEntity
{
private ICollection<VendorNote> _vendorNotes;
private ICollection<string> _appliedDiscounts;
diff --git a/src/Core/Grand.Domain/Vendors/VendorNote.cs b/src/Core/Grand.Domain/Vendors/VendorNote.cs
index cb55e3258..9444838fb 100644
--- a/src/Core/Grand.Domain/Vendors/VendorNote.cs
+++ b/src/Core/Grand.Domain/Vendors/VendorNote.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a vendor note
/// </summary>
- public partial class VendorNote : SubBaseEntity
+ public class VendorNote : SubBaseEntity
{
/// <summary>
diff --git a/src/Core/Grand.Domain/Vendors/VendorReview.cs b/src/Core/Grand.Domain/Vendors/VendorReview.cs
index 4878a5e9f..042f00c6a 100644
--- a/src/Core/Grand.Domain/Vendors/VendorReview.cs
+++ b/src/Core/Grand.Domain/Vendors/VendorReview.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a vendor review
/// </summary>
- public partial class VendorReview : BaseEntity
+ public class VendorReview : BaseEntity
{
private ICollection<VendorReviewHelpfulness> _vendorReviewHelpfulnessEntries;
diff --git a/src/Core/Grand.Domain/Vendors/VendorReviewHelpfulness.cs b/src/Core/Grand.Domain/Vendors/VendorReviewHelpfulness.cs
index 5ea5207f8..4bc687405 100644
--- a/src/Core/Grand.Domain/Vendors/VendorReviewHelpfulness.cs
+++ b/src/Core/Grand.Domain/Vendors/VendorReviewHelpfulness.cs
@@ -3,7 +3,7 @@
/// <summary>
/// Represents a vendor review helpfulness
/// </summary>
- public partial class VendorReviewHelpfulness : SubBaseEntity
+ public class VendorReviewHelpfulness : SubBaseEntity
{
/// <summary>
/// Gets or sets the vendor review identifier
diff --git a/src/Core/Grand.Infrastructure/Roslyn/ResultCompiler.cs b/src/Core/Grand.Infrastructure/Roslyn/ResultCompiler.cs
index 679509619..6a7c03638 100644
--- a/src/Core/Grand.Infrastructure/Roslyn/ResultCompiler.cs
+++ b/src/Core/Grand.Infrastructure/Roslyn/ResultCompiler.cs
@@ -4,15 +4,10 @@ namespace Grand.Infrastructure.Roslyn
{
public class ResultCompiler
{
- public ResultCompiler()
- {
- ErrorInfo = new List<string>();
- }
-
public Assembly ReferencedAssembly { get; internal set; }
public string OriginalFile { get; internal set; }
public virtual string DLLAssemblyFile { get; internal set; }
public bool IsCompiled { get; internal set; }
- public IList<string> ErrorInfo { get; internal set; }
+ public IList<string> ErrorInfo { get; internal set; } = new List<string>();
}
}
diff --git a/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs b/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs
index fa6cb8db1..73ce10547 100644
--- a/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs
+++ b/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs
@@ -7,11 +7,6 @@ namespace DiscountRules.Standard.Models;
public class RequirementCustomerGroupsModel
{
- public RequirementCustomerGroupsModel()
- {
- AvailableCustomerGroups = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup")]
public string CustomerGroupId { get; set; }
@@ -19,7 +14,7 @@ public class RequirementCustomerGroupsModel
public string RequirementId { get; set; }
- public IList<SelectListItem> AvailableCustomerGroups { get; set; }
+ public IList<SelectListItem> AvailableCustomerGroups { get; set; } = new List<SelectListItem>();
}
public class RequirementSpentAmountModel
@@ -45,13 +40,6 @@ public class RequirementAllProductsModel
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
[UIHint("Category")]
@@ -68,9 +56,9 @@ public class RequirementAllProductsModel
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
//vendor
public bool IsLoggedInAsVendor { get; set; }
@@ -98,13 +86,6 @@ public class RequirementOneProductModel
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
[UIHint("Category")]
@@ -120,9 +101,9 @@ public class RequirementOneProductModel
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
//vendor
public bool IsLoggedInAsVendor { get; set; }
diff --git a/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs b/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs
index 64560a2a3..f5d78ccc7 100644
--- a/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs
+++ b/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs
@@ -6,12 +6,6 @@ namespace Payments.BrainTree.Models
{
public class PaymentInfoModel : BaseModel
{
- public PaymentInfoModel()
- {
- ExpireMonths = new List<SelectListItem>();
- ExpireYears = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Payment.SelectCreditCard")]
public string CreditCardType { get; set; }
@@ -28,9 +22,9 @@ namespace Payments.BrainTree.Models
[GrandResourceDisplayName("Payment.ExpirationDate")]
public string ExpireYear { get; set; }
- public IList<SelectListItem> ExpireMonths { get; set; }
+ public IList<SelectListItem> ExpireMonths { get; set; } = new List<SelectListItem>();
- public IList<SelectListItem> ExpireYears { get; set; }
+ public IList<SelectListItem> ExpireYears { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Payment.CardCode")]
public string CardCode { get; set; }
diff --git a/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs b/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs
index 261ef1385..3ed6e8745 100644
--- a/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs
+++ b/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs
@@ -6,11 +6,6 @@ namespace Payments.CashOnDelivery.Models
{
public class ConfigurationModel : BaseModel, ILocalizedModel<ConfigurationModel.ConfigurationLocalizedModel>
{
- public ConfigurationModel()
- {
- Locales = new List<ConfigurationLocalizedModel>();
- }
-
public string ActiveStore { get; set; }
[GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DescriptionText")]
@@ -31,7 +26,7 @@ namespace Payments.CashOnDelivery.Models
[GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.SkipPaymentInfo")]
public bool SkipPaymentInfo { get; set; }
- public IList<ConfigurationLocalizedModel> Locales { get; set; }
+ public IList<ConfigurationLocalizedModel> Locales { get; set; } = new List<ConfigurationLocalizedModel>();
#region Nested class
diff --git a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs
index 377e6d3e5..0e2dd4ce5 100644
--- a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs
+++ b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs
@@ -6,15 +6,6 @@ namespace Shipping.ByWeight.Models
{
public class ShippingByWeightModel : BaseEntityModel
{
- public ShippingByWeightModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- AvailableShippingMethods = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]
public string StoreId { get; set; }
[GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]
@@ -68,10 +59,10 @@ namespace Shipping.ByWeight.Models
public string BaseWeightIn { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
- public IList<SelectListItem> AvailableShippingMethods { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableShippingMethods { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs b/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs
index 69946f229..5de59783b 100644
--- a/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs
+++ b/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs
@@ -6,12 +6,6 @@ namespace Shipping.ShippingPoint.Models
{
public class ShippingPointModel : BaseEntityModel
{
- public ShippingPointModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Shipping.ShippingPoint.Fields.ShippingPointName")]
public string ShippingPointName { get; set; }
@@ -24,7 +18,8 @@ namespace Shipping.ShippingPoint.Models
[GrandResourceDisplayName("Shipping.ShippingPoint.Fields.PickupFee")]
public double PickupFee { get; set; }
- public List<SelectListItem> AvailableStores { get; set; }
+ public List<SelectListItem> AvailableStores { get; set; } = new();
+
[GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Store")]
public string StoreId { get; set; }
@@ -42,7 +37,7 @@ namespace Shipping.ShippingPoint.Models
[GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Country")]
public string CountryId { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
}
diff --git a/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs b/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs
index 7b8db02c7..a99f5e33c 100644
--- a/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs
+++ b/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs
@@ -6,15 +6,6 @@ namespace Tax.CountryStateZip.Models
{
public class TaxRateListModel : BaseModel
{
- public TaxRateListModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- AvailableTaxCategories = new List<SelectListItem>();
- TaxRates = new List<TaxRateModel>();
- }
-
[GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]
public string AddStoreId { get; set; }
[GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]
@@ -28,12 +19,11 @@ namespace Tax.CountryStateZip.Models
[GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Percentage")]
public double AddPercentage { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
- public IList<SelectListItem> AvailableTaxCategories { get; set; }
-
- public IList<TaxRateModel> TaxRates { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();
+ public IList<TaxRateModel> TaxRates { get; set; } = new List<TaxRateModel>();
}
}
\ No newline at end of file
diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml
index ed5df48e3..02d186294 100644
--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml
+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml
@@ -28,7 +28,7 @@
<div>
<b-tabs content-class="mt-3">
<b-tab title="@Loc["Account.Auctions.Tab.Ongoing"]" active>
- @if (Model.ProductBidList.Where(x => !x.Ended).Any())
+ @if (Model.ProductBidList.Any(x => !x.Ended))
{
<div id="auction-table-ongoing" class="table-responsive">
<table class="table">
@@ -89,7 +89,7 @@
}
</b-tab>
<b-tab title="@Loc["Account.Auctions.Tab.Ended"]">
- @if (Model.ProductBidList.Where(x => x.Ended).Any())
+ @if (Model.ProductBidList.Any(x => x.Ended))
{
<div id="auction-table-ended" class="table-responsive">
diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml
index b45368c32..b3522f517 100644
--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml
+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml
@@ -10,26 +10,12 @@
var quantity = 1;
if (!Model.ShowQty)
{
- if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
- }
- else
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, quantity });
- }
+ addtocartlink = Model.ProductPrice.ForceRedirectionAfterAddingToCart ? Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }) : Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, quantity });
addtowishlistlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist, quantity });
}
else
{
- if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
- }
- else
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId });
- }
+ addtocartlink = Model.ProductPrice.ForceRedirectionAfterAddingToCart ? Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }) : Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId });
addtowishlistlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist });
}
var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id });
diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml
index cc15461e7..cb7adcd0a 100644
--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml
+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml
@@ -84,7 +84,7 @@
}
</ul>
}
- @if (Model.Category.SubCategories.Count() > 0)
+ @if (Model.Category.SubCategories.Any())
{
<span class="go-back"></span>
<span class="go-forward"></span>
diff --git a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs b/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs
index d86209e2f..43ee2bc77 100644
--- a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs
+++ b/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs
@@ -6,11 +6,6 @@ namespace Widgets.Slider.Domain
{
public class PictureSlider : BaseEntity, ITranslationEntity, IStoreLinkEntity
{
- public PictureSlider()
- {
- Stores = new List<string>();
- Locales = new List<TranslationEntity>();
- }
public string PictureId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
@@ -21,8 +16,8 @@ namespace Widgets.Slider.Domain
public string ObjectEntry { get; set; }
public SliderType SliderTypeId { get; set; }
public bool LimitedToStores { get; set; }
- public IList<string> Stores { get; set; }
- public IList<TranslationEntity> Locales { get; set; }
+ public IList<string> Stores { get; set; } = new List<string>();
+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();
public DateTime? StartDateUtc { get; set; }
public DateTime? EndDateUtc { get; set; }
}
diff --git a/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs b/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs
index f1ad14a69..820db2d13 100644
--- a/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs
+++ b/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs
@@ -4,11 +4,7 @@ namespace Widgets.Slider.Models
{
public class PublicInfoModel : BaseModel
{
- public PublicInfoModel()
- {
- Slide = new List<Slider>();
- }
- public IList<Slider> Slide { get; set; }
+ public IList<Slider> Slide { get; set; } = new List<Slider>();
public class Slider
{
diff --git a/src/Plugins/Widgets.Slider/Models/SlideModel.cs b/src/Plugins/Widgets.Slider/Models/SlideModel.cs
index b84abe6ab..57e1ad56a 100644
--- a/src/Plugins/Widgets.Slider/Models/SlideModel.cs
+++ b/src/Plugins/Widgets.Slider/Models/SlideModel.cs
@@ -8,10 +8,6 @@ namespace Widgets.Slider.Models
{
public class SlideModel : BaseEntityModel, ILocalizedModel<SlideLocalizedModel>, IStoreLinkModel
{
- public SlideModel()
- {
- Locales = new List<SlideLocalizedModel>();
- }
[GrandResourceDisplayName("Widgets.Slider.Name")]
public string Name { get; set; }
@@ -37,7 +33,7 @@ namespace Widgets.Slider.Models
[UIHint("Picture")]
public string PictureId { get; set; }
- public IList<SlideLocalizedModel> Locales { get; set; }
+ public IList<SlideLocalizedModel> Locales { get; set; } = new List<SlideLocalizedModel>();
//Store acl
[GrandResourceDisplayName("Widgets.Slider.LimitedToStores")]
diff --git a/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs b/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs
index ec25066c8..a54e6a568 100644
--- a/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs
+++ b/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs
@@ -4,14 +4,9 @@ namespace Widgets.Slider
{
public class SliderWidgetSettings : ISettings
{
- public SliderWidgetSettings()
- {
- LimitedToStores = new List<string>();
- LimitedToGroups = new List<string>();
- }
public int DisplayOrder { get; set; }
- public IList<string> LimitedToStores { get; set; }
+ public IList<string> LimitedToStores { get; set; } = new List<string>();
- public IList<string> LimitedToGroups { get; set; }
+ public IList<string> LimitedToGroups { get; set; } = new List<string>();
}
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountProviderTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountProviderTest.cs
index 4c8dc8934..913624f8c 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountProviderTest.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountProviderTest.cs
@@ -5,13 +5,8 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
{
public class DiscountProviderTest : IDiscountProvider
{
- private IList<string> limitedToStores;
- private IList<string> limitedToGroups;
- public DiscountProviderTest()
- {
- limitedToStores = new List<string>();
- limitedToGroups = new List<string>();
- }
+ private IList<string> limitedToStores = new List<string>();
+ private IList<string> limitedToGroups = new List<string>();
public string ConfigurationUrl => throw new NotImplementedException();
diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs
index f9e6107fa..c8f8df0e9 100644
--- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs
+++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerHistoryPasswordServiceTests.cs
@@ -29,7 +29,7 @@ namespace Grand.Business.Customers.Tests.Services
//Act
await _customerHistoryPasswordService.InsertCustomerPassword(new Customer());
//Asser
- Assert.IsTrue(_repository.Table.Count() > 0);
+ Assert.IsTrue(_repository.Table.Any());
}
[TestMethod()]
diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs
index 6c9ff7d98..3979e8537 100644
--- a/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs
+++ b/src/Tests/Grand.Business.Customers.Tests/Services/CustomerServiceTests.cs
@@ -143,7 +143,7 @@ namespace Grand.Business.Customers.Tests.Services
await _customerService.InsertGuestCustomer(new Domain.Stores.Store { Id = "1" });
//Assert
Assert.IsTrue(_repository.Table.Any());
- Assert.IsTrue(_repository.Table.Where(x => x.StoreId == "1").Any());
+ Assert.IsTrue(_repository.Table.Any(x => x.StoreId == "1"));
}
[TestMethod()]
diff --git a/src/Tests/Grand.Data.Tests/SampleCollection.cs b/src/Tests/Grand.Data.Tests/SampleCollection.cs
index bc8cb59d0..e2bba1d24 100644
--- a/src/Tests/Grand.Data.Tests/SampleCollection.cs
+++ b/src/Tests/Grand.Data.Tests/SampleCollection.cs
@@ -4,17 +4,12 @@ namespace Grand.Data.Tests
{
public class SampleCollection : BaseEntity
{
- public SampleCollection()
- {
- Phones = new List<string>();
- Category = new List<SampleCategory>();
- }
public string Name { get; set; }
public int Count { get; set; }
- public IList<string> Phones { get; set; }
+ public IList<string> Phones { get; set; } = new List<string>();
- public IList<SampleCategory> Category { get; set; }
+ public IList<SampleCategory> Category { get; set; } = new List<SampleCategory>();
public class SampleCategory
{
diff --git a/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs b/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs
index b2c5abdd0..b3f26a029 100644
--- a/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs
+++ b/src/Tests/Grand.Domain.Tests/Orders/GiftVoucherExtensionsTests.cs
@@ -7,17 +7,12 @@ namespace Grand.Domain.Tests.Orders
[TestClass()]
public class GiftVoucherExtensionsTests
{
- private GiftVoucher giftVoucher;
-
- public GiftVoucherExtensionsTests()
- {
- giftVoucher = new GiftVoucher {
- Amount = 10,
- Code = "123456",
- CurrencyCode = "USD",
- IsGiftVoucherActivated = true
- };
- }
+ private GiftVoucher giftVoucher = new() {
+ Amount = 10,
+ Code = "123456",
+ CurrencyCode = "USD",
+ IsGiftVoucherActivated = true
+ };
[TestMethod()]
public void AddGiftVoucherAttributeTest()
diff --git a/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs b/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs
index 700ea8e7f..f348d67d0 100644
--- a/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/Migrations/MigrationManagerTests.cs
@@ -6,12 +6,7 @@ namespace Grand.Infrastructure.Tests.Migrations
[TestClass()]
public class MigrationManagerTests
{
- MigrationManager migrationManager;
-
- public MigrationManagerTests()
- {
- migrationManager = new MigrationManager();
- }
+ MigrationManager migrationManager = new();
[TestMethod()]
public void GetAllMigrationsTest()
diff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs
index 1b78bed0a..ba4b933ca 100644
--- a/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs
@@ -4,16 +4,13 @@ namespace Grand.Infrastructure.Tests.Plugins
{
public class SampleBasePlugin : BasePlugin, IPlugin
{
- private PluginInfo _pluginInfo;
- public SampleBasePlugin()
- {
- _pluginInfo = new PluginInfo {
- Author = "grandnode",
- DisplayOrder = 0,
- FriendlyName = "sample plugin",
- SystemName = "SamplePlugin"
- };
- }
+ private PluginInfo _pluginInfo = new() {
+ Author = "grandnode",
+ DisplayOrder = 0,
+ FriendlyName = "sample plugin",
+ SystemName = "SamplePlugin"
+ };
+
public override PluginInfo PluginInfo {
get {
return _pluginInfo;
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/BoolTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/BoolTypeConverterTests.cs
index ff9e07628..1e525b220 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/BoolTypeConverterTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/BoolTypeConverterTests.cs
@@ -6,11 +6,7 @@ namespace Grand.Infrastructure.Tests.TypeConverters.Converter
[TestClass()]
public class BoolTypeConverterTests
{
- BoolTypeConverter boolTypeConverter;
- public BoolTypeConverterTests()
- {
- boolTypeConverter = new BoolTypeConverter();
- }
+ BoolTypeConverter boolTypeConverter = new();
[TestMethod()]
public void ConvertFromTest_Null_False()
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CaptchaInterfaceConverter.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CaptchaInterfaceConverter.cs
index db1ac9024..7f250fed6 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CaptchaInterfaceConverter.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CaptchaInterfaceConverter.cs
@@ -71,11 +71,6 @@ public class CaptchaInterfaceConverter
public class SampleClass
{
- public SampleClass()
- {
- CaptchaValidModel = new CaptchaModel();
- }
-
- public ICaptchaValidModel CaptchaValidModel { get; set; }
+ public ICaptchaValidModel CaptchaValidModel { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CustomAttributeListTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CustomAttributeListTypeConverterTests.cs
index 23125f6f1..267f0c00e 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CustomAttributeListTypeConverterTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/CustomAttributeListTypeConverterTests.cs
@@ -7,12 +7,7 @@ namespace Grand.Infrastructure.Tests.TypeConverters.Converter
[TestClass()]
public class CustomAttributeListTypeConverterTests
{
- CustomAttributeListTypeConverter _converter;
-
- public CustomAttributeListTypeConverterTests()
- {
- _converter = new CustomAttributeListTypeConverter();
- }
+ CustomAttributeListTypeConverter _converter = new();
[TestMethod()]
public void CanConvertFromTest_True()
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs
index 3a06411f3..5d8c80f37 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/GenericListTypeConverterTests.cs
@@ -6,16 +6,9 @@ namespace Grand.Infrastructure.Tests.TypeConverters.Converter
[TestClass()]
public class GenericListTypeConverterTests
{
- GenericListTypeConverter<int> _intconverter;
- GenericListTypeConverter<double> _doubleconverter;
- GenericListTypeConverter<string> _stringconverter;
-
- public GenericListTypeConverterTests()
- {
- _intconverter = new GenericListTypeConverter<int>();
- _doubleconverter = new GenericListTypeConverter<double>();
- _stringconverter = new GenericListTypeConverter<string>();
- }
+ GenericListTypeConverter<int> _intconverter = new();
+ GenericListTypeConverter<double> _doubleconverter = new();
+ GenericListTypeConverter<string> _stringconverter = new();
[TestMethod()]
public void CanConvertFromTest_string_true()
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/RefreshTokenTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/RefreshTokenTypeConverterTests.cs
index 3b27b328d..8ee923d94 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/RefreshTokenTypeConverterTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/RefreshTokenTypeConverterTests.cs
@@ -7,11 +7,7 @@ namespace Grand.Infrastructure.Tests.TypeConverters.Converter
[TestClass()]
public class RefreshTokenTypeConverterTests
{
- RefreshTokenTypeConverter refreshTokenTypeConverter;
- public RefreshTokenTypeConverterTests()
- {
- refreshTokenTypeConverter = new RefreshTokenTypeConverter();
- }
+ RefreshTokenTypeConverter refreshTokenTypeConverter = new();
[TestMethod()]
public void CanConvertFromTest_string()
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/ShippingOptionTypeConverterTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/ShippingOptionTypeConverterTests.cs
index 8ecedf3a9..99d15ac3e 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/ShippingOptionTypeConverterTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeConverters/Converter/ShippingOptionTypeConverterTests.cs
@@ -7,12 +7,7 @@ namespace Grand.Infrastructure.Tests.TypeConverters.Converter
[TestClass()]
public class ShippingOptionTypeConverterTests
{
- ShippingOptionTypeConverter _converter;
-
- public ShippingOptionTypeConverterTests()
- {
- _converter = new ShippingOptionTypeConverter();
- }
+ ShippingOptionTypeConverter _converter = new();
[TestMethod()]
public void CanConvertFromTest()
diff --git a/src/Tests/Grand.Infrastructure.Tests/TypeSearcher/TypeSearcherTests.cs b/src/Tests/Grand.Infrastructure.Tests/TypeSearcher/TypeSearcherTests.cs
index 29296a2b0..9166559ed 100644
--- a/src/Tests/Grand.Infrastructure.Tests/TypeSearcher/TypeSearcherTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/TypeSearcher/TypeSearcherTests.cs
@@ -6,12 +6,7 @@ namespace Grand.Infrastructure.Tests.TypeSearcher
[TestClass()]
public class TypeSearcherTests
{
- private TypeSearch.TypeSearcher _typeSearcher;
-
- public TypeSearcherTests()
- {
- _typeSearcher = new TypeSearch.TypeSearcher();
- }
+ private TypeSearch.TypeSearcher _typeSearcher = new();
[TestMethod()]
public void GetAssembliesTest()
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml
index 51ea4089a..1599d34dc 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Blog/Comments.cshtml
@@ -28,15 +28,7 @@
</div>
@{
- var readUrl = "";
- if (!string.IsNullOrEmpty(filterByBlogPostId))
- {
- readUrl = Url.Action("Comments", "Blog", new { filterByBlogPostId, area = Constants.AreaAdmin });
- }
- else
- {
- readUrl = Url.Action("Comments", "Blog", new { area = Constants.AreaAdmin });
- }
+ var readUrl = !string.IsNullOrEmpty(filterByBlogPostId) ? Url.Action("Comments", "Blog", new { filterByBlogPostId, area = Constants.AreaAdmin }) : Url.Action("Comments", "Blog", new { area = Constants.AreaAdmin });
}
<script>
$(document).ready(function () {
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/AttributeCombinationPopup.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/AttributeCombinationPopup.cshtml
index eb6f9251f..ce87a9268 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/AttributeCombinationPopup.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/AttributeCombinationPopup.cshtml
@@ -3,14 +3,7 @@
@inject Grand.Business.Core.Interfaces.Common.Directory.IGroupService _groupService
@{
Layout = "";
- if (string.IsNullOrEmpty(Model.Id))
- {
- ViewBag.Title = Loc["Admin.Catalog.Products.ProductAttributes.AttributeCombinations.AddTitle"];
- }
- else
- {
- ViewBag.Title = Loc["Admin.Catalog.Products.ProductAttributes.AttributeCombinations.Update"];
- }
+ ViewBag.Title = string.IsNullOrEmpty(Model.Id) ? Loc["Admin.Catalog.Products.ProductAttributes.AttributeCombinations.AddTitle"] : Loc["Admin.Catalog.Products.ProductAttributes.AttributeCombinations.Update"];
}
<form id="AttributeCombinationPopup" asp-area="@Constants.AreaAdmin" asp-controller="Product" asp-action="AttributeCombinationPopup" enctype="multipart/form-data"
asp-route-productId="@Context.Request.Query["productId"]"
diff --git a/src/Web/Grand.Web.Admin/Controllers/NewsLetterCategoryController.cs b/src/Web/Grand.Web.Admin/Controllers/NewsLetterCategoryController.cs
index f8a836ad0..b132e77f4 100644
--- a/src/Web/Grand.Web.Admin/Controllers/NewsLetterCategoryController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/NewsLetterCategoryController.cs
@@ -49,15 +49,12 @@ namespace Grand.Web.Admin.Controllers
var newslettercategories = await _newsletterCategoryService.GetAllNewsletterCategory();
var gridModel = new DataSourceResult
{
- Data = newslettercategories.Select(x =>
+ Data = newslettercategories.Select(x => new
{
- return new
- {
- x.Id,
- x.Name,
- x.Selected,
- x.DisplayOrder
- };
+ x.Id,
+ x.Name,
+ x.Selected,
+ x.DisplayOrder
}).OrderBy(x => x.DisplayOrder),
Total = newslettercategories.Count
};
diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
index cd84e0b20..67d840fdb 100644
--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs
@@ -23,54 +23,32 @@ using Grand.Business.Core.Interfaces.ExportImport;
namespace Grand.Web.Admin.Controllers
{
[PermissionAuthorize(PermissionSystemName.Orders)]
- public class OrderController : BaseAdminController
+ public class OrderController(
+ IOrderViewModelService orderViewModelService,
+ IOrderService orderService,
+ IOrderStatusService orderStatusService,
+ ITranslationService translationService,
+ IWorkContext workContext,
+ IPdfService pdfService,
+ IGroupService groupService,
+ IExportManager<Order> exportManager,
+ IMediator mediator)
+ : BaseAdminController
{
#region Fields
- private readonly IOrderViewModelService _orderViewModelService;
- private readonly IOrderService _orderService;
- private readonly IOrderStatusService _orderStatusService;
- private readonly ITranslationService _translationService;
- private readonly IWorkContext _workContext;
- private readonly IPdfService _pdfService;
- private readonly IGroupService _groupService;
- private readonly IExportManager<Order> _exportManager;
- private readonly IMediator _mediator;
-
#endregion
#region Ctor
- public OrderController(
- IOrderViewModelService orderViewModelService,
- IOrderService orderService,
- IOrderStatusService orderStatusService,
- ITranslationService translationService,
- IWorkContext workContext,
- IPdfService pdfService,
- IGroupService groupService,
- IExportManager<Order> exportManager,
- IMediator mediator)
- {
- _orderViewModelService = orderViewModelService;
- _orderService = orderService;
- _orderStatusService = orderStatusService;
- _translationService = translationService;
- _workContext = workContext;
- _groupService = groupService;
- _pdfService = pdfService;
- _exportManager = exportManager;
- _mediator = mediator;
- }
-
#endregion
#region Utilities
protected virtual async Task<bool> CheckSalesManager(Order order)
{
- return await _groupService.IsSalesManager(_workContext.CurrentCustomer)
- && _workContext.CurrentCustomer.SeId != order.SeId;
+ return await groupService.IsSalesManager(workContext.CurrentCustomer)
+ && workContext.CurrentCustomer.SeId != order.SeId;
}
#endregion
@@ -82,7 +60,7 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> List(int? orderStatusId = null,
int? paymentStatusId = null, int? shippingStatusId = null, DateTime? startDate = null, string code = null)
{
- var model = await _orderViewModelService.PrepareOrderListModel(orderStatusId, paymentStatusId, shippingStatusId, startDate, _workContext.CurrentCustomer.StaffStoreId, code);
+ var model = await orderViewModelService.PrepareOrderListModel(orderStatusId, paymentStatusId, shippingStatusId, startDate, workContext.CurrentCustomer.StaffStoreId, code);
return View(model);
}
@@ -93,8 +71,8 @@ namespace Grand.Web.Admin.Controllers
return Content("");
var storeId = string.Empty;
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
- storeId = _workContext.CurrentCustomer.StaffStoreId;
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
+ storeId = workContext.CurrentCustomer.StaffStoreId;
//products
const int productNumber = 15;
@@ -119,12 +97,12 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> OrderList(DataSourceRequest command, OrderListModel model)
{
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- model.StoreId = _workContext.CurrentCustomer.StaffStoreId;
+ model.StoreId = workContext.CurrentCustomer.StaffStoreId;
}
- var (orderModels, totalCount) = await _orderViewModelService.PrepareOrderModel(model, command.Page, command.PageSize);
+ var (orderModels, totalCount) = await orderViewModelService.PrepareOrderModel(model, command.Page, command.PageSize);
var gridModel = new DataSourceResult
{
@@ -142,9 +120,9 @@ namespace Grand.Web.Admin.Controllers
int.TryParse(model.GoDirectlyToNumber, out var orderNumber);
if (orderNumber > 0)
{
- order = await _orderService.GetOrderByNumber(orderNumber);
+ order = await orderService.GetOrderByNumber(orderNumber);
}
- var orders = await _orderService.GetOrdersByCode(model.GoDirectlyToNumber);
+ var orders = await orderService.GetOrdersByCode(model.GoDirectlyToNumber);
switch (orders.Count)
{
case > 1:
@@ -157,7 +135,7 @@ namespace Grand.Web.Admin.Controllers
if (order == null || await CheckSalesManager(order))
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
@@ -173,16 +151,16 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> ExportExcelAll(OrderListModel model)
{
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- model.StoreId = _workContext.CurrentCustomer.StaffStoreId;
+ model.StoreId = workContext.CurrentCustomer.StaffStoreId;
}
//load orders
- var orders = await _orderViewModelService.PrepareOrders(model);
+ var orders = await orderViewModelService.PrepareOrders(model);
try
{
- var bytes = await _exportManager.Export(orders);
+ var bytes = await exportManager.Export(orders);
return File(bytes, "text/xls", "orders.xlsx");
}
catch (Exception exc)
@@ -203,13 +181,13 @@ namespace Grand.Web.Admin.Controllers
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => x)
.ToArray();
- orders.AddRange(await _orderService.GetOrdersByIds(ids));
+ orders.AddRange(await orderService.GetOrdersByIds(ids));
}
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- orders = orders.Where(x => x.StoreId == _workContext.CurrentCustomer.StaffStoreId).ToList();
+ orders = orders.Where(x => x.StoreId == workContext.CurrentCustomer.StaffStoreId).ToList();
}
- var bytes = await _exportManager.Export(orders);
+ var bytes = await exportManager.Export(orders);
return File(bytes, "text/xls", "orders.xlsx");
}
@@ -223,18 +201,18 @@ namespace Grand.Web.Admin.Controllers
[HttpGet]
public async Task<IActionResult> CancelOrder(string id)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
try
{
- await _mediator.Send(new CancelOrderCommand { Order = order, NotifyCustomer = true });
+ await mediator.Send(new CancelOrderCommand { Order = order, NotifyCustomer = true });
Success("Successfully canceled order");
return RedirectToAction("Edit", "Order", new { id });
@@ -251,22 +229,22 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> SaveOrderTags(OrderModel orderModel)
{
- var order = await _orderService.GetOrderById(orderModel.Id);
+ var order = await orderService.GetOrderById(orderModel.Id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
try
{
- await _orderViewModelService.SaveOrderTags(order, orderModel.OrderTags);
+ await orderViewModelService.SaveOrderTags(order, orderModel.OrderTags);
var model = new OrderModel();
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
return RedirectToAction("Edit", "Order", new { id = order.Id });
}
catch (Exception exception)
@@ -281,27 +259,27 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> ChangeOrderStatus(string id, OrderModel model)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
try
{
- var status = await _orderStatusService.GetByStatusId(model.OrderStatusId);
+ var status = await orderStatusService.GetByStatusId(model.OrderStatusId);
if (status == null)
throw new ArgumentNullException(nameof(status));
order.OrderStatusId = model.OrderStatusId;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
//add a note
- await _orderService.InsertOrderNote(new OrderNote
+ await orderService.InsertOrderNote(new OrderNote
{
Note = $"Order status has been edited. New status: {status?.Name}",
DisplayToCustomer = false,
@@ -309,7 +287,7 @@ namespace Grand.Web.Admin.Controllers
});
model = new OrderModel();
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
return RedirectToAction("Edit", "Order", new { id });
}
catch (Exception exc)
@@ -327,18 +305,18 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Preview)]
public async Task<IActionResult> Edit(string id)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || order.Deleted || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
var model = new OrderModel();
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
return View(model);
}
@@ -347,14 +325,14 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> Delete(OrderDeleteModel model)
{
- var order = await _orderService.GetOrderById(model.Id);
+ var order = await orderService.GetOrderById(model.Id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
if (ModelState.IsValid)
{
- await _mediator.Send(new DeleteOrderCommand { Order = order });
+ await mediator.Send(new DeleteOrderCommand { Order = order });
return RedirectToAction("List");
}
@@ -368,13 +346,13 @@ namespace Grand.Web.Admin.Controllers
ICollection<string> selectedIds,
[FromServices] IShipmentService shipmentService)
{
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
return RedirectToAction("List", "Order");
if (selectedIds != null)
{
var orders = new List<Order>();
- orders.AddRange(await _orderService.GetOrdersByIds(selectedIds.ToArray()));
+ orders.AddRange(await orderService.GetOrdersByIds(selectedIds.ToArray()));
for (var i = 0; i < orders.Count; i++)
{
var order = orders[i];
@@ -384,7 +362,7 @@ namespace Grand.Web.Admin.Controllers
if (!shipments.Any())
{
- await _mediator.Send(new DeleteOrderCommand { Order = order });
+ await mediator.Send(new DeleteOrderCommand { Order = order });
}
}
}
@@ -394,8 +372,8 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> PdfInvoice(string orderId)
{
- var order = await _orderService.GetOrderById(orderId);
- if ((await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId) || await CheckSalesManager(order))
+ var order = await orderService.GetOrderById(orderId);
+ if ((await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId) || await CheckSalesManager(order))
{
return RedirectToAction("List");
}
@@ -407,7 +385,7 @@ namespace Grand.Web.Admin.Controllers
byte[] bytes;
using (var stream = new MemoryStream())
{
- await _pdfService.PrintOrdersToPdf(stream, orders, _workContext.WorkingLanguage.Id);
+ await pdfService.PrintOrdersToPdf(stream, orders, workContext.WorkingLanguage.Id);
bytes = stream.ToArray();
}
return File(bytes, "application/pdf", $"order_{order.Id}.pdf");
@@ -418,16 +396,16 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> PdfInvoiceAll(OrderListModel model)
{
//load orders
- var orders = await _orderViewModelService.PrepareOrders(model);
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ var orders = await orderViewModelService.PrepareOrders(model);
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- orders = orders.Where(x => x.StoreId == _workContext.CurrentCustomer.StaffStoreId).ToList();
+ orders = orders.Where(x => x.StoreId == workContext.CurrentCustomer.StaffStoreId).ToList();
}
byte[] bytes;
using (var stream = new MemoryStream())
{
- await _pdfService.PrintOrdersToPdf(stream, orders, _workContext.WorkingLanguage.Id, model.VendorId);
+ await pdfService.PrintOrdersToPdf(stream, orders, workContext.WorkingLanguage.Id, model.VendorId);
bytes = stream.ToArray();
}
return File(bytes, "application/pdf", "orders.pdf");
@@ -444,25 +422,25 @@ namespace Grand.Web.Admin.Controllers
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => x)
.ToArray();
- orders.AddRange(await _orderService.GetOrdersByIds(ids));
+ orders.AddRange(await orderService.GetOrdersByIds(ids));
}
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- orders = orders.Where(x => x.StoreId == _workContext.CurrentCustomer.StaffStoreId).ToList();
+ orders = orders.Where(x => x.StoreId == workContext.CurrentCustomer.StaffStoreId).ToList();
}
//ensure that we at least one order selected
if (orders.Count == 0)
{
- Error(_translationService.GetResource("Admin.Orders.PdfInvoice.NoOrders"));
+ Error(translationService.GetResource("Admin.Orders.PdfInvoice.NoOrders"));
return RedirectToAction("List");
}
byte[] bytes;
using (var stream = new MemoryStream())
{
- await _pdfService.PrintOrdersToPdf(stream, orders, _workContext.WorkingLanguage.Id);
+ await pdfService.PrintOrdersToPdf(stream, orders, workContext.WorkingLanguage.Id);
bytes = stream.ToArray();
}
return File(bytes, "application/pdf", "orders.pdf");
@@ -472,12 +450,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> EditOrderTotals(string id, OrderModel model)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -494,44 +472,44 @@ namespace Grand.Web.Admin.Controllers
order.OrderDiscount = model.OrderTotalDiscountValue;
order.OrderTotal = model.OrderTotalValue;
order.CurrencyRate = model.CurrencyRate;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
//add a note
- await _orderService.InsertOrderNote(new OrderNote
+ await orderService.InsertOrderNote(new OrderNote
{
Note = "Order totals have been edited",
DisplayToCustomer = false,
OrderId = order.Id
});
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
return RedirectToAction("Edit", "Order", new { id });
}
[PermissionAuthorizeAction(PermissionActionName.Edit)]
[HttpPost]
public async Task<IActionResult> EditShippingMethod(string id, OrderModel model)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
order.ShippingMethod = model.ShippingMethod;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
//add a note
- await _orderService.InsertOrderNote(new OrderNote
+ await orderService.InsertOrderNote(new OrderNote
{
Note = "Shipping method has been edited",
DisplayToCustomer = false,
OrderId = order.Id
});
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
//selected tab
await SaveSelectedTabIndex(persistForTheNextRequest: true);
@@ -542,21 +520,21 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> EditUserFields(string id, OrderModel model)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
order.UserFields = model.UserFields;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
//selected tab
await SaveSelectedTabIndex(persistForTheNextRequest: true);
@@ -568,12 +546,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> SaveOrderItem(string id, OrderItemsModel model)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -622,7 +600,7 @@ namespace Grand.Web.Admin.Controllers
orderItem.DiscountAmountExclTax = 0;
}
- await _mediator.Send(new UpdateOrderItemCommand { Order = order, OrderItem = orderItem });
+ await mediator.Send(new UpdateOrderItemCommand { Order = order, OrderItem = orderItem });
//selected tab
await SaveSelectedTabIndex(persistForTheNextRequest: true);
@@ -634,12 +612,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> DeleteOrderItem(string id, string orderItemId)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -648,7 +626,7 @@ namespace Grand.Web.Admin.Controllers
if (orderItem == null)
throw new ArgumentException("No order item found with the specified id");
- var result = await _mediator.Send(new DeleteOrderItemCommand { Order = order, OrderItem = orderItem });
+ var result = await mediator.Send(new DeleteOrderItemCommand { Order = order, OrderItem = orderItem });
if (result.error)
Error(result.message);
@@ -663,12 +641,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> CancelOrderItem(string id, string orderItemId)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -678,7 +656,7 @@ namespace Grand.Web.Admin.Controllers
throw new ArgumentException("No order item found with the specified id");
- var result = await _mediator.Send(new CancelOrderItemCommand { Order = order, OrderItem = orderItem });
+ var result = await mediator.Send(new CancelOrderItemCommand { Order = order, OrderItem = orderItem });
if (result.error)
Error(result.message);
else
@@ -694,12 +672,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> ResetDownloadCount(string id, string orderItemId)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -709,9 +687,9 @@ namespace Grand.Web.Admin.Controllers
throw new ArgumentException("No order item found with the specified id");
orderItem.DownloadCount = 0;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
var model = new OrderModel();
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
//selected tab
await SaveSelectedTabIndex(persistForTheNextRequest: true);
@@ -723,12 +701,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> ActivateDownloadItem(string id, string orderItemId)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -738,9 +716,9 @@ namespace Grand.Web.Admin.Controllers
throw new ArgumentException("No order item found with the specified id");
orderItem.IsDownloadActivated = !orderItem.IsDownloadActivated;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
var model = new OrderModel();
- await _orderViewModelService.PrepareOrderDetailsModel(model, order);
+ await orderViewModelService.PrepareOrderDetailsModel(model, order);
//selected tab
await SaveSelectedTabIndex(persistForTheNextRequest: true);
@@ -751,12 +729,12 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Edit)]
public async Task<IActionResult> UploadLicenseFilePopup(string id, string orderItemId, [FromServices] IProductService productService)
{
- var order = await _orderService.GetOrderById(id);
+ var order = await orderService.GetOrderById(id);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id });
}
@@ -783,12 +761,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> UploadLicenseFilePopup(OrderModel.UploadLicenseModel model)
{
- var order = await _orderService.GetOrderById(model.OrderId);
+ var order = await orderService.GetOrderById(model.OrderId);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id = order.Id });
}
@@ -798,11 +776,8 @@ namespace Grand.Web.Admin.Controllers
throw new ArgumentException("No order item found with the specified id");
//attach license
- if (!string.IsNullOrEmpty(model.LicenseDownloadId))
- orderItem.LicenseDownloadId = model.LicenseDownloadId;
- else
- orderItem.LicenseDownloadId = null;
- await _orderService.UpdateOrder(order);
+ orderItem.LicenseDownloadId = !string.IsNullOrEmpty(model.LicenseDownloadId) ? model.LicenseDownloadId : null;
+ await orderService.UpdateOrder(order);
//success
ViewBag.RefreshPage = true;
@@ -814,12 +789,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> DeleteLicenseFilePopup(OrderModel.UploadLicenseModel model)
{
- var order = await _orderService.GetOrderById(model.OrderId);
+ var order = await orderService.GetOrderById(model.OrderId);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
}
@@ -830,7 +805,7 @@ namespace Grand.Web.Admin.Controllers
//attach license
orderItem.LicenseDownloadId = null;
- await _orderService.UpdateOrder(order);
+ await orderService.UpdateOrder(order);
//success
ViewBag.RefreshPage = true;
@@ -841,12 +816,12 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Edit)]
public async Task<IActionResult> AddProductToOrder(string orderId)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- var model = await _orderViewModelService.PrepareAddOrderProductModel(order);
+ var model = await orderViewModelService.PrepareAddOrderProductModel(order);
return View(model);
}
@@ -859,9 +834,9 @@ namespace Grand.Web.Admin.Controllers
categoryIds.Add(model.SearchCategoryId);
var storeId = string.Empty;
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- storeId = _workContext.CurrentCustomer.StaffStoreId;
+ storeId = workContext.CurrentCustomer.StaffStoreId;
}
var gridModel = new DataSourceResult();
@@ -893,16 +868,16 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Edit)]
public async Task<IActionResult> AddProductToOrderDetails(string orderId, string productId)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
- var model = await _orderViewModelService.PrepareAddProductToOrderModel(order, productId);
+ var model = await orderViewModelService.PrepareAddProductToOrderModel(order, productId);
return View(model);
}
@@ -910,22 +885,22 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> AddProductToOrderDetails(AddProductToOrderModel model)
{
- var order = await _orderService.GetOrderById(model.OrderId);
+ var order = await orderService.GetOrderById(model.OrderId);
if (order == null || await CheckSalesManager(order))
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
- var warnings = await _orderViewModelService.AddProductToOrderDetails(model);
+ var warnings = await orderViewModelService.AddProductToOrderDetails(model);
if (!warnings.Any())
//redirect to order details page
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
//errors
- var result = await _orderViewModelService.PrepareAddProductToOrderModel(order, model.ProductId);
+ var result = await orderViewModelService.PrepareAddProductToOrderModel(order, model.ProductId);
result.Warnings.AddRange(warnings);
return View(result);
}
@@ -939,12 +914,12 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Preview)]
public async Task<IActionResult> AddressEdit(string addressId, string orderId, bool billingAddress)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
@@ -969,7 +944,7 @@ namespace Grand.Web.Admin.Controllers
if (address == null)
throw new ArgumentException("No address found with the specified id", "addressId");
- var model = await _orderViewModelService.PrepareOrderAddressModel(order, address);
+ var model = await orderViewModelService.PrepareOrderAddressModel(order, address);
model.BillingAddress = billingAddress;
return View(model);
}
@@ -980,12 +955,12 @@ namespace Grand.Web.Admin.Controllers
[FromServices] IAddressAttributeService addressAttributeService,
[FromServices] IAddressAttributeParser addressAttributeParser)
{
- var order = await _orderService.GetOrderById(model.OrderId);
+ var order = await orderService.GetOrderById(model.OrderId);
if (order == null || await CheckSalesManager(order))
//No order found with the specified id
return RedirectToAction("List");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return RedirectToAction("List");
}
@@ -1010,12 +985,12 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
var customAttributes = await model.Address.ParseCustomAddressAttributes(addressAttributeParser, addressAttributeService);
- await _orderViewModelService.UpdateOrderAddress(order, address, model, customAttributes);
+ await orderViewModelService.UpdateOrderAddress(order, address, model, customAttributes);
return RedirectToAction("AddressEdit", new { addressId = model.Address.Id, orderId = model.OrderId, model.BillingAddress });
}
//If we got this far, something failed, redisplay form
- model = await _orderViewModelService.PrepareOrderAddressModel(order, address);
+ model = await orderViewModelService.PrepareOrderAddressModel(order, address);
model.BillingAddress = model.BillingAddress;
return View(model);
}
@@ -1028,16 +1003,16 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> OrderNotesSelect(string orderId, DataSourceRequest command)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
throw new ArgumentException("No order found with the specified id");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return Content("");
}
//order notes
- var orderNoteModels = await _orderViewModelService.PrepareOrderNotes(order);
+ var orderNoteModels = await orderViewModelService.PrepareOrderNotes(order);
var gridModel = new DataSourceResult
{
Data = orderNoteModels,
@@ -1049,15 +1024,15 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Edit)]
public async Task<IActionResult> OrderNoteAdd(string orderId, string downloadId, bool displayToCustomer, string message)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
return Json(new { Result = false });
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return Json(new { Result = false });
}
- await _orderViewModelService.InsertOrderNote(order, downloadId, displayToCustomer, message);
+ await orderViewModelService.InsertOrderNote(order, downloadId, displayToCustomer, message);
return Json(new { Result = true });
}
@@ -1066,16 +1041,16 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> OrderNoteDelete(string id, string orderId)
{
- var order = await _orderService.GetOrderById(orderId);
+ var order = await orderService.GetOrderById(orderId);
if (order == null || await CheckSalesManager(order))
throw new ArgumentException("No order found with the specified id");
- if (await _groupService.IsStaff(_workContext.CurrentCustomer) && order.StoreId != _workContext.CurrentCustomer.StaffStoreId)
+ if (await groupService.IsStaff(workContext.CurrentCustomer) && order.StoreId != workContext.CurrentCustomer.StaffStoreId)
{
return Json(new { Result = false });
}
- await _orderViewModelService.DeleteOrderNote(order, id);
+ await orderViewModelService.DeleteOrderNote(order, id);
return new JsonResult("");
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
index 60dadd16f..999f1c9d6 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
@@ -20,37 +20,21 @@ using System.Reflection;
namespace Grand.Web.Admin.Controllers
{
[PermissionAuthorize(PermissionSystemName.Plugins)]
- public class PluginController : BaseAdminController
+ public class PluginController(
+ ITranslationService translationService,
+ ILogger<PluginController> logger,
+ IHostApplicationLifetime applicationLifetime,
+ IWorkContext workContext,
+ IServiceProvider serviceProvider,
+ ExtensionsConfig extConfig)
+ : BaseAdminController
{
#region Fields
- private readonly ITranslationService _translationService;
- private readonly ILogger<PluginController> _logger;
- private readonly IHostApplicationLifetime _applicationLifetime;
- private readonly IServiceProvider _serviceProvider;
- private readonly IWorkContext _workContext;
- private readonly ExtensionsConfig _extConfig;
-
#endregion
#region Constructors
- public PluginController(
- ITranslationService translationService,
- ILogger<PluginController> logger,
- IHostApplicationLifetime applicationLifetime,
- IWorkContext workContext,
- IServiceProvider serviceProvider,
- ExtensionsConfig extConfig)
- {
- _translationService = translationService;
- _logger = logger;
- _workContext = workContext;
- _applicationLifetime = applicationLifetime;
- _serviceProvider = serviceProvider;
- _extConfig = extConfig;
- }
-
#endregion
#region Utilities
@@ -60,12 +44,12 @@ namespace Grand.Web.Admin.Controllers
{
var pluginModel = PluginInfo.ToModel();
//logo
- pluginModel.LogoUrl = PluginInfo.GetLogoUrl(_workContext);
+ pluginModel.LogoUrl = PluginInfo.GetLogoUrl(workContext);
//configuration URLs
if (PluginInfo.Installed)
{
- var pluginInstance = PluginInfo.Instance(_serviceProvider);
+ var pluginInstance = PluginInfo.Instance(serviceProvider);
pluginModel.ConfigurationUrl = pluginInstance.ConfigurationUrl();
}
@@ -180,16 +164,16 @@ namespace Grand.Web.Admin.Controllers
return RedirectToAction("List");
//install plugin
- var plugin = pluginInfo.Instance<IPlugin>(_serviceProvider);
+ var plugin = pluginInfo.Instance<IPlugin>(serviceProvider);
await plugin.Install();
- Success(_translationService.GetResource("Admin.Plugins.Installed"));
+ Success(translationService.GetResource("Admin.Plugins.Installed"));
- _logger.LogInformation("The plugin has been installed by the user {CurrentCustomerEmail}",
- _workContext.CurrentCustomer.Email);
+ logger.LogInformation("The plugin has been installed by the user {CurrentCustomerEmail}",
+ workContext.CurrentCustomer.Email);
//stop application
- _applicationLifetime.StopApplication();
+ applicationLifetime.StopApplication();
}
catch (Exception exc)
{
@@ -214,16 +198,16 @@ namespace Grand.Web.Admin.Controllers
return RedirectToAction("List");
//uninstall plugin
- var plugin = pluginInfo.Instance<IPlugin>(_serviceProvider);
+ var plugin = pluginInfo.Instance<IPlugin>(serviceProvider);
await plugin.Uninstall();
- Success(_translationService.GetResource("Admin.Plugins.Uninstalled"));
+ Success(translationService.GetResource("Admin.Plugins.Uninstalled"));
- _logger.LogInformation("The plugin has been uninstalled by the user {CurrentCustomerEmail}",
- _workContext.CurrentCustomer.Email);
+ logger.LogInformation("The plugin has been uninstalled by the user {CurrentCustomerEmail}",
+ workContext.CurrentCustomer.Email);
//stop application
- _applicationLifetime.StopApplication();
+ applicationLifetime.StopApplication();
}
catch (Exception exc)
{
@@ -236,7 +220,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public IActionResult Remove(string systemName)
{
- if (_extConfig.DisableUploadExtensions)
+ if (extConfig.DisableUploadExtensions)
{
Error("Upload plugins is disable");
return RedirectToAction("List");
@@ -261,13 +245,13 @@ namespace Grand.Web.Admin.Controllers
}
//uninstall plugin
- Success(_translationService.GetResource("Admin.Plugins.Removed"));
+ Success(translationService.GetResource("Admin.Plugins.Removed"));
- _logger.LogInformation("The plugin has been removed by the user {CurrentCustomerEmail}",
- _workContext.CurrentCustomer.Email);
+ logger.LogInformation("The plugin has been removed by the user {CurrentCustomerEmail}",
+ workContext.CurrentCustomer.Email);
//stop application
- _applicationLifetime.StopApplication();
+ applicationLifetime.StopApplication();
}
catch (Exception exc)
{
@@ -279,11 +263,11 @@ namespace Grand.Web.Admin.Controllers
public IActionResult ReloadList()
{
- _logger.LogInformation("Reload list of plugins by the user {CurrentCustomerEmail}",
- _workContext.CurrentCustomer.Email);
+ logger.LogInformation("Reload list of plugins by the user {CurrentCustomerEmail}",
+ workContext.CurrentCustomer.Email);
//stop application
- _applicationLifetime.StopApplication();
+ applicationLifetime.StopApplication();
return RedirectToAction("List");
}
@@ -291,7 +275,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public IActionResult UploadPlugin(IFormFile zippedFile)
{
- if (_extConfig.DisableUploadExtensions)
+ if (extConfig.DisableUploadExtensions)
{
Error("Upload plugins is disable");
return RedirectToAction("List");
@@ -299,7 +283,7 @@ namespace Grand.Web.Admin.Controllers
if (zippedFile == null || zippedFile.Length == 0)
{
- Error(_translationService.GetResource("Admin.Common.UploadFile"));
+ Error(translationService.GetResource("Admin.Common.UploadFile"));
return RedirectToAction("List");
}
@@ -320,7 +304,7 @@ namespace Grand.Web.Admin.Controllers
Upload(zipFilePath);
- var message = _translationService.GetResource("Admin.Plugins.Uploaded");
+ var message = translationService.GetResource("Admin.Plugins.Uploaded");
Success(message);
}
finally
@@ -330,11 +314,11 @@ namespace Grand.Web.Admin.Controllers
System.IO.File.Delete(zipFilePath);
}
- _logger.LogInformation("The plugin has been uploaded by the user {CurrentCustomerEmail}",
- _workContext.CurrentCustomer.Email);
+ logger.LogInformation("The plugin has been uploaded by the user {CurrentCustomerEmail}",
+ workContext.CurrentCustomer.Email);
//stop application
- _applicationLifetime.StopApplication();
+ applicationLifetime.StopApplication();
return RedirectToAction("List");
}
@@ -379,7 +363,7 @@ namespace Grand.Web.Admin.Controllers
}
catch (Exception ex)
{
- _logger.LogError(ex, ex.Message);
+ logger.LogError(ex, ex.Message);
}
}
@@ -393,14 +377,11 @@ namespace Grand.Web.Admin.Controllers
var entries = archive.Entries.ToArray();
foreach (var y in entries)
{
- if (y.Name.Length > 0)
- _path = y.FullName.Replace(y.Name, "").Replace(_fpath, pluginname).TrimEnd('/');
- else
- _path = y.FullName.Replace(_fpath, pluginname);
+ _path = y.Name.Length > 0 ? y.FullName.Replace(y.Name, "").Replace(_fpath, pluginname).TrimEnd('/') : y.FullName.Replace(_fpath, pluginname);
- var _entry = archive.CreateEntry($"{_path}/{y.Name}");
+ var entry = archive.CreateEntry($"{_path}/{y.Name}");
using (var a = y.Open())
- using (var b = _entry.Open())
+ using (var b = entry.Open())
a.CopyTo(b);
archive.GetEntry(y.FullName).Delete();
diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs
index 683a1cea1..e3d99f804 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs
@@ -202,14 +202,11 @@ namespace Grand.Web.Admin.Controllers
pageSize: command.PageSize);
var gridModel = new DataSourceResult
{
- Data = orders.Select(x =>
+ Data = orders.Select(x => new ProductAttributeModel.UsedByProductModel
{
- return new ProductAttributeModel.UsedByProductModel
- {
- Id = x.Id,
- ProductName = x.Name,
- Published = x.Published
- };
+ Id = x.Id,
+ ProductName = x.Name,
+ Published = x.Published
}),
Total = orders.TotalCount
};
diff --git a/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs b/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
index 73ba16fab..6fa8e8047 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PushNotificationsController.cs
@@ -14,42 +14,24 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Admin.Controllers
{
[PermissionAuthorize(PermissionSystemName.PushNotifications)]
- public class PushNotificationsController : BaseAdminController
+ public class PushNotificationsController(
+ PushNotificationsSettings pushNotificationsSettings,
+ ITranslationService translationService,
+ ISettingService settingService,
+ IPushNotificationsService pushNotificationsService,
+ ICustomerService customerService,
+ IPictureService pictureService,
+ IDateTimeService dateTimeService)
+ : BaseAdminController
{
- private readonly PushNotificationsSettings _pushNotificationsSettings;
- private readonly ITranslationService _translationService;
- private readonly ISettingService _settingService;
- private readonly IPushNotificationsService _pushNotificationsService;
- private readonly ICustomerService _customerService;
- private readonly IPictureService _pictureService;
- private readonly IDateTimeService _dateTimeService;
-
- public PushNotificationsController(
- PushNotificationsSettings pushNotificationsSettings,
- ITranslationService translationService,
- ISettingService settingService,
- IPushNotificationsService pushNotificationsService,
- ICustomerService customerService,
- IPictureService pictureService,
- IDateTimeService dateTimeService)
- {
- _pushNotificationsSettings = pushNotificationsSettings;
- _translationService = translationService;
- _settingService = settingService;
- _pushNotificationsService = pushNotificationsService;
- _customerService = customerService;
- _pictureService = pictureService;
- _dateTimeService = dateTimeService;
- }
-
public IActionResult Send()
{
var model = new PushModel
{
- MessageText = _translationService.GetResource("Admin.PushNotifications.MessageTextPlaceholder"),
- Title = _translationService.GetResource("Admin.PushNotifications.MessageTitlePlaceholder"),
- PictureId = _pushNotificationsSettings.PictureId,
- ClickUrl = _pushNotificationsSettings.ClickUrl
+ MessageText = translationService.GetResource("Admin.PushNotifications.MessageTextPlaceholder"),
+ Title = translationService.GetResource("Admin.PushNotifications.MessageTitlePlaceholder"),
+ PictureId = pushNotificationsSettings.PictureId,
+ ClickUrl = pushNotificationsSettings.ClickUrl
};
return View(model);
@@ -59,25 +41,25 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> Send(PushModel model)
{
- if (!string.IsNullOrEmpty(_pushNotificationsSettings.PrivateApiKey) && !string.IsNullOrEmpty(model.MessageText))
+ if (!string.IsNullOrEmpty(pushNotificationsSettings.PrivateApiKey) && !string.IsNullOrEmpty(model.MessageText))
{
- _pushNotificationsSettings.PictureId = model.PictureId;
- _pushNotificationsSettings.ClickUrl = model.ClickUrl;
- await _settingService.SaveSetting(_pushNotificationsSettings);
- var pictureUrl = await _pictureService.GetPictureUrl(model.PictureId);
- var result = await _pushNotificationsService.SendPushNotification(model.Title, model.MessageText, pictureUrl, model.ClickUrl);
+ pushNotificationsSettings.PictureId = model.PictureId;
+ pushNotificationsSettings.ClickUrl = model.ClickUrl;
+ await settingService.SaveSetting(pushNotificationsSettings);
+ var pictureUrl = await pictureService.GetPictureUrl(model.PictureId);
+ var result = await pushNotificationsService.SendPushNotification(model.Title, model.MessageText, pictureUrl, model.ClickUrl);
if (result.Item1)
{
- Success(_translationService.GetResource(result.Item2));
+ Success(translationService.GetResource(result.Item2));
}
else
{
- Error(_translationService.GetResource(result.Item2));
+ Error(translationService.GetResource(result.Item2));
}
}
else
{
- Error(_translationService.GetResource("PushNotifications.Error.PushApiMessage"));
+ Error(translationService.GetResource("PushNotifications.Error.PushApiMessage"));
}
return RedirectToAction("Send");
@@ -88,8 +70,8 @@ namespace Grand.Web.Admin.Controllers
{
var model = new MessagesModel
{
- Allowed = await _pushNotificationsService.GetAllowedReceivers(),
- Denied = await _pushNotificationsService.GetDeniedReceivers()
+ Allowed = await pushNotificationsService.GetAllowedReceivers(),
+ Denied = await pushNotificationsService.GetDeniedReceivers()
};
return View(model);
@@ -100,8 +82,8 @@ namespace Grand.Web.Admin.Controllers
{
var model = new ReceiversModel
{
- Allowed = await _pushNotificationsService.GetAllowedReceivers(),
- Denied = await _pushNotificationsService.GetDeniedReceivers()
+ Allowed = await pushNotificationsService.GetAllowedReceivers(),
+ Denied = await pushNotificationsService.GetDeniedReceivers()
};
return View(model);
@@ -111,7 +93,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> PushMessagesList(DataSourceRequest command)
{
- var messages = await _pushNotificationsService.GetPushMessages(command.Page - 1, command.PageSize);
+ var messages = await pushNotificationsService.GetPushMessages(command.Page - 1, command.PageSize);
var gridModel = new DataSourceResult
{
Data = messages.Select(x => new PushMessageGridModel
@@ -119,7 +101,7 @@ namespace Grand.Web.Admin.Controllers
Id = x.Id,
Text = x.Text,
Title = x.Title,
- SentOn = _dateTimeService.ConvertToUserTime(x.SentOn, DateTimeKind.Utc),
+ SentOn = dateTimeService.ConvertToUserTime(x.SentOn, DateTimeKind.Utc),
NumberOfReceivers = x.NumberOfReceivers
}),
Total = messages.TotalCount
@@ -132,32 +114,25 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> PushReceiversList(DataSourceRequest command)
{
- var receivers = await _pushNotificationsService.GetPushReceivers(command.Page - 1, command.PageSize);
+ var receivers = await pushNotificationsService.GetPushReceivers(command.Page - 1, command.PageSize);
var gridModel = new DataSourceResult();
var list = new List<PushRegistrationGridModel>();
foreach (var receiver in receivers)
{
var gridReceiver = new PushRegistrationGridModel();
- var customer = await _customerService.GetCustomerById(receiver.CustomerId);
+ var customer = await customerService.GetCustomerById(receiver.CustomerId);
if (customer == null)
{
- await _pushNotificationsService.DeletePushReceiver(receiver);
+ await pushNotificationsService.DeletePushReceiver(receiver);
continue;
}
- if (!string.IsNullOrEmpty(customer.Email))
- {
- gridReceiver.CustomerEmail = customer.Email;
- }
- else
- {
- gridReceiver.CustomerEmail = _translationService.GetResource("Admin.Customers.Guest");
- }
+ gridReceiver.CustomerEmail = !string.IsNullOrEmpty(customer.Email) ? customer.Email : translationService.GetResource("Admin.Customers.Guest");
gridReceiver.CustomerId = receiver.CustomerId;
gridReceiver.Id = receiver.Id;
- gridReceiver.RegisteredOn = _dateTimeService.ConvertToUserTime(receiver.RegisteredOn, DateTimeKind.Utc);
+ gridReceiver.RegisteredOn = dateTimeService.ConvertToUserTime(receiver.RegisteredOn, DateTimeKind.Utc);
gridReceiver.Token = receiver.Token;
gridReceiver.Allowed = receiver.Allowed;
@@ -174,8 +149,8 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> DeleteReceiver(string id)
{
- var receiver = await _pushNotificationsService.GetPushReceiver(id);
- await _pushNotificationsService.DeletePushReceiver(receiver);
+ var receiver = await pushNotificationsService.GetPushReceiver(id);
+ await pushNotificationsService.DeletePushReceiver(receiver);
return new JsonResult("");
}
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
index 8c75bb9b8..56bfc2088 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
@@ -42,67 +42,42 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Controllers
{
[PermissionAuthorize(PermissionSystemName.Settings)]
- public class SettingController : BaseAdminController
+ public class SettingController(
+ ISettingService settingService,
+ ICurrencyService currencyService,
+ IPictureService pictureService,
+ ITranslationService translationService,
+ IDateTimeService dateTimeService,
+ IWorkContext workContext,
+ IMediator mediator,
+ IMerchandiseReturnService merchandiseReturnService,
+ ILanguageService languageService,
+ IOrderStatusService orderStatusService,
+ ICacheBase cacheBase)
+ : BaseAdminController
{
#region Fields
- private readonly ISettingService _settingService;
- private readonly ICurrencyService _currencyService;
- private readonly IPictureService _pictureService;
- private readonly ITranslationService _translationService;
- private readonly IDateTimeService _dateTimeService;
- private readonly IWorkContext _workContext;
- private readonly IMediator _mediator;
- private readonly IMerchandiseReturnService _merchandiseReturnService;
- private readonly ILanguageService _languageService;
- private readonly IOrderStatusService _orderStatusService;
- private readonly ICacheBase _cacheBase;
-
#endregion
#region Constructors
- public SettingController(ISettingService settingService,
- ICurrencyService currencyService,
- IPictureService pictureService,
- ITranslationService translationService,
- IDateTimeService dateTimeService,
- IWorkContext workContext,
- IMediator mediator,
- IMerchandiseReturnService merchandiseReturnService,
- ILanguageService languageService,
- IOrderStatusService orderStatusService,
- ICacheBase cacheBase)
- {
- _settingService = settingService;
- _currencyService = currencyService;
- _pictureService = pictureService;
- _translationService = translationService;
- _dateTimeService = dateTimeService;
- _workContext = workContext;
- _mediator = mediator;
- _merchandiseReturnService = merchandiseReturnService;
- _languageService = languageService;
- _orderStatusService = orderStatusService;
- _cacheBase = cacheBase;
- }
-
#endregion
#region Utilities
protected async Task ClearCache()
{
- await _cacheBase.Clear();
+ await cacheBase.Clear();
}
public async Task<IActionResult> Content()
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var blogSettings = _settingService.LoadSetting<BlogSettings>(storeScope);
- var newsSettings = _settingService.LoadSetting<NewsSettings>(storeScope);
- var knowledgebaseSettings = _settingService.LoadSetting<KnowledgebaseSettings>(storeScope);
+ var blogSettings = settingService.LoadSetting<BlogSettings>(storeScope);
+ var newsSettings = settingService.LoadSetting<NewsSettings>(storeScope);
+ var knowledgebaseSettings = settingService.LoadSetting<KnowledgebaseSettings>(storeScope);
var model = new ContentSettingsModel {
BlogSettings = blogSettings.ToModel(),
NewsSettings = newsSettings.ToModel(),
@@ -118,19 +93,19 @@ namespace Grand.Web.Admin.Controllers
{
var storeScope = await GetActiveStore();
//blog
- var blogSettings = _settingService.LoadSetting<BlogSettings>(storeScope);
+ var blogSettings = settingService.LoadSetting<BlogSettings>(storeScope);
blogSettings = model.BlogSettings.ToEntity(blogSettings);
- await _settingService.SaveSetting(blogSettings, storeScope);
+ await settingService.SaveSetting(blogSettings, storeScope);
//news
- var newsSettings = _settingService.LoadSetting<NewsSettings>(storeScope);
+ var newsSettings = settingService.LoadSetting<NewsSettings>(storeScope);
newsSettings = model.NewsSettings.ToEntity(newsSettings);
- await _settingService.SaveSetting(newsSettings, storeScope);
+ await settingService.SaveSetting(newsSettings, storeScope);
//knowledgebase
- var knowledgeBaseSettings = _settingService.LoadSetting<KnowledgebaseSettings>(storeScope);
+ var knowledgeBaseSettings = settingService.LoadSetting<KnowledgebaseSettings>(storeScope);
knowledgeBaseSettings = model.KnowledgebaseSettings.ToEntity(knowledgeBaseSettings);
- await _settingService.SaveSetting(knowledgeBaseSettings, storeScope);
+ await settingService.SaveSetting(knowledgeBaseSettings, storeScope);
//selected tab
await SaveSelectedTabIndex();
@@ -138,7 +113,7 @@ namespace Grand.Web.Admin.Controllers
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return RedirectToAction("Content");
}
@@ -146,7 +121,7 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var vendorSettings = _settingService.LoadSetting<VendorSettings>(storeScope);
+ var vendorSettings = settingService.LoadSetting<VendorSettings>(storeScope);
var model = vendorSettings.ToModel();
model.ActiveStore = storeScope;
@@ -158,15 +133,15 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var vendorSettings = _settingService.LoadSetting<VendorSettings>(storeScope);
+ var vendorSettings = settingService.LoadSetting<VendorSettings>(storeScope);
vendorSettings = model.ToEntity(vendorSettings);
- await _settingService.SaveSetting(vendorSettings, storeScope);
+ await settingService.SaveSetting(vendorSettings, storeScope);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return RedirectToAction("Vendor");
}
@@ -174,7 +149,7 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var catalogSettings = _settingService.LoadSetting<CatalogSettings>(storeScope);
+ var catalogSettings = settingService.LoadSetting<CatalogSettings>(storeScope);
var model = catalogSettings.ToModel();
model.ActiveStore = storeScope;
return View(model);
@@ -184,15 +159,15 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var catalogSettings = _settingService.LoadSetting<CatalogSettings>(storeScope);
+ var catalogSettings = settingService.LoadSetting<CatalogSettings>(storeScope);
catalogSettings = model.ToEntity(catalogSettings);
- await _settingService.SaveSetting(catalogSettings, storeScope);
+ await settingService.SaveSetting(catalogSettings, storeScope);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
//selected tab
await SaveSelectedTabIndex();
@@ -206,13 +181,13 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> SortOptionsList(DataSourceRequest command)
{
var storeScope = await GetActiveStore();
- var catalogSettings = _settingService.LoadSetting<CatalogSettings>(storeScope);
+ var catalogSettings = settingService.LoadSetting<CatalogSettings>(storeScope);
var model = new List<SortOptionModel>();
foreach (int option in Enum.GetValues(typeof(ProductSortingEnum)))
{
model.Add(new SortOptionModel {
Id = option,
- Name = ((ProductSortingEnum)option).GetTranslationEnum(_translationService, _workContext),
+ Name = ((ProductSortingEnum)option).GetTranslationEnum(translationService, workContext),
IsActive = !catalogSettings.ProductSortingEnumDisabled.Contains(option),
DisplayOrder = catalogSettings.ProductSortingEnumDisplayOrder.TryGetValue(option, out var value) ? value : option
});
@@ -228,7 +203,7 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> SortOptionUpdate(SortOptionModel model)
{
var storeScope = await GetActiveStore();
- var catalogSettings = _settingService.LoadSetting<CatalogSettings>(storeScope);
+ var catalogSettings = settingService.LoadSetting<CatalogSettings>(storeScope);
catalogSettings.ProductSortingEnumDisplayOrder[model.Id] = model.DisplayOrder;
switch (model.IsActive)
@@ -241,7 +216,7 @@ namespace Grand.Web.Admin.Controllers
break;
}
- await _settingService.SaveSetting(catalogSettings, storeScope);
+ await settingService.SaveSetting(catalogSettings, storeScope);
await ClearCache();
@@ -254,9 +229,9 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var loyaltyPointsSettings = _settingService.LoadSetting<LoyaltyPointsSettings>(storeScope);
- var orderSettings = _settingService.LoadSetting<OrderSettings>(storeScope);
- var shoppingCartSettings = _settingService.LoadSetting<ShoppingCartSettings>(storeScope);
+ var loyaltyPointsSettings = settingService.LoadSetting<LoyaltyPointsSettings>(storeScope);
+ var orderSettings = settingService.LoadSetting<OrderSettings>(storeScope);
+ var shoppingCartSettings = settingService.LoadSetting<ShoppingCartSettings>(storeScope);
var model = new SalesSettingsModel {
LoyaltyPointsSettings = loyaltyPointsSettings.ToModel(),
@@ -265,13 +240,13 @@ namespace Grand.Web.Admin.Controllers
ActiveStore = storeScope
};
- var currencySettings = _settingService.LoadSetting<CurrencySettings>();
- var currency = await _currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId);
+ var currencySettings = settingService.LoadSetting<CurrencySettings>();
+ var currency = await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId);
//loyal
model.LoyaltyPointsSettings.PrimaryStoreCurrencyCode = currency?.CurrencyCode;
//order statuses
- var status = await _orderStatusService.GetAll();
+ var status = await orderStatusService.GetAll();
model.LoyaltyPointsSettings.PointsForPurchases_Awarded_OrderStatuses = status.Select(x => new SelectListItem { Value = x.StatusId.ToString(), Text = x.Name }).ToList();
//orders
@@ -291,18 +266,18 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
- var loyaltyPointsSettings = _settingService.LoadSetting<LoyaltyPointsSettings>(storeScope);
+ var loyaltyPointsSettings = settingService.LoadSetting<LoyaltyPointsSettings>(storeScope);
loyaltyPointsSettings = model.LoyaltyPointsSettings.ToEntity(loyaltyPointsSettings);
- await _settingService.SaveSetting(loyaltyPointsSettings, storeScope);
+ await settingService.SaveSetting(loyaltyPointsSettings, storeScope);
- var shoppingCartSettings = _settingService.LoadSetting<ShoppingCartSettings>(storeScope);
+ var shoppingCartSettings = settingService.LoadSetting<ShoppingCartSettings>(storeScope);
shoppingCartSettings = model.ShoppingCartSettings.ToEntity(shoppingCartSettings);
- await _settingService.SaveSetting(shoppingCartSettings, storeScope);
+ await settingService.SaveSetting(shoppingCartSettings, storeScope);
- var orderSettings = _settingService.LoadSetting<OrderSettings>(storeScope);
+ var orderSettings = settingService.LoadSetting<OrderSettings>(storeScope);
orderSettings = model.OrderSettings.ToEntity(orderSettings);
- await _settingService.SaveSetting(orderSettings, storeScope);
+ await settingService.SaveSetting(orderSettings, storeScope);
//now clear cache
await ClearCache();
@@ -321,7 +296,7 @@ namespace Grand.Web.Admin.Controllers
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return RedirectToAction("Sales");
}
@@ -338,7 +313,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> MerchandiseReturnReasonList(DataSourceRequest command)
{
- var reasons = await _merchandiseReturnService.GetAllMerchandiseReturnReasons();
+ var reasons = await merchandiseReturnService.GetAllMerchandiseReturnReasons();
var gridModel = new DataSourceResult {
Data = reasons.Select(x => x.ToModel()),
Total = reasons.Count
@@ -350,7 +325,7 @@ namespace Grand.Web.Admin.Controllers
{
var model = new MerchandiseReturnReasonModel();
//locales
- await AddLocales(_languageService, model.Locales);
+ await AddLocales(languageService, model.Locales);
return View(model);
}
[HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
@@ -359,9 +334,9 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
var rrr = model.ToEntity();
- await _merchandiseReturnService.InsertMerchandiseReturnReason(rrr);
+ await merchandiseReturnService.InsertMerchandiseReturnReason(rrr);
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Added"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Added"));
return continueEditing ? RedirectToAction("MerchandiseReturnReasonEdit", new { id = rrr.Id }) : RedirectToAction("MerchandiseReturnReasonList");
}
@@ -371,14 +346,14 @@ namespace Grand.Web.Admin.Controllers
//edit
public async Task<IActionResult> MerchandiseReturnReasonEdit(string id)
{
- var rrr = await _merchandiseReturnService.GetMerchandiseReturnReasonById(id);
+ var rrr = await merchandiseReturnService.GetMerchandiseReturnReasonById(id);
if (rrr == null)
//No reason found with the specified id
return RedirectToAction("MerchandiseReturnReasonList");
var model = rrr.ToModel();
//locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
{
locale.Name = rrr.GetTranslation(x => x.Name, languageId, false);
});
@@ -387,7 +362,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
public async Task<IActionResult> MerchandiseReturnReasonEdit(MerchandiseReturnReasonModel model, bool continueEditing)
{
- var rrr = await _merchandiseReturnService.GetMerchandiseReturnReasonById(model.Id);
+ var rrr = await merchandiseReturnService.GetMerchandiseReturnReasonById(model.Id);
if (rrr == null)
//No reason found with the specified id
return RedirectToAction("MerchandiseReturnReasonList");
@@ -395,9 +370,9 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
rrr = model.ToEntity(rrr);
- await _merchandiseReturnService.UpdateMerchandiseReturnReason(rrr);
+ await merchandiseReturnService.UpdateMerchandiseReturnReason(rrr);
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Updated"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Updated"));
if (continueEditing)
{
//selected tab
@@ -415,10 +390,10 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> MerchandiseReturnReasonDelete(string id)
{
- var rrr = await _merchandiseReturnService.GetMerchandiseReturnReasonById(id);
- await _merchandiseReturnService.DeleteMerchandiseReturnReason(rrr);
+ var rrr = await merchandiseReturnService.GetMerchandiseReturnReasonById(id);
+ await merchandiseReturnService.DeleteMerchandiseReturnReason(rrr);
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Deleted"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnReasons.Deleted"));
return RedirectToAction("MerchandiseReturnReasonList");
}
@@ -436,7 +411,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> MerchandiseReturnActionList(DataSourceRequest command)
{
- var actions = await _merchandiseReturnService.GetAllMerchandiseReturnActions();
+ var actions = await merchandiseReturnService.GetAllMerchandiseReturnActions();
var gridModel = new DataSourceResult {
Data = actions.Select(x => x.ToModel()),
Total = actions.Count
@@ -448,7 +423,7 @@ namespace Grand.Web.Admin.Controllers
{
var model = new MerchandiseReturnActionModel();
//locales
- await AddLocales(_languageService, model.Locales);
+ await AddLocales(languageService, model.Locales);
return View(model);
}
[HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
@@ -457,12 +432,12 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
var rra = model.ToEntity();
- await _merchandiseReturnService.InsertMerchandiseReturnAction(rra);
+ await merchandiseReturnService.InsertMerchandiseReturnAction(rra);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Added"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Added"));
return continueEditing ? RedirectToAction("MerchandiseReturnActionEdit", new { id = rra.Id }) : RedirectToAction("MerchandiseReturnActionList");
}
@@ -472,14 +447,14 @@ namespace Grand.Web.Admin.Controllers
//edit
public async Task<IActionResult> MerchandiseReturnActionEdit(string id)
{
- var rra = await _merchandiseReturnService.GetMerchandiseReturnActionById(id);
+ var rra = await merchandiseReturnService.GetMerchandiseReturnActionById(id);
if (rra == null)
//No action found with the specified id
return RedirectToAction("MerchandiseReturnActionList");
var model = rra.ToModel();
//locales
- await AddLocales(_languageService, model.Locales, (locale, languageId) =>
+ await AddLocales(languageService, model.Locales, (locale, languageId) =>
{
locale.Name = rra.GetTranslation(x => x.Name, languageId, false);
});
@@ -488,7 +463,7 @@ namespace Grand.Web.Admin.Controllers
[HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]
public async Task<IActionResult> MerchandiseReturnActionEdit(MerchandiseReturnActionModel model, bool continueEditing)
{
- var rra = await _merchandiseReturnService.GetMerchandiseReturnActionById(model.Id);
+ var rra = await merchandiseReturnService.GetMerchandiseReturnActionById(model.Id);
if (rra == null)
//No action found with the specified id
return RedirectToAction("MerchandiseReturnActionList");
@@ -496,9 +471,9 @@ namespace Grand.Web.Admin.Controllers
if (ModelState.IsValid)
{
rra = model.ToEntity(rra);
- await _merchandiseReturnService.UpdateMerchandiseReturnAction(rra);
+ await merchandiseReturnService.UpdateMerchandiseReturnAction(rra);
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Updated"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Updated"));
if (continueEditing)
{
//selected tab
@@ -516,10 +491,10 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> MerchandiseReturnActionDelete(string id)
{
- var rra = await _merchandiseReturnService.GetMerchandiseReturnActionById(id);
- await _merchandiseReturnService.DeleteMerchandiseReturnAction(rra);
+ var rra = await merchandiseReturnService.GetMerchandiseReturnActionById(id);
+ await merchandiseReturnService.DeleteMerchandiseReturnAction(rra);
- Success(_translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Deleted"));
+ Success(translationService.GetResource("Admin.Settings.Order.MerchandiseReturnActions.Deleted"));
return RedirectToAction("MerchandiseReturnActionList");
}
#endregion
@@ -527,7 +502,7 @@ namespace Grand.Web.Admin.Controllers
{
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var mediaSettings = _settingService.LoadSetting<MediaSettings>(storeScope);
+ var mediaSettings = settingService.LoadSetting<MediaSettings>(storeScope);
var model = mediaSettings.ToModel();
model.ActiveStore = storeScope;
@@ -540,25 +515,25 @@ namespace Grand.Web.Admin.Controllers
//load settings for a chosen store scope
var storeScope = await GetActiveStore();
- var mediaSettings = _settingService.LoadSetting<MediaSettings>(storeScope);
+ var mediaSettings = settingService.LoadSetting<MediaSettings>(storeScope);
mediaSettings = model.ToEntity(mediaSettings);
- await _settingService.SaveSetting(mediaSettings, storeScope);
+ await settingService.SaveSetting(mediaSettings, storeScope);
//now clear cache
await ClearCache();
//clear old Thumbs
- await _pictureService.ClearThumbs();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ await pictureService.ClearThumbs();
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return RedirectToAction("Media");
}
public async Task<IActionResult> Customer()
{
var storeScope = await GetActiveStore();
- var customerSettings = _settingService.LoadSetting<CustomerSettings>(storeScope);
- var addressSettings = _settingService.LoadSetting<AddressSettings>(storeScope);
+ var customerSettings = settingService.LoadSetting<CustomerSettings>(storeScope);
+ var addressSettings = settingService.LoadSetting<AddressSettings>(storeScope);
//merge settings
var model = new CustomerSettingsModel {
@@ -572,19 +547,19 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> Customer(CustomerSettingsModel model)
{
var storeScope = await GetActiveStore();
- var customerSettings = _settingService.LoadSetting<CustomerSettings>(storeScope);
- var addressSettings = _settingService.LoadSetting<AddressSettings>(storeScope);
+ var customerSettings = settingService.LoadSetting<CustomerSettings>(storeScope);
+ var addressSettings = settingService.LoadSetting<AddressSettings>(storeScope);
customerSettings = model.CustomerSettings.ToEntity(customerSettings);
- await _settingService.SaveSetting(customerSettings, storeScope);
+ await settingService.SaveSetting(customerSettings, storeScope);
addressSettings = model.AddressSettings.ToEntity(addressSettings);
- await _settingService.SaveSetting(addressSettings, storeScope);
+ await settingService.SaveSetting(addressSettings, storeScope);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
//selected tab
await SaveSelectedTabIndex();
@@ -598,10 +573,10 @@ namespace Grand.Web.Admin.Controllers
var storeScope = await GetActiveStore();
model.ActiveStore = storeScope;
//datettime settings
- var dateTimeSettings = _settingService.LoadSetting<DateTimeSettings>(storeScope);
+ var dateTimeSettings = settingService.LoadSetting<DateTimeSettings>(storeScope);
model.DateTimeSettings.DefaultStoreTimeZoneId = dateTimeSettings.DefaultStoreTimeZoneId;
var iswindows = Grand.Infrastructure.OperatingSystem.IsWindows();
- foreach (TimeZoneInfo timeZone in _dateTimeService.GetSystemTimeZones())
+ foreach (TimeZoneInfo timeZone in dateTimeService.GetSystemTimeZones())
{
var name = iswindows ? timeZone.DisplayName : $"{timeZone.StandardName} ({timeZone.Id})";
model.DateTimeSettings.AvailableTimeZones.Add(new SelectListItem {
@@ -611,7 +586,7 @@ namespace Grand.Web.Admin.Controllers
});
}
//store information
- var storeInformationSettings = _settingService.LoadSetting<StoreInformationSettings>(storeScope);
+ var storeInformationSettings = settingService.LoadSetting<StoreInformationSettings>(storeScope);
model.StoreInformationSettings = storeInformationSettings.ToModel();
model.StoreInformationSettings.AvailableStoreThemes =
@@ -626,17 +601,17 @@ namespace Grand.Web.Admin.Controllers
}).ToList();
//common
- var commonSettings = _settingService.LoadSetting<CommonSettings>(storeScope);
+ var commonSettings = settingService.LoadSetting<CommonSettings>(storeScope);
model.CommonSettings = commonSettings.ToModel();
//seo settings
- var seoSettings = _settingService.LoadSetting<SeoSettings>(storeScope);
+ var seoSettings = settingService.LoadSetting<SeoSettings>(storeScope);
model.SeoSettings = seoSettings.ToModel();
//security settings
- var securitySettings = _settingService.LoadSetting<SecuritySettings>(storeScope);
+ var securitySettings = settingService.LoadSetting<SecuritySettings>(storeScope);
//captcha settings
- var captchaSettings = _settingService.LoadSetting<CaptchaSettings>(storeScope);
+ var captchaSettings = settingService.LoadSetting<CaptchaSettings>(storeScope);
model.SecuritySettings = captchaSettings.ToModel();
if (securitySettings.AdminAreaAllowedIpAddresses != null)
@@ -650,11 +625,11 @@ namespace Grand.Web.Admin.Controllers
model.SecuritySettings.AvailableReCaptchaVersions = GoogleReCaptchaVersion.V2.ToSelectList(HttpContext, false).ToList();
//PDF settings
- var pdfSettings = _settingService.LoadSetting<PdfSettings>(storeScope);
+ var pdfSettings = settingService.LoadSetting<PdfSettings>(storeScope);
model.PdfSettings = pdfSettings.ToModel();
//display menu settings
- var displayMenuItemSettings = _settingService.LoadSetting<MenuItemSettings>(storeScope);
+ var displayMenuItemSettings = settingService.LoadSetting<MenuItemSettings>(storeScope);
model.DisplayMenuSettings = displayMenuItemSettings.ToModel();
return View(model);
@@ -667,42 +642,41 @@ namespace Grand.Web.Admin.Controllers
var storeScope = await GetActiveStore();
//store information settings
- var storeInformationSettings = _settingService.LoadSetting<StoreInformationSettings>(storeScope);
+ var storeInformationSettings = settingService.LoadSetting<StoreInformationSettings>(storeScope);
storeInformationSettings = model.StoreInformationSettings.ToEntity(storeInformationSettings);
- await _settingService.SaveSetting(storeInformationSettings, storeScope);
+ await settingService.SaveSetting(storeInformationSettings, storeScope);
//datetime settings
- var dateTimeSettings = _settingService.LoadSetting<DateTimeSettings>(storeScope);
+ var dateTimeSettings = settingService.LoadSetting<DateTimeSettings>(storeScope);
dateTimeSettings.DefaultStoreTimeZoneId = model.DateTimeSettings.DefaultStoreTimeZoneId;
- await _settingService.SaveSetting(dateTimeSettings, storeScope);
+ await settingService.SaveSetting(dateTimeSettings, storeScope);
//common settings
- var commonSettings = _settingService.LoadSetting<CommonSettings>(storeScope);
+ var commonSettings = settingService.LoadSetting<CommonSettings>(storeScope);
commonSettings = model.CommonSettings.ToEntity(commonSettings);
- await _settingService.SaveSetting(commonSettings, storeScope);
+ await settingService.SaveSetting(commonSettings, storeScope);
//seo settings
- var seoSettings = _settingService.LoadSetting<SeoSettings>(storeScope);
+ var seoSettings = settingService.LoadSetting<SeoSettings>(storeScope);
seoSettings = model.SeoSettings.ToEntity(seoSettings);
- await _settingService.SaveSetting(seoSettings, storeScope);
+ await settingService.SaveSetting(seoSettings, storeScope);
//security settings
- var securitySettings = _settingService.LoadSetting<SecuritySettings>(storeScope);
+ var securitySettings = settingService.LoadSetting<SecuritySettings>(storeScope);
- if (securitySettings.AdminAreaAllowedIpAddresses == null)
- securitySettings.AdminAreaAllowedIpAddresses = new List<string>();
+ securitySettings.AdminAreaAllowedIpAddresses ??= new List<string>();
securitySettings.AdminAreaAllowedIpAddresses.Clear();
if (!string.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses))
foreach (var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
if (!string.IsNullOrWhiteSpace(s))
securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim());
- await _settingService.SaveSetting(securitySettings);
+ await settingService.SaveSetting(securitySettings);
//captcha settings
- var captchaSettings = _settingService.LoadSetting<CaptchaSettings>(storeScope);
+ var captchaSettings = settingService.LoadSetting<CaptchaSettings>(storeScope);
captchaSettings = model.SecuritySettings.ToEntity(captchaSettings);
- await _settingService.SaveSetting(captchaSettings);
+ await settingService.SaveSetting(captchaSettings);
if (captchaSettings.Enabled &&
(string.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPublicKey) || string.IsNullOrWhiteSpace(captchaSettings.ReCaptchaPrivateKey)))
{
@@ -711,19 +685,19 @@ namespace Grand.Web.Admin.Controllers
}
//PDF settings
- var pdfSettings = _settingService.LoadSetting<PdfSettings>(storeScope);
+ var pdfSettings = settingService.LoadSetting<PdfSettings>(storeScope);
pdfSettings = model.PdfSettings.ToEntity(pdfSettings);
- await _settingService.SaveSetting(pdfSettings, storeScope);
+ await settingService.SaveSetting(pdfSettings, storeScope);
//menu item settings
- var displayMenuItemSettings = _settingService.LoadSetting<MenuItemSettings>(storeScope);
+ var displayMenuItemSettings = settingService.LoadSetting<MenuItemSettings>(storeScope);
displayMenuItemSettings = model.DisplayMenuSettings.ToEntity(displayMenuItemSettings);
- await _settingService.SaveSetting(displayMenuItemSettings, storeScope);
+ await settingService.SaveSetting(displayMenuItemSettings, storeScope);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
//selected tab
await SaveSelectedTabIndex();
@@ -734,7 +708,7 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> PushNotifications()
{
var storeScope = await GetActiveStore();
- var settings = _settingService.LoadSetting<PushNotificationsSettings>(storeScope);
+ var settings = settingService.LoadSetting<PushNotificationsSettings>(storeScope);
var model = settings.ToModel();
return View(model);
@@ -744,10 +718,10 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> PushNotifications(PushNotificationsSettingsModel model)
{
var storeScope = await GetActiveStore();
- var settings = _settingService.LoadSetting<PushNotificationsSettings>(storeScope);
+ var settings = settingService.LoadSetting<PushNotificationsSettings>(storeScope);
settings = model.ToEntity(settings);
- await _settingService.SaveSetting(settings);
+ await settingService.SaveSetting(settings);
//now clear cache
await ClearCache();
@@ -755,7 +729,7 @@ namespace Grand.Web.Admin.Controllers
//save to file
SavePushNotificationsToFile(model);
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return await PushNotifications();
}
@@ -810,7 +784,7 @@ namespace Grand.Web.Admin.Controllers
public IActionResult AdminSearch()
{
- var settings = _settingService.LoadSetting<AdminSearchSettings>();
+ var settings = settingService.LoadSetting<AdminSearchSettings>();
var model = settings.ToModel();
return View(model);
}
@@ -818,14 +792,14 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> AdminSearch(AdminSearchSettingsModel model)
{
- var settings = _settingService.LoadSetting<AdminSearchSettings>();
+ var settings = settingService.LoadSetting<AdminSearchSettings>();
settings = model.ToEntity(settings);
- await _settingService.SaveSetting(settings);
+ await settingService.SaveSetting(settings);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return AdminSearch();
}
@@ -833,35 +807,35 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> SystemSetting()
{
- var settings = _settingService.LoadSetting<SystemSettings>();
+ var settings = settingService.LoadSetting<SystemSettings>();
var model = new SystemSettingsModel {
//order ident
- OrderIdent = await _mediator.Send(new MaxOrderNumberCommand()),
+ OrderIdent = await mediator.Send(new MaxOrderNumberCommand()),
//system settings
DaysToCancelUnpaidOrder = settings.DaysToCancelUnpaidOrder,
DeleteGuestTaskOlderThanMinutes = settings.DeleteGuestTaskOlderThanMinutes
};
//storage settings
- var storagesettings = _settingService.LoadSetting<StorageSettings>();
+ var storagesettings = settingService.LoadSetting<StorageSettings>();
model.PicturesStoredIntoDatabase = storagesettings.PictureStoreInDb;
//area admin settings
- var adminsettings = _settingService.LoadSetting<AdminAreaSettings>();
+ var adminsettings = settingService.LoadSetting<AdminAreaSettings>();
model.DefaultGridPageSize = adminsettings.DefaultGridPageSize;
model.GridPageSizes = adminsettings.GridPageSizes;
model.UseIsoDateTimeConverterInJson = adminsettings.UseIsoDateTimeConverterInJson;
model.HideStoreColumn = adminsettings.HideStoreColumn;
//language settings
- var langsettings = _settingService.LoadSetting<LanguageSettings>();
+ var langsettings = settingService.LoadSetting<LanguageSettings>();
model.IgnoreRtlPropertyForAdminArea = langsettings.IgnoreRtlPropertyForAdminArea;
model.AutomaticallyDetectLanguage = langsettings.AutomaticallyDetectLanguage;
model.DefaultAdminLanguageId = langsettings.DefaultAdminLanguageId;
//others
- var docsettings = _settingService.LoadSetting<DocumentSettings>();
+ var docsettings = settingService.LoadSetting<DocumentSettings>();
model.DocumentPageSizeSettings = docsettings.PageSize;
return View(model);
@@ -871,41 +845,41 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> SystemSetting(SystemSettingsModel model)
{
//system
- var settings = _settingService.LoadSetting<SystemSettings>();
+ var settings = settingService.LoadSetting<SystemSettings>();
settings.DaysToCancelUnpaidOrder = model.DaysToCancelUnpaidOrder;
settings.DeleteGuestTaskOlderThanMinutes = model.DeleteGuestTaskOlderThanMinutes;
- await _settingService.SaveSetting(settings);
+ await settingService.SaveSetting(settings);
//order ident
if (model.OrderIdent is > 0)
{
- await _mediator.Send(new MaxOrderNumberCommand { OrderNumber = model.OrderIdent });
+ await mediator.Send(new MaxOrderNumberCommand { OrderNumber = model.OrderIdent });
}
//admin area
- var adminAreaSettings = _settingService.LoadSetting<AdminAreaSettings>();
+ var adminAreaSettings = settingService.LoadSetting<AdminAreaSettings>();
adminAreaSettings.DefaultGridPageSize = model.DefaultGridPageSize;
adminAreaSettings.GridPageSizes = model.GridPageSizes;
adminAreaSettings.UseIsoDateTimeConverterInJson = model.UseIsoDateTimeConverterInJson;
adminAreaSettings.HideStoreColumn = model.HideStoreColumn;
- await _settingService.SaveSetting(adminAreaSettings);
+ await settingService.SaveSetting(adminAreaSettings);
//language settings
- var langsettings = _settingService.LoadSetting<LanguageSettings>();
+ var langsettings = settingService.LoadSetting<LanguageSettings>();
langsettings.IgnoreRtlPropertyForAdminArea = model.IgnoreRtlPropertyForAdminArea;
langsettings.AutomaticallyDetectLanguage = model.AutomaticallyDetectLanguage;
langsettings.DefaultAdminLanguageId = model.DefaultAdminLanguageId;
- await _settingService.SaveSetting(langsettings);
+ await settingService.SaveSetting(langsettings);
//doc settings
- var docsettings = _settingService.LoadSetting<DocumentSettings>();
+ var docsettings = settingService.LoadSetting<DocumentSettings>();
docsettings.PageSize = model.DocumentPageSizeSettings;
- await _settingService.SaveSetting(docsettings);
+ await settingService.SaveSetting(docsettings);
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return await SystemSetting();
}
@@ -913,12 +887,12 @@ namespace Grand.Web.Admin.Controllers
[HttpPost]
public async Task<IActionResult> ChangePictureStorage()
{
- var storageSettings = _settingService.LoadSetting<StorageSettings>();
+ var storageSettings = settingService.LoadSetting<StorageSettings>();
var storeIdDb = !storageSettings.PictureStoreInDb;
storageSettings.PictureStoreInDb = storeIdDb;
//save the new setting value
- await _settingService.SaveSetting(storageSettings);
+ await settingService.SaveSetting(storageSettings);
//save picture
await SavePictureStorage(storeIdDb);
@@ -926,7 +900,7 @@ namespace Grand.Web.Admin.Controllers
//now clear cache
await ClearCache();
- Success(_translationService.GetResource("Admin.Configuration.Updated"));
+ Success(translationService.GetResource("Admin.Configuration.Updated"));
return RedirectToAction("SystemSetting");
}
@@ -936,26 +910,26 @@ namespace Grand.Web.Admin.Controllers
const int pageSize = 100;
while (true)
{
- var pictures = _pictureService.GetPictures(pageIndex, pageSize);
+ var pictures = pictureService.GetPictures(pageIndex, pageSize);
pageIndex++;
if (!pictures.Any())
break;
foreach (var picture in pictures)
{
- var pictureBinary = await _pictureService.LoadPictureBinary(picture, !storeIdDb);
+ var pictureBinary = await pictureService.LoadPictureBinary(picture, !storeIdDb);
if (storeIdDb)
- await _pictureService.DeletePictureOnFileSystem(picture);
+ await pictureService.DeletePictureOnFileSystem(picture);
else
{
//now on file system
if (pictureBinary != null)
- await _pictureService.SavePictureInFile(picture.Id, pictureBinary, picture.MimeType);
+ await pictureService.SavePictureInFile(picture.Id, pictureBinary, picture.MimeType);
}
picture.PictureBinary = storeIdDb ? pictureBinary : Array.Empty<byte>();
picture.IsNew = true;
- await _pictureService.UpdatePicture(picture);
+ await pictureService.UpdatePicture(picture);
}
}
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
index 50077dab5..1ff9ce42b 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
@@ -320,14 +320,11 @@ namespace Grand.Web.Admin.Controllers
var scripts = RoslynCompiler.ReferencedScripts != null ? RoslynCompiler.ReferencedScripts.ToList() : new List<ResultCompiler>();
var gridModel = new DataSourceResult {
- Data = scripts.Select(x =>
+ Data = scripts.Select(x => new
{
- return new
- {
- FileName = x.OriginalFile,
- x.IsCompiled,
- Errors = string.Join(",", x.ErrorInfo)
- };
+ FileName = x.OriginalFile,
+ x.IsCompiled,
+ Errors = string.Join(",", x.ErrorInfo)
}),
Total = scripts.Count
};
diff --git a/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliateModel.cs b/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliateModel.cs
index be2b15080..ee94545e0 100644
--- a/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliateModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliateModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Affiliates
{
public class AffiliateModel : BaseEntityModel
{
- public AffiliateModel()
- {
- Address = new AddressModel();
- }
-
[GrandResourceDisplayName("Admin.Affiliates.Fields.ID")]
public override string Id { get; set; }
@@ -32,7 +27,7 @@ namespace Grand.Web.Admin.Models.Affiliates
[GrandResourceDisplayName("Admin.Affiliates.Fields.Active")]
public bool Active { get; set; }
- public AddressModel Address { get; set; }
+ public AddressModel Address { get; set; } = new();
#region Nested classes
diff --git a/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliatedOrderListModel.cs b/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliatedOrderListModel.cs
index 2bd59a3db..fa6a4ba02 100644
--- a/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliatedOrderListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Affiliates/AffiliatedOrderListModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Admin.Models.Affiliates
{
public class AffiliatedOrderListModel : BaseModel
{
- public AffiliatedOrderListModel()
- {
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableShippingStatuses = new List<SelectListItem>();
- }
-
public string AffliateId { get; set; }
[GrandResourceDisplayName("Admin.Affiliates.Orders.StartDate")]
@@ -31,8 +24,8 @@ namespace Grand.Web.Admin.Models.Affiliates
[GrandResourceDisplayName("Admin.Affiliates.Orders.ShippingStatus")]
public int ShippingStatusId { get; set; }
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableShippingStatuses { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableShippingStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Blogs/BlogCategoryModel.cs b/src/Web/Grand.Web.Admin/Models/Blogs/BlogCategoryModel.cs
index 72464531a..69f1269c0 100644
--- a/src/Web/Grand.Web.Admin/Models/Blogs/BlogCategoryModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Blogs/BlogCategoryModel.cs
@@ -9,10 +9,6 @@ namespace Grand.Web.Admin.Models.Blogs
{
public class BlogCategoryModel : BaseEntityModel, ILocalizedModel<BlogCategoryLocalizedModel>, IStoreLinkModel
{
- public BlogCategoryModel()
- {
- Locales = new List<BlogCategoryLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Content.Blog.BlogCategory.Fields.Name")]
public string Name { get; set; }
@@ -22,7 +18,8 @@ namespace Grand.Web.Admin.Models.Blogs
[GrandResourceDisplayName("Admin.Content.Blog.BlogCategory.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<BlogCategoryLocalizedModel> Locales { get; set; }
+ public IList<BlogCategoryLocalizedModel> Locales { get; set; } = new List<BlogCategoryLocalizedModel>();
+
//Store acl
[UIHint("Stores")]
public string[] Stores { get; set; }
@@ -36,18 +33,13 @@ namespace Grand.Web.Admin.Models.Blogs
public class AddBlogPostCategoryModel : BaseModel
{
- public AddBlogPostCategoryModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Content.Blog.BlogCategory.SearchBlogTitle")]
public string SearchBlogTitle { get; set; }
[GrandResourceDisplayName("Admin.Content.Blog.BlogCategory.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
public string CategoryId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Blogs/BlogPostModel.cs b/src/Web/Grand.Web.Admin/Models/Blogs/BlogPostModel.cs
index 9106ac274..e7839cbf8 100644
--- a/src/Web/Grand.Web.Admin/Models/Blogs/BlogPostModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Blogs/BlogPostModel.cs
@@ -8,11 +8,6 @@ namespace Grand.Web.Admin.Models.Blogs
{
public class BlogPostModel : BaseEntityModel, ILocalizedModel<BlogLocalizedModel>, IStoreLinkModel
{
- public BlogPostModel()
- {
- Locales = new List<BlogLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Content.Blog.BlogPosts.Fields.Title")]
public string Title { get; set; }
@@ -66,7 +61,7 @@ namespace Grand.Web.Admin.Models.Blogs
public string SeName { get; set; }
- public IList<BlogLocalizedModel> Locales { get; set; }
+ public IList<BlogLocalizedModel> Locales { get; set; } = new List<BlogLocalizedModel>();
[GrandResourceDisplayName("Admin.Content.Blog.BlogPosts.Fields.CreatedOn")]
public DateTime CreatedOn { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Blogs/BlogProductModel.cs b/src/Web/Grand.Web.Admin/Models/Blogs/BlogProductModel.cs
index 3c50a0443..5308a14d1 100644
--- a/src/Web/Grand.Web.Admin/Models/Blogs/BlogProductModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Blogs/BlogProductModel.cs
@@ -17,13 +17,6 @@ namespace Grand.Web.Admin.Models.Blogs
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -43,9 +36,9 @@ namespace Grand.Web.Admin.Models.Blogs
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string BlogPostId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/BrandListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/BrandListModel.cs
index 4a555ecbe..51142ec71 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/BrandListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/BrandListModel.cs
@@ -6,17 +6,12 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class BrandListModel : BaseModel
{
- public BrandListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Brands.List.SearchBrandName")]
public string SearchBrandName { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Brands.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/BulkEditListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/BulkEditListModel.cs
index 4676a5301..39e8bf199 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/BulkEditListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/BulkEditListModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class BulkEditListModel : BaseModel
{
- public BulkEditListModel()
- {
- AvailableProductTypes = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.BulkEdit.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -34,7 +28,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/CategoryListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/CategoryListModel.cs
index cd2d69b22..2fdf1fed6 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/CategoryListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/CategoryListModel.cs
@@ -6,16 +6,11 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class CategoryListModel : BaseModel
{
- public CategoryListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Categories.List.SearchCategoryName")]
public string SearchCategoryName { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Categories.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/CategoryModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/CategoryModel.cs
index 6a24970e9..23ab4d668 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/CategoryModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/CategoryModel.cs
@@ -142,13 +142,6 @@ namespace Grand.Web.Admin.Models.Catalog
}
public class AddCategoryProductModel : BaseModel
{
- public AddCategoryProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -168,9 +161,9 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string CategoryId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/CollectionListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/CollectionListModel.cs
index b3f866309..05b93367d 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/CollectionListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/CollectionListModel.cs
@@ -6,17 +6,12 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class CollectionListModel : BaseModel
{
- public CollectionListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Collections.List.SearchCollectionName")]
public string SearchCollectionName { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Collections.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/CollectionModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/CollectionModel.cs
index 454d15777..974553bee 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/CollectionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/CollectionModel.cs
@@ -119,14 +119,6 @@ namespace Grand.Web.Admin.Models.Catalog
public class AddCollectionProductModel : BaseModel
{
- public AddCollectionProductModel()
- {
- AvailableCollections = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
[UIHint("Category")]
@@ -145,10 +137,10 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableCollections { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableCollections { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string CollectionId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeCombinationModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeCombinationModel.cs
index e2eeefe75..f9427e9f6 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeCombinationModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeCombinationModel.cs
@@ -12,14 +12,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public string Id { get; set; }
- public ProductAttributeCombinationModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- Warnings = new List<string>();
- WarehouseInventoryModels = new List<WarehouseInventoryModel>();
- ProductPictureModels = new List<ProductModel.ProductPictureModel>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.AttributeCombinations.Fields.StockQuantity")]
public int StockQuantity { get; set; }
@@ -53,37 +45,32 @@ namespace Grand.Web.Admin.Models.Catalog
public string PictureId { get; set; }
public string PictureThumbnailUrl { get; set; }
- public IList<ProductModel.ProductPictureModel> ProductPictureModels { get; set; }
+ public IList<ProductModel.ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductModel.ProductPictureModel>();
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
public string ProductId { get; set; }
public string Attributes { get; set; }
public bool UseMultipleWarehouses { get; set; }
- public IList<WarehouseInventoryModel> WarehouseInventoryModels { get; set; }
+ public IList<WarehouseInventoryModel> WarehouseInventoryModels { get; set; } = new List<WarehouseInventoryModel>();
#region Nested classes
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductAttributeId { get; set; }
public string Name { get; set; }
public string TextPrompt { get; set; }
public bool IsRequired { get; set; }
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeConditionModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeConditionModel.cs
index c2fb95e4c..4d79d3bb9 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeConditionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeConditionModel.cs
@@ -9,17 +9,12 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductAttributeConditionModel : BaseModel
{
- public ProductAttributeConditionModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.Attributes.Condition.EnableCondition")]
public bool EnableCondition { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.Attributes.Condition.Attributes")]
public string SelectedProductAttributeId { get; set; }
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
@@ -30,11 +25,6 @@ namespace Grand.Web.Admin.Models.Catalog
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductAttributeId { get; set; }
public string Name { get; set; }
@@ -45,7 +35,7 @@ namespace Grand.Web.Admin.Models.Catalog
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeModel.cs
index 9b3f94d11..30b13c3ba 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductAttributeModel.cs
@@ -8,11 +8,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductAttributeModel : BaseEntityModel, ILocalizedModel<ProductAttributeLocalizedModel>, IStoreLinkModel
{
- public ProductAttributeModel()
- {
- Locales = new List<ProductAttributeLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Attributes.ProductAttributes.Fields.Name")]
public string Name { get; set; }
@@ -27,7 +22,7 @@ namespace Grand.Web.Admin.Models.Catalog
[UIHint("Stores")]
public string[] Stores { get; set; }
- public IList<ProductAttributeLocalizedModel> Locales { get; set; }
+ public IList<ProductAttributeLocalizedModel> Locales { get; set; } = new List<ProductAttributeLocalizedModel>();
#region Nested classes
@@ -57,11 +52,6 @@ namespace Grand.Web.Admin.Models.Catalog
public class PredefinedProductAttributeValueModel : BaseEntityModel, ILocalizedModel<PredefinedProductAttributeValueLocalizedModel>
{
- public PredefinedProductAttributeValueModel()
- {
- Locales = new List<PredefinedProductAttributeValueLocalizedModel>();
- }
-
public string ProductAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.Name")]
@@ -89,7 +79,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<PredefinedProductAttributeValueLocalizedModel> Locales { get; set; }
+ public IList<PredefinedProductAttributeValueLocalizedModel> Locales { get; set; } = new List<PredefinedProductAttributeValueLocalizedModel>();
}
public class PredefinedProductAttributeValueLocalizedModel : ILocalizedModelLocal
{
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductListModel.cs
index 47722acac..6418e543c 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductListModel.cs
@@ -7,14 +7,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductListModel : BaseModel
{
- public ProductListModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- AvailablePublishedOptions = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchCategory")]
@@ -46,9 +38,9 @@ namespace Grand.Web.Admin.Models.Catalog
public string GoDirectlyToSku { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
- public IList<SelectListItem> AvailablePublishedOptions { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePublishedOptions { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
index d25faf080..33e47d7a8 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductModel.cs
@@ -11,24 +11,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductModel : BaseEntityModel, ILocalizedModel<ProductLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public ProductModel()
- {
- Locales = new List<ProductLocalizedModel>();
- ProductPictureModels = new List<ProductPictureModel>();
- CopyProductModel = new CopyProductModel();
- AvailableBasepriceUnits = new List<SelectListItem>();
- AvailableBasepriceBaseUnits = new List<SelectListItem>();
- AvailableProductLayouts = new List<SelectListItem>();
- AvailableTaxCategories = new List<SelectListItem>();
- AvailableDeliveryDates = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailableProductAttributes = new List<SelectListItem>();
- AvailableUnits = new List<SelectListItem>();
- AddPictureModel = new ProductPictureModel();
- ProductWarehouseInventoryModels = new List<ProductWarehouseInventoryModel>();
- CalendarModel = new GenerateCalendarModel();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.ID")]
public override string Id { get; set; }
@@ -52,7 +34,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.ProductLayout")]
public string ProductLayoutId { get; set; }
- public IList<SelectListItem> AvailableProductLayouts { get; set; }
+ public IList<SelectListItem> AvailableProductLayouts { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Name")]
public string Name { get; set; }
@@ -183,7 +165,7 @@ namespace Grand.Web.Admin.Models.Catalog
public int RecurringTotalCycles { get; set; }
//calendar
- public GenerateCalendarModel CalendarModel { get; set; }
+ public GenerateCalendarModel CalendarModel { get; set; } = new();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.IsShipEnabled")]
public bool IsShipEnabled { get; set; }
@@ -199,14 +181,14 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.DeliveryDate")]
public string DeliveryDateId { get; set; }
- public IList<SelectListItem> AvailableDeliveryDates { get; set; }
+ public IList<SelectListItem> AvailableDeliveryDates { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.IsTaxExempt")]
public bool IsTaxExempt { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.TaxCategory")]
public string TaxCategoryId { get; set; }
- public IList<SelectListItem> AvailableTaxCategories { get; set; }
+ public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.IsTelecommunicationsOrBroadcastingOrElectronicServices")]
public bool IsTele { get; set; }
@@ -219,7 +201,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Warehouse")]
public string WarehouseId { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.StockQuantity")]
public int StockQuantity { get; set; }
@@ -308,12 +290,13 @@ namespace Grand.Web.Admin.Models.Catalog
public double BasepriceAmount { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.BasepriceUnit")]
public string BasepriceUnitId { get; set; }
- public IList<SelectListItem> AvailableBasepriceUnits { get; set; }
+ public IList<SelectListItem> AvailableBasepriceUnits { get; set; } = new List<SelectListItem>();
+
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.BasepriceBaseAmount")]
public double BasepriceBaseAmount { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.BasepriceBaseUnit")]
public string BasepriceBaseUnitId { get; set; }
- public IList<SelectListItem> AvailableBasepriceBaseUnits { get; set; }
+ public IList<SelectListItem> AvailableBasepriceBaseUnits { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.MarkAsNew")]
public bool MarkAsNew { get; set; }
@@ -326,7 +309,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Unit")]
public string UnitId { get; set; }
- public IList<SelectListItem> AvailableUnits { get; set; }
+ public IList<SelectListItem> AvailableUnits { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.Fields.Weight")]
public double Weight { get; set; }
@@ -376,7 +359,7 @@ namespace Grand.Web.Admin.Models.Catalog
public string BaseDimensionIn { get; set; }
public string BaseWeightIn { get; set; }
- public IList<ProductLocalizedModel> Locales { get; set; }
+ public IList<ProductLocalizedModel> Locales { get; set; } = new List<ProductLocalizedModel>();
//ACL (customer groups)
[UIHint("CustomerGroups")]
@@ -389,11 +372,11 @@ namespace Grand.Web.Admin.Models.Catalog
public string[] Stores { get; set; }
//product attributes
- public IList<SelectListItem> AvailableProductAttributes { get; set; }
+ public IList<SelectListItem> AvailableProductAttributes { get; set; } = new List<SelectListItem>();
//pictures
- public ProductPictureModel AddPictureModel { get; set; }
- public IList<ProductPictureModel> ProductPictureModels { get; set; }
+ public ProductPictureModel AddPictureModel { get; set; } = new();
+ public IList<ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductPictureModel>();
//discounts
public List<DiscountModel> AvailableDiscounts { get; set; }
@@ -401,22 +384,15 @@ namespace Grand.Web.Admin.Models.Catalog
//multiple warehouses
[GrandResourceDisplayName("Admin.Catalog.Products.ProductWarehouseInventory")]
- public IList<ProductWarehouseInventoryModel> ProductWarehouseInventoryModels { get; set; }
+ public IList<ProductWarehouseInventoryModel> ProductWarehouseInventoryModels { get; set; } = new List<ProductWarehouseInventoryModel>();
//copy product
- public CopyProductModel CopyProductModel { get; set; }
+ public CopyProductModel CopyProductModel { get; set; } = new();
#region Nested classes
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -436,9 +412,9 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
}
public class AddRequiredProductModel : AddProductModel
{
@@ -447,12 +423,6 @@ namespace Grand.Web.Admin.Models.Catalog
public class AddProductSpecificationAttributeModel : BaseModel
{
- public AddProductSpecificationAttributeModel()
- {
- AvailableAttributes = new List<SelectListItem>();
- AvailableOptions = new List<SelectListItem>();
- }
-
public string Id { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.SpecificationAttributes.Fields.SpecificationAttribute")]
@@ -480,17 +450,12 @@ namespace Grand.Web.Admin.Models.Catalog
public int DisplayOrder { get; set; }
public string ProductId { get; set; }
- public IList<SelectListItem> AvailableAttributes { get; set; }
- public IList<SelectListItem> AvailableOptions { get; set; }
+ public IList<SelectListItem> AvailableAttributes { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableOptions { get; set; } = new List<SelectListItem>();
}
public class ProductPictureModel : BaseEntityModel, ILocalizedModel<ProductPictureModel.ProductPictureLocalizedModel>
{
- public ProductPictureModel()
- {
- Locales = new List<ProductPictureLocalizedModel>();
- }
-
public string ProductId { get; set; }
[UIHint("MultiPicture")]
@@ -515,7 +480,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.Pictures.Fields.ExtraField")]
public string ExtraField { get; set; }
- public IList<ProductPictureLocalizedModel> Locales { get; set; }
+ public IList<ProductPictureLocalizedModel> Locales { get; set; } = new List<ProductPictureLocalizedModel>();
public class ProductPictureLocalizedModel : ILocalizedModelLocal
{
@@ -675,28 +640,21 @@ namespace Grand.Web.Admin.Models.Catalog
public class TierPriceModel : BaseEntityModel
{
-
- public TierPriceModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableCustomerGroups = new List<SelectListItem>();
- AvailableCurrencies = new List<SelectListItem>();
- }
public string ProductId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.TierPrices.Fields.CustomerGroup")]
public string CustomerGroupId { get; set; }
- public IList<SelectListItem> AvailableCustomerGroups { get; set; }
+ public IList<SelectListItem> AvailableCustomerGroups { get; set; } = new List<SelectListItem>();
public string CustomerGroup { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.TierPrices.Fields.Store")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
public string Store { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.TierPrices.Fields.CurrencyCode")]
public string CurrencyCode { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.TierPrices.Fields.Quantity")]
public int Quantity { get; set; }
@@ -820,16 +778,12 @@ namespace Grand.Web.Admin.Models.Catalog
public class ProductAttributeMappingModel : BaseEntityModel
{
- public ProductAttributeMappingModel()
- {
- AvailableProductAttribute = new List<SelectListItem>();
- }
public string ProductId { get; set; }
public string ProductAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.Attributes.Fields.Attribute")]
public string ProductAttribute { get; set; }
- public IList<SelectListItem> AvailableProductAttribute { get; set; }
+ public IList<SelectListItem> AvailableProductAttribute { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.Attributes.Fields.TextPrompt")]
public string TextPrompt { get; set; }
@@ -894,12 +848,6 @@ namespace Grand.Web.Admin.Models.Catalog
public class ProductAttributeValueModel : BaseEntityModel, ILocalizedModel<ProductAttributeValueLocalizedModel>
{
- public ProductAttributeValueModel()
- {
- ProductPictureModels = new List<ProductPictureModel>();
- Locales = new List<ProductAttributeValueLocalizedModel>();
- }
-
public string ProductAttributeMappingId { get; set; }
public string ProductId { get; set; }
@@ -956,8 +904,8 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Picture")]
public string PictureThumbnailUrl { get; set; }
- public IList<ProductPictureModel> ProductPictureModels { get; set; }
- public IList<ProductAttributeValueLocalizedModel> Locales { get; set; }
+ public IList<ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductPictureModel>();
+ public IList<ProductAttributeValueLocalizedModel> Locales { get; set; } = new List<ProductAttributeValueLocalizedModel>();
#region Nested classes
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductReviewListModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductReviewListModel.cs
index 993c4aa34..f43655b25 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductReviewListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductReviewListModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductReviewListModel : BaseModel
{
- public ProductReviewListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.ProductReviews.List.CreatedOnFrom")]
[UIHint("DateNullable")]
public DateTime? CreatedOnFrom { get; set; }
@@ -30,6 +25,6 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.ProductReviews.List.SearchProduct")]
public string SearchProductId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/ProductTagModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/ProductTagModel.cs
index a6697cfbf..4091979d6 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/ProductTagModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/ProductTagModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class ProductTagModel : BaseEntityModel, ILocalizedModel<ProductTagLocalizedModel>
{
- public ProductTagModel()
- {
- Locales = new List<ProductTagLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Catalog.ProductTags.Fields.Name")]
public string Name { get; set; }
@@ -17,7 +13,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.ProductTags.Fields.ProductCount")]
public int ProductCount { get; set; }
- public IList<ProductTagLocalizedModel> Locales { get; set; }
+ public IList<ProductTagLocalizedModel> Locales { get; set; } = new List<ProductTagLocalizedModel>();
}
public class ProductTagLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeModel.cs
index 939a39bb7..479722ec6 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeModel.cs
@@ -8,11 +8,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class SpecificationAttributeModel : BaseEntityModel, ILocalizedModel<SpecificationAttributeLocalizedModel>, IStoreLinkModel
{
- public SpecificationAttributeModel()
- {
- Locales = new List<SpecificationAttributeLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Attributes.SpecificationAttributes.Fields.Name")]
public string Name { get; set; }
@@ -27,7 +22,7 @@ namespace Grand.Web.Admin.Models.Catalog
[UIHint("Stores")]
public string[] Stores { get; set; }
- public IList<SpecificationAttributeLocalizedModel> Locales { get; set; }
+ public IList<SpecificationAttributeLocalizedModel> Locales { get; set; } = new List<SpecificationAttributeLocalizedModel>();
public class UsedByProductModel : BaseEntityModel
{
diff --git a/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeOptionModel.cs b/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeOptionModel.cs
index 6c9ad692b..007caf9dc 100644
--- a/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeOptionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Catalog/SpecificationAttributeOptionModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Catalog
{
public class SpecificationAttributeOptionModel : BaseEntityModel, ILocalizedModel<SpecificationAttributeOptionLocalizedModel>
{
- public SpecificationAttributeOptionModel()
- {
- Locales = new List<SpecificationAttributeOptionLocalizedModel>();
- }
-
public string SpecificationAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Attributes.SpecificationAttributes.Options.Fields.Name")]
@@ -30,8 +25,7 @@ namespace Grand.Web.Admin.Models.Catalog
[GrandResourceDisplayName("Admin.Catalog.Attributes.SpecificationAttributes.Options.Fields.NumberOfAssociatedProducts")]
public int NumberOfAssociatedProducts { get; set; }
- public IList<SpecificationAttributeOptionLocalizedModel> Locales { get; set; }
-
+ public IList<SpecificationAttributeOptionLocalizedModel> Locales { get; set; } = new List<SpecificationAttributeOptionLocalizedModel>();
}
public class SpecificationAttributeOptionLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeModel.cs
index d59262a8f..cabc2630d 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class AddressAttributeModel : BaseEntityModel, ILocalizedModel<AddressAttributeLocalizedModel>
{
- public AddressAttributeModel()
- {
- Locales = new List<AddressAttributeLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Address.AddressAttributes.Fields.Name")]
public string Name { get; set; }
@@ -28,8 +23,7 @@ namespace Grand.Web.Admin.Models.Common
public int DisplayOrder { get; set; }
- public IList<AddressAttributeLocalizedModel> Locales { get; set; }
-
+ public IList<AddressAttributeLocalizedModel> Locales { get; set; } = new List<AddressAttributeLocalizedModel>();
}
public class AddressAttributeLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeValueModel.cs b/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeValueModel.cs
index a86442bcc..d2e14e7c3 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeValueModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/AddressAttributeValueModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class AddressAttributeValueModel : BaseEntityModel, ILocalizedModel<AddressAttributeValueLocalizedModel>
{
- public AddressAttributeValueModel()
- {
- Locales = new List<AddressAttributeValueLocalizedModel>();
- }
-
public string AddressAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Address.AddressAttributes.Values.Fields.Name")]
@@ -23,8 +18,7 @@ namespace Grand.Web.Admin.Models.Common
[GrandResourceDisplayName("Admin.Address.AddressAttributes.Values.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<AddressAttributeValueLocalizedModel> Locales { get; set; }
-
+ public IList<AddressAttributeValueLocalizedModel> Locales { get; set; } = new List<AddressAttributeValueLocalizedModel>();
}
public class AddressAttributeValueLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Common/AddressModel.cs b/src/Web/Grand.Web.Admin/Models/Common/AddressModel.cs
index 07eb77f33..a7b107d54 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/AddressModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/AddressModel.cs
@@ -11,13 +11,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class AddressModel : BaseEntityModel
{
- public AddressModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- CustomAddressAttributes = new List<AddressAttributeModel>();
- }
-
[GrandResourceDisplayName("Admin.Address.Fields.AddressName")]
public string Name { get; set; }
@@ -76,13 +69,13 @@ namespace Grand.Web.Admin.Models.Common
//formatted custom address attributes
public string FormattedCustomAddressAttributes { get; set; }
- public IList<AddressAttributeModel> CustomAddressAttributes { get; set; }
+ public IList<AddressAttributeModel> CustomAddressAttributes { get; set; } = new List<AddressAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public bool NameEnabled { get; set; }
@@ -120,11 +113,6 @@ namespace Grand.Web.Admin.Models.Common
public class AddressAttributeModel : BaseEntityModel
{
- public AddressAttributeModel()
- {
- Values = new List<AddressAttributeValueModel>();
- }
-
public string Name { get; set; }
public bool IsRequired { get; set; }
@@ -136,7 +124,7 @@ namespace Grand.Web.Admin.Models.Common
public AttributeControlType AttributeControlType { get; set; }
- public IList<AddressAttributeValueModel> Values { get; set; }
+ public IList<AddressAttributeValueModel> Values { get; set; } = new List<AddressAttributeValueModel>();
}
public class AddressAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Admin/Models/Common/LanguageSelectorModel.cs b/src/Web/Grand.Web.Admin/Models/Common/LanguageSelectorModel.cs
index e7d8db832..de2d9aacd 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/LanguageSelectorModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/LanguageSelectorModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Admin.Models.Common
{
public class LanguageSelectorModel : BaseModel
{
- public LanguageSelectorModel()
- {
- AvailableLanguages = new List<LanguageModel>();
- }
-
- public IList<LanguageModel> AvailableLanguages { get; set; }
+ public IList<LanguageModel> AvailableLanguages { get; set; } = new List<LanguageModel>();
public LanguageModel CurrentLanguage { get; set; }
}
diff --git a/src/Web/Grand.Web.Admin/Models/Common/LoginModel.cs b/src/Web/Grand.Web.Admin/Models/Common/LoginModel.cs
index daf4d05c0..6624982db 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/LoginModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/LoginModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class LoginModel : BaseModel
{
- public LoginModel()
- {
- Captcha = new CaptchaModel();
- }
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.Login.Fields.Email")]
public string Email { get; set; }
@@ -26,6 +22,6 @@ namespace Grand.Web.Admin.Models.Common
public bool RememberMe { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Common/MaintenanceModel.cs b/src/Web/Grand.Web.Admin/Models/Common/MaintenanceModel.cs
index 2433a65c8..862761a58 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/MaintenanceModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/MaintenanceModel.cs
@@ -6,18 +6,10 @@ namespace Grand.Web.Admin.Models.Common
{
public class MaintenanceModel : BaseModel
{
- public MaintenanceModel()
- {
- DeleteGuests = new DeleteGuestsModel();
- DeleteAbandonedCarts = new DeleteAbandonedCartsModel();
- DeleteExportedFiles = new DeleteExportedFilesModel();
- ConvertedPictureModel = new ConvertPictureModel { NumberOfConvertItems = -1 };
- }
-
- public DeleteGuestsModel DeleteGuests { get; set; }
- public DeleteAbandonedCartsModel DeleteAbandonedCarts { get; set; }
- public DeleteExportedFilesModel DeleteExportedFiles { get; set; }
- public ConvertPictureModel ConvertedPictureModel { get; set; }
+ public DeleteGuestsModel DeleteGuests { get; set; } = new();
+ public DeleteAbandonedCartsModel DeleteAbandonedCarts { get; set; } = new();
+ public DeleteExportedFilesModel DeleteExportedFiles { get; set; } = new();
+ public ConvertPictureModel ConvertedPictureModel { get; set; } = new() { NumberOfConvertItems = -1 };
#region Nested classes
diff --git a/src/Web/Grand.Web.Admin/Models/Common/PictureModel.cs b/src/Web/Grand.Web.Admin/Models/Common/PictureModel.cs
index f295cad1b..56374d86c 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/PictureModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/PictureModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class PictureModel : BaseEntityModel, ILocalizedModel<PictureModel.PictureLocalizedModel>
{
- public PictureModel()
- {
- Locales = new List<PictureLocalizedModel>();
- }
public string ObjectId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Picture")]
@@ -28,7 +24,7 @@ namespace Grand.Web.Admin.Models.Common
[GrandResourceDisplayName("Admin.Catalog.Picture.Fields.ExtraField")]
public string ExtraField { get; set; }
- public IList<PictureLocalizedModel> Locales { get; set; }
+ public IList<PictureLocalizedModel> Locales { get; set; } = new List<PictureLocalizedModel>();
public class PictureLocalizedModel : ILocalizedModelLocal
{
diff --git a/src/Web/Grand.Web.Admin/Models/Common/SystemInfoModel.cs b/src/Web/Grand.Web.Admin/Models/Common/SystemInfoModel.cs
index d2872c17e..42a9708fc 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/SystemInfoModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/SystemInfoModel.cs
@@ -5,13 +5,6 @@ namespace Grand.Web.Admin.Models.Common
{
public class SystemInfoModel : BaseModel
{
- public SystemInfoModel()
- {
- ServerVariables = new List<ServerVariableModel>();
- LoadedAssemblies = new List<LoadedAssembly>();
- SystemWarnings = new List<SystemWarningModel>();
- }
-
[GrandResourceDisplayName("Admin.System.SystemInfo.ASPNETInfo")]
public string AspNetInfo { get; set; }
@@ -58,12 +51,12 @@ namespace Grand.Web.Admin.Models.Common
public bool IsHttps { get; set; }
[GrandResourceDisplayName("Admin.System.SystemInfo.ServerVariables")]
- public IList<ServerVariableModel> ServerVariables { get; set; }
+ public IList<ServerVariableModel> ServerVariables { get; set; } = new List<ServerVariableModel>();
[GrandResourceDisplayName("Admin.System.SystemInfo.LoadedAssemblies")]
- public IList<LoadedAssembly> LoadedAssemblies { get; set; }
+ public IList<LoadedAssembly> LoadedAssemblies { get; set; } = new List<LoadedAssembly>();
- public IList<SystemWarningModel> SystemWarnings { get; set; }
+ public IList<SystemWarningModel> SystemWarnings { get; set; } = new List<SystemWarningModel>();
public class ServerVariableModel : BaseModel
{
diff --git a/src/Web/Grand.Web.Admin/Models/Common/UrlEntityListModel.cs b/src/Web/Grand.Web.Admin/Models/Common/UrlEntityListModel.cs
index 99807ab4e..b5ced0c9e 100644
--- a/src/Web/Grand.Web.Admin/Models/Common/UrlEntityListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/UrlEntityListModel.cs
@@ -6,16 +6,11 @@ namespace Grand.Web.Admin.Models.Common
{
public class UrlEntityListModel : BaseModel
{
- public UrlEntityListModel()
- {
- AvailableActiveOptions = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("admin.configuration.senames.Name")]
public string SeName { get; set; }
[GrandResourceDisplayName("admin.configuration.senames.Active")]
public int SearchActiveId { get; set; }
- public IList<SelectListItem> AvailableActiveOptions { get; set; }
+ public IList<SelectListItem> AvailableActiveOptions { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Courses/CourseLessonModel.cs b/src/Web/Grand.Web.Admin/Models/Courses/CourseLessonModel.cs
index ebb2115f3..196e5b6a6 100644
--- a/src/Web/Grand.Web.Admin/Models/Courses/CourseLessonModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Courses/CourseLessonModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Admin.Models.Courses
{
public class CourseLessonModel : BaseEntityModel
{
- public CourseLessonModel()
- {
- AvailableSubjects = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Courses.Course.Lesson.Fields.Name")]
public string Name { get; set; }
@@ -28,7 +23,7 @@ namespace Grand.Web.Admin.Models.Courses
[GrandResourceDisplayName("Admin.Courses.Course.Lesson.Fields.SubjectId")]
public string SubjectId { get; set; }
- public IList<SelectListItem> AvailableSubjects { get; set; }
+ public IList<SelectListItem> AvailableSubjects { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Courses.Course.Lesson.Fields.VideoFile")]
[UIHint("Download")]
diff --git a/src/Web/Grand.Web.Admin/Models/Courses/CourseModel.cs b/src/Web/Grand.Web.Admin/Models/Courses/CourseModel.cs
index 7ad4932c5..81b4bbc02 100644
--- a/src/Web/Grand.Web.Admin/Models/Courses/CourseModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Courses/CourseModel.cs
@@ -9,12 +9,6 @@ namespace Grand.Web.Admin.Models.Courses
{
public class CourseModel : BaseEntityModel, ILocalizedModel<CourseLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public CourseModel()
- {
- Locales = new List<CourseLocalizedModel>();
- AvailableLevels = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Courses.Course.Fields.Name")]
public string Name { get; set; }
@@ -36,7 +30,7 @@ namespace Grand.Web.Admin.Models.Courses
[GrandResourceDisplayName("Admin.Courses.Course.Fields.LevelId")]
public string LevelId { get; set; }
- public IList<SelectListItem> AvailableLevels { get; set; }
+ public IList<SelectListItem> AvailableLevels { get; set; } = new List<SelectListItem>();
//ACL
[UIHint("CustomerGroups")]
@@ -63,7 +57,7 @@ namespace Grand.Web.Admin.Models.Courses
public string SeName { get; set; }
- public IList<CourseLocalizedModel> Locales { get; set; }
+ public IList<CourseLocalizedModel> Locales { get; set; } = new List<CourseLocalizedModel>();
[GrandResourceDisplayName("Admin.Courses.Course.Fields.ProductId")]
public string ProductId { get; set; }
@@ -73,13 +67,6 @@ namespace Grand.Web.Admin.Models.Courses
public class AssociateProductToCourseModel : BaseModel
{
- public AssociateProductToCourseModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -99,9 +86,9 @@ namespace Grand.Web.Admin.Models.Courses
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string AssociatedToProductId { get; set; }
}
#endregion
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/BestCustomersReportModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/BestCustomersReportModel.cs
index 8c08973db..da040bb63 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/BestCustomersReportModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/BestCustomersReportModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Admin.Models.Customers
{
public class BestCustomersReportModel : BaseModel
{
- public BestCustomersReportModel()
- {
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableShippingStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Reports.Customers.BestBy.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -31,8 +24,8 @@ namespace Grand.Web.Admin.Models.Customers
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableShippingStatuses { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableShippingStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeModel.cs
index 3f0d80821..66eff97cb 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Customers
{
public class CustomerAttributeModel : BaseEntityModel, ILocalizedModel<CustomerAttributeLocalizedModel>
{
- public CustomerAttributeModel()
- {
- Locales = new List<CustomerAttributeLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Fields.Name")]
public string Name { get; set; }
@@ -30,8 +25,7 @@ namespace Grand.Web.Admin.Models.Customers
public int DisplayOrder { get; set; }
- public IList<CustomerAttributeLocalizedModel> Locales { get; set; }
-
+ public IList<CustomerAttributeLocalizedModel> Locales { get; set; } = new List<CustomerAttributeLocalizedModel>();
}
public class CustomerAttributeLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeValueModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeValueModel.cs
index 629dcb40a..4b4b8dbd6 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeValueModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerAttributeValueModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Customers
{
public class CustomerAttributeValueModel : BaseEntityModel, ILocalizedModel<CustomerAttributeValueLocalizedModel>
{
- public CustomerAttributeValueModel()
- {
- Locales = new List<CustomerAttributeValueLocalizedModel>();
- }
-
public string CustomerAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Values.Fields.Name")]
@@ -23,8 +18,7 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Customers.CustomerAttributes.Values.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<CustomerAttributeValueLocalizedModel> Locales { get; set; }
-
+ public IList<CustomerAttributeValueLocalizedModel> Locales { get; set; } = new List<CustomerAttributeValueLocalizedModel>();
}
public class CustomerAttributeValueLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupPermissionModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupPermissionModel.cs
index 7bb14a2b0..9ec316182 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupPermissionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupPermissionModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Admin.Models.Customers
{
public class CustomerGroupPermissionModel : BaseEntityModel
{
- public CustomerGroupPermissionModel()
- {
- Actions = new List<string>();
- }
[GrandResourceDisplayName("Admin.Customers.CustomerGroups.Acl.Fields.Name")]
public string Name { get; set; }
@@ -18,6 +14,6 @@ namespace Grand.Web.Admin.Models.Customers
public bool Access { get; set; }
[GrandResourceDisplayName("Admin.Customers.CustomerGroups.Acl.Fields.Actions")]
- public IList<string> Actions { get; set; }
+ public IList<string> Actions { get; set; } = new List<string>();
}
}
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupProductModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupProductModel.cs
index 437562ee9..0734514fb 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupProductModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerGroupProductModel.cs
@@ -20,13 +20,6 @@ namespace Grand.Web.Admin.Models.Customers
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -46,9 +39,9 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string CustomerGroupId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerListModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerListModel.cs
index 356004dd2..0168b6442 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerListModel.cs
@@ -7,29 +7,21 @@ namespace Grand.Web.Admin.Models.Customers
{
public class CustomerListModel : BaseModel
{
- public CustomerListModel()
- {
- AvailableCustomerTags = new List<SelectListItem>();
- SearchCustomerTagIds = new List<string>();
- SearchCustomerGroupIds = new List<string>();
- AvailableCustomerGroups = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Customers.Customers.List.CustomerGroups")]
- public IList<SelectListItem> AvailableCustomerGroups { get; set; }
+ public IList<SelectListItem> AvailableCustomerGroups { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Customers.Customers.List.CustomerGroups")]
[UIHint("MultiSelect")]
- public IList<string> SearchCustomerGroupIds { get; set; }
+ public IList<string> SearchCustomerGroupIds { get; set; } = new List<string>();
[GrandResourceDisplayName("Admin.Customers.Customers.List.CustomerTags")]
- public IList<SelectListItem> AvailableCustomerTags { get; set; }
+ public IList<SelectListItem> AvailableCustomerTags { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Customers.Customers.List.CustomerTags")]
[UIHint("MultiSelect")]
- public IList<string> SearchCustomerTagIds { get; set; }
+ public IList<string> SearchCustomerTagIds { get; set; } = new List<string>();
[GrandResourceDisplayName("Admin.Customers.Customers.List.SearchEmail")]
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerModel.cs
index 930599bec..ef9a2fa0a 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerModel.cs
@@ -12,20 +12,6 @@ namespace Grand.Web.Admin.Models.Customers
{
public class CustomerModel : BaseEntityModel
{
- public CustomerModel()
- {
- SendEmail = new SendEmailModel { SendImmediately = true };
- AssociatedExternalAuthRecords = new List<AssociatedExternalAuthModel>();
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- AvailableSalesEmployees = new List<SelectListItem>();
- CustomerAttributes = new List<CustomerAttributeModel>();
- AvailableNewsletterSubscriptionStores = new List<StoreModel>();
- LoyaltyPointsAvailableStores = new List<SelectListItem>();
- Attributes = new List<CustomAttribute>();
- }
-
public bool AllowUsersToChangeUsernames { get; set; }
public bool UsernamesEnabled { get; set; }
@@ -57,11 +43,11 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.SeId")]
public string SeId { get; set; }
- public IList<SelectListItem> AvailableSalesEmployees { get; set; }
+ public IList<SelectListItem> AvailableSalesEmployees { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.StaffStore")]
public string StaffStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
//form fields & properties
public bool GenderEnabled { get; set; }
@@ -111,13 +97,13 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.Country")]
public string CountryId { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
public bool StateProvinceEnabled { get; set; }
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.StateProvince")]
public string StateProvinceId { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public bool PhoneEnabled { get; set; }
@@ -129,8 +115,8 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.Fax")]
public string Fax { get; set; }
- public List<CustomerAttributeModel> CustomerAttributes { get; set; }
-
+ public List<CustomerAttributeModel> CustomerAttributes { get; set; } = new();
+
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
@@ -155,7 +141,7 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.Affiliate")]
public string AffiliateName { get; set; }
- public IList<CustomAttribute> Attributes { get; set; }
+ public IList<CustomAttribute> Attributes { get; set; } = new List<CustomAttribute>();
//EU VAT
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.VatNumber")]
@@ -189,7 +175,7 @@ namespace Grand.Web.Admin.Models.Customers
//newsletter subscriptions (per store)
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.Newsletter")]
- public List<StoreModel> AvailableNewsletterSubscriptionStores { get; set; }
+ public List<StoreModel> AvailableNewsletterSubscriptionStores { get; set; } = new();
[GrandResourceDisplayName("Admin.Customers.Customers.Fields.Newsletter")]
public string[] SelectedNewsletterSubscriptionStoreIds { get; set; }
@@ -207,10 +193,10 @@ namespace Grand.Web.Admin.Models.Customers
public string AddLoyaltyPointsStoreId { get; set; }
[GrandResourceDisplayName("Admin.Customers.Customers.LoyaltyPoints.Fields.AddLoyaltyPointsStore")]
- public IList<SelectListItem> LoyaltyPointsAvailableStores { get; set; }
+ public IList<SelectListItem> LoyaltyPointsAvailableStores { get; set; } = new List<SelectListItem>();
//send email model
- public SendEmailModel SendEmail { get; set; }
+ public SendEmailModel SendEmail { get; set; } = new() { SendImmediately = true };
//send the welcome message
public bool AllowSendingOfWelcomeMessage { get; set; }
@@ -220,7 +206,8 @@ namespace Grand.Web.Admin.Models.Customers
//external auth
[GrandResourceDisplayName("Admin.Customers.Customers.AssociatedExternalAuth")]
- public IList<AssociatedExternalAuthModel> AssociatedExternalAuthRecords { get; set; }
+ public IList<AssociatedExternalAuthModel> AssociatedExternalAuthRecords { get; set; } = new List<AssociatedExternalAuthModel>();
+
//customer notes
[GrandResourceDisplayName("Admin.Customers.CustomerNotes.Fields.DisplayToCustomer")]
public bool AddCustomerNoteDisplayToCustomer { get; set; }
@@ -324,13 +311,6 @@ namespace Grand.Web.Admin.Models.Customers
}
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -350,9 +330,9 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string CustomerId { get; set; }
@@ -373,11 +353,6 @@ namespace Grand.Web.Admin.Models.Customers
public class CustomerAttributeModel : BaseEntityModel
{
- public CustomerAttributeModel()
- {
- Values = new List<CustomerAttributeValueModel>();
- }
-
public string Name { get; set; }
public bool IsRequired { get; set; }
@@ -389,8 +364,7 @@ namespace Grand.Web.Admin.Models.Customers
public AttributeControlType AttributeControlType { get; set; }
- public IList<CustomerAttributeValueModel> Values { get; set; }
-
+ public IList<CustomerAttributeValueModel> Values { get; set; } = new List<CustomerAttributeValueModel>();
}
public class CustomerAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Admin/Models/Customers/CustomerTagProductModel.cs b/src/Web/Grand.Web.Admin/Models/Customers/CustomerTagProductModel.cs
index 56e909916..51c1567f7 100644
--- a/src/Web/Grand.Web.Admin/Models/Customers/CustomerTagProductModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Customers/CustomerTagProductModel.cs
@@ -18,13 +18,6 @@ namespace Grand.Web.Admin.Models.Customers
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -45,9 +38,9 @@ namespace Grand.Web.Admin.Models.Customers
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string CustomerTagId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Directory/CountryModel.cs b/src/Web/Grand.Web.Admin/Models/Directory/CountryModel.cs
index 7d63a678d..0a6f42f4b 100644
--- a/src/Web/Grand.Web.Admin/Models/Directory/CountryModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Directory/CountryModel.cs
@@ -8,10 +8,6 @@ namespace Grand.Web.Admin.Models.Directory
{
public class CountryModel : BaseEntityModel, ILocalizedModel<CountryLocalizedModel>, IStoreLinkModel
{
- public CountryModel()
- {
- Locales = new List<CountryLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Configuration.Countries.Fields.Name")]
public string Name { get; set; }
@@ -46,7 +42,7 @@ namespace Grand.Web.Admin.Models.Directory
[GrandResourceDisplayName("Admin.Configuration.Countries.Fields.NumberOfStates")]
public int NumberOfStates { get; set; }
- public IList<CountryLocalizedModel> Locales { get; set; }
+ public IList<CountryLocalizedModel> Locales { get; set; } = new List<CountryLocalizedModel>();
//Store acl
[GrandResourceDisplayName("Admin.Configuration.Countries.Fields.LimitedToStores")]
diff --git a/src/Web/Grand.Web.Admin/Models/Directory/CurrencyModel.cs b/src/Web/Grand.Web.Admin/Models/Directory/CurrencyModel.cs
index f54bb77b2..0ffdf734e 100644
--- a/src/Web/Grand.Web.Admin/Models/Directory/CurrencyModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Directory/CurrencyModel.cs
@@ -8,10 +8,6 @@ namespace Grand.Web.Admin.Models.Directory
{
public class CurrencyModel : BaseEntityModel, ILocalizedModel<CurrencyLocalizedModel>, IStoreLinkModel
{
- public CurrencyModel()
- {
- Locales = new List<CurrencyLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Configuration.Currencies.Fields.Name")]
public string Name { get; set; }
@@ -49,7 +45,7 @@ namespace Grand.Web.Admin.Models.Directory
[GrandResourceDisplayName("Admin.Configuration.Currencies.Fields.IsPrimaryStoreCurrency")]
public bool IsPrimaryStoreCurrency { get; set; }
- public IList<CurrencyLocalizedModel> Locales { get; set; }
+ public IList<CurrencyLocalizedModel> Locales { get; set; } = new List<CurrencyLocalizedModel>();
[GrandResourceDisplayName("Admin.Configuration.Currencies.Fields.RoundingType")]
public int RoundingTypeId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Directory/StateProvinceModel.cs b/src/Web/Grand.Web.Admin/Models/Directory/StateProvinceModel.cs
index 07ef382fe..4670f7b53 100644
--- a/src/Web/Grand.Web.Admin/Models/Directory/StateProvinceModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Directory/StateProvinceModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Directory
{
public class StateProvinceModel : BaseEntityModel, ILocalizedModel<StateProvinceLocalizedModel>
{
- public StateProvinceModel()
- {
- Locales = new List<StateProvinceLocalizedModel>();
- }
public string CountryId { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Countries.States.Fields.Name")]
@@ -26,7 +22,7 @@ namespace Grand.Web.Admin.Models.Directory
[GrandResourceDisplayName("Admin.Configuration.Countries.States.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<StateProvinceLocalizedModel> Locales { get; set; }
+ public IList<StateProvinceLocalizedModel> Locales { get; set; } = new List<StateProvinceLocalizedModel>();
}
public class StateProvinceLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Discounts/DiscountListModel.cs b/src/Web/Grand.Web.Admin/Models/Discounts/DiscountListModel.cs
index d2c3e0d0c..c8034fe1c 100644
--- a/src/Web/Grand.Web.Admin/Models/Discounts/DiscountListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Discounts/DiscountListModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Discounts
{
public class DiscountListModel : BaseModel
{
- public DiscountListModel()
- {
- AvailableDiscountTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("admin.marketing.Discounts.List.SearchDiscountCouponCode")]
public string SearchDiscountCouponCode { get; set; }
@@ -21,6 +16,6 @@ namespace Grand.Web.Admin.Models.Discounts
[GrandResourceDisplayName("admin.marketing.Discounts.List.SearchDiscountType")]
public int SearchDiscountTypeId { get; set; }
- public IList<SelectListItem> AvailableDiscountTypes { get; set; }
+ public IList<SelectListItem> AvailableDiscountTypes { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Discounts/DiscountModel.cs b/src/Web/Grand.Web.Admin/Models/Discounts/DiscountModel.cs
index f78a9cd76..ce86bc3b8 100644
--- a/src/Web/Grand.Web.Admin/Models/Discounts/DiscountModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Discounts/DiscountModel.cs
@@ -8,14 +8,6 @@ namespace Grand.Web.Admin.Models.Discounts
{
public class DiscountModel : BaseEntityModel, IStoreLinkModel
{
- public DiscountModel()
- {
- AvailableDiscountRequirementRules = new List<SelectListItem>();
- DiscountRequirementMetaInfos = new List<DiscountRequirementMetaInfo>();
- AvailableDiscountAmountProviders = new List<SelectListItem>();
- AvailableCurrencies = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("admin.marketing.Discounts.Fields.Name")]
public string Name { get; set; }
@@ -39,7 +31,7 @@ namespace Grand.Web.Admin.Models.Discounts
[GrandResourceDisplayName("admin.marketing.Discounts.Fields.CurrencyCode")]
public string CurrencyCode { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Discounts.Fields.CalculateByPlugin")]
public bool CalculateByPlugin { get; set; }
@@ -85,9 +77,9 @@ namespace Grand.Web.Admin.Models.Discounts
[GrandResourceDisplayName("admin.marketing.Discounts.Requirements.DiscountRequirementType")]
public string AddDiscountRequirement { get; set; }
- public IList<SelectListItem> AvailableDiscountRequirementRules { get; set; }
- public IList<DiscountRequirementMetaInfo> DiscountRequirementMetaInfos { get; set; }
- public IList<SelectListItem> AvailableDiscountAmountProviders { get; set; }
+ public IList<SelectListItem> AvailableDiscountRequirementRules { get; set; } = new List<SelectListItem>();
+ public IList<DiscountRequirementMetaInfo> DiscountRequirementMetaInfos { get; set; } = new List<DiscountRequirementMetaInfo>();
+ public IList<SelectListItem> AvailableDiscountAmountProviders { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Discounts.Fields.IsEnabled")]
public bool IsEnabled { get; set; }
@@ -161,13 +153,6 @@ namespace Grand.Web.Admin.Models.Discounts
}
public class AddProductToDiscountModel : BaseModel
{
- public AddProductToDiscountModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -187,9 +172,9 @@ namespace Grand.Web.Admin.Models.Discounts
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string DiscountId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Documents/DocumentModel.cs b/src/Web/Grand.Web.Admin/Models/Documents/DocumentModel.cs
index 8ceeaf540..dd0eb4e12 100644
--- a/src/Web/Grand.Web.Admin/Models/Documents/DocumentModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Documents/DocumentModel.cs
@@ -8,12 +8,6 @@ namespace Grand.Web.Admin.Models.Documents
{
public class DocumentModel : BaseEntityModel, IGroupLinkModel, IStoreLinkModel
{
- public DocumentModel()
- {
- AvailableDocumentTypes = new List<SelectListItem>();
- AvailableSelesEmployees = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Documents.Document.Fields.Number")]
public string Number { get; set; }
@@ -22,7 +16,7 @@ namespace Grand.Web.Admin.Models.Documents
[GrandResourceDisplayName("Admin.Documents.Document.Fields.SeId")]
public string SeId { get; set; }
- public IList<SelectListItem> AvailableSelesEmployees { get; set; }
+ public IList<SelectListItem> AvailableSelesEmployees { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Documents.Document.Fields.Description")]
public string Description { get; set; }
@@ -62,7 +56,7 @@ namespace Grand.Web.Admin.Models.Documents
[GrandResourceDisplayName("Admin.Documents.Document.Fields.DocumentType")]
public string DocumentTypeId { get; set; }
- public IList<SelectListItem> AvailableDocumentTypes { get; set; }
+ public IList<SelectListItem> AvailableDocumentTypes { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Documents.Document.Fields.CustomerEmail")]
public string CustomerEmail { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseArticleModel.cs b/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseArticleModel.cs
index d5c760898..bc2ca74ee 100644
--- a/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseArticleModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseArticleModel.cs
@@ -9,12 +9,6 @@ namespace Grand.Web.Admin.Models.Knowledgebase
{
public class KnowledgebaseArticleModel : BaseEntityModel, ILocalizedModel<KnowledgebaseArticleLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public KnowledgebaseArticleModel()
- {
- Categories = new List<SelectListItem>();
- Locales = new List<KnowledgebaseArticleLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseArticle.Fields.Name")]
public string Name { get; set; }
@@ -48,9 +42,9 @@ namespace Grand.Web.Admin.Models.Knowledgebase
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseArticle.Fields.AllowComments")]
public bool AllowComments { get; set; }
- public List<SelectListItem> Categories { get; set; }
+ public List<SelectListItem> Categories { get; set; } = new();
- public IList<KnowledgebaseArticleLocalizedModel> Locales { get; set; }
+ public IList<KnowledgebaseArticleLocalizedModel> Locales { get; set; } = new List<KnowledgebaseArticleLocalizedModel>();
//ACL
[UIHint("CustomerGroups")]
@@ -63,11 +57,6 @@ namespace Grand.Web.Admin.Models.Knowledgebase
public class AddRelatedArticleModel : BaseEntityModel
{
- public AddRelatedArticleModel()
- {
- AvailableArticles = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseArticle.Related.SearchArticleName")]
public string SearchArticleName { get; set; }
@@ -75,7 +64,7 @@ namespace Grand.Web.Admin.Models.Knowledgebase
public string[] SelectedArticlesIds { get; set; }
- public IList<SelectListItem> AvailableArticles { get; set; }
+ public IList<SelectListItem> AvailableArticles { get; set; } = new List<SelectListItem>();
}
}
diff --git a/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseCategoryModel.cs b/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseCategoryModel.cs
index addd8db74..0d980895d 100644
--- a/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseCategoryModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Knowledgebase/KnowledgebaseCategoryModel.cs
@@ -9,12 +9,6 @@ namespace Grand.Web.Admin.Models.Knowledgebase
{
public class KnowledgebaseCategoryModel : BaseEntityModel, ILocalizedModel<KnowledgebaseCategoryLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public KnowledgebaseCategoryModel()
- {
- Categories = new List<SelectListItem>();
- Locales = new List<KnowledgebaseCategoryLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Name")]
public string Name { get; set; }
@@ -30,9 +24,9 @@ namespace Grand.Web.Admin.Models.Knowledgebase
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Published")]
public bool Published { get; set; }
- public List<SelectListItem> Categories { get; set; }
+ public List<SelectListItem> Categories { get; set; } = new();
- public IList<KnowledgebaseCategoryLocalizedModel> Locales { get; set; }
+ public IList<KnowledgebaseCategoryLocalizedModel> Locales { get; set; } = new List<KnowledgebaseCategoryLocalizedModel>();
[UIHint("CustomerGroups")]
[GrandResourceDisplayName("Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.LimitedToGroups")]
diff --git a/src/Web/Grand.Web.Admin/Models/Localization/LanguageModel.cs b/src/Web/Grand.Web.Admin/Models/Localization/LanguageModel.cs
index 32d38742f..542d83875 100644
--- a/src/Web/Grand.Web.Admin/Models/Localization/LanguageModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Localization/LanguageModel.cs
@@ -8,12 +8,6 @@ namespace Grand.Web.Admin.Models.Localization
{
public class LanguageModel : BaseEntityModel, IStoreLinkModel
{
- public LanguageModel()
- {
- FlagFileNames = new List<string>();
- AvailableCurrencies = new List<SelectListItem>();
- Search = new LanguageResourceFilterModel();
- }
[GrandResourceDisplayName("Admin.Configuration.Languages.Fields.Name")]
public string Name { get; set; }
@@ -30,7 +24,7 @@ namespace Grand.Web.Admin.Models.Localization
[GrandResourceDisplayName("Admin.Configuration.Languages.Fields.FlagImageFileName")]
public string FlagImageFileName { get; set; }
- public IList<string> FlagFileNames { get; set; }
+ public IList<string> FlagFileNames { get; set; } = new List<string>();
[GrandResourceDisplayName("Admin.Configuration.Languages.Fields.Rtl")]
public bool Rtl { get; set; }
@@ -39,7 +33,7 @@ namespace Grand.Web.Admin.Models.Localization
[GrandResourceDisplayName("Admin.Configuration.Languages.Fields.DefaultCurrency")]
public string DefaultCurrencyId { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Configuration.Languages.Fields.Published")]
public bool Published { get; set; }
@@ -53,6 +47,6 @@ namespace Grand.Web.Admin.Models.Localization
[UIHint("Stores")]
public string[] Stores { get; set; }
- public LanguageResourceFilterModel Search { get; set; }
+ public LanguageResourceFilterModel Search { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Menu/MenuModel.cs b/src/Web/Grand.Web.Admin/Models/Menu/MenuModel.cs
index ae176f6ab..a45dd5daa 100644
--- a/src/Web/Grand.Web.Admin/Models/Menu/MenuModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Menu/MenuModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Admin.Models.Menu;
public class MenuModel : BaseEntityModel
{
- public MenuModel()
- {
- PermissionNames = new List<string>();
- }
-
/// <summary>
/// Gets or sets the system name.
/// </summary>
@@ -61,8 +56,8 @@ public class MenuModel : BaseEntityModel
/// <summary>
/// Gets or sets permissions
/// </summary>
- public IList<string> PermissionNames { get; set; }
-
+ public IList<string> PermissionNames { get; set; } = new List<string>();
+
/// <summary>
/// Gets or sets all permissions
/// </summary>
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/CampaignModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/CampaignModel.cs
index 62ffd2adf..8857a48c8 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/CampaignModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/CampaignModel.cs
@@ -7,18 +7,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class CampaignModel : BaseEntityModel
{
- public CampaignModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableLanguages = new List<SelectListItem>();
- AvailableCustomerTags = new List<SelectListItem>();
- CustomerTags = new List<string>();
- NewsletterCategories = new List<string>();
- AvailableCustomerGroups = new List<SelectListItem>();
- CustomerGroups = new List<string>();
- AvailableEmailAccounts = new List<EmailAccountModel>();
- }
-
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.Name")]
public string Name { get; set; }
@@ -33,11 +21,11 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.Store")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.Language")]
public string LanguageId { get; set; }
- public IList<SelectListItem> AvailableLanguages { get; set; }
+ public IList<SelectListItem> AvailableLanguages { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.CustomerCreatedDateFrom")]
@@ -72,24 +60,25 @@ namespace Grand.Web.Admin.Models.Messages
public DateTime CreatedOn { get; set; }
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.CustomerTags")]
- public IList<SelectListItem> AvailableCustomerTags { get; set; }
+ public IList<SelectListItem> AvailableCustomerTags { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.CustomerTags")]
[UIHint("MultiSelect")]
- public IList<string> CustomerTags { get; set; }
+ public IList<string> CustomerTags { get; set; } = new List<string>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.NewsletterCategory")]
[UIHint("MultiSelect")]
- public IList<string> NewsletterCategories { get; set; }
+ public IList<string> NewsletterCategories { get; set; } = new List<string>();
+
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.NewsletterCategory")]
public IList<SelectListItem> AvailableNewsletterCategories { get; set; }
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.CustomerGroups")]
- public IList<SelectListItem> AvailableCustomerGroups { get; set; }
+ public IList<SelectListItem> AvailableCustomerGroups { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.CustomerGroups")]
[UIHint("MultiSelect")]
- public IList<string> CustomerGroups { get; set; }
+ public IList<string> CustomerGroups { get; set; } = new List<string>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.AllowedTokens")]
@@ -97,7 +86,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.EmailAccount")]
public string EmailAccountId { get; set; }
- public IList<EmailAccountModel> AvailableEmailAccounts { get; set; }
+ public IList<EmailAccountModel> AvailableEmailAccounts { get; set; } = new List<EmailAccountModel>();
[GrandResourceDisplayName("admin.marketing.Campaigns.Fields.TestEmail")]
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeModel.cs
index b3ac0f2d6..6223dc5cb 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeModel.cs
@@ -10,11 +10,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class ContactAttributeModel : BaseEntityModel, ILocalizedModel<ContactAttributeLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public ContactAttributeModel()
- {
- Locales = new List<ContactAttributeLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Attributes.ContactAttributes.Fields.Name")]
public string Name { get; set; }
@@ -54,7 +49,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("Admin.Catalog.Attributes.ContactAttributes.Fields.DefaultValue")]
public string DefaultValue { get; set; }
- public IList<ContactAttributeLocalizedModel> Locales { get; set; }
+ public IList<ContactAttributeLocalizedModel> Locales { get; set; } = new List<ContactAttributeLocalizedModel>();
//condition
public bool ConditionAllowed { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeValueModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeValueModel.cs
index 354c8ed33..5596b8d12 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeValueModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/ContactAttributeValueModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class ContactAttributeValueModel : BaseEntityModel, ILocalizedModel<ContactAttributeValueLocalizedModel>
{
- public ContactAttributeValueModel()
- {
- Locales = new List<ContactAttributeValueLocalizedModel>();
- }
-
public string ContactAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Catalog.Attributes.ContactAttributes.Values.Fields.Name")]
@@ -26,8 +21,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("Admin.Catalog.Attributes.ContactAttributes.Values.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<ContactAttributeValueLocalizedModel> Locales { get; set; }
-
+ public IList<ContactAttributeValueLocalizedModel> Locales { get; set; } = new List<ContactAttributeValueLocalizedModel>();
}
public class ContactAttributeValueLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/ContactFormListModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/ContactFormListModel.cs
index 0f8a692bb..0cd246bdc 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/ContactFormListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/ContactFormListModel.cs
@@ -7,10 +7,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class ContactFormListModel : BaseModel
{
- public ContactFormListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
[GrandResourceDisplayName("Admin.System.ContactForm.List.StartDate")]
[UIHint("DateNullable")]
public DateTime? SearchStartDate { get; set; }
@@ -25,7 +21,6 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("Admin.System.ContactForm.List.Store")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
-
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateListModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateListModel.cs
index 3f368cf93..5fb1db145 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateListModel.cs
@@ -6,14 +6,10 @@ namespace Grand.Web.Admin.Models.Messages
{
public class MessageTemplateListModel : BaseModel
{
- public MessageTemplateListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
[GrandResourceDisplayName("Admin.Content.MessageTemplates.List.Name")]
public string Name { get; set; }
[GrandResourceDisplayName("Admin.Content.MessageTemplates.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateModel.cs
index bc67b4581..f6efec6bf 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/MessageTemplateModel.cs
@@ -8,13 +8,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class MessageTemplateModel : BaseEntityModel, ILocalizedModel<MessageTemplateLocalizedModel>, IStoreLinkModel
{
- public MessageTemplateModel()
- {
- Locales = new List<MessageTemplateLocalizedModel>();
- AvailableEmailAccounts = new List<EmailAccountModel>();
- }
-
-
[GrandResourceDisplayName("Admin.Content.MessageTemplates.Fields.AllowedTokens")]
public string[] AllowedTokens { get; set; }
@@ -52,7 +45,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("Admin.Content.MessageTemplates.Fields.EmailAccount")]
public string EmailAccountId { get; set; }
- public IList<EmailAccountModel> AvailableEmailAccounts { get; set; }
+ public IList<EmailAccountModel> AvailableEmailAccounts { get; set; } = new List<EmailAccountModel>();
//Store acl
[GrandResourceDisplayName("Admin.Content.MessageTemplates.Fields.LimitedToStores")]
@@ -64,7 +57,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("Admin.Content.MessageTemplates.Fields.LimitedToStores")]
public string ListOfStores { get; set; }
- public IList<MessageTemplateLocalizedModel> Locales { get; set; }
+ public IList<MessageTemplateLocalizedModel> Locales { get; set; } = new List<MessageTemplateLocalizedModel>();
}
public class MessageTemplateLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/NewsLetterSubscriptionListModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/NewsLetterSubscriptionListModel.cs
index fa019be95..a37284a47 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/NewsLetterSubscriptionListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/NewsLetterSubscriptionListModel.cs
@@ -7,33 +7,24 @@ namespace Grand.Web.Admin.Models.Messages
{
public class NewsLetterSubscriptionListModel : BaseModel
{
- public NewsLetterSubscriptionListModel()
- {
- AvailableStores = new List<SelectListItem>();
- ActiveList = new List<SelectListItem>();
- SearchCategoryIds = new List<string>();
- AvailableCategories = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.SearchEmail")]
public string SearchEmail { get; set; }
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.SearchStore")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.SearchActive")]
public int ActiveId { get; set; }
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.SearchActive")]
- public IList<SelectListItem> ActiveList { get; set; }
+ public IList<SelectListItem> ActiveList { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.Categories")]
- public IList<SelectListItem> AvailableCategories { get; set; }
+ public IList<SelectListItem> AvailableCategories { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("admin.marketing.NewsLetterSubscriptions.List.Category")]
[UIHint("MultiSelect")]
- public IList<string> SearchCategoryIds { get; set; }
-
+ public IList<string> SearchCategoryIds { get; set; } = new List<string>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Messages/NewsletterCategoryModel.cs b/src/Web/Grand.Web.Admin/Models/Messages/NewsletterCategoryModel.cs
index 6d75e4c88..d68734897 100644
--- a/src/Web/Grand.Web.Admin/Models/Messages/NewsletterCategoryModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Messages/NewsletterCategoryModel.cs
@@ -8,11 +8,6 @@ namespace Grand.Web.Admin.Models.Messages
{
public class NewsletterCategoryModel : BaseEntityModel, ILocalizedModel<NewsletterCategoryLocalizedModel>, IStoreLinkModel
{
- public NewsletterCategoryModel()
- {
- Locales = new List<NewsletterCategoryLocalizedModel>();
- }
-
[GrandResourceDisplayName("admin.marketing.NewsletterCategory.Fields.Name")]
public string Name { get; set; }
@@ -30,7 +25,7 @@ namespace Grand.Web.Admin.Models.Messages
[GrandResourceDisplayName("admin.marketing.NewsletterCategory.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<NewsletterCategoryLocalizedModel> Locales { get; set; }
+ public IList<NewsletterCategoryLocalizedModel> Locales { get; set; } = new List<NewsletterCategoryLocalizedModel>();
}
public class NewsletterCategoryLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/News/NewsItemListModel.cs b/src/Web/Grand.Web.Admin/Models/News/NewsItemListModel.cs
index fbbc78371..c4e4d1f71 100644
--- a/src/Web/Grand.Web.Admin/Models/News/NewsItemListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/News/NewsItemListModel.cs
@@ -6,13 +6,8 @@ namespace Grand.Web.Admin.Models.News
{
public class NewsItemListModel : BaseModel
{
- public NewsItemListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Content.News.NewsItems.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/News/NewsItemModel.cs b/src/Web/Grand.Web.Admin/Models/News/NewsItemModel.cs
index 9dddabfab..f5f5552ab 100644
--- a/src/Web/Grand.Web.Admin/Models/News/NewsItemModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/News/NewsItemModel.cs
@@ -8,11 +8,6 @@ namespace Grand.Web.Admin.Models.News
{
public class NewsItemModel : BaseEntityModel, ILocalizedModel<NewsLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public NewsItemModel()
- {
- Locales = new List<NewsLocalizedModel>();
- }
-
//Store acl
[GrandResourceDisplayName("Admin.Content.News.NewsItems.Fields.LimitedToStores")]
[UIHint("Stores")]
@@ -54,7 +49,7 @@ namespace Grand.Web.Admin.Models.News
[GrandResourceDisplayName("Admin.Content.News.NewsItems.Fields.SeName")]
public string SeName { get; set; }
- public IList<NewsLocalizedModel> Locales { get; set; }
+ public IList<NewsLocalizedModel> Locales { get; set; } = new List<NewsLocalizedModel>();
[GrandResourceDisplayName("Admin.Content.News.NewsItems.Fields.Published")]
public bool Published { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/AddShipmentModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/AddShipmentModel.cs
index db92e9b33..9ed91bb93 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/AddShipmentModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/AddShipmentModel.cs
@@ -2,17 +2,12 @@
public class AddShipmentModel
{
- public AddShipmentModel()
- {
- Items = new List<ShipmentItemModel>();
- }
-
public string OrderId { get; set; }
public string TrackingNumber { get; set; }
public string AdminComment { get; set; }
- public IList<ShipmentItemModel> Items { get; set; }
-
+ public IList<ShipmentItemModel> Items { get; set; } = new List<ShipmentItemModel>();
+
public class ShipmentItemModel
{
public string OrderItemId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/BestsellersReportModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/BestsellersReportModel.cs
index cb2b84055..f7848c01d 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/BestsellersReportModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/BestsellersReportModel.cs
@@ -7,16 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class BestsellersReportModel : BaseModel
{
- public BestsellersReportModel()
- {
- AvailableStores = new List<SelectListItem>();
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
-
- }
-
[GrandResourceDisplayName("Admin.Reports.Bestsellers.Store")]
public string StoreId { get; set; }
@@ -38,11 +28,11 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Reports.Bestsellers.Vendor")]
public string VendorId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeModel.cs
index f23f925ed..eaff5d7bc 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeModel.cs
@@ -10,12 +10,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class CheckoutAttributeModel : BaseEntityModel, ILocalizedModel<CheckoutAttributeLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public CheckoutAttributeModel()
- {
- Locales = new List<CheckoutAttributeLocalizedModel>();
- AvailableTaxCategories = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Fields.Name")]
public string Name { get; set; }
@@ -35,7 +29,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Fields.TaxCategory")]
public string TaxCategoryId { get; set; }
- public IList<SelectListItem> AvailableTaxCategories { get; set; }
+ public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Fields.AttributeControlType")]
public int AttributeControlTypeId { get; set; }
@@ -65,7 +59,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Fields.DefaultValue")]
public string DefaultValue { get; set; }
- public IList<CheckoutAttributeLocalizedModel> Locales { get; set; }
+ public IList<CheckoutAttributeLocalizedModel> Locales { get; set; } = new List<CheckoutAttributeLocalizedModel>();
//condition
public bool ConditionAllowed { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeValueModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeValueModel.cs
index d71a32a53..ef07d420e 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeValueModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/CheckoutAttributeValueModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class CheckoutAttributeValueModel : BaseEntityModel, ILocalizedModel<CheckoutAttributeValueLocalizedModel>
{
- public CheckoutAttributeValueModel()
- {
- Locales = new List<CheckoutAttributeValueLocalizedModel>();
- }
-
public string CheckoutAttributeId { get; set; }
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Values.Fields.Name")]
@@ -36,8 +31,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.CheckoutAttributes.Values.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<CheckoutAttributeValueLocalizedModel> Locales { get; set; }
-
+ public IList<CheckoutAttributeValueLocalizedModel> Locales { get; set; } = new List<CheckoutAttributeValueLocalizedModel>();
}
public class CheckoutAttributeValueLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/CountryReportModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/CountryReportModel.cs
index c20ab11a2..562e11403 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/CountryReportModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/CountryReportModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class CountryReportModel : BaseModel
{
- public CountryReportModel()
- {
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Reports.Country.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -27,7 +21,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Reports.Country.PaymentStatus")]
public int PaymentStatusId { get; set; }
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherListModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherListModel.cs
index ffbbd1088..f0b36e1de 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherListModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class GiftVoucherListModel : BaseModel
{
- public GiftVoucherListModel()
- {
- ActivatedList = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.GiftVouchers.List.CouponCode")]
public string CouponCode { get; set; }
@@ -22,6 +17,6 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.GiftVouchers.List.Activated")]
public int ActivatedId { get; set; }
[GrandResourceDisplayName("Admin.GiftVouchers.List.Activated")]
- public IList<SelectListItem> ActivatedList { get; set; }
+ public IList<SelectListItem> ActivatedList { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherModel.cs
index b15948a49..0d049672c 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/GiftVoucherModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class GiftVoucherModel : BaseEntityModel
{
- public GiftVoucherModel()
- {
- AvailableCurrencies = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- }
[GrandResourceDisplayName("Admin.GiftVouchers.Fields.GiftVoucherType")]
public int GiftVoucherTypeId { get; set; }
@@ -24,12 +19,12 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.GiftVouchers.Fields.CurrencyCode")]
public string CurrencyCode { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.GiftVouchers.Fields.StoreId")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.GiftVouchers.Fields.Amount")]
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnListModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnListModel.cs
index 55c8783d0..893381b2f 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnListModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class MerchandiseReturnListModel : BaseModel
{
- public MerchandiseReturnListModel()
- {
- MerchandiseReturnStatus = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Orders.MerchandiseReturns.List.SearchCustomerEmail")]
public string SearchCustomerEmail { get; set; }
@@ -31,6 +26,6 @@ namespace Grand.Web.Admin.Models.Orders
public string StoreId { get; set; }
- public IList<SelectListItem> MerchandiseReturnStatus { get; set; }
+ public IList<SelectListItem> MerchandiseReturnStatus { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnModel.cs
index b45de168d..0ac43920d 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/MerchandiseReturnModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class MerchandiseReturnModel : BaseEntityModel
{
- public MerchandiseReturnModel()
- {
- Items = new List<MerchandiseReturnItemModel>();
- }
-
[GrandResourceDisplayName("Admin.Orders.MerchandiseReturns.Fields.ID")]
public override string Id { get; set; }
@@ -57,7 +52,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.MerchandiseReturns.Fields.PickupAddress")]
public AddressModel PickupAddress { get; set; }
- public List<MerchandiseReturnItemModel> Items { get; set; }
+ public List<MerchandiseReturnItemModel> Items { get; set; } = new();
[GrandResourceDisplayName("Admin.Orders.MerchandiseReturns.NotifyCustomer")]
public bool NotifyCustomer { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/OrderListModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/OrderListModel.cs
index 1f2a9b7d1..1bb3504a7 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/OrderListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/OrderListModel.cs
@@ -7,19 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class OrderListModel : BaseModel
{
- public OrderListModel()
- {
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableShippingStatuses = new List<SelectListItem>();
- AvailableStores = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailablePaymentMethods = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- AvailableOrderTags = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Orders.List.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -78,14 +65,14 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.List.OrderTagId")]
public string OrderTag { get; set; }
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableShippingStatuses { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
- public IList<SelectListItem> AvailablePaymentMethods { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableOrderTags { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableShippingStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentMethods { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableOrderTags { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/OrderModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/OrderModel.cs
index cbb0f545f..5981adb3c 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/OrderModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/OrderModel.cs
@@ -11,16 +11,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class OrderModel : BaseEntityModel
{
- public OrderModel()
- {
- CustomValues = new Dictionary<string, object>();
- TaxRates = new List<TaxRate>();
- GiftVouchers = new List<GiftVoucher>();
- Items = new List<OrderItemModel>();
- UsedDiscounts = new List<UsedDiscountModel>();
- OrderStatuses = new List<SelectListItem>();
- }
-
//identifiers
[GrandResourceDisplayName("Admin.Orders.Fields.ID")]
public override string Id { get; set; }
@@ -51,7 +41,7 @@ namespace Grand.Web.Admin.Models.Orders
public string UrlReferrer { get; set; }
[GrandResourceDisplayName("Admin.Orders.Fields.CustomValues")]
- public Dictionary<string, object> CustomValues { get; set; }
+ public Dictionary<string, object> CustomValues { get; set; } = new();
[GrandResourceDisplayName("Admin.Orders.Fields.Affiliate")]
public string AffiliateId { get; set; }
@@ -65,7 +55,7 @@ namespace Grand.Web.Admin.Models.Orders
//Used discounts
[GrandResourceDisplayName("Admin.Orders.Fields.UsedDiscounts")]
- public IList<UsedDiscountModel> UsedDiscounts { get; set; }
+ public IList<UsedDiscountModel> UsedDiscounts { get; set; } = new List<UsedDiscountModel>();
//totals
public TaxDisplayType TaxDisplayType { get; set; }
@@ -87,7 +77,7 @@ namespace Grand.Web.Admin.Models.Orders
public string PaymentMethodAdditionalFeeExclTax { get; set; }
[GrandResourceDisplayName("Admin.Orders.Fields.Tax")]
public string Tax { get; set; }
- public IList<TaxRate> TaxRates { get; set; }
+ public IList<TaxRate> TaxRates { get; set; } = new List<TaxRate>();
public bool DisplayTax { get; set; }
public bool DisplayTaxRates { get; set; }
[GrandResourceDisplayName("Admin.Orders.Fields.OrderTotalDiscount")]
@@ -141,7 +131,8 @@ namespace Grand.Web.Admin.Models.Orders
public string OrderStatus { get; set; }
[GrandResourceDisplayName("Admin.Orders.Fields.OrderStatus")]
public int OrderStatusId { get; set; }
- public IList<SelectListItem> OrderStatuses { get; set; }
+ public IList<SelectListItem> OrderStatuses { get; set; } = new List<SelectListItem>();
+
//payment info
[GrandResourceDisplayName("Admin.Orders.Fields.PaymentStatus")]
public string PaymentStatus { get; set; }
@@ -174,11 +165,11 @@ namespace Grand.Web.Admin.Models.Orders
public string VatNumber { get; set; }
//gift vouchers
- public IList<GiftVoucher> GiftVouchers { get; set; }
+ public IList<GiftVoucher> GiftVouchers { get; set; } = new List<GiftVoucher>();
//items
public bool HasDownloadableProducts { get; set; }
- public IList<OrderItemModel> Items { get; set; }
+ public IList<OrderItemModel> Items { get; set; } = new List<OrderItemModel>();
//creation date
[GrandResourceDisplayName("Admin.Orders.Fields.CreatedOn")]
@@ -217,11 +208,6 @@ namespace Grand.Web.Admin.Models.Orders
public class OrderItemModel : BaseEntityModel
{
- public OrderItemModel()
- {
- MerchandiseReturnIds = new List<string>();
- PurchasedGiftVoucherIds = new List<string>();
- }
public string ProductId { get; set; }
public string ProductName { get; set; }
public string VendorName { get; set; }
@@ -253,8 +239,8 @@ namespace Grand.Web.Admin.Models.Orders
public string AttributeInfo { get; set; }
public string RecurringInfo { get; set; }
public string RentalInfo { get; set; }
- public IList<string> MerchandiseReturnIds { get; set; }
- public IList<string> PurchasedGiftVoucherIds { get; set; }
+ public IList<string> MerchandiseReturnIds { get; set; } = new List<string>();
+ public IList<string> PurchasedGiftVoucherIds { get; set; } = new List<string>();
public bool IsDownload { get; set; }
public int DownloadCount { get; set; }
@@ -309,11 +295,6 @@ namespace Grand.Web.Admin.Models.Orders
public class AddOrderProductModel : BaseModel
{
- public AddOrderProductModel()
- {
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -330,7 +311,7 @@ namespace Grand.Web.Admin.Models.Orders
public int SearchProductTypeId { get; set; }
public IList<SelectListItem> AvailableCollections { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
public string OrderId { get; set; }
public int OrderNumber { get; set; }
@@ -349,13 +330,6 @@ namespace Grand.Web.Admin.Models.Orders
public class ProductDetailsModel : BaseModel
{
- public ProductDetailsModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- GiftVoucher = new GiftVoucherModel();
- Warnings = new List<string>();
- }
-
public string ProductId { get; set; }
public string OrderId { get; set; }
@@ -377,21 +351,16 @@ namespace Grand.Web.Admin.Models.Orders
public double TaxRate { get; set; }
//product attributes
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
- //gift voucher info
- public GiftVoucherModel GiftVoucher { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
- public List<string> Warnings { get; set; }
+ //gift voucher info
+ public GiftVoucherModel GiftVoucher { get; set; } = new();
+ public List<string> Warnings { get; set; } = new();
}
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductAttributeId { get; set; }
public string Name { get; set; }
@@ -402,7 +371,7 @@ namespace Grand.Web.Admin.Models.Orders
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/OrderTagModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/OrderTagModel.cs
index 0aca606b1..943bc8b96 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/OrderTagModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/OrderTagModel.cs
@@ -6,17 +6,12 @@ namespace Grand.Web.Admin.Models.Orders
{
public class OrderTagModel : BaseEntityModel, ILocalizedModel<OrderTagLocalizedModel>
{
- public OrderTagModel()
- {
- Locales = new List<OrderTagLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Orders.OrderTags.Fields.Name")]
public string Name { get; set; }
[GrandResourceDisplayName("Admin.Orders.OrderTags.Fields.OrderCount")]
public int OrderCount { get; set; }
- public IList<OrderTagLocalizedModel> Locales { get; set; }
+ public IList<OrderTagLocalizedModel> Locales { get; set; } = new List<OrderTagLocalizedModel>();
}
public class OrderTagLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/PaymentTransactionListModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/PaymentTransactionListModel.cs
index 91633fb12..97495cca8 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/PaymentTransactionListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/PaymentTransactionListModel.cs
@@ -7,17 +7,11 @@ namespace Grand.Web.Admin.Models.Orders
{
public class PaymentTransactionListModel : BaseModel
{
- public PaymentTransactionListModel()
- {
- PaymentTransactionStatus = new List<SelectListItem>();
- SearchTransactionStatus = -1;
- }
-
[GrandResourceDisplayName("Admin.Orders.PaymentTransaction.List.SearchCustomerEmail")]
public string SearchCustomerEmail { get; set; }
[GrandResourceDisplayName("Admin.Orders.PaymentTransaction.List.SearchTransactionStatus")]
- public int SearchTransactionStatus { get; set; }
+ public int SearchTransactionStatus { get; set; } = -1;
[GrandResourceDisplayName("Admin.Orders.PaymentTransaction.List.OrderNumber")]
public string OrderNumber { get; set; }
@@ -32,6 +26,6 @@ namespace Grand.Web.Admin.Models.Orders
public string StoreId { get; set; }
- public IList<SelectListItem> PaymentTransactionStatus { get; set; }
+ public IList<SelectListItem> PaymentTransactionStatus { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentListModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentListModel.cs
index d1e58e69d..14d69b3fa 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentListModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class ShipmentListModel : BaseModel
{
- public ShipmentListModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Orders.Shipments.List.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -26,11 +19,13 @@ namespace Grand.Web.Admin.Models.Orders
public string TrackingNumber { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+
[GrandResourceDisplayName("Admin.Orders.Shipments.List.Country")]
public string CountryId { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
+
[GrandResourceDisplayName("Admin.Orders.Shipments.List.StateProvince")]
public int StateProvinceId { get; set; }
@@ -44,7 +39,7 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.Shipments.List.Warehouse")]
public string WarehouseId { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
public string StoreId { get; set; }
public string VendorId { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
index c98ec72e6..1db9efb1e 100644
--- a/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Orders/ShipmentModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Orders
{
public class ShipmentModel : BaseEntityModel
{
- public ShipmentModel()
- {
- ShipmentStatusEvents = new List<ShipmentStatusEventModel>();
- Items = new List<ShipmentItemModel>();
- }
[GrandResourceDisplayName("Admin.Orders.Shipments.ID")]
public override string Id { get; set; }
public int ShipmentNumber { get; set; }
@@ -38,9 +33,9 @@ namespace Grand.Web.Admin.Models.Orders
[GrandResourceDisplayName("Admin.Orders.Shipments.AdminComment")]
public string AdminComment { get; set; }
- public List<ShipmentItemModel> Items { get; set; }
+ public List<ShipmentItemModel> Items { get; set; } = new();
- public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; }
+ public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; } = new List<ShipmentStatusEventModel>();
//shipment notes
[GrandResourceDisplayName("Admin.Orders.Shipments.ShipmentNotes.Fields.DisplayToCustomer")]
@@ -58,11 +53,6 @@ namespace Grand.Web.Admin.Models.Orders
public class ShipmentItemModel : BaseEntityModel
{
- public ShipmentItemModel()
- {
- AvailableWarehouses = new List<WarehouseInfo>();
- }
-
public string OrderItemId { get; set; }
public string ProductId { get; set; }
[GrandResourceDisplayName("Admin.Orders.Shipments.Products.ProductName")]
@@ -87,7 +77,7 @@ namespace Grand.Web.Admin.Models.Orders
public string ShippedFromWarehouse { get; set; }
public bool AllowToChooseWarehouse { get; set; }
//used before a shipment is created
- public List<WarehouseInfo> AvailableWarehouses { get; set; }
+ public List<WarehouseInfo> AvailableWarehouses { get; set; } = new();
public string WarehouseId { get; set; }
#region Nested Classes
diff --git a/src/Web/Grand.Web.Admin/Models/Pages/PageListModel.cs b/src/Web/Grand.Web.Admin/Models/Pages/PageListModel.cs
index c76b0645d..4108c61dd 100644
--- a/src/Web/Grand.Web.Admin/Models/Pages/PageListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Pages/PageListModel.cs
@@ -6,15 +6,11 @@ namespace Grand.Web.Admin.Models.Pages
{
public class PageListModel : BaseModel
{
- public PageListModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
[GrandResourceDisplayName("Admin.Content.Pages.List.Name")]
public string Name { get; set; }
[GrandResourceDisplayName("Admin.Content.Pages.List.SearchStore")]
public string SearchStoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Pages/PageModel.cs b/src/Web/Grand.Web.Admin/Models/Pages/PageModel.cs
index d39ccbc32..bdff10c65 100644
--- a/src/Web/Grand.Web.Admin/Models/Pages/PageModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Pages/PageModel.cs
@@ -9,12 +9,6 @@ namespace Grand.Web.Admin.Models.Pages
{
public class PageModel : BaseEntityModel, ILocalizedModel<PageLocalizedModel>, IGroupLinkModel, IStoreLinkModel
{
- public PageModel()
- {
- AvailablePageLayouts = new List<SelectListItem>();
- Locales = new List<PageLocalizedModel>();
- }
-
//Store acl
[GrandResourceDisplayName("Admin.Content.Pages.Fields.LimitedToStores")]
[UIHint("Stores")]
@@ -66,7 +60,7 @@ namespace Grand.Web.Admin.Models.Pages
[GrandResourceDisplayName("Admin.Content.Pages.Fields.PageLayout")]
public string PageLayoutId { get; set; }
- public IList<SelectListItem> AvailablePageLayouts { get; set; }
+ public IList<SelectListItem> AvailablePageLayouts { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Content.Pages.Fields.MetaKeywords")]
@@ -84,7 +78,8 @@ namespace Grand.Web.Admin.Models.Pages
public string SeName { get; set; }
- public IList<PageLocalizedModel> Locales { get; set; }
+ public IList<PageLocalizedModel> Locales { get; set; } = new List<PageLocalizedModel>();
+
//ACL
[UIHint("CustomerGroups")]
[GrandResourceDisplayName("Admin.Content.Pages.Fields.LimitedToGroups")]
diff --git a/src/Web/Grand.Web.Admin/Models/Payments/PaymentMethodRestrictionModel.cs b/src/Web/Grand.Web.Admin/Models/Payments/PaymentMethodRestrictionModel.cs
index ac0632514..36c00b111 100644
--- a/src/Web/Grand.Web.Admin/Models/Payments/PaymentMethodRestrictionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Payments/PaymentMethodRestrictionModel.cs
@@ -6,21 +6,13 @@ namespace Grand.Web.Admin.Models.Payments
{
public class PaymentMethodRestrictionModel : BaseModel
{
- public PaymentMethodRestrictionModel()
- {
- AvailablePaymentMethods = new List<PaymentMethodModel>();
- AvailableCountries = new List<CountryModel>();
- AvailableShippingMethods = new List<ShippingMethodModel>();
- Resticted = new Dictionary<string, IDictionary<string, bool>>();
- RestictedShipping = new Dictionary<string, IDictionary<string, bool>>();
- }
- public IList<PaymentMethodModel> AvailablePaymentMethods { get; set; }
- public IList<CountryModel> AvailableCountries { get; set; }
- public IList<ShippingMethodModel> AvailableShippingMethods { get; set; }
+ public IList<PaymentMethodModel> AvailablePaymentMethods { get; set; } = new List<PaymentMethodModel>();
+ public IList<CountryModel> AvailableCountries { get; set; } = new List<CountryModel>();
+ public IList<ShippingMethodModel> AvailableShippingMethods { get; set; } = new List<ShippingMethodModel>();
//[payment method system name] / [resticted]
- public IDictionary<string, IDictionary<string, bool>> Resticted { get; set; }
- public IDictionary<string, IDictionary<string, bool>> RestictedShipping { get; set; }
+ public IDictionary<string, IDictionary<string, bool>> Resticted { get; set; } = new Dictionary<string, IDictionary<string, bool>>();
+ public IDictionary<string, IDictionary<string, bool>> RestictedShipping { get; set; } = new Dictionary<string, IDictionary<string, bool>>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Permissions/PermissionActionModel.cs b/src/Web/Grand.Web.Admin/Models/Permissions/PermissionActionModel.cs
index e4fadccf8..38085a289 100644
--- a/src/Web/Grand.Web.Admin/Models/Permissions/PermissionActionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Permissions/PermissionActionModel.cs
@@ -4,16 +4,11 @@ namespace Grand.Web.Admin.Models.Permissions
{
public class PermissionActionModel : BaseModel
{
- public PermissionActionModel()
- {
- AvailableActions = new List<string>();
- DeniedActions = new List<string>();
- }
public string SystemName { get; set; }
public string PermissionName { get; set; }
public string CustomerGroupId { get; set; }
public string CustomerGroupName { get; set; }
- public IList<string> AvailableActions { get; set; }
- public IList<string> DeniedActions { get; set; }
+ public IList<string> AvailableActions { get; set; } = new List<string>();
+ public IList<string> DeniedActions { get; set; } = new List<string>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Permissions/PermissionMappingModel.cs b/src/Web/Grand.Web.Admin/Models/Permissions/PermissionMappingModel.cs
index 36edaa4e4..afdab7f03 100644
--- a/src/Web/Grand.Web.Admin/Models/Permissions/PermissionMappingModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Permissions/PermissionMappingModel.cs
@@ -5,16 +5,10 @@ namespace Grand.Web.Admin.Models.Permissions
{
public class PermissionMappingModel : BaseModel
{
- public PermissionMappingModel()
- {
- AvailablePermissions = new List<PermissionRecordModel>();
- AvailableCustomerGroups = new List<CustomerGroupModel>();
- Allowed = new Dictionary<string, IDictionary<string, bool>>();
- }
- public IList<PermissionRecordModel> AvailablePermissions { get; set; }
- public IList<CustomerGroupModel> AvailableCustomerGroups { get; set; }
+ public IList<PermissionRecordModel> AvailablePermissions { get; set; } = new List<PermissionRecordModel>();
+ public IList<CustomerGroupModel> AvailableCustomerGroups { get; set; } = new List<CustomerGroupModel>();
//[permission system name] / [customer group id] / [allowed]
- public IDictionary<string, IDictionary<string, bool>> Allowed { get; set; }
+ public IDictionary<string, IDictionary<string, bool>> Allowed { get; set; } = new Dictionary<string, IDictionary<string, bool>>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Plugins/PluginListModel.cs b/src/Web/Grand.Web.Admin/Models/Plugins/PluginListModel.cs
index 6b8ae09ed..14d032180 100644
--- a/src/Web/Grand.Web.Admin/Models/Plugins/PluginListModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Plugins/PluginListModel.cs
@@ -6,14 +6,9 @@ namespace Grand.Web.Admin.Models.Plugins
{
public class PluginListModel : BaseModel
{
- public PluginListModel()
- {
- AvailableLoadModes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Plugins.LoadMode")]
public int SearchLoadModeId { get; set; }
[GrandResourceDisplayName("Admin.Plugins.LoadMode")]
- public IList<SelectListItem> AvailableLoadModes { get; set; }
+ public IList<SelectListItem> AvailableLoadModes { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/ContentSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/ContentSettingsModel.cs
index d08a7b4ab..bc0a7fc1b 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/ContentSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/ContentSettingsModel.cs
@@ -5,18 +5,10 @@ namespace Grand.Web.Admin.Models.Settings
{
public class ContentSettingsModel : BaseModel
{
-
- public ContentSettingsModel()
- {
- BlogSettings = new BlogSettingsModel();
- NewsSettings = new NewsSettingsModel();
- KnowledgebaseSettings = new KnowledgebaseSettingsModel();
-
- }
public string ActiveStore { get; set; }
- public BlogSettingsModel BlogSettings { get; set; }
- public NewsSettingsModel NewsSettings { get; set; }
- public KnowledgebaseSettingsModel KnowledgebaseSettings { get; set; }
+ public BlogSettingsModel BlogSettings { get; set; } = new();
+ public NewsSettingsModel NewsSettings { get; set; } = new();
+ public KnowledgebaseSettingsModel KnowledgebaseSettings { get; set; } = new();
public class BlogSettingsModel : BaseModel
{
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/CustomerSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/CustomerSettingsModel.cs
index 472fa1e7f..1459af041 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/CustomerSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/CustomerSettingsModel.cs
@@ -7,13 +7,8 @@ namespace Grand.Web.Admin.Models.Settings
{
public class CustomerSettingsModel : BaseModel
{
- public CustomerSettingsModel()
- {
- CustomerSettings = new CustomersSettingsModel();
- AddressSettings = new AddressSettingsModel();
- }
- public CustomersSettingsModel CustomerSettings { get; set; }
- public AddressSettingsModel AddressSettings { get; set; }
+ public CustomersSettingsModel CustomerSettings { get; set; } = new();
+ public AddressSettingsModel AddressSettings { get; set; } = new();
#region Nested classes
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
index e75180bac..d73549791 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
@@ -8,42 +8,27 @@ namespace Grand.Web.Admin.Models.Settings
{
public class GeneralCommonSettingsModel : BaseModel
{
- public GeneralCommonSettingsModel()
- {
- StoreInformationSettings = new StoreInformationSettingsModel();
- CommonSettings = new CommonSettingsModel();
- DateTimeSettings = new DateTimeSettingsModel();
- SeoSettings = new SeoSettingsModel();
- SecuritySettings = new SecuritySettingsModel();
- PdfSettings = new PdfSettingsModel();
- DisplayMenuSettings = new DisplayMenuSettingsModel();
- }
public string ActiveStore { get; set; }
- public StoreInformationSettingsModel StoreInformationSettings { get; set; }
- public CommonSettingsModel CommonSettings { get; set; }
- public DateTimeSettingsModel DateTimeSettings { get; set; }
- public SeoSettingsModel SeoSettings { get; set; }
- public SecuritySettingsModel SecuritySettings { get; set; }
- public PdfSettingsModel PdfSettings { get; set; }
- public DisplayMenuSettingsModel DisplayMenuSettings { get; set; }
-
+ public StoreInformationSettingsModel StoreInformationSettings { get; set; } = new();
+ public CommonSettingsModel CommonSettings { get; set; } = new();
+ public DateTimeSettingsModel DateTimeSettings { get; set; } = new();
+ public SeoSettingsModel SeoSettings { get; set; } = new();
+ public SecuritySettingsModel SecuritySettings { get; set; } = new();
+ public PdfSettingsModel PdfSettings { get; set; } = new();
+ public DisplayMenuSettingsModel DisplayMenuSettings { get; set; } = new();
+
#region Nested classes
public class StoreInformationSettingsModel : BaseModel
{
- public StoreInformationSettingsModel()
- {
- this.AvailableStoreThemes = new List<ThemeConfigurationModel>();
- }
-
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.StoreClosed")]
public bool StoreClosed { get; set; }
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.DefaultStoreTheme")]
public string DefaultStoreTheme { get; set; }
- public IList<ThemeConfigurationModel> AvailableStoreThemes { get; set; }
+ public IList<ThemeConfigurationModel> AvailableStoreThemes { get; set; } = new List<ThemeConfigurationModel>();
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.AllowCustomerToSelectTheme")]
public bool AllowCustomerToSelectTheme { get; set; }
@@ -137,16 +122,11 @@ namespace Grand.Web.Admin.Models.Settings
}
public class DateTimeSettingsModel : BaseModel
{
- public DateTimeSettingsModel()
- {
- AvailableTimeZones = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.DefaultStoreTimeZone")]
public string DefaultStoreTimeZoneId { get; set; }
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.DefaultStoreTimeZone")]
- public IList<SelectListItem> AvailableTimeZones { get; set; }
+ public IList<SelectListItem> AvailableTimeZones { get; set; } = new List<SelectListItem>();
}
public class SeoSettingsModel : BaseModel
@@ -208,11 +188,6 @@ namespace Grand.Web.Admin.Models.Settings
public class SecuritySettingsModel : BaseModel
{
- public SecuritySettingsModel()
- {
- this.AvailableReCaptchaVersions = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.AdminAreaAllowedIpAddresses")]
public string AdminAreaAllowedIpAddresses { get; set; }
@@ -273,7 +248,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.reCaptchaVersion")]
public GoogleReCaptchaVersion ReCaptchaVersion { get; set; }
- public IList<SelectListItem> AvailableReCaptchaVersions { get; set; }
+ public IList<SelectListItem> AvailableReCaptchaVersions { get; set; } = new List<SelectListItem>();
}
public class PdfSettingsModel : BaseModel
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnActionModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnActionModel.cs
index b28ab9e32..bc43b9b3f 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnActionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnActionModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Settings
{
public class MerchandiseReturnActionModel : BaseEntityModel, ILocalizedModel<MerchandiseReturnActionLocalizedModel>
{
- public MerchandiseReturnActionModel()
- {
- Locales = new List<MerchandiseReturnActionLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Settings.Order.MerchandiseReturnActions.Name")]
public string Name { get; set; }
@@ -18,7 +13,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.Order.MerchandiseReturnActions.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<MerchandiseReturnActionLocalizedModel> Locales { get; set; }
+ public IList<MerchandiseReturnActionLocalizedModel> Locales { get; set; } = new List<MerchandiseReturnActionLocalizedModel>();
}
public class MerchandiseReturnActionLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnReasonModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnReasonModel.cs
index cf48839af..1baaf14c8 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnReasonModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/MerchandiseReturnReasonModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Admin.Models.Settings
{
public class MerchandiseReturnReasonModel : BaseEntityModel, ILocalizedModel<MerchandiseReturnReasonLocalizedModel>
{
- public MerchandiseReturnReasonModel()
- {
- Locales = new List<MerchandiseReturnReasonLocalizedModel>();
- }
-
[GrandResourceDisplayName("Admin.Settings.Order.MerchandiseReturnReasons.Name")]
public string Name { get; set; }
@@ -18,7 +13,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.Order.MerchandiseReturnReasons.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<MerchandiseReturnReasonLocalizedModel> Locales { get; set; }
+ public IList<MerchandiseReturnReasonLocalizedModel> Locales { get; set; } = new List<MerchandiseReturnReasonLocalizedModel>();
}
public class MerchandiseReturnReasonLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/SalesSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/SalesSettingsModel.cs
index 0bdcd44d7..d9f7e478b 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/SalesSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/SalesSettingsModel.cs
@@ -6,25 +6,13 @@ namespace Grand.Web.Admin.Models.Settings
{
public class SalesSettingsModel : BaseModel
{
- public SalesSettingsModel()
- {
- OrderSettings = new OrderSettingsModel();
- ShoppingCartSettings = new ShoppingCartSettingsModel();
- LoyaltyPointsSettings = new LoyaltyPointsSettingsModel();
- }
-
public string ActiveStore { get; set; }
- public OrderSettingsModel OrderSettings { get; set; }
- public ShoppingCartSettingsModel ShoppingCartSettings { get; set; }
- public LoyaltyPointsSettingsModel LoyaltyPointsSettings { get; set; }
+ public OrderSettingsModel OrderSettings { get; set; } = new();
+ public ShoppingCartSettingsModel ShoppingCartSettings { get; set; } = new();
+ public LoyaltyPointsSettingsModel LoyaltyPointsSettings { get; set; } = new();
public class OrderSettingsModel : BaseModel
{
- public OrderSettingsModel()
- {
- GiftVouchers_Activated_OrderStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Settings.Order.IsReOrderAllowed")]
public bool IsReOrderAllowed { get; set; }
@@ -69,7 +57,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.Order.GiftVouchers_Activated")]
public int GiftVouchers_Activated_OrderStatusId { get; set; }
- public IList<SelectListItem> GiftVouchers_Activated_OrderStatuses { get; set; }
+ public IList<SelectListItem> GiftVouchers_Activated_OrderStatuses { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Settings.Order.DeactivateGiftVouchersAfterCancelOrder")]
public bool DeactivateGiftVouchersAfterCancelOrder { get; set; }
@@ -188,11 +176,6 @@ namespace Grand.Web.Admin.Models.Settings
public class LoyaltyPointsSettingsModel : BaseModel
{
- public LoyaltyPointsSettingsModel()
- {
- PointsForPurchases_Awarded_OrderStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Settings.LoyaltyPoints.Enabled")]
public bool Enabled { get; set; }
@@ -211,7 +194,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.LoyaltyPoints.PointsForPurchases_Awarded")]
public int PointsForPurchases_Awarded { get; set; }
- public IList<SelectListItem> PointsForPurchases_Awarded_OrderStatuses { get; set; }
+ public IList<SelectListItem> PointsForPurchases_Awarded_OrderStatuses { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Settings.LoyaltyPoints.ReduceLoyaltyPointsAfterCancelOrder")]
public bool ReduceLoyaltyPointsAfterCancelOrder { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/StoreScopeModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/StoreScopeModel.cs
index f4f9c7508..fd703dd1d 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/StoreScopeModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/StoreScopeModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Admin.Models.Settings
{
public class StoreScopeModel : BaseModel
{
- public StoreScopeModel()
- {
- Stores = new List<StoreModel>();
- }
-
public string StoreId { get; set; }
- public IList<StoreModel> Stores { get; set; }
+ public IList<StoreModel> Stores { get; set; } = new List<StoreModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs
index 901f197b4..41fe980fa 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs
@@ -5,12 +5,6 @@ namespace Grand.Web.Admin.Models.Settings
{
public class VendorSettingsModel : BaseModel
{
-
- public VendorSettingsModel()
- {
- AddressSettings = new AddressSettingsModel();
- }
-
public string ActiveStore { get; set; }
[GrandResourceDisplayName("Admin.Settings.Vendor.VendorsBlockItemsToDisplay")]
@@ -64,7 +58,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.Vendor.DefaultVendorPageSizeOptions")]
public string DefaultVendorPageSizeOptions { get; set; }
- public AddressSettingsModel AddressSettings { get; set; }
+ public AddressSettingsModel AddressSettings { get; set; } = new();
#region Nested classes
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/DeliveryDateModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/DeliveryDateModel.cs
index 07deab5c2..7dd215e7b 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/DeliveryDateModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/DeliveryDateModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Shipping
{
public class DeliveryDateModel : BaseEntityModel, ILocalizedModel<DeliveryDateLocalizedModel>
{
- public DeliveryDateModel()
- {
- Locales = new List<DeliveryDateLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Configuration.Shipping.DeliveryDates.Fields.Name")]
public string Name { get; set; }
@@ -21,7 +17,7 @@ namespace Grand.Web.Admin.Models.Shipping
public string ColorSquaresRgb { get; set; }
- public IList<DeliveryDateLocalizedModel> Locales { get; set; }
+ public IList<DeliveryDateLocalizedModel> Locales { get; set; } = new List<DeliveryDateLocalizedModel>();
}
public class DeliveryDateLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/PickupPointModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/PickupPointModel.cs
index 1f7670dc8..db1dfdd7b 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/PickupPointModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/PickupPointModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Admin.Models.Shipping
{
public class PickupPointModel : BaseEntityModel
{
- public PickupPointModel()
- {
- this.Address = new AddressModel();
- this.AvailableWarehouses = new List<SelectListItem>();
- this.AvailableStores = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.Name")]
public string Name { get; set; }
@@ -27,18 +20,19 @@ namespace Grand.Web.Admin.Models.Shipping
public string AdminComment { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.Address")]
- public AddressModel Address { get; set; }
+ public AddressModel Address { get; set; } = new();
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.Warehouses")]
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
public string WarehouseId { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.Stores")]
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
+
public string StoreId { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.PickupPoint.Fields.PickupFee")]
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodModel.cs
index b5cd15d24..f50dc9926 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Shipping
{
public class ShippingMethodModel : BaseEntityModel, ILocalizedModel<ShippingMethodLocalizedModel>
{
- public ShippingMethodModel()
- {
- Locales = new List<ShippingMethodLocalizedModel>();
- }
[GrandResourceDisplayName("Admin.Configuration.Shipping.Methods.Fields.Name")]
public string Name { get; set; }
@@ -21,7 +17,7 @@ namespace Grand.Web.Admin.Models.Shipping
[GrandResourceDisplayName("Admin.Configuration.Shipping.Methods.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<ShippingMethodLocalizedModel> Locales { get; set; }
+ public IList<ShippingMethodLocalizedModel> Locales { get; set; } = new List<ShippingMethodLocalizedModel>();
}
public class ShippingMethodLocalizedModel : ILocalizedModelLocal
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodRestrictionModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodRestrictionModel.cs
index fd76c6f9c..28277ad33 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodRestrictionModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/ShippingMethodRestrictionModel.cs
@@ -6,20 +6,12 @@ namespace Grand.Web.Admin.Models.Shipping
{
public class ShippingMethodRestrictionModel : BaseModel
{
- public ShippingMethodRestrictionModel()
- {
- AvailableShippingMethods = new List<ShippingMethodModel>();
- AvailableCountries = new List<CountryModel>();
- AvailableCustomerGroups = new List<CustomerGroupModel>();
- Restricted = new Dictionary<string, IDictionary<string, bool>>();
- RestictedGroup = new Dictionary<string, IDictionary<string, bool>>();
- }
- public IList<ShippingMethodModel> AvailableShippingMethods { get; set; }
- public IList<CountryModel> AvailableCountries { get; set; }
- public IList<CustomerGroupModel> AvailableCustomerGroups { get; set; }
+ public IList<ShippingMethodModel> AvailableShippingMethods { get; set; } = new List<ShippingMethodModel>();
+ public IList<CountryModel> AvailableCountries { get; set; } = new List<CountryModel>();
+ public IList<CustomerGroupModel> AvailableCustomerGroups { get; set; } = new List<CustomerGroupModel>();
//[country id] / [shipping method id] / [restricted]
- public IDictionary<string, IDictionary<string, bool>> Restricted { get; set; }
- public IDictionary<string, IDictionary<string, bool>> RestictedGroup { get; set; }
+ public IDictionary<string, IDictionary<string, bool>> Restricted { get; set; } = new Dictionary<string, IDictionary<string, bool>>();
+ public IDictionary<string, IDictionary<string, bool>> RestictedGroup { get; set; } = new Dictionary<string, IDictionary<string, bool>>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs b/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
index 6a907f5c7..289bfb375 100644
--- a/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Shipping/WarehouseModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Shipping
{
public class WarehouseModel : BaseEntityModel
{
- public WarehouseModel()
- {
- Address = new AddressModel();
- }
[GrandResourceDisplayName("Admin.Configuration.Shipping.Warehouses.Fields.Code")]
public string Code { get; set; }
@@ -26,7 +22,7 @@ namespace Grand.Web.Admin.Models.Shipping
public double? Longitude { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Shipping.Warehouses.Fields.Address")]
- public AddressModel Address { get; set; }
+ public AddressModel Address { get; set; } = new();
[GrandResourceDisplayName("Admin.Configuration.Shipping.Warehouses.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Stores/StoreModel.cs b/src/Web/Grand.Web.Admin/Models/Stores/StoreModel.cs
index b1c6ed733..36c0d0fdc 100644
--- a/src/Web/Grand.Web.Admin/Models/Stores/StoreModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Stores/StoreModel.cs
@@ -7,16 +7,6 @@ namespace Grand.Web.Admin.Models.Stores
{
public class StoreModel : BaseEntityModel, ILocalizedModel<StoreLocalizedModel>
{
- public StoreModel()
- {
- Locales = new List<StoreLocalizedModel>();
- Domains = new List<DomainHostModel>();
- AvailableLanguages = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- AvailableCurrencies = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.Name")]
public string Name { get; set; }
@@ -59,27 +49,28 @@ namespace Grand.Web.Admin.Models.Stores
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.CompanyHours")]
public string CompanyHours { get; set; }
- public IList<StoreLocalizedModel> Locales { get; set; }
+ public IList<StoreLocalizedModel> Locales { get; set; } = new List<StoreLocalizedModel>();
+
//default language
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.DefaultLanguage")]
public string DefaultLanguageId { get; set; }
- public IList<SelectListItem> AvailableLanguages { get; set; }
+ public IList<SelectListItem> AvailableLanguages { get; set; } = new List<SelectListItem>();
//default warehouse
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.DefaultWarehouse")]
public string DefaultWarehouseId { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
//default country
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.DefaultCountry")]
public string DefaultCountryId { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Configuration.Stores.Fields.DefaultCurrency")]
public string DefaultCurrencyId { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
- public IList<DomainHostModel> Domains { get; set; }
+ public IList<DomainHostModel> Domains { get; set; } = new List<DomainHostModel>();
public BankAccountModel BankAccount { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Models/Tasks/ScheduleTaskModel.cs b/src/Web/Grand.Web.Admin/Models/Tasks/ScheduleTaskModel.cs
index 80b3c231c..f6a6f2b79 100644
--- a/src/Web/Grand.Web.Admin/Models/Tasks/ScheduleTaskModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Tasks/ScheduleTaskModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Admin.Models.Tasks
{
public class ScheduleTaskModel : BaseEntityModel
{
- public ScheduleTaskModel()
- {
- AvailableStores = new List<SelectListItem>();
- }
[GrandResourceDisplayName("Admin.System.ScheduleTasks.ScheduleTaskName")]
public string ScheduleTaskName { get; set; }
@@ -32,6 +28,6 @@ namespace Grand.Web.Admin.Models.Tasks
public int TimeInterval { get; set; }
[GrandResourceDisplayName("Admin.System.ScheduleTasks.StoreId")]
public string StoreId { get; set; }
- public IList<SelectListItem> AvailableStores { get; set; }
+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Models/Tax/TaxSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Tax/TaxSettingsModel.cs
index c83966f63..c5830a45b 100644
--- a/src/Web/Grand.Web.Admin/Models/Tax/TaxSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Tax/TaxSettingsModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Admin.Models.Tax
{
public class TaxSettingsModel : BaseModel
{
- public TaxSettingsModel()
- {
- TaxCategories = new List<SelectListItem>();
- EuVatShopCountries = new List<SelectListItem>();
- DefaultTaxAddress = new AddressModel();
- }
-
public string ActiveStore { get; set; }
@@ -44,12 +37,12 @@ namespace Grand.Web.Admin.Models.Tax
public SelectList TaxBasedOnValues { get; set; }
[GrandResourceDisplayName("Admin.Configuration.Tax.Settings.DefaultTaxAddress")]
- public AddressModel DefaultTaxAddress { get; set; }
+ public AddressModel DefaultTaxAddress { get; set; } = new();
[GrandResourceDisplayName("Admin.Configuration.Tax.Settings.DefaultTaxCategory")]
public string DefaultTaxCategoryId { get; set; }
- public IList<SelectListItem> TaxCategories { get; set; }
+ public IList<SelectListItem> TaxCategories { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Configuration.Tax.Settings.ShippingIsTaxable")]
public bool ShippingIsTaxable { get; set; }
@@ -74,7 +67,7 @@ namespace Grand.Web.Admin.Models.Tax
[GrandResourceDisplayName("Admin.Configuration.Tax.Settings.EuVatShopCountry")]
public string EuVatShopCountryId { get; set; }
- public IList<SelectListItem> EuVatShopCountries { get; set; }
+ public IList<SelectListItem> EuVatShopCountries { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Admin.Configuration.Tax.Settings.EuVatAllowVatExemption")]
public bool EuVatAllowVatExemption { get; set; }
diff --git a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs
index d82c2c502..a8186b96e 100644
--- a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs
@@ -16,41 +16,18 @@ using Grand.Web.Admin.Extensions.Mapping;
namespace Grand.Web.Admin.Services
{
- public class CheckoutAttributeViewModelService : ICheckoutAttributeViewModelService
+ public class CheckoutAttributeViewModelService(
+ ICheckoutAttributeService checkoutAttributeService,
+ ICheckoutAttributeParser checkoutAttributeParser,
+ ITranslationService translationService,
+ ITaxCategoryService taxCategoryService,
+ IWorkContext workContext,
+ ICurrencyService currencyService,
+ CurrencySettings currencySettings,
+ IMeasureService measureService,
+ MeasureSettings measureSettings)
+ : ICheckoutAttributeViewModelService
{
- private readonly ICheckoutAttributeService _checkoutAttributeService;
- private readonly ICheckoutAttributeParser _checkoutAttributeParser;
- private readonly ITranslationService _translationService;
- private readonly ITaxCategoryService _taxCategoryService;
- private readonly IWorkContext _workContext;
- private readonly ICurrencyService _currencyService;
- private readonly CurrencySettings _currencySettings;
- private readonly IMeasureService _measureService;
- private readonly MeasureSettings _measureSettings;
-
-
- public CheckoutAttributeViewModelService(ICheckoutAttributeService checkoutAttributeService,
- ICheckoutAttributeParser checkoutAttributeParser,
- ITranslationService translationService,
- ITaxCategoryService taxCategoryService,
- IWorkContext workContext,
- ICurrencyService currencyService,
- CurrencySettings currencySettings,
- IMeasureService measureService,
- MeasureSettings measureSettings
- )
- {
- _checkoutAttributeService = checkoutAttributeService;
- _checkoutAttributeParser = checkoutAttributeParser;
- _translationService = translationService;
- _taxCategoryService = taxCategoryService;
- _workContext = workContext;
- _currencyService = currencyService;
- _currencySettings = currencySettings;
- _measureService = measureService;
- _measureSettings = measureSettings;
- }
-
#region Utilities
public virtual async Task PrepareTaxCategories(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties)
@@ -59,8 +36,8 @@ namespace Grand.Web.Admin.Services
throw new ArgumentNullException(nameof(model));
//tax categories
- var taxCategories = await _taxCategoryService.GetAllTaxCategories();
- model.AvailableTaxCategories.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Configuration.Tax.Settings.TaxCategories.None"), Value = "" });
+ var taxCategories = await taxCategoryService.GetAllTaxCategories();
+ model.AvailableTaxCategories.Add(new SelectListItem { Text = translationService.GetResource("Admin.Configuration.Tax.Settings.TaxCategories.None"), Value = "" });
foreach (var tc in taxCategories)
model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.Id, Selected = checkoutAttribute != null && !excludeProperties && tc.Id == checkoutAttribute.TaxCategoryId });
}
@@ -76,13 +53,13 @@ namespace Grand.Web.Admin.Services
if (checkoutAttribute == null)
return;
- var selectedAttribute = (await _checkoutAttributeParser.ParseCheckoutAttributes(checkoutAttribute.ConditionAttribute)).FirstOrDefault();
- var selectedValues = await _checkoutAttributeParser.ParseCheckoutAttributeValues(checkoutAttribute.ConditionAttribute);
+ var selectedAttribute = (await checkoutAttributeParser.ParseCheckoutAttributes(checkoutAttribute.ConditionAttribute)).FirstOrDefault();
+ var selectedValues = await checkoutAttributeParser.ParseCheckoutAttributeValues(checkoutAttribute.ConditionAttribute);
model.ConditionModel = new ConditionModel {
EnableCondition = checkoutAttribute.ConditionAttribute.Any(),
SelectedAttributeId = selectedAttribute != null ? selectedAttribute.Id : "",
- ConditionAttributes = (await _checkoutAttributeService.GetAllCheckoutAttributes(ignoreAcl: false))
+ ConditionAttributes = (await checkoutAttributeService.GetAllCheckoutAttributes(ignoreAcl: false))
//ignore this attribute and non-combinable attributes
.Where(x => x.Id != checkoutAttribute.Id && x.CanBeUsedAsCondition())
.Select(x =>
@@ -105,7 +82,7 @@ namespace Grand.Web.Admin.Services
var conditionAttributes = new List<CustomAttribute>();
if (model.ConditionModel.EnableCondition)
{
- var attribute = await _checkoutAttributeService.GetCheckoutAttributeById(model.ConditionModel.SelectedAttributeId);
+ var attribute = await checkoutAttributeService.GetCheckoutAttributeById(model.ConditionModel.SelectedAttributeId);
if (attribute != null)
{
switch (attribute.AttributeControlTypeId)
@@ -118,10 +95,7 @@ namespace Grand.Web.Admin.Services
var selectedAttribute = model.ConditionModel.ConditionAttributes
.FirstOrDefault(x => x.Id == model.ConditionModel.SelectedAttributeId);
var selectedValue = selectedAttribute?.SelectedValueId;
- if (!string.IsNullOrEmpty(selectedValue))
- conditionAttributes = _checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, selectedValue).ToList();
- else
- conditionAttributes = _checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, string.Empty).ToList();
+ conditionAttributes = !string.IsNullOrEmpty(selectedValue) ? checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, selectedValue).ToList() : checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, string.Empty).ToList();
}
break;
case AttributeControlType.Checkboxes:
@@ -131,9 +105,9 @@ namespace Grand.Web.Admin.Services
var selectedValues = selectedAttribute?.Values.Where(x => x.Selected).Select(x => x.Value);
if (selectedValues.Any())
foreach (var value in selectedValues)
- conditionAttributes = _checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, value).ToList();
+ conditionAttributes = checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, value).ToList();
else
- conditionAttributes = _checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, string.Empty).ToList();
+ conditionAttributes = checkoutAttributeParser.AddCheckoutAttribute(conditionAttributes, attribute, string.Empty).ToList();
}
break;
case AttributeControlType.ReadonlyCheckboxes:
@@ -155,17 +129,17 @@ namespace Grand.Web.Admin.Services
public virtual async Task<IEnumerable<CheckoutAttributeModel>> PrepareCheckoutAttributeListModel()
{
- var checkoutAttributes = await _checkoutAttributeService.GetAllCheckoutAttributes(ignoreAcl: true);
+ var checkoutAttributes = await checkoutAttributeService.GetAllCheckoutAttributes(ignoreAcl: true);
return checkoutAttributes.Select((Func<CheckoutAttribute, CheckoutAttributeModel>)(x =>
{
var attributeModel = x.ToModel();
- attributeModel.AttributeControlTypeName = x.AttributeControlTypeId.GetTranslationEnum(_translationService, _workContext);
+ attributeModel.AttributeControlTypeName = x.AttributeControlTypeId.GetTranslationEnum(translationService, workContext);
return attributeModel;
}));
}
public virtual async Task<IEnumerable<CheckoutAttributeValueModel>> PrepareCheckoutAttributeValuesModel(string checkoutAttributeId)
{
- var checkoutAttribute = await _checkoutAttributeService.GetCheckoutAttributeById(checkoutAttributeId);
+ var checkoutAttribute = await checkoutAttributeService.GetCheckoutAttributeById(checkoutAttributeId);
var values = checkoutAttribute.CheckoutAttributeValues;
return values.Select(x => new CheckoutAttributeValueModel
{
@@ -191,11 +165,11 @@ namespace Grand.Web.Admin.Services
public virtual async Task<CheckoutAttributeValueModel> PrepareCheckoutAttributeValueModel(string checkoutAttributeId)
{
- var checkoutAttribute = await _checkoutAttributeService.GetCheckoutAttributeById(checkoutAttributeId);
+ var checkoutAttribute = await checkoutAttributeService.GetCheckoutAttributeById(checkoutAttributeId);
var model = new CheckoutAttributeValueModel {
CheckoutAttributeId = checkoutAttributeId,
- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,
- BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name,
+ PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,
+ BaseWeightIn = (await measureService.GetMeasureWeightById(measureSettings.BaseWeightId)).Name,
//color squares
DisplayColorSquaresRgb = checkoutAttribute.AttributeControlTypeId == AttributeControlType.ColorSquares,
ColorSquaresRgb = "#000000"
@@ -207,15 +181,15 @@ namespace Grand.Web.Admin.Services
{
var model = checkoutAttributeValue.ToModel();
model.DisplayColorSquaresRgb = checkoutAttribute.AttributeControlTypeId == AttributeControlType.ColorSquares;
- model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode;
- model.BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name;
+ model.PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId)).CurrencyCode;
+ model.BaseWeightIn = (await measureService.GetMeasureWeightById(measureSettings.BaseWeightId)).Name;
return model;
}
public virtual async Task<CheckoutAttribute> InsertCheckoutAttributeModel(CheckoutAttributeModel model)
{
var checkoutAttribute = model.ToEntity();
- await _checkoutAttributeService.InsertCheckoutAttribute(checkoutAttribute);
+ await checkoutAttributeService.InsertCheckoutAttribute(checkoutAttribute);
return checkoutAttribute;
}
@@ -223,7 +197,7 @@ namespace Grand.Web.Admin.Services
{
checkoutAttribute = model.ToEntity(checkoutAttribute);
await SaveConditionAttributes(checkoutAttribute, model);
- await _checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
+ await checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
return checkoutAttribute;
}
@@ -231,14 +205,14 @@ namespace Grand.Web.Admin.Services
{
var cav = model.ToEntity();
checkoutAttribute.CheckoutAttributeValues.Add(cav);
- await _checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
+ await checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
return cav;
}
public virtual async Task<CheckoutAttributeValue> UpdateCheckoutAttributeValueModel(CheckoutAttribute checkoutAttribute, CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
{
checkoutAttributeValue = model.ToEntity(checkoutAttributeValue);
- await _checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
+ await checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
return checkoutAttributeValue;
}
}
diff --git a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs
index 2eed0d8b5..def86fd12 100644
--- a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs
@@ -12,25 +12,13 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services
{
- public class ContactAttributeViewModelService : IContactAttributeViewModelService
+ public class ContactAttributeViewModelService(
+ IContactAttributeService contactAttributeService,
+ IContactAttributeParser contactAttributeParser,
+ ITranslationService translationService,
+ IWorkContext workContext)
+ : IContactAttributeViewModelService
{
-
- private readonly IContactAttributeService _contactAttributeService;
- private readonly IContactAttributeParser _contactAttributeParser;
- private readonly ITranslationService _translationService;
- private readonly IWorkContext _workContext;
-
- public ContactAttributeViewModelService(IContactAttributeService contactAttributeService,
- IContactAttributeParser contactAttributeParser,
- ITranslationService translationService,
- IWorkContext workContext)
- {
- _contactAttributeService = contactAttributeService;
- _contactAttributeParser = contactAttributeParser;
- _translationService = translationService;
- _workContext = workContext;
- }
-
#region Utilities
protected virtual async Task SaveConditionAttributes(ContactAttribute contactAttribute, ContactAttributeModel model)
@@ -38,7 +26,7 @@ namespace Grand.Web.Admin.Services
var customattributes = new List<CustomAttribute>();
if (model.ConditionModel.EnableCondition)
{
- var attribute = await _contactAttributeService.GetContactAttributeById(model.ConditionModel.SelectedAttributeId);
+ var attribute = await contactAttributeService.GetContactAttributeById(model.ConditionModel.SelectedAttributeId);
if (attribute != null)
{
switch (attribute.AttributeControlType)
@@ -51,10 +39,7 @@ namespace Grand.Web.Admin.Services
var selectedAttribute = model.ConditionModel.ConditionAttributes
.FirstOrDefault(x => x.Id == model.ConditionModel.SelectedAttributeId);
var selectedValue = selectedAttribute?.SelectedValueId;
- if (!string.IsNullOrEmpty(selectedValue))
- customattributes = _contactAttributeParser.AddContactAttribute(customattributes, attribute, selectedValue).ToList();
- else
- customattributes = _contactAttributeParser.AddContactAttribute(customattributes, attribute, string.Empty).ToList();
+ customattributes = !string.IsNullOrEmpty(selectedValue) ? contactAttributeParser.AddContactAttribute(customattributes, attribute, selectedValue).ToList() : contactAttributeParser.AddContactAttribute(customattributes, attribute, string.Empty).ToList();
}
break;
case AttributeControlType.Checkboxes:
@@ -64,9 +49,9 @@ namespace Grand.Web.Admin.Services
var selectedValues = selectedAttribute?.Values.Where(x => x.Selected).Select(x => x.Value);
if (selectedValues.Any())
foreach (var value in selectedValues)
- customattributes = _contactAttributeParser.AddContactAttribute(customattributes, attribute, value).ToList();
+ customattributes = contactAttributeParser.AddContactAttribute(customattributes, attribute, value).ToList();
else
- customattributes = _contactAttributeParser.AddContactAttribute(customattributes, attribute, string.Empty).ToList();
+ customattributes = contactAttributeParser.AddContactAttribute(customattributes, attribute, string.Empty).ToList();
}
break;
case AttributeControlType.ReadonlyCheckboxes:
@@ -86,11 +71,11 @@ namespace Grand.Web.Admin.Services
public virtual async Task<IEnumerable<ContactAttributeModel>> PrepareContactAttributeListModel()
{
- var contactAttributes = await _contactAttributeService.GetAllContactAttributes(_workContext.CurrentCustomer.StaffStoreId, ignoreAcl: true);
+ var contactAttributes = await contactAttributeService.GetAllContactAttributes(workContext.CurrentCustomer.StaffStoreId, ignoreAcl: true);
return contactAttributes.Select(x =>
{
var attributeModel = x.ToModel();
- attributeModel.AttributeControlTypeName = x.AttributeControlType.GetTranslationEnum(_translationService, _workContext);
+ attributeModel.AttributeControlTypeName = x.AttributeControlType.GetTranslationEnum(translationService, workContext);
return attributeModel;
});
}
@@ -106,13 +91,13 @@ namespace Grand.Web.Admin.Services
if (contactAttribute == null)
return;
- var selectedAttribute = (await _contactAttributeParser.ParseContactAttributes(contactAttribute.ConditionAttribute)).FirstOrDefault();
- var selectedValues = await _contactAttributeParser.ParseContactAttributeValues(contactAttribute.ConditionAttribute);
+ var selectedAttribute = (await contactAttributeParser.ParseContactAttributes(contactAttribute.ConditionAttribute)).FirstOrDefault();
+ var selectedValues = await contactAttributeParser.ParseContactAttributeValues(contactAttribute.ConditionAttribute);
model.ConditionModel = new ConditionModel {
EnableCondition = contactAttribute.ConditionAttribute.Any(),
SelectedAttributeId = selectedAttribute != null ? selectedAttribute.Id : "",
- ConditionAttributes = (await _contactAttributeService.GetAllContactAttributes(_workContext.CurrentCustomer.StaffStoreId, ignoreAcl: true))
+ ConditionAttributes = (await contactAttributeService.GetAllContactAttributes(workContext.CurrentCustomer.StaffStoreId, ignoreAcl: true))
//ignore this attribute and non-combinable attributes
.Where(x => x.Id != contactAttribute.Id && x.CanBeUsedAsCondition())
.Select(x =>
@@ -133,14 +118,14 @@ namespace Grand.Web.Admin.Services
public virtual async Task<ContactAttribute> InsertContactAttributeModel(ContactAttributeModel model)
{
var contactAttribute = model.ToEntity();
- await _contactAttributeService.InsertContactAttribute(contactAttribute);
+ await contactAttributeService.InsertContactAttribute(contactAttribute);
return contactAttribute;
}
public virtual async Task<ContactAttribute> UpdateContactAttributeModel(ContactAttribute contactAttribute, ContactAttributeModel model)
{
contactAttribute = model.ToEntity(contactAttribute);
await SaveConditionAttributes(contactAttribute, model);
- await _contactAttributeService.UpdateContactAttribute(contactAttribute);
+ await contactAttributeService.UpdateContactAttribute(contactAttribute);
return contactAttribute;
}
@@ -165,14 +150,14 @@ namespace Grand.Web.Admin.Services
{
var cav = model.ToEntity();
contactAttribute.ContactAttributeValues.Add(cav);
- await _contactAttributeService.UpdateContactAttribute(contactAttribute);
+ await contactAttributeService.UpdateContactAttribute(contactAttribute);
return cav;
}
public virtual async Task<ContactAttributeValue> UpdateContactAttributeValueModel(ContactAttribute contactAttribute, ContactAttributeValue contactAttributeValue, ContactAttributeValueModel model)
{
contactAttributeValue = model.ToEntity(contactAttributeValue);
- await _contactAttributeService.UpdateContactAttribute(contactAttribute);
+ await contactAttributeService.UpdateContactAttribute(contactAttribute);
return contactAttributeValue;
}
}
diff --git a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
index 2cd872665..82cc95e5d 100644
--- a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs
@@ -19,65 +19,31 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services
{
- public class CourseViewModelService : ICourseViewModelService
+ public class CourseViewModelService(
+ ICourseService courseService,
+ ICourseLevelService courseLevelService,
+ ICourseLessonService courseLessonService,
+ ICourseSubjectService courseSubjectService,
+ ISlugService slugService,
+ IPictureService pictureService,
+ ILanguageService languageService,
+ ITranslationService translationService,
+ IProductCourseService productCourseService,
+ IDownloadService downloadService,
+ IProductService productService,
+ IStoreService storeService,
+ IVendorService vendorService,
+ SeoSettings seoSettings)
+ : ICourseViewModelService
{
- private readonly ICourseService _courseService;
- private readonly ICourseLevelService _courseLevelService;
- private readonly ICourseLessonService _courseLessonService;
- private readonly ICourseSubjectService _courseSubjectService;
- private readonly ISlugService _slugService;
- private readonly IPictureService _pictureService;
- private readonly ILanguageService _languageService;
- private readonly ITranslationService _translationService;
- private readonly IProductCourseService _productCourseService;
- private readonly IDownloadService _downloadService;
- private readonly IStoreService _storeService;
- private readonly IProductService _productService;
- private readonly IVendorService _vendorService;
- private readonly SeoSettings _seoSettings;
-
- public CourseViewModelService(
- ICourseService courseService,
- ICourseLevelService courseLevelService,
- ICourseLessonService courseLessonService,
- ICourseSubjectService courseSubjectService,
- ISlugService slugService,
- IPictureService pictureService,
- ILanguageService languageService,
- ITranslationService translationService,
- IProductCourseService productCourseService,
- IDownloadService downloadService,
- IProductService productService,
- IStoreService storeService,
- IVendorService vendorService,
- SeoSettings seoSettings)
- {
- _courseService = courseService;
- _courseLevelService = courseLevelService;
- _courseLessonService = courseLessonService;
- _courseSubjectService = courseSubjectService;
- _slugService = slugService;
- _pictureService = pictureService;
- _languageService = languageService;
- _translationService = translationService;
- _productCourseService = productCourseService;
- _downloadService = downloadService;
- _productService = productService;
- _seoSettings = seoSettings;
- _storeService = storeService;
- _vendorService = vendorService;
- }
-
public virtual async Task<CourseModel> PrepareCourseModel(CourseModel model = null)
{
- if (model == null)
+ model ??= new CourseModel
{
- model = new CourseModel {
- Published = true
- };
- }
+ Published = true
+ };
- foreach (var item in await _courseLevelService.GetAll())
+ foreach (var item in await courseLevelService.GetAll())
{
model.AvailableLevels.Add(new SelectListItem {
Text = item.Name,
@@ -86,7 +52,7 @@ namespace Grand.Web.Admin.Services
}
if (!string.IsNullOrEmpty(model.ProductId))
{
- model.ProductName = (await _productService.GetProductById(model.ProductId))?.Name;
+ model.ProductName = (await productService.GetProductById(model.ProductId))?.Name;
}
return model;
}
@@ -94,21 +60,21 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Course> InsertCourseModel(CourseModel model)
{
var course = model.ToEntity();
- await _courseService.Insert(course);
+ await courseService.Insert(course);
//locales
- model.SeName = await course.ValidateSeName(model.SeName, course.Name, true, _seoSettings, _slugService, _languageService);
+ model.SeName = await course.ValidateSeName(model.SeName, course.Name, true, seoSettings, slugService, languageService);
course.SeName = model.SeName;
- await _courseService.Update(course);
+ await courseService.Update(course);
- await _slugService.SaveSlug(course, model.SeName, "");
+ await slugService.SaveSlug(course, model.SeName, "");
//update picture seo file name
- await _pictureService.UpdatePictureSeoNames(course.PictureId, course.Name);
+ await pictureService.UpdatePictureSeoNames(course.PictureId, course.Name);
//course on the product
if (!string.IsNullOrEmpty(course.ProductId))
- await _productCourseService.UpdateCourseOnProduct(course.ProductId, course.Id);
+ await productCourseService.UpdateCourseOnProduct(course.ProductId, course.Id);
return course;
}
@@ -119,49 +85,47 @@ namespace Grand.Web.Admin.Services
var prevProductId = course.ProductId;
course = model.ToEntity(course);
- model.SeName = await course.ValidateSeName(model.SeName, course.Name, true, _seoSettings, _slugService, _languageService);
+ model.SeName = await course.ValidateSeName(model.SeName, course.Name, true, seoSettings, slugService, languageService);
course.SeName = model.SeName;
//locales
- course.Locales = await model.Locales.ToTranslationProperty(course, x => x.Name, _seoSettings, _slugService, _languageService);
- await _courseService.Update(course);
+ course.Locales = await model.Locales.ToTranslationProperty(course, x => x.Name, seoSettings, slugService, languageService);
+ await courseService.Update(course);
//search engine name
- await _slugService.SaveSlug(course, model.SeName, "");
+ await slugService.SaveSlug(course, model.SeName, "");
//delete an old picture (if deleted or updated)
if (!string.IsNullOrEmpty(prevPictureId) && prevPictureId != course.PictureId)
{
- var prevPicture = await _pictureService.GetPictureById(prevPictureId);
+ var prevPicture = await pictureService.GetPictureById(prevPictureId);
if (prevPicture != null)
- await _pictureService.DeletePicture(prevPicture);
+ await pictureService.DeletePicture(prevPicture);
}
//update picture seo file name
- await _pictureService.UpdatePictureSeoNames(course.PictureId, course.Name);
+ await pictureService.UpdatePictureSeoNames(course.PictureId, course.Name);
//course on the product
if (!string.IsNullOrEmpty(prevProductId))
- await _productCourseService.UpdateCourseOnProduct(prevProductId, string.Empty);
+ await productCourseService.UpdateCourseOnProduct(prevProductId, string.Empty);
if (!string.IsNullOrEmpty(course.ProductId))
- await _productCourseService.UpdateCourseOnProduct(course.ProductId, course.Id);
+ await productCourseService.UpdateCourseOnProduct(course.ProductId, course.Id);
return course;
}
public virtual async Task DeleteCourse(Course course)
{
- await _courseService.Delete(course);
+ await courseService.Delete(course);
}
public virtual async Task<CourseLessonModel> PrepareCourseLessonModel(string courseId, CourseLessonModel model = null)
{
- if (model == null)
+ model ??= new CourseLessonModel
{
- model = new CourseLessonModel {
- Published = true
- };
- }
+ Published = true
+ };
model.CourseId = courseId;
- foreach (var item in await _courseSubjectService.GetByCourseId(courseId))
+ foreach (var item in await courseSubjectService.GetByCourseId(courseId))
{
model.AvailableSubjects.Add(new SelectListItem {
Text = item.Name,
@@ -175,7 +139,7 @@ namespace Grand.Web.Admin.Services
public virtual async Task<CourseLesson> InsertCourseLessonModel(CourseLessonModel model)
{
var lesson = model.ToEntity();
- await _courseLessonService.Insert(lesson);
+ await courseLessonService.Insert(lesson);
return lesson;
}
@@ -187,50 +151,50 @@ namespace Grand.Web.Admin.Services
var prevPictureId = lesson.PictureId;
lesson = model.ToEntity(lesson);
- await _courseLessonService.Update(lesson);
+ await courseLessonService.Update(lesson);
//delete an old picture (if deleted or updated)
if (!string.IsNullOrEmpty(prevPictureId) && prevPictureId != lesson.PictureId)
{
- var prevPicture = await _pictureService.GetPictureById(prevPictureId);
+ var prevPicture = await pictureService.GetPictureById(prevPictureId);
if (prevPicture != null)
- await _pictureService.DeletePicture(prevPicture);
+ await pictureService.DeletePicture(prevPicture);
}
//delete an old "attachment" file (if deleted or updated)
if (!string.IsNullOrEmpty(prevAttachmentId) && prevAttachmentId != lesson.AttachmentId)
{
- var prevAttachment = await _downloadService.GetDownloadById(prevAttachmentId);
+ var prevAttachment = await downloadService.GetDownloadById(prevAttachmentId);
if (prevAttachment != null)
- await _downloadService.DeleteDownload(prevAttachment);
+ await downloadService.DeleteDownload(prevAttachment);
}
//delete an old "video" file (if deleted or updated)
if (!string.IsNullOrEmpty(prevVideoFile) && prevVideoFile != lesson.VideoFile)
{
- var prevVideo = await _downloadService.GetDownloadById(prevVideoFile);
+ var prevVideo = await downloadService.GetDownloadById(prevVideoFile);
if (prevVideo != null)
- await _downloadService.DeleteDownload(prevVideo);
+ await downloadService.DeleteDownload(prevVideo);
}
return lesson;
}
public virtual async Task DeleteCourseLesson(CourseLesson lesson)
{
- await _courseLessonService.Delete(lesson);
+ await courseLessonService.Delete(lesson);
if (!string.IsNullOrEmpty(lesson.VideoFile))
{
- var prevVideo = await _downloadService.GetDownloadById(lesson.VideoFile);
+ var prevVideo = await downloadService.GetDownloadById(lesson.VideoFile);
if (prevVideo != null)
- await _downloadService.DeleteDownload(prevVideo);
+ await downloadService.DeleteDownload(prevVideo);
}
if (!string.IsNullOrEmpty(lesson.AttachmentId))
{
- var prevAttachment = await _downloadService.GetDownloadById(lesson.AttachmentId);
+ var prevAttachment = await downloadService.GetDownloadById(lesson.AttachmentId);
if (prevAttachment != null)
- await _downloadService.DeleteDownload(prevAttachment);
+ await downloadService.DeleteDownload(prevAttachment);
}
}
@@ -239,23 +203,23 @@ namespace Grand.Web.Admin.Services
{
var model = new CourseModel.AssociateProductToCourseModel();
//stores
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var s in await _storeService.GetAllStores())
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var s in await storeService.GetAllStores())
model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
//vendors
- model.AvailableVendors.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var v in await _vendorService.GetAllVendors(showHidden: true))
+ model.AvailableVendors.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var v in await vendorService.GetAllVendors(showHidden: true))
model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });
//product types
model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList().ToList();
- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
+ model.AvailableProductTypes.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
return model;
}
public virtual async Task<(IList<ProductModel> products, int totalCount)> PrepareProductModel(CourseModel.AssociateProductToCourseModel model, int pageIndex, int pageSize)
{
- var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);
+ var products = await productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);
return (products.Select(x => x.ToModel()).ToList(), products.TotalCount);
}
}
diff --git a/src/Web/Grand.Web.Admin/Services/ElFinderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ElFinderViewModelService.cs
index d959dfe29..06fbb1cb7 100644
--- a/src/Web/Grand.Web.Admin/Services/ElFinderViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ElFinderViewModelService.cs
@@ -71,15 +71,9 @@ namespace Grand.Web.Admin.Services
protected virtual bool NotAllowedExtensions(string extensions)
{
var allowedFileTypes = new List<string>();
- if (string.IsNullOrEmpty(_mediaSettings.AllowedFileTypes))
- allowedFileTypes = [".gif", ".jpg", ".jpeg", ".png", ".bmp", ".webp"];
- else
- allowedFileTypes = _mediaSettings.AllowedFileTypes.Split(',').Select(x => x.Trim().ToLowerInvariant()).ToList();
+ allowedFileTypes = string.IsNullOrEmpty(_mediaSettings.AllowedFileTypes) ? [".gif", ".jpg", ".jpeg", ".png", ".bmp", ".webp"] : _mediaSettings.AllowedFileTypes.Split(',').Select(x => x.Trim().ToLowerInvariant()).ToList();
- if (allowedFileTypes.Contains(extensions))
- return false;
-
- return true;
+ return !allowedFileTypes.Contains(extensions);
}
public virtual async Task SetupConnectorAsync()
@@ -94,9 +88,7 @@ namespace Grand.Web.Admin.Services
MaxUploadSizeInMb = 4,
ObjectAttributes = new List<FilteredObjectAttribute> {
new FilteredObjectAttribute {
- FileFilter = file => {
- return NotAllowedExtensions(file.Extension);
- },
+ FileFilter = file => NotAllowedExtensions(file.Extension),
ObjectFilter = obj =>
{
var extensions = Path.GetExtension(obj.FullName);
diff --git a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
index deac80337..2aeb9c374 100644
--- a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs
@@ -21,64 +21,31 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services
{
- public class MerchandiseReturnViewModelService : IMerchandiseReturnViewModelService
+ public class MerchandiseReturnViewModelService(
+ IOrderService orderService,
+ IWorkContext workContext,
+ IProductService productService,
+ ICustomerService customerService,
+ IDateTimeService dateTimeService,
+ ITranslationService translationService,
+ IMessageProviderService messageProviderService,
+ LanguageSettings languageSettings,
+ IMerchandiseReturnService merchandiseReturnService,
+ IPriceFormatter priceFormatter,
+ AddressSettings addressSettings,
+ ICountryService countryService,
+ IAddressAttributeService addressAttributeService,
+ IAddressAttributeParser addressAttributeParser,
+ IDownloadService downloadService,
+ OrderSettings orderSettings)
+ : IMerchandiseReturnViewModelService
{
#region Fields
- private readonly IOrderService _orderService;
- private readonly IWorkContext _workContext;
- private readonly IProductService _productService;
- private readonly IDateTimeService _dateTimeService;
- private readonly ICustomerService _customerService;
- private readonly ITranslationService _translationService;
- private readonly IMessageProviderService _messageProviderService;
- private readonly LanguageSettings _languageSettings;
- private readonly IMerchandiseReturnService _merchandiseReturnService;
- private readonly IPriceFormatter _priceFormatter;
- private readonly AddressSettings _addressSettings;
- private readonly OrderSettings _orderSettings;
- private readonly ICountryService _countryService;
- private readonly IAddressAttributeService _addressAttributeService;
- private readonly IAddressAttributeParser _addressAttributeParser;
- private readonly IDownloadService _downloadService;
-
#endregion Fields
#region Constructors
- public MerchandiseReturnViewModelService(IOrderService orderService,
- IWorkContext workContext,
- IProductService productService,
- ICustomerService customerService, IDateTimeService dateTimeService,
- ITranslationService translationService,
- IMessageProviderService messageProviderService, LanguageSettings languageSettings,
- IMerchandiseReturnService merchandiseReturnService,
- IPriceFormatter priceFormatter,
- AddressSettings addressSettings,
- ICountryService countryService,
- IAddressAttributeService addressAttributeService,
- IAddressAttributeParser addressAttributeParser,
- IDownloadService downloadService,
- OrderSettings orderSettings)
- {
- _orderService = orderService;
- _workContext = workContext;
- _productService = productService;
- _customerService = customerService;
- _dateTimeService = dateTimeService;
- _translationService = translationService;
- _messageProviderService = messageProviderService;
- _languageSettings = languageSettings;
- _merchandiseReturnService = merchandiseReturnService;
- _priceFormatter = priceFormatter;
- _addressSettings = addressSettings;
- _countryService = countryService;
- _addressAttributeService = addressAttributeService;
- _addressAttributeParser = addressAttributeParser;
- _downloadService = downloadService;
- _orderSettings = orderSettings;
- }
-
#endregion
public virtual async Task<MerchandiseReturnModel> PrepareMerchandiseReturnModel(MerchandiseReturnModel model,
@@ -90,7 +57,7 @@ namespace Grand.Web.Admin.Services
if (merchandiseReturn == null)
throw new ArgumentNullException(nameof(merchandiseReturn));
- var order = await _orderService.GetOrderById(merchandiseReturn.OrderId);
+ var order = await orderService.GetOrderById(merchandiseReturn.OrderId);
double unitPriceInclTaxInCustomerCurrency = 0;
foreach (var item in merchandiseReturn.MerchandiseReturnItems)
{
@@ -98,7 +65,7 @@ namespace Grand.Web.Admin.Services
unitPriceInclTaxInCustomerCurrency += orderItem.UnitPriceInclTax * item.Quantity;
}
- model.Total = _priceFormatter.FormatPrice(unitPriceInclTaxInCustomerCurrency);
+ model.Total = priceFormatter.FormatPrice(unitPriceInclTaxInCustomerCurrency);
model.Quantity = merchandiseReturn.MerchandiseReturnItems.Sum(x => x.Quantity);
model.Id = merchandiseReturn.Id;
model.OrderId = order.Id;
@@ -107,14 +74,14 @@ namespace Grand.Web.Admin.Services
model.ReturnNumber = merchandiseReturn.ReturnNumber;
model.CustomerId = merchandiseReturn.CustomerId;
model.NotifyCustomer = merchandiseReturn.NotifyCustomer;
- var customer = await _customerService.GetCustomerById(merchandiseReturn.CustomerId);
+ var customer = await customerService.GetCustomerById(merchandiseReturn.CustomerId);
if (customer != null)
- model.CustomerInfo = !string.IsNullOrEmpty(customer.Email) ? customer.Email : _translationService.GetResource("Admin.Customers.Guest");
+ model.CustomerInfo = !string.IsNullOrEmpty(customer.Email) ? customer.Email : translationService.GetResource("Admin.Customers.Guest");
else
- model.CustomerInfo = _translationService.GetResource("Admin.Customers.Guest");
+ model.CustomerInfo = translationService.GetResource("Admin.Customers.Guest");
model.MerchandiseReturnStatusStr = merchandiseReturn.MerchandiseReturnStatus.ToString();
- model.CreatedOn = _dateTimeService.ConvertToUserTime(merchandiseReturn.CreatedOnUtc, DateTimeKind.Utc);
+ model.CreatedOn = dateTimeService.ConvertToUserTime(merchandiseReturn.CreatedOnUtc, DateTimeKind.Utc);
model.PickupDate = merchandiseReturn.PickupDate;
model.UserFields = merchandiseReturn.UserFields;
@@ -135,19 +102,16 @@ namespace Grand.Web.Admin.Services
var customerId = string.Empty;
if (!string.IsNullOrEmpty(model.SearchCustomerEmail))
{
- var customer = await _customerService.GetCustomerByEmail(model.SearchCustomerEmail.ToLowerInvariant());
- if (customer != null)
- customerId = customer.Id;
- else
- customerId = "00000000-0000-0000-0000-000000000000";
+ var customer = await customerService.GetCustomerByEmail(model.SearchCustomerEmail.ToLowerInvariant());
+ customerId = customer != null ? customer.Id : "00000000-0000-0000-0000-000000000000";
}
DateTime? startDateValue = model.StartDate == null ? null
- : _dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);
+ : dateTimeService.ConvertToUtcTime(model.StartDate.Value, dateTimeService.CurrentTimeZone);
DateTime? endDateValue = model.EndDate == null ? null
- : _dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone);
+ : dateTimeService.ConvertToUtcTime(model.EndDate.Value, dateTimeService.CurrentTimeZone);
- var merchandiseReturns = await _merchandiseReturnService.SearchMerchandiseReturns(model.StoreId,
+ var merchandiseReturns = await merchandiseReturnService.SearchMerchandiseReturns(model.StoreId,
customerId,
"",
"",
@@ -171,12 +135,11 @@ namespace Grand.Web.Admin.Services
{
if (!excludeProperties)
{
- model = await address.ToModel(_countryService);
+ model = await address.ToModel(countryService);
}
}
- if (model == null)
- model = new AddressModel();
+ model ??= new AddressModel();
model.FirstNameEnabled = true;
model.FirstNameRequired = true;
@@ -184,64 +147,64 @@ namespace Grand.Web.Admin.Services
model.LastNameRequired = true;
model.EmailEnabled = true;
model.EmailRequired = true;
- model.CompanyEnabled = _addressSettings.CompanyEnabled;
- model.CompanyRequired = _addressSettings.CompanyRequired;
- model.VatNumberEnabled = _addressSettings.VatNumberEnabled;
- model.VatNumberRequired = _addressSettings.VatNumberRequired;
- model.CountryEnabled = _addressSettings.CountryEnabled;
- model.StateProvinceEnabled = _addressSettings.StateProvinceEnabled;
- model.CityEnabled = _addressSettings.CityEnabled;
- model.CityRequired = _addressSettings.CityRequired;
- model.StreetAddressEnabled = _addressSettings.StreetAddressEnabled;
- model.StreetAddressRequired = _addressSettings.StreetAddressRequired;
- model.StreetAddress2Enabled = _addressSettings.StreetAddress2Enabled;
- model.StreetAddress2Required = _addressSettings.StreetAddress2Required;
- model.ZipPostalCodeEnabled = _addressSettings.ZipPostalCodeEnabled;
- model.ZipPostalCodeRequired = _addressSettings.ZipPostalCodeRequired;
- model.PhoneEnabled = _addressSettings.PhoneEnabled;
- model.PhoneRequired = _addressSettings.PhoneRequired;
- model.FaxEnabled = _addressSettings.FaxEnabled;
- model.FaxRequired = _addressSettings.FaxRequired;
- model.NoteEnabled = _addressSettings.NoteEnabled;
+ model.CompanyEnabled = addressSettings.CompanyEnabled;
+ model.CompanyRequired = addressSettings.CompanyRequired;
+ model.VatNumberEnabled = addressSettings.VatNumberEnabled;
+ model.VatNumberRequired = addressSettings.VatNumberRequired;
+ model.CountryEnabled = addressSettings.CountryEnabled;
+ model.StateProvinceEnabled = addressSettings.StateProvinceEnabled;
+ model.CityEnabled = addressSettings.CityEnabled;
+ model.CityRequired = addressSettings.CityRequired;
+ model.StreetAddressEnabled = addressSettings.StreetAddressEnabled;
+ model.StreetAddressRequired = addressSettings.StreetAddressRequired;
+ model.StreetAddress2Enabled = addressSettings.StreetAddress2Enabled;
+ model.StreetAddress2Required = addressSettings.StreetAddress2Required;
+ model.ZipPostalCodeEnabled = addressSettings.ZipPostalCodeEnabled;
+ model.ZipPostalCodeRequired = addressSettings.ZipPostalCodeRequired;
+ model.PhoneEnabled = addressSettings.PhoneEnabled;
+ model.PhoneRequired = addressSettings.PhoneRequired;
+ model.FaxEnabled = addressSettings.FaxEnabled;
+ model.FaxRequired = addressSettings.FaxRequired;
+ model.NoteEnabled = addressSettings.NoteEnabled;
//countries
- model.AvailableCountries.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Address.SelectCountry"), Value = "" });
- foreach (var c in await _countryService.GetAllCountries(showHidden: true))
+ model.AvailableCountries.Add(new SelectListItem { Text = translationService.GetResource("Admin.Address.SelectCountry"), Value = "" });
+ foreach (var c in await countryService.GetAllCountries(showHidden: true))
model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id, Selected = c.Id == model.CountryId });
//states
- var states = !string.IsNullOrEmpty(model.CountryId) ? (await _countryService.GetCountryById(model.CountryId))?.StateProvinces : new List<StateProvince>();
+ var states = !string.IsNullOrEmpty(model.CountryId) ? (await countryService.GetCountryById(model.CountryId))?.StateProvinces : new List<StateProvince>();
if (states.Count > 0)
{
foreach (var s in states)
model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id, Selected = s.Id == model.StateProvinceId });
}
//customer attribute services
- await model.PrepareCustomAddressAttributes(address, _addressAttributeService, _addressAttributeParser);
+ await model.PrepareCustomAddressAttributes(address, addressAttributeService, addressAttributeParser);
return model;
}
public virtual async Task NotifyCustomer(MerchandiseReturn merchandiseReturn)
{
- var order = await _orderService.GetOrderById(merchandiseReturn.OrderId);
- await _messageProviderService.SendMerchandiseReturnStatusChangedCustomerMessage(merchandiseReturn, order, _languageSettings.DefaultAdminLanguageId);
+ var order = await orderService.GetOrderById(merchandiseReturn.OrderId);
+ await messageProviderService.SendMerchandiseReturnStatusChangedCustomerMessage(merchandiseReturn, order, languageSettings.DefaultAdminLanguageId);
}
public virtual MerchandiseReturnListModel PrepareReturnReqestListModel()
{
var model = new MerchandiseReturnListModel
{
//Merchandise return status
- MerchandiseReturnStatus = MerchandiseReturnStatus.Pending.ToSelectList(_translationService, _workContext, false).ToList()
+ MerchandiseReturnStatus = MerchandiseReturnStatus.Pending.ToSelectList(translationService, workContext, false).ToList()
};
- model.MerchandiseReturnStatus.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "-1" });
+ model.MerchandiseReturnStatus.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "-1" });
return model;
}
public virtual async Task<IList<MerchandiseReturnModel.MerchandiseReturnItemModel>> PrepareMerchandiseReturnItemModel(string merchandiseReturnId)
{
- var merchandiseReturn = await _merchandiseReturnService.GetMerchandiseReturnById(merchandiseReturnId);
+ var merchandiseReturn = await merchandiseReturnService.GetMerchandiseReturnById(merchandiseReturnId);
var items = new List<MerchandiseReturnModel.MerchandiseReturnItemModel>();
- var order = await _orderService.GetOrderById(merchandiseReturn.OrderId);
+ var order = await orderService.GetOrderById(merchandiseReturn.OrderId);
foreach (var item in merchandiseReturn.MerchandiseReturnItems)
{
@@ -249,10 +212,10 @@ namespace Grand.Web.Admin.Services
items.Add(new MerchandiseReturnModel.MerchandiseReturnItemModel
{
ProductId = orderItem.ProductId,
- ProductName = (await _productService.GetProductByIdIncludeArch(orderItem.ProductId)).Name,
+ ProductName = (await productService.GetProductByIdIncludeArch(orderItem.ProductId)).Name,
ProductSku = orderItem.Sku,
Quantity = item.Quantity,
- UnitPrice = _priceFormatter.FormatPrice(orderItem.UnitPriceInclTax),
+ UnitPrice = priceFormatter.FormatPrice(orderItem.UnitPriceInclTax),
ReasonForReturn = item.ReasonForReturn,
RequestedAction = item.RequestedAction
});
@@ -267,33 +230,33 @@ namespace Grand.Web.Admin.Services
merchandiseReturn.ExternalId = model.ExternalId;
merchandiseReturn.UserFields = model.UserFields;
- if (_orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate)
+ if (orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate)
merchandiseReturn.PickupDate = model.PickupDate;
- if (_orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress)
+ if (orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress)
{
merchandiseReturn.PickupAddress = model.PickupAddress.ToEntity();
if (merchandiseReturn.PickupAddress != null)
merchandiseReturn.PickupAddress.Attributes = customAddressAttributes;
}
merchandiseReturn.NotifyCustomer = model.NotifyCustomer;
- await _merchandiseReturnService.UpdateMerchandiseReturn(merchandiseReturn);
+ await merchandiseReturnService.UpdateMerchandiseReturn(merchandiseReturn);
if (model.NotifyCustomer)
await NotifyCustomer(merchandiseReturn);
return merchandiseReturn;
}
public virtual async Task DeleteMerchandiseReturn(MerchandiseReturn merchandiseReturn)
{
- await _merchandiseReturnService.DeleteMerchandiseReturn(merchandiseReturn);
+ await merchandiseReturnService.DeleteMerchandiseReturn(merchandiseReturn);
}
public virtual async Task<IList<MerchandiseReturnModel.MerchandiseReturnNote>> PrepareMerchandiseReturnNotes(MerchandiseReturn merchandiseReturn)
{
//merchandise return notes
var merchandiseReturnNoteModels = new List<MerchandiseReturnModel.MerchandiseReturnNote>();
- foreach (var merchandiseReturnNote in (await _merchandiseReturnService.GetMerchandiseReturnNotes(merchandiseReturn.Id))
+ foreach (var merchandiseReturnNote in (await merchandiseReturnService.GetMerchandiseReturnNotes(merchandiseReturn.Id))
.OrderByDescending(on => on.CreatedOnUtc))
{
- var download = await _downloadService.GetDownloadById(merchandiseReturnNote.DownloadId);
+ var download = await downloadService.GetDownloadById(merchandiseReturnNote.DownloadId);
merchandiseReturnNoteModels.Add(new MerchandiseReturnModel.MerchandiseReturnNote
{
Id = merchandiseReturnNote.Id,
@@ -302,7 +265,7 @@ namespace Grand.Web.Admin.Services
DownloadGuid = download?.DownloadGuid ?? Guid.Empty,
DisplayToCustomer = merchandiseReturnNote.DisplayToCustomer,
Note = merchandiseReturnNote.Note,
- CreatedOn = _dateTimeService.ConvertToUserTime(merchandiseReturnNote.CreatedOnUtc, DateTimeKind.Utc),
+ CreatedOn = dateTimeService.ConvertToUserTime(merchandiseReturnNote.CreatedOnUtc, DateTimeKind.Utc),
CreatedByCustomer = merchandiseReturnNote.CreatedByCustomer
});
}
@@ -318,31 +281,31 @@ namespace Grand.Web.Admin.Services
DownloadId = downloadId,
MerchandiseReturnId = merchandiseReturn.Id
};
- await _merchandiseReturnService.InsertMerchandiseReturnNote(merchandiseReturnNote);
+ await merchandiseReturnService.InsertMerchandiseReturnNote(merchandiseReturnNote);
//new merchandise return notification
if (displayToCustomer)
{
//email
- await _messageProviderService.SendNewMerchandiseReturnNoteAddedCustomerMessage(merchandiseReturn, merchandiseReturnNote, order);
+ await messageProviderService.SendNewMerchandiseReturnNoteAddedCustomerMessage(merchandiseReturn, merchandiseReturnNote, order);
}
}
public virtual async Task DeleteMerchandiseReturnNote(MerchandiseReturn merchandiseReturn, string id)
{
- var merchandiseReturnNote = (await _merchandiseReturnService.GetMerchandiseReturnNotes(merchandiseReturn.Id)).FirstOrDefault(on => on.Id == id);
+ var merchandiseReturnNote = (await merchandiseReturnService.GetMerchandiseReturnNotes(merchandiseReturn.Id)).FirstOrDefault(on => on.Id == id);
if (merchandiseReturnNote == null)
throw new ArgumentException("No merchandise return note found with the specified id");
merchandiseReturnNote.MerchandiseReturnId = merchandiseReturn.Id;
- await _merchandiseReturnService.DeleteMerchandiseReturnNote(merchandiseReturnNote);
+ await merchandiseReturnService.DeleteMerchandiseReturnNote(merchandiseReturnNote);
//delete an old "attachment" file
if (!string.IsNullOrEmpty(merchandiseReturnNote.DownloadId))
{
- var attachment = await _downloadService.GetDownloadById(merchandiseReturnNote.DownloadId);
+ var attachment = await downloadService.GetDownloadById(merchandiseReturnNote.DownloadId);
if (attachment != null)
- await _downloadService.DeleteDownload(attachment);
+ await downloadService.DeleteDownload(attachment);
}
}
}
diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
index 396966f1b..d68d8de7b 100644
--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
@@ -32,134 +32,59 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services
{
- public class ProductViewModelService : IProductViewModelService
+ public class ProductViewModelService(
+ IProductService productService,
+ IInventoryManageService inventoryManageService,
+ IPictureService pictureService,
+ IProductAttributeService productAttributeService,
+ IProductTagService productTagService,
+ ICurrencyService currencyService,
+ IMeasureService measureService,
+ IDateTimeService dateTimeService,
+ ICollectionService collectionService,
+ IProductCollectionService productCollectionService,
+ ICategoryService categoryService,
+ IProductCategoryService productCategoryService,
+ IVendorService vendorService,
+ ITranslationService translationService,
+ IProductLayoutService productLayoutService,
+ ISpecificationAttributeService specificationAttributeService,
+ IWorkContext workContext,
+ IGroupService groupService,
+ IWarehouseService warehouseService,
+ IDeliveryDateService deliveryDateService,
+ ITaxCategoryService taxCategoryService,
+ IDiscountService discountService,
+ ICustomerService customerService,
+ IStoreService storeService,
+ ISlugService slugService,
+ IOutOfStockSubscriptionService outOfStockSubscriptionService,
+ IDownloadService downloadService,
+ ILanguageService languageService,
+ IProductAttributeFormatter productAttributeFormatter,
+ IStockQuantityService stockQuantityService,
+ CurrencySettings currencySettings,
+ MeasureSettings measureSettings,
+ TaxSettings taxSettings,
+ SeoSettings seoSettings,
+ IAuctionService auctionService,
+ IPriceFormatter priceFormatter)
+ : IProductViewModelService
{
- private readonly IProductService _productService;
- private readonly IInventoryManageService _inventoryManageService;
- private readonly IPictureService _pictureService;
- private readonly IProductAttributeService _productAttributeService;
- private readonly IProductTagService _productTagService;
- private readonly ICurrencyService _currencyService;
- private readonly IMeasureService _measureService;
- private readonly IDateTimeService _dateTimeService;
- private readonly ICollectionService _collectionService;
- private readonly IProductCollectionService _productCollectionService;
- private readonly ICategoryService _categoryService;
- private readonly IProductCategoryService _productCategoryService;
- private readonly IVendorService _vendorService;
- private readonly ITranslationService _translationService;
- private readonly IProductLayoutService _productLayoutService;
- private readonly ISpecificationAttributeService _specificationAttributeService;
- private readonly IWorkContext _workContext;
- private readonly IGroupService _groupService;
- private readonly IWarehouseService _warehouseService;
- private readonly IDeliveryDateService _deliveryDateService;
- private readonly ITaxCategoryService _taxCategoryService;
- private readonly IDiscountService _discountService;
- private readonly ICustomerService _customerService;
- private readonly IStoreService _storeService;
- private readonly ISlugService _slugService;
- private readonly IOutOfStockSubscriptionService _outOfStockSubscriptionService;
- private readonly IDownloadService _downloadService;
- private readonly IStockQuantityService _stockQuantityService;
- private readonly ILanguageService _languageService;
- private readonly IProductAttributeFormatter _productAttributeFormatter;
- private readonly IAuctionService _auctionService;
- private readonly IPriceFormatter _priceFormatter;
- private readonly CurrencySettings _currencySettings;
- private readonly MeasureSettings _measureSettings;
- private readonly TaxSettings _taxSettings;
- private readonly SeoSettings _seoSettings;
-
- public ProductViewModelService(
- IProductService productService,
- IInventoryManageService inventoryManageService,
- IPictureService pictureService,
- IProductAttributeService productAttributeService,
- IProductTagService productTagService,
- ICurrencyService currencyService,
- IMeasureService measureService,
- IDateTimeService dateTimeService,
- ICollectionService collectionService,
- IProductCollectionService productCollectionService,
- ICategoryService categoryService,
- IProductCategoryService productCategoryService,
- IVendorService vendorService,
- ITranslationService translationService,
- IProductLayoutService productLayoutService,
- ISpecificationAttributeService specificationAttributeService,
- IWorkContext workContext,
- IGroupService groupService,
- IWarehouseService warehouseService,
- IDeliveryDateService deliveryDateService,
- ITaxCategoryService taxCategoryService,
- IDiscountService discountService,
- ICustomerService customerService,
- IStoreService storeService,
- ISlugService slugService,
- IOutOfStockSubscriptionService outOfStockSubscriptionService,
- IDownloadService downloadService,
- ILanguageService languageService,
- IProductAttributeFormatter productAttributeFormatter,
- IStockQuantityService stockQuantityService,
- CurrencySettings currencySettings,
- MeasureSettings measureSettings,
- TaxSettings taxSettings,
- SeoSettings seoSettings,
- IAuctionService auctionService,
- IPriceFormatter priceFormatter)
- {
- _productService = productService;
- _inventoryManageService = inventoryManageService;
- _pictureService = pictureService;
- _productAttributeService = productAttributeService;
- _productTagService = productTagService;
- _currencyService = currencyService;
- _measureService = measureService;
- _dateTimeService = dateTimeService;
- _collectionService = collectionService;
- _productCollectionService = productCollectionService;
- _categoryService = categoryService;
- _productCategoryService = productCategoryService;
- _vendorService = vendorService;
- _translationService = translationService;
- _productLayoutService = productLayoutService;
- _specificationAttributeService = specificationAttributeService;
- _workContext = workContext;
- _groupService = groupService;
- _warehouseService = warehouseService;
- _deliveryDateService = deliveryDateService;
- _taxCategoryService = taxCategoryService;
- _discountService = discountService;
- _customerService = customerService;
- _storeService = storeService;
- _slugService = slugService;
- _outOfStockSubscriptionService = outOfStockSubscriptionService;
- _downloadService = downloadService;
- _stockQuantityService = stockQuantityService;
- _languageService = languageService;
- _productAttributeFormatter = productAttributeFormatter;
- _currencySettings = currencySettings;
- _measureSettings = measureSettings;
- _taxSettings = taxSettings;
- _seoSettings = seoSettings;
- _auctionService = auctionService;
- _priceFormatter = priceFormatter;
- }
protected virtual async Task UpdatePictureSeoNames(Product product)
{
- var picturesename = _pictureService.GetPictureSeName(product.Name);
+ var picturesename = pictureService.GetPictureSeName(product.Name);
foreach (var pp in product.ProductPictures)
{
- var picture = await _pictureService.GetPictureById(pp.PictureId);
+ var picture = await pictureService.GetPictureById(pp.PictureId);
if (picture != null)
- await _pictureService.SetSeoFilename(picture, picturesename);
+ await pictureService.SetSeoFilename(picture, picturesename);
}
}
protected virtual async Task<List<string>> GetChildCategoryIds(string parentCategoryId)
{
var categoriesIds = new List<string>();
- var categories = await _categoryService.GetAllCategoriesByParentCategoryId(parentCategoryId, true);
+ var categories = await categoryService.GetAllCategoriesByParentCategoryId(parentCategoryId, true);
foreach (var category in categories)
{
categoriesIds.Add(category.Id);
@@ -189,7 +114,7 @@ namespace Grand.Web.Admin.Services
var productTagsToRemove = new List<ProductTag>();
foreach (var existingProductTag in existingProductTags)
{
- var existingProductTagText = await _productTagService.GetProductTagByName(existingProductTag.ToLowerInvariant());
+ var existingProductTagText = await productTagService.GetProductTagByName(existingProductTag.ToLowerInvariant());
var found = false;
foreach (var newProductTag in productTags)
{
@@ -209,22 +134,22 @@ namespace Grand.Web.Admin.Services
{
if (productTag != null)
{
- await _productTagService.DetachProductTag(productTag, product.Id);
+ await productTagService.DetachProductTag(productTag, product.Id);
}
}
foreach (var productTagName in productTags)
{
ProductTag productTag;
- var productTag2 = await _productTagService.GetProductTagByName(productTagName);
+ var productTag2 = await productTagService.GetProductTagByName(productTagName);
if (productTag2 == null)
{
//add new product tag
productTag = new ProductTag {
Name = productTagName,
- SeName = SeoExtensions.GetSeName(productTagName, _seoSettings.ConvertNonWesternChars, _seoSettings.AllowUnicodeCharsInUrls, _seoSettings.SeoCharConversion),
+ SeName = SeoExtensions.GetSeName(productTagName, seoSettings.ConvertNonWesternChars, seoSettings.AllowUnicodeCharsInUrls, seoSettings.SeoCharConversion),
Count = 0
};
- await _productTagService.InsertProductTag(productTag);
+ await productTagService.InsertProductTag(productTag);
}
else
{
@@ -232,7 +157,7 @@ namespace Grand.Web.Admin.Services
}
if (!product.ProductTagExists(productTag.Name))
{
- await _productTagService.AttachProductTag(productTag, product.Id);
+ await productTagService.AttachProductTag(productTag, product.Id);
}
}
}
@@ -241,21 +166,21 @@ namespace Grand.Web.Admin.Services
{
var model = new T();
- var storeId = _workContext.CurrentCustomer.StaffStoreId;
+ var storeId = workContext.CurrentCustomer.StaffStoreId;
//stores
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var s in (await _storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var s in (await storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
//vendors
- model.AvailableVendors.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var v in await _vendorService.GetAllVendors(showHidden: true))
+ model.AvailableVendors.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var v in await vendorService.GetAllVendors(showHidden: true))
model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });
//product types
- model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(_translationService, _workContext, false).ToList();
- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "0" });
+ model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(translationService, workContext, false).ToList();
+ model.AvailableProductTypes.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "0" });
return model;
}
@@ -278,7 +203,7 @@ namespace Grand.Web.Admin.Services
.ToList();
foreach (var attribute in attributes)
{
- var productAttribute = await _productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
+ var productAttribute = await productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
var attributeModel = new ProductAttributeCombinationModel.ProductAttributeModel {
Id = attribute.Id,
ProductAttributeId = attribute.ProductAttributeId,
@@ -310,7 +235,7 @@ namespace Grand.Web.Admin.Services
if (!string.IsNullOrEmpty(model.PictureId))
{
- var pictureThumbnailUrl = await _pictureService.GetPictureUrl(model.PictureId, 100, false);
+ var pictureThumbnailUrl = await pictureService.GetPictureUrl(model.PictureId, 100, false);
model.PictureThumbnailUrl = pictureThumbnailUrl;
}
foreach (var picture in product.ProductPictures)
@@ -319,29 +244,29 @@ namespace Grand.Web.Admin.Services
Id = picture.Id,
ProductId = product.Id,
PictureId = picture.PictureId,
- PictureUrl = await _pictureService.GetPictureUrl(picture.PictureId),
+ PictureUrl = await pictureService.GetPictureUrl(picture.PictureId),
DisplayOrder = picture.DisplayOrder
});
}
- model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;
+ model.PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;
}
public virtual async Task PrepareTierPriceModel(ProductModel.TierPriceModel model)
{
- var storeId = _workContext.CurrentCustomer.StaffStoreId;
+ var storeId = workContext.CurrentCustomer.StaffStoreId;
if (string.IsNullOrEmpty(storeId))
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var store in (await _storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
+ foreach (var store in (await storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });
//customer groups
- model.AvailableCustomerGroups.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var role in await _groupService.GetAllCustomerGroups(showHidden: true))
+ model.AvailableCustomerGroups.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var role in await groupService.GetAllCustomerGroups(showHidden: true))
model.AvailableCustomerGroups.Add(new SelectListItem { Text = role.Name, Value = role.Id });
- foreach (var currency in await _currencyService.GetAllCurrencies())
+ foreach (var currency in await currencyService.GetAllCurrencies())
model.AvailableCurrencies.Add(new SelectListItem { Text = currency.Name, Value = currency.CurrencyCode });
}
@@ -354,12 +279,12 @@ namespace Grand.Web.Admin.Services
Id = x.Id,
ProductId = product.Id,
PictureId = x.PictureId,
- PictureUrl = await _pictureService.GetPictureUrl(x.PictureId),
+ PictureUrl = await pictureService.GetPictureUrl(x.PictureId),
DisplayOrder = x.DisplayOrder
});
}
- var associatedProduct = await _productService.GetProductById(model.AssociatedProductId);
+ var associatedProduct = await productService.GetProductById(model.AssociatedProductId);
model.AssociatedProductName = associatedProduct != null ? associatedProduct.Name : "";
}
public virtual async Task OutOfStockNotifications(Product product, ProductModel model, int prevStockQuantity,
@@ -369,11 +294,11 @@ namespace Grand.Web.Admin.Services
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock &&
product.BackorderModeId == BackorderMode.NoBackorders &&
product.AllowOutOfStockSubscriptions &&
- _stockQuantityService.GetTotalStockQuantity(product, total: true) > 0 &&
+ stockQuantityService.GetTotalStockQuantity(product, total: true) > 0 &&
prevStockQuantity <= 0 && !product.UseMultipleWarehouses &&
product.Published)
{
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
}
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock &&
product.BackorderModeId == BackorderMode.NoBackorders &&
@@ -389,7 +314,7 @@ namespace Grand.Web.Admin.Services
if (actualStock != null)
{
if (actualStock.StockQuantity - actualStock.ReservedQuantity > 0)
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, prevstock.WarehouseId);
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, prevstock.WarehouseId);
}
}
}
@@ -397,7 +322,7 @@ namespace Grand.Web.Admin.Services
{
if (prevMultiWarehouseStock.Sum(x => x.StockQuantity - x.ReservedQuantity) <= 0)
{
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
}
}
}
@@ -411,7 +336,7 @@ namespace Grand.Web.Admin.Services
prevcombination.StockQuantity <= 0 && !product.UseMultipleWarehouses &&
product.Published)
{
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, "");
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, "");
}
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes &&
product.BackorderModeId == BackorderMode.NoBackorders &&
@@ -427,7 +352,7 @@ namespace Grand.Web.Admin.Services
if (actualStock != null)
{
if (actualStock.StockQuantity - actualStock.ReservedQuantity > 0)
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, prevstock.WarehouseId);
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, prevstock.WarehouseId);
}
}
}
@@ -435,7 +360,7 @@ namespace Grand.Web.Admin.Services
{
if (prevcombination.WarehouseInventory.Sum(x => x.StockQuantity - x.ReservedQuantity) <= 0)
{
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, "");
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, combination.Attributes, "");
}
}
}
@@ -446,18 +371,18 @@ namespace Grand.Web.Admin.Services
if (model == null)
throw new ArgumentNullException(nameof(model));
- model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;
- model.BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId))?.Name;
- model.BaseDimensionIn = (await _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId))?.Name;
+ model.PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode;
+ model.BaseWeightIn = (await measureService.GetMeasureWeightById(measureSettings.BaseWeightId))?.Name;
+ model.BaseDimensionIn = (await measureService.GetMeasureDimensionById(measureSettings.BaseDimensionId))?.Name;
if (product != null)
{
//date
- model.CreatedOn = _dateTimeService.ConvertToUserTime(product.CreatedOnUtc, DateTimeKind.Utc);
- model.UpdatedOn = product.UpdatedOnUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.UpdatedOnUtc.Value, DateTimeKind.Utc) : null;
+ model.CreatedOn = dateTimeService.ConvertToUserTime(product.CreatedOnUtc, 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);
+ var parentGroupedProduct = await productService.GetProductById(product.ParentGroupedProductId);
if (parentGroupedProduct != null)
{
model.AssociatedToProductId = product.ParentGroupedProductId;
@@ -472,7 +397,7 @@ namespace Grand.Web.Admin.Services
model.AutoAddRequiredProducts = product.AutoAddRequiredProducts;
//product attributes
- foreach (var productAttribute in await _productAttributeService.GetAllProductAttributes())
+ foreach (var productAttribute in await productAttributeService.GetAllProductAttributes())
{
model.AvailableProductAttributes.Add(new SelectListItem {
Text = productAttribute.Name,
@@ -491,7 +416,7 @@ namespace Grand.Web.Admin.Services
}
//layouts
- var layouts = await _productLayoutService.GetAllProductLayouts();
+ var layouts = await productLayoutService.GetAllProductLayouts();
foreach (var layout in layouts)
{
model.AvailableProductLayouts.Add(new SelectListItem {
@@ -502,10 +427,10 @@ namespace Grand.Web.Admin.Services
//delivery dates
model.AvailableDeliveryDates.Add(new SelectListItem {
- Text = _translationService.GetResource("Admin.Catalog.Products.Fields.DeliveryDate.None"),
+ Text = translationService.GetResource("Admin.Catalog.Products.Fields.DeliveryDate.None"),
Value = ""
});
- var deliveryDates = await _deliveryDateService.GetAllDeliveryDates();
+ var deliveryDates = await deliveryDateService.GetAllDeliveryDates();
foreach (var deliveryDate in deliveryDates)
{
model.AvailableDeliveryDates.Add(new SelectListItem {
@@ -515,9 +440,9 @@ namespace Grand.Web.Admin.Services
}
//warehouses
- var warehouses = await _warehouseService.GetAllWarehouses();
+ var warehouses = await warehouseService.GetAllWarehouses();
model.AvailableWarehouses.Add(new SelectListItem {
- Text = _translationService.GetResource("Admin.Catalog.Products.Fields.Warehouse.None"),
+ Text = translationService.GetResource("Admin.Catalog.Products.Fields.Warehouse.None"),
Value = ""
});
foreach (var warehouse in warehouses)
@@ -556,7 +481,7 @@ namespace Grand.Web.Admin.Services
for (var i = 0; i < product.ProductTags.Count; i++)
{
var pt = product.ProductTags.ToList()[i];
- var productTag = await _productTagService.GetProductTagByName(pt);
+ var productTag = await productTagService.GetProductTagByName(pt);
if (productTag != null)
{
result.Append(productTag.Name);
@@ -568,28 +493,28 @@ namespace Grand.Web.Admin.Services
}
//tax categories
- var taxCategories = await _taxCategoryService.GetAllTaxCategories();
- model.AvailableTaxCategories.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Configuration.Tax.Settings.TaxCategories.None"), Value = "" });
+ var taxCategories = await taxCategoryService.GetAllTaxCategories();
+ model.AvailableTaxCategories.Add(new SelectListItem { Text = translationService.GetResource("Admin.Configuration.Tax.Settings.TaxCategories.None"), Value = "" });
foreach (var tc in taxCategories)
model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.Id, Selected = product != null && !setPredefinedValues && tc.Id == product.TaxCategoryId });
//baseprice units
- var measureWeights = await _measureService.GetAllMeasureWeights();
+ var measureWeights = await measureService.GetAllMeasureWeights();
foreach (var mw in measureWeights)
model.AvailableBasepriceUnits.Add(new SelectListItem { Text = mw.Name, Value = mw.Id, Selected = product != null && !setPredefinedValues && mw.Id == product.BasepriceUnitId });
foreach (var mw in measureWeights)
model.AvailableBasepriceBaseUnits.Add(new SelectListItem { Text = mw.Name, Value = mw.Id, Selected = product != null && !setPredefinedValues && mw.Id == product.BasepriceBaseUnitId });
//units
- var units = await _measureService.GetAllMeasureUnits();
+ var units = await measureService.GetAllMeasureUnits();
model.AvailableUnits.Add(new SelectListItem { Text = "---", Value = "" });
foreach (var un in units)
model.AvailableUnits.Add(new SelectListItem { Text = un.Name, Value = un.Id, Selected = product != null && un.Id == product.UnitId });
//discounts
- model.AvailableDiscounts = (await _discountService
- .GetAllDiscounts(DiscountType.AssignedToSkus, storeId: _workContext.CurrentCustomer.StaffStoreId, showHidden: true))
- .Select(d => d.ToModel(_dateTimeService))
+ model.AvailableDiscounts = (await discountService
+ .GetAllDiscounts(DiscountType.AssignedToSkus, storeId: workContext.CurrentCustomer.StaffStoreId, showHidden: true))
+ .Select(d => d.ToModel(dateTimeService))
.ToList();
if (!excludeProperties && product != null)
{
@@ -607,7 +532,7 @@ namespace Grand.Web.Admin.Services
model.NotifyAdminForQuantityBelow = 1;
model.OrderMinimumQuantity = 1;
model.OrderMaximumQuantity = 10000;
- model.TaxCategoryId = _taxSettings.DefaultTaxCategoryId;
+ model.TaxCategoryId = taxSettings.DefaultTaxCategoryId;
model.UnlimitedDownloads = true;
model.IsShipEnabled = true;
model.AllowCustomerReviews = true;
@@ -627,7 +552,7 @@ namespace Grand.Web.Admin.Services
if (!product.UseMultipleWarehouses)
return;
- var warehouses = await _warehouseService.GetAllWarehouses();
+ var warehouses = await warehouseService.GetAllWarehouses();
foreach (var warehouse in warehouses)
{
@@ -640,12 +565,12 @@ namespace Grand.Web.Admin.Services
//update existing record
existingPwI.StockQuantity = whim.StockQuantity;
existingPwI.ReservedQuantity = whim.ReservedQuantity;
- await _productService.UpdateProductWarehouseInventory(existingPwI, product.Id);
+ await productService.UpdateProductWarehouseInventory(existingPwI, product.Id);
}
else
{
//delete. no need to store record for qty 0
- await _productService.DeleteProductWarehouseInventory(existingPwI, product.Id);
+ await productService.DeleteProductWarehouseInventory(existingPwI, product.Id);
}
}
else
@@ -659,14 +584,14 @@ namespace Grand.Web.Admin.Services
ReservedQuantity = whim.ReservedQuantity
};
product.ProductWarehouseInventory.Add(existingPwI);
- await _productService.InsertProductWarehouseInventory(existingPwI, product.Id);
+ await productService.InsertProductWarehouseInventory(existingPwI, product.Id);
}
}
}
product.StockQuantity = product.ProductWarehouseInventory.Sum(x => x.StockQuantity);
product.ReservedQuantity = product.ProductWarehouseInventory.Sum(x => x.ReservedQuantity);
- await _inventoryManageService.UpdateStockProduct(product, false);
+ await inventoryManageService.UpdateStockProduct(product, false);
}
public virtual async Task PrepareProductReviewModel(ProductReviewModel model,
@@ -677,17 +602,17 @@ namespace Grand.Web.Admin.Services
if (productReview == null)
throw new ArgumentNullException(nameof(productReview));
- var product = await _productService.GetProductById(productReview.ProductId);
- var customer = await _customerService.GetCustomerById(productReview.CustomerId);
- var store = await _storeService.GetStoreById(productReview.StoreId);
+ var product = await productService.GetProductById(productReview.ProductId);
+ var customer = await customerService.GetCustomerById(productReview.CustomerId);
+ var store = await storeService.GetStoreById(productReview.StoreId);
model.Id = productReview.Id;
model.StoreName = store != null ? store.Shortcut : "";
model.ProductId = productReview.ProductId;
model.ProductName = product.Name;
model.CustomerId = productReview.CustomerId;
- model.CustomerInfo = customer != null ? !string.IsNullOrEmpty(customer.Email) ? customer.Email : _translationService.GetResource("Admin.Customers.Guest") : "";
+ model.CustomerInfo = customer != null ? !string.IsNullOrEmpty(customer.Email) ? customer.Email : translationService.GetResource("Admin.Customers.Guest") : "";
model.Rating = productReview.Rating;
- model.CreatedOn = _dateTimeService.ConvertToUserTime(productReview.CreatedOnUtc, DateTimeKind.Utc);
+ model.CreatedOn = dateTimeService.ConvertToUserTime(productReview.CreatedOnUtc, DateTimeKind.Utc);
model.Signature = productReview.Signature;
if (!excludeProperties)
{
@@ -709,22 +634,22 @@ namespace Grand.Web.Admin.Services
{
var model = new ProductListModel();
- var storeId = _workContext.CurrentCustomer.StaffStoreId;
+ var storeId = workContext.CurrentCustomer.StaffStoreId;
//stores
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var s in (await _storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var s in (await storeService.GetAllStores()).Where(x => x.Id == storeId || string.IsNullOrWhiteSpace(storeId)))
{
model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
}
//warehouses
- model.AvailableWarehouses.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });
- foreach (var wh in await _warehouseService.GetAllWarehouses())
+ model.AvailableWarehouses.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = " " });
+ foreach (var wh in await warehouseService.GetAllWarehouses())
model.AvailableWarehouses.Add(new SelectListItem { Text = wh.Name, Value = wh.Id });
//product types
- model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(_translationService, _workContext, false).ToList();
- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "0" });
+ model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(translationService, workContext, false).ToList();
+ model.AvailableProductTypes.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "0" });
//"published" property
//0 - all (according to "ShowHidden" parameter)
@@ -732,19 +657,19 @@ namespace Grand.Web.Admin.Services
//2 - unpublished only
//3 - Show on homepage
//4 - mark as new
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.All"), Value = " " });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.PublishedOnly"), Value = "1" });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.UnpublishedOnly"), Value = "2" });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.ShowOnHomePage"), Value = "3" });
- model.AvailablePublishedOptions.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.MarkAsNew"), Value = "4" });
+ model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.All"), Value = " " });
+ model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.PublishedOnly"), Value = "1" });
+ model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.UnpublishedOnly"), Value = "2" });
+ model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.ShowOnHomePage"), Value = "3" });
+ model.AvailablePublishedOptions.Add(new SelectListItem { Text = translationService.GetResource("Admin.Catalog.Products.List.SearchPublished.MarkAsNew"), Value = "4" });
return model;
}
public virtual async Task<(IEnumerable<ProductModel> productModels, int totalCount)> PrepareProductsModel(ProductListModel model, int pageIndex, int pageSize)
{
//limit for store manager
- if (!string.IsNullOrEmpty(_workContext.CurrentCustomer.StaffStoreId))
- model.SearchStoreId = _workContext.CurrentCustomer.StaffStoreId;
+ if (!string.IsNullOrEmpty(workContext.CurrentCustomer.StaffStoreId))
+ model.SearchStoreId = workContext.CurrentCustomer.StaffStoreId;
var categoryIds = new List<string>();
if (!string.IsNullOrEmpty(model.SearchCategoryId))
@@ -774,7 +699,7 @@ namespace Grand.Web.Admin.Services
var markedAsNewOnly = model.SearchPublishedId == 4;
- var products = (await _productService.SearchProducts(
+ var products = (await productService.SearchProducts(
categoryIds: categoryIds,
brandId: model.SearchBrandId,
collectionId: model.SearchCollectionId,
@@ -794,20 +719,20 @@ namespace Grand.Web.Admin.Services
var items = new List<ProductModel>();
foreach (var x in products)
{
- var productModel = x.ToModel(_dateTimeService);
+ var productModel = x.ToModel(dateTimeService);
//"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
//also it improves performance
productModel.FullDescription = "";
//picture
var defaultProductPicture = x.ProductPictures.FirstOrDefault() ?? new ProductPicture();
- productModel.PictureThumbnailUrl = await _pictureService.GetPictureUrl(defaultProductPicture.PictureId, 100);
+ productModel.PictureThumbnailUrl = await pictureService.GetPictureUrl(defaultProductPicture.PictureId, 100);
//product type
- productModel.ProductTypeName = x.ProductTypeId.GetTranslationEnum(_translationService, _workContext);
+ productModel.ProductTypeName = x.ProductTypeId.GetTranslationEnum(translationService, workContext);
//friendly stock quantity
//if a simple product AND "manage inventory" is "Track inventory", then display
if (x.ProductTypeId == ProductType.SimpleProduct && x.ManageInventoryMethodId == ManageInventoryMethod.ManageStock)
- productModel.StockQuantityStr = _stockQuantityService.GetTotalStockQuantity(x, total: true).ToString();
+ productModel.StockQuantityStr = stockQuantityService.GetTotalStockQuantity(x, total: true).ToString();
items.Add(productModel);
}
return (items, products.TotalCount);
@@ -815,7 +740,7 @@ namespace Grand.Web.Admin.Services
public virtual async Task<IList<Product>> PrepareProducts(ProductListModel model)
{
//limit for store manager
- model.SearchStoreId = _workContext.CurrentCustomer.StaffStoreId;
+ model.SearchStoreId = workContext.CurrentCustomer.StaffStoreId;
var categoryIds = new List<string>();
if (!string.IsNullOrEmpty(model.SearchCategoryId))
@@ -839,7 +764,7 @@ namespace Grand.Web.Admin.Services
break;
}
- var products = (await _productService.SearchProducts(
+ var products = (await productService.SearchProducts(
categoryIds: categoryIds,
brandId: model.SearchBrandId,
collectionId: model.SearchCollectionId,
@@ -857,62 +782,62 @@ namespace Grand.Web.Admin.Services
public virtual async Task<Product> InsertProductModel(ProductModel model)
{
//a staff should have access only to his products
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- model.Stores = [_workContext.CurrentCustomer.StaffStoreId];
+ model.Stores = [workContext.CurrentCustomer.StaffStoreId];
}
//product
- var product = model.ToEntity(_dateTimeService);
- await _productService.InsertProduct(product);
+ var product = model.ToEntity(dateTimeService);
+ 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);
+ product.Locales = await model.Locales.ToTranslationProperty(product, x => x.Name, seoSettings, slugService, languageService);
//search engine name
- await _slugService.SaveSlug(product, model.SeName, "");
+ await slugService.SaveSlug(product, model.SeName, "");
//tags
await SaveProductTags(product, ParseProductTags(model.ProductTags));
//warehouses
await SaveProductWarehouseInventory(product, model.ProductWarehouseInventoryModels);
//discounts
- var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToSkus, storeId: _workContext.CurrentCustomer.StaffStoreId, showHidden: true);
+ var allDiscounts = await discountService.GetAllDiscounts(DiscountType.AssignedToSkus, storeId: workContext.CurrentCustomer.StaffStoreId, showHidden: true);
foreach (var discount in allDiscounts)
{
if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id))
{
product.AppliedDiscounts.Add(discount.Id);
- await _productService.InsertDiscount(discount.Id, product.Id);
+ await productService.InsertDiscount(discount.Id, product.Id);
}
}
- await _productService.UpdateProduct(product);
+ await productService.UpdateProduct(product);
return product;
}
public virtual async Task<Product> UpdateProductModel(Product product, ProductModel model)
{
//a staff should have access only to his products
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- model.Stores = [_workContext.CurrentCustomer.StaffStoreId];
+ model.Stores = [workContext.CurrentCustomer.StaffStoreId];
}
- var prevStockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true);
+ var prevStockQuantity = stockQuantityService.GetTotalStockQuantity(product, total: true);
var prevMultiWarehouseStock = product.ProductWarehouseInventory.Select(i => new ProductWarehouseInventory { WarehouseId = i.WarehouseId, StockQuantity = i.StockQuantity, ReservedQuantity = i.ReservedQuantity }).ToList();
var prevDownloadId = product.DownloadId;
var prevSampleDownloadId = product.SampleDownloadId;
//product
- product = model.ToEntity(product, _dateTimeService);
+ product = model.ToEntity(product, dateTimeService);
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, "");
+ await slugService.SaveSlug(product, model.SeName, "");
//tags
await SaveProductTags(product, ParseProductTags(model.ProductTags));
//warehouses
@@ -920,7 +845,7 @@ namespace Grand.Web.Admin.Services
//picture seo names
await UpdatePictureSeoNames(product);
//discounts
- var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToSkus, storeId: _workContext.CurrentCustomer.StaffStoreId, showHidden: true);
+ var allDiscounts = await discountService.GetAllDiscounts(DiscountType.AssignedToSkus, storeId: workContext.CurrentCustomer.StaffStoreId, showHidden: true);
foreach (var discount in allDiscounts)
{
if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id))
@@ -929,7 +854,7 @@ namespace Grand.Web.Admin.Services
if (product.AppliedDiscounts.Count(d => d == discount.Id) == 0)
{
product.AppliedDiscounts.Add(discount.Id);
- await _productService.InsertDiscount(discount.Id, product.Id);
+ await productService.InsertDiscount(discount.Id, product.Id);
}
}
else
@@ -938,11 +863,11 @@ namespace Grand.Web.Admin.Services
if (product.AppliedDiscounts.Count(d => d == discount.Id) > 0)
{
product.AppliedDiscounts.Remove(discount.Id);
- await _productService.DeleteDiscount(discount.Id, product.Id);
+ await productService.DeleteDiscount(discount.Id, product.Id);
}
}
}
- await _productService.UpdateProduct(product);
+ await productService.UpdateProduct(product);
//out of stock notifications
await OutOfStockNotifications(product, model, prevStockQuantity, prevMultiWarehouseStock);
@@ -950,48 +875,48 @@ namespace Grand.Web.Admin.Services
//delete an old "download" file (if deleted or updated)
if (!string.IsNullOrEmpty(prevDownloadId) && prevDownloadId != product.DownloadId)
{
- var prevDownload = await _downloadService.GetDownloadById(prevDownloadId);
+ var prevDownload = await downloadService.GetDownloadById(prevDownloadId);
if (prevDownload != null)
- await _downloadService.DeleteDownload(prevDownload);
+ await downloadService.DeleteDownload(prevDownload);
}
//delete an old "sample download" file (if deleted or updated)
if (!string.IsNullOrEmpty(prevSampleDownloadId) && prevSampleDownloadId != product.SampleDownloadId)
{
- var prevSampleDownload = await _downloadService.GetDownloadById(prevSampleDownloadId);
+ var prevSampleDownload = await downloadService.GetDownloadById(prevSampleDownloadId);
if (prevSampleDownload != null)
- await _downloadService.DeleteDownload(prevSampleDownload);
+ await downloadService.DeleteDownload(prevSampleDownload);
}
return product;
}
public virtual async Task DeleteProduct(Product product)
{
- await _productService.DeleteProduct(product);
+ await productService.DeleteProduct(product);
//delete an "download" file
if (!string.IsNullOrEmpty(product.DownloadId))
{
- var download = await _downloadService.GetDownloadById(product.DownloadId);
+ var download = await downloadService.GetDownloadById(product.DownloadId);
if (download != null)
- await _downloadService.DeleteDownload(download);
+ await downloadService.DeleteDownload(download);
}
if (!string.IsNullOrEmpty(product.SampleDownloadId))
{
- var sampledownload = await _downloadService.GetDownloadById(product.SampleDownloadId);
+ var sampledownload = await downloadService.GetDownloadById(product.SampleDownloadId);
if (sampledownload != null)
- await _downloadService.DeleteDownload(sampledownload);
+ await downloadService.DeleteDownload(sampledownload);
}
}
public virtual async Task DeleteSelected(IEnumerable<string> selectedIds)
{
var products = new List<Product>();
- products.AddRange(await _productService.GetProductsByIds(selectedIds.ToArray(), true));
+ products.AddRange(await productService.GetProductsByIds(selectedIds.ToArray(), true));
for (var i = 0; i < products.Count; i++)
{
var product = products[i];
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- if (!(product.LimitedToStores && product.Stores.Contains(_workContext.CurrentCustomer.StaffStoreId) && product.Stores.Count == 1))
+ if (!(product.LimitedToStores && product.Stores.Contains(workContext.CurrentCustomer.StaffStoreId) && product.Stores.Count == 1))
continue;
}
await DeleteProduct(product);
@@ -1005,10 +930,10 @@ namespace Grand.Web.Admin.Services
public virtual async Task<(IList<ProductModel> products, int totalCount)> PrepareProductModel(ProductModel.AddProductModel model, int pageIndex, int pageSize)
{
//limit for store manager
- model.SearchStoreId = _workContext.CurrentCustomer.StaffStoreId;
+ model.SearchStoreId = workContext.CurrentCustomer.StaffStoreId;
- var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);
- return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount);
+ var products = await productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize);
+ return (products.Select(x => x.ToModel(dateTimeService)).ToList(), products.TotalCount);
}
public virtual async Task<IList<ProductModel.ProductCategoryModel>> PrepareProductCategoryModel(Product product)
@@ -1017,10 +942,10 @@ namespace Grand.Web.Admin.Services
var items = new List<ProductModel.ProductCategoryModel>();
foreach (var x in productCategories)
{
- var category = await _categoryService.GetCategoryById(x.CategoryId);
+ var category = await categoryService.GetCategoryById(x.CategoryId);
items.Add(new ProductModel.ProductCategoryModel {
Id = x.Id,
- Category = await _categoryService.GetFormattedBreadCrumb(category),
+ Category = await categoryService.GetFormattedBreadCrumb(category),
ProductId = product.Id,
CategoryId = x.CategoryId,
IsFeaturedProduct = x.IsFeaturedProduct,
@@ -1031,7 +956,7 @@ namespace Grand.Web.Admin.Services
}
public virtual async Task InsertProductCategoryModel(ProductModel.ProductCategoryModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
if (product != null && product.ProductCategories.All(x => x.CategoryId != model.CategoryId))
{
var productCategory = new ProductCategory {
@@ -1039,12 +964,12 @@ namespace Grand.Web.Admin.Services
DisplayOrder = model.DisplayOrder,
IsFeaturedProduct = model.IsFeaturedProduct
};
- await _productCategoryService.InsertProductCategory(productCategory, product.Id);
+ await productCategoryService.InsertProductCategory(productCategory, product.Id);
}
}
public virtual async Task UpdateProductCategoryModel(ProductModel.ProductCategoryModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
var productCategory = product.ProductCategories.FirstOrDefault(x => x.Id == model.Id);
if (productCategory == null)
throw new ArgumentException("No product category mapping found with the specified id");
@@ -1055,16 +980,16 @@ namespace Grand.Web.Admin.Services
productCategory.CategoryId = model.CategoryId;
productCategory.DisplayOrder = model.DisplayOrder;
productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
- await _productCategoryService.UpdateProductCategory(productCategory, product.Id);
+ await productCategoryService.UpdateProductCategory(productCategory, product.Id);
}
public virtual async Task DeleteProductCategory(string id, string productId)
{
- var product = await _productService.GetProductById(productId, true);
+ var product = await productService.GetProductById(productId, true);
var productCategory = product.ProductCategories.FirstOrDefault(x => x.Id == id);
if (productCategory == null)
throw new ArgumentException("No product category mapping found with the specified id");
- await _productCategoryService.DeleteProductCategory(productCategory, product.Id);
+ await productCategoryService.DeleteProductCategory(productCategory, product.Id);
}
public virtual async Task<IList<ProductModel.ProductCollectionModel>> PrepareProductCollectionModel(Product product)
{
@@ -1073,7 +998,7 @@ namespace Grand.Web.Admin.Services
{
items.Add(new ProductModel.ProductCollectionModel {
Id = x.Id,
- Collection = (await _collectionService.GetCollectionById(x.CollectionId)).Name,
+ Collection = (await collectionService.GetCollectionById(x.CollectionId)).Name,
ProductId = product.Id,
CollectionId = x.CollectionId,
IsFeaturedProduct = x.IsFeaturedProduct,
@@ -1085,7 +1010,7 @@ namespace Grand.Web.Admin.Services
public virtual async Task InsertProductCollection(ProductModel.ProductCollectionModel model)
{
var collectionId = model.CollectionId;
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
if (product != null && product.ProductCollections.All(x => x.CollectionId != collectionId))
{
var productCollection = new ProductCollection {
@@ -1093,12 +1018,12 @@ namespace Grand.Web.Admin.Services
DisplayOrder = model.DisplayOrder,
IsFeaturedProduct = model.IsFeaturedProduct
};
- await _productCollectionService.InsertProductCollection(productCollection, model.ProductId);
+ await productCollectionService.InsertProductCollection(productCollection, model.ProductId);
}
}
public virtual async Task UpdateProductCollection(ProductModel.ProductCollectionModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
var productCollection = product.ProductCollections.FirstOrDefault(x => x.Id == model.Id);
if (productCollection == null)
throw new ArgumentException("No product collection mapping found with the specified id");
@@ -1110,24 +1035,24 @@ namespace Grand.Web.Admin.Services
productCollection.DisplayOrder = model.DisplayOrder;
productCollection.IsFeaturedProduct = model.IsFeaturedProduct;
- await _productCollectionService.UpdateProductCollection(productCollection, product.Id);
+ await productCollectionService.UpdateProductCollection(productCollection, product.Id);
}
public virtual async Task DeleteProductCollection(string id, string productId)
{
- var product = await _productService.GetProductById(productId, true);
+ var product = await productService.GetProductById(productId, true);
var productCollection = product.ProductCollections.FirstOrDefault(x => x.Id == id);
if (productCollection == null)
throw new ArgumentException("No product collection mapping found with the specified id");
- await _productCollectionService.DeleteProductCollection(productCollection, product.Id);
+ await productCollectionService.DeleteProductCollection(productCollection, product.Id);
}
public virtual async Task InsertRelatedProductModel(ProductModel.AddRelatedProductModel model)
{
- var productId1 = await _productService.GetProductById(model.ProductId, true);
+ var productId1 = await productService.GetProductById(model.ProductId, true);
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
var existingRelatedProducts = productId1.RelatedProducts;
@@ -1139,41 +1064,41 @@ namespace Grand.Web.Admin.Services
DisplayOrder = 1
};
productId1.RelatedProducts.Add(related);
- await _productService.InsertRelatedProduct(related, model.ProductId);
+ await productService.InsertRelatedProduct(related, model.ProductId);
}
}
}
}
public virtual async Task UpdateRelatedProductModel(ProductModel.RelatedProductModel model)
{
- var product1 = await _productService.GetProductById(model.ProductId1, true);
+ var product1 = await productService.GetProductById(model.ProductId1, true);
var relatedProduct = product1.RelatedProducts.FirstOrDefault(x => x.Id == model.Id);
if (relatedProduct == null)
throw new ArgumentException("No related product found with the specified id");
- var product2 = await _productService.GetProductById(relatedProduct.ProductId2);
+ var product2 = await productService.GetProductById(relatedProduct.ProductId2);
if (product2 == null)
throw new ArgumentException("No product found with the specified id");
relatedProduct.DisplayOrder = model.DisplayOrder;
- await _productService.UpdateRelatedProduct(relatedProduct, model.ProductId1);
+ await productService.UpdateRelatedProduct(relatedProduct, model.ProductId1);
}
public virtual async Task DeleteRelatedProductModel(ProductModel.RelatedProductModel model)
{
- var product = await _productService.GetProductById(model.ProductId1, true);
+ var product = await productService.GetProductById(model.ProductId1, true);
var relatedProduct = product.RelatedProducts.FirstOrDefault(x => x.Id == model.Id);
if (relatedProduct == null)
throw new ArgumentException("No related product found with the specified id");
- await _productService.DeleteRelatedProduct(relatedProduct, model.ProductId1);
+ await productService.DeleteRelatedProduct(relatedProduct, model.ProductId1);
}
public virtual async Task InsertSimilarProductModel(ProductModel.AddSimilarProductModel model)
{
- var productId1 = await _productService.GetProductById(model.ProductId, true);
+ var productId1 = await productService.GetProductById(model.ProductId, true);
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
var existingSimilarProducts = productId1.SimilarProducts;
@@ -1186,43 +1111,43 @@ namespace Grand.Web.Admin.Services
DisplayOrder = 1
};
productId1.SimilarProducts.Add(similar);
- await _productService.InsertSimilarProduct(similar);
+ await productService.InsertSimilarProduct(similar);
}
}
}
}
public virtual async Task UpdateSimilarProductModel(ProductModel.SimilarProductModel model)
{
- var product1 = await _productService.GetProductById(model.ProductId1, true);
+ var product1 = await productService.GetProductById(model.ProductId1, true);
var similarProduct = product1.SimilarProducts.FirstOrDefault(x => x.Id == model.Id);
if (similarProduct == null)
throw new ArgumentException("No similar product found with the specified id");
- var product2 = await _productService.GetProductById(similarProduct.ProductId2);
+ var product2 = await productService.GetProductById(similarProduct.ProductId2);
if (product2 == null)
throw new ArgumentException("No product found with the specified id");
similarProduct.ProductId1 = model.ProductId1;
similarProduct.DisplayOrder = model.DisplayOrder;
- await _productService.UpdateSimilarProduct(similarProduct);
+ await productService.UpdateSimilarProduct(similarProduct);
}
public virtual async Task DeleteSimilarProductModel(ProductModel.SimilarProductModel model)
{
- var product = await _productService.GetProductById(model.ProductId1, true);
+ var product = await productService.GetProductById(model.ProductId1, true);
var similarProduct = product.SimilarProducts.FirstOrDefault(x => x.Id == model.Id);
if (similarProduct == null)
throw new ArgumentException("No similar product found with the specified id");
similarProduct.ProductId1 = model.ProductId1;
- await _productService.DeleteSimilarProduct(similarProduct);
+ await productService.DeleteSimilarProduct(similarProduct);
}
public virtual async Task InsertBundleProductModel(ProductModel.AddBundleProductModel model)
{
- var productId1 = await _productService.GetProductById(model.ProductId, true);
+ var productId1 = await productService.GetProductById(model.ProductId, true);
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
var existingBundleProducts = productId1.BundleProducts;
@@ -1235,48 +1160,48 @@ namespace Grand.Web.Admin.Services
Quantity = 1
};
productId1.BundleProducts.Add(bundle);
- await _productService.InsertBundleProduct(bundle, model.ProductId);
+ await productService.InsertBundleProduct(bundle, model.ProductId);
}
}
}
}
public virtual async Task UpdateBundleProductModel(ProductModel.BundleProductModel model)
{
- var product = await _productService.GetProductById(model.ProductBundleId, true);
+ var product = await productService.GetProductById(model.ProductBundleId, true);
var bundleProduct = product.BundleProducts.FirstOrDefault(x => x.Id == model.Id);
if (bundleProduct == null)
throw new ArgumentException("No bundle product found with the specified id");
- var product2 = await _productService.GetProductById(bundleProduct.ProductId);
+ var product2 = await productService.GetProductById(bundleProduct.ProductId);
if (product2 == null)
throw new ArgumentException("No product found with the specified id");
bundleProduct.ProductId = model.ProductId;
bundleProduct.Quantity = model.Quantity > 0 ? model.Quantity : 1;
bundleProduct.DisplayOrder = model.DisplayOrder;
- await _productService.UpdateBundleProduct(bundleProduct, model.ProductBundleId);
+ await productService.UpdateBundleProduct(bundleProduct, model.ProductBundleId);
}
public virtual async Task DeleteBundleProductModel(ProductModel.BundleProductModel model)
{
- var product = await _productService.GetProductById(model.ProductBundleId, true);
+ var product = await productService.GetProductById(model.ProductBundleId, true);
var bundleProduct = product.BundleProducts.FirstOrDefault(x => x.Id == model.Id);
if (bundleProduct == null)
throw new ArgumentException("No bundle product found with the specified id");
- await _productService.DeleteBundleProduct(bundleProduct, model.ProductBundleId);
+ await productService.DeleteBundleProduct(bundleProduct, model.ProductBundleId);
}
public virtual async Task InsertCrossSellProductModel(ProductModel.AddCrossSellProductModel model)
{
- var crossSellProduct = await _productService.GetProductById(model.ProductId, true);
+ var crossSellProduct = await productService.GetProductById(model.ProductId, true);
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
if (!crossSellProduct.CrossSellProduct.Any(x => x == id))
{
if (model.ProductId != id)
- await _productService.InsertCrossSellProduct(
+ await productService.InsertCrossSellProduct(
new CrossSellProduct {
ProductId1 = model.ProductId,
ProductId2 = id
@@ -1291,45 +1216,45 @@ namespace Grand.Web.Admin.Services
ProductId1 = productId,
ProductId2 = crossSellProductId
};
- await _productService.DeleteCrossSellProduct(crosssell);
+ await productService.DeleteCrossSellProduct(crosssell);
}
public virtual async Task InsertRecommendedProductModel(ProductModel.AddRecommendedProductModel model)
{
- var mainproduct = await _productService.GetProductById(model.ProductId, true);
+ var mainproduct = await productService.GetProductById(model.ProductId, true);
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
if (!mainproduct.RecommendedProduct.Any(x => x == id))
{
if (model.ProductId != id)
- await _productService.InsertRecommendedProduct(model.ProductId, id);
+ await productService.InsertRecommendedProduct(model.ProductId, id);
}
}
}
}
public virtual async Task DeleteRecommendedProduct(string productId, string recommendedProductId)
{
- await _productService.DeleteRecommendedProduct(productId, recommendedProductId);
+ await productService.DeleteRecommendedProduct(productId, recommendedProductId);
}
public virtual async Task InsertAssociatedProductModel(ProductModel.AddAssociatedProductModel model)
{
foreach (var id in model.SelectedProductIds)
{
- var product = await _productService.GetProductById(id);
+ var product = await productService.GetProductById(id);
if (product != null)
{
product.ParentGroupedProductId = model.ProductId;
- await _productService.UpdateAssociatedProduct(product);
+ await productService.UpdateAssociatedProduct(product);
}
}
}
public virtual async Task DeleteAssociatedProduct(Product product)
{
product.ParentGroupedProductId = "";
- await _productService.UpdateAssociatedProduct(product);
+ await productService.UpdateAssociatedProduct(product);
}
public virtual async Task<ProductModel.AddRelatedProductModel> PrepareRelatedProductModel()
{
@@ -1368,22 +1293,22 @@ namespace Grand.Web.Admin.Services
var storeId = string.Empty;
//product types
- model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(_translationService, _workContext, false).ToList();
- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "0" });
+ model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(translationService, workContext, false).ToList();
+ model.AvailableProductTypes.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "0" });
// avaible stores
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- storeId = _workContext.CurrentCustomer.StaffStoreId;
- var store = (await _storeService.GetAllStores()).FirstOrDefault(x => x.Id == storeId);
+ storeId = workContext.CurrentCustomer.StaffStoreId;
+ var store = (await storeService.GetAllStores()).FirstOrDefault(x => x.Id == storeId);
if (store != null)
model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });
}
else
{
- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });
+ model.AvailableStores.Add(new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "" });
- foreach (var s in await _storeService.GetAllStores())
+ foreach (var s in await storeService.GetAllStores())
{
model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });
}
@@ -1393,14 +1318,14 @@ namespace Grand.Web.Admin.Services
public virtual async Task<(IEnumerable<BulkEditProductModel> bulkEditProductModels, int totalCount)> PrepareBulkEditProductModel(BulkEditListModel model, int pageIndex, int pageSize)
{
var storeId = model.SearchStoreId;
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
- storeId = _workContext.CurrentCustomer.StaffStoreId;
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
+ storeId = workContext.CurrentCustomer.StaffStoreId;
var searchCategoryIds = new List<string>();
if (!string.IsNullOrEmpty(model.SearchCategoryId))
searchCategoryIds.Add(model.SearchCategoryId);
- var products = (await _productService.SearchProducts(categoryIds: searchCategoryIds,
+ var products = (await productService.SearchProducts(categoryIds: searchCategoryIds,
brandId: model.SearchBrandId,
collectionId: model.SearchCollectionId,
storeId: storeId,
@@ -1419,7 +1344,7 @@ namespace Grand.Web.Admin.Services
OldPrice = x.OldPrice,
Price = x.Price,
ManageInventoryMethodId = (int)x.ManageInventoryMethodId,
- ManageInventoryMethod = x.ManageInventoryMethodId.GetTranslationEnum(_translationService, _workContext.WorkingLanguage.Id),
+ ManageInventoryMethod = x.ManageInventoryMethodId.GetTranslationEnum(translationService, workContext.WorkingLanguage.Id),
StockQuantity = x.StockQuantity,
Published = x.Published
};
@@ -1431,17 +1356,17 @@ namespace Grand.Web.Admin.Services
foreach (var pModel in products)
{
//update
- var product = await _productService.GetProductById(pModel.Id, true);
+ var product = await productService.GetProductById(pModel.Id, true);
if (product != null)
{
//a staff can have access only to his products
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- if (!product.AccessToEntityByStore(_workContext.CurrentCustomer.StaffStoreId))
+ if (!product.AccessToEntityByStore(workContext.CurrentCustomer.StaffStoreId))
continue;
}
- var prevStockQuantity = _stockQuantityService.GetTotalStockQuantity(product, total: true);
+ var prevStockQuantity = stockQuantityService.GetTotalStockQuantity(product, total: true);
product.Sku = pModel.Sku;
product.Price = pModel.Price;
@@ -1450,17 +1375,17 @@ namespace Grand.Web.Admin.Services
product.Published = pModel.Published;
product.Name = pModel.Name;
product.ManageInventoryMethodId = (ManageInventoryMethod)pModel.ManageInventoryMethodId;
- await _productService.UpdateProduct(product);
+ await productService.UpdateProduct(product);
//out of stock notifications
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock &&
product.BackorderModeId == BackorderMode.NoBackorders &&
product.AllowOutOfStockSubscriptions &&
- _stockQuantityService.GetTotalStockQuantity(product, total: true) > 0 &&
+ stockQuantityService.GetTotalStockQuantity(product, total: true) > 0 &&
prevStockQuantity <= 0 && !product.UseMultipleWarehouses &&
product.Published)
{
- await _outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
+ await outOfStockSubscriptionService.SendNotificationsToSubscribers(product, "");
}
}
}
@@ -1471,23 +1396,23 @@ namespace Grand.Web.Admin.Services
foreach (var pModel in products)
{
//delete
- var product = await _productService.GetProductById(pModel.Id, true);
+ var product = await productService.GetProductById(pModel.Id, true);
if (product != null)
{
- if (await _groupService.IsStaff(_workContext.CurrentCustomer))
+ if (await groupService.IsStaff(workContext.CurrentCustomer))
{
- if (!product.AccessToEntityByStore(_workContext.CurrentCustomer.StaffStoreId))
+ if (!product.AccessToEntityByStore(workContext.CurrentCustomer.StaffStoreId))
continue;
}
- await _productService.DeleteProduct(product);
+ await productService.DeleteProduct(product);
}
}
}
public virtual async Task<IList<ProductModel.TierPriceModel>> PrepareTierPriceModel(Product product)
{
- var storeId = _workContext.CurrentCustomer.StaffStoreId;
+ var storeId = workContext.CurrentCustomer.StaffStoreId;
var items = new List<ProductModel.TierPriceModel>();
foreach (var x in product.TierPrices.Where(x => x.StoreId == storeId || string.IsNullOrWhiteSpace(storeId) || string.IsNullOrWhiteSpace(x.StoreId)).OrderBy(x => x.StoreId).ThenBy(x => x.Quantity).ThenBy(x => x.CustomerGroupId))
@@ -1495,17 +1420,17 @@ namespace Grand.Web.Admin.Services
string storeName;
if (!string.IsNullOrEmpty(x.StoreId))
{
- var store = await _storeService.GetStoreById(x.StoreId);
+ var store = await storeService.GetStoreById(x.StoreId);
storeName = store != null ? store.Shortcut : "Deleted";
}
else
- storeName = _translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.Store.All");
+ storeName = translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.Store.All");
var groupName = string.Empty;
if(string.IsNullOrEmpty(x.CustomerGroupId))
- groupName =_translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.CustomerGroup.All");
+ groupName =translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.CustomerGroup.All");
else
- groupName = (await _groupService.GetCustomerGroupById(x.CustomerGroupId))?.Name ?? "NOT FOUND";
+ groupName = (await groupService.GetCustomerGroupById(x.CustomerGroupId))?.Name ?? "NOT FOUND";
items.Add(new ProductModel.TierPriceModel {
Id = x.Id,
@@ -1517,25 +1442,25 @@ namespace Grand.Web.Admin.Services
CustomerGroupId = !string.IsNullOrEmpty(x.CustomerGroupId) ? x.CustomerGroupId : "",
Quantity = x.Quantity,
Price = x.Price,
- StartDateTime = x.StartDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(x.StartDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?(),
- EndDateTime = x.EndDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(x.EndDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?()
+ StartDateTime = x.StartDateTimeUtc.HasValue ? dateTimeService.ConvertToUserTime(x.StartDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?(),
+ EndDateTime = x.EndDateTimeUtc.HasValue ? dateTimeService.ConvertToUserTime(x.EndDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?()
});
}
return items;
}
public virtual async Task<(IEnumerable<ProductModel.BidModel> bidModels, int totalCount)> PrepareBidMode(string productId, int pageIndex, int pageSize)
{
- var bids = await _auctionService.GetBidsByProductId(productId, pageIndex - 1, pageSize);
+ var bids = await auctionService.GetBidsByProductId(productId, pageIndex - 1, pageSize);
var bidsModel = new List<ProductModel.BidModel>();
foreach (var x in bids)
{
bidsModel.Add(new ProductModel.BidModel {
BidId = x.Id,
ProductId = x.ProductId,
- Amount = _priceFormatter.FormatPrice(x.Amount),
- Date = _dateTimeService.ConvertToUserTime(x.Date, DateTimeKind.Utc),
+ Amount = priceFormatter.FormatPrice(x.Amount),
+ Date = dateTimeService.ConvertToUserTime(x.Date, DateTimeKind.Utc),
CustomerId = x.CustomerId,
- Email = (await _customerService.GetCustomerById(x.CustomerId))?.Email,
+ Email = (await customerService.GetCustomerById(x.CustomerId))?.Email,
OrderId = x.OrderId
});
}
@@ -1546,7 +1471,7 @@ namespace Grand.Web.Admin.Services
var model = new ProductModel.ProductAttributeMappingModel {
ProductId = product.Id
};
- foreach (var attribute in await _productAttributeService.GetAllProductAttributes())
+ foreach (var attribute in await productAttributeService.GetAllProductAttributes())
{
model.AvailableProductAttribute.Add(new SelectListItem {
Value = attribute.Id,
@@ -1558,7 +1483,7 @@ namespace Grand.Web.Admin.Services
public virtual async Task<ProductModel.ProductAttributeMappingModel> PrepareProductAttributeMappingModel(Product product, ProductAttributeMapping productAttributeMapping)
{
var model = productAttributeMapping.ToModel();
- foreach (var attribute in await _productAttributeService.GetAllProductAttributes())
+ foreach (var attribute in await productAttributeService.GetAllProductAttributes())
{
model.AvailableProductAttribute.Add(new SelectListItem {
Value = attribute.Id,
@@ -1570,7 +1495,7 @@ namespace Grand.Web.Admin.Services
}
public virtual async Task<ProductModel.ProductAttributeMappingModel> PrepareProductAttributeMappingModel(ProductModel.ProductAttributeMappingModel model)
{
- foreach (var attribute in await _productAttributeService.GetAllProductAttributes())
+ foreach (var attribute in await productAttributeService.GetAllProductAttributes())
{
model.AvailableProductAttribute.Add(new SelectListItem {
Value = attribute.Id,
@@ -1587,12 +1512,12 @@ namespace Grand.Web.Admin.Services
var attributeModel = new ProductModel.ProductAttributeMappingModel {
Id = x.Id,
ProductId = product.Id,
- ProductAttribute = (await _productAttributeService.GetProductAttributeById(x.ProductAttributeId))?.Name,
+ ProductAttribute = (await productAttributeService.GetProductAttributeById(x.ProductAttributeId))?.Name,
ProductAttributeId = x.ProductAttributeId,
TextPrompt = x.TextPrompt,
IsRequired = x.IsRequired,
ShowOnCatalogPage = x.ShowOnCatalogPage,
- AttributeControlType = x.AttributeControlTypeId.GetTranslationEnum(_translationService, _workContext),
+ AttributeControlType = x.AttributeControlTypeId.GetTranslationEnum(translationService, workContext),
AttributeControlTypeId = x.AttributeControlTypeId,
DisplayOrder = x.DisplayOrder,
Combination = x.Combination
@@ -1611,23 +1536,23 @@ namespace Grand.Web.Admin.Services
attributeModel.ValidationRulesAllowed = true;
if (x.ValidationMinLength != null)
validationRules.AppendFormat("{0}: {1}<br />",
- _translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.MinLength"),
+ translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.MinLength"),
x.ValidationMinLength);
if (x.ValidationMaxLength != null)
validationRules.AppendFormat("{0}: {1}<br />",
- _translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.MaxLength"),
+ translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.MaxLength"),
x.ValidationMaxLength);
if (!string.IsNullOrEmpty(x.ValidationFileAllowedExtensions))
validationRules.AppendFormat("{0}: {1}<br />",
- _translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileAllowedExtensions"),
+ translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileAllowedExtensions"),
System.Net.WebUtility.HtmlEncode(x.ValidationFileAllowedExtensions));
if (x.ValidationFileMaximumSize != null)
validationRules.AppendFormat("{0}: {1}<br />",
- _translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileMaximumSize"),
+ translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.FileMaximumSize"),
x.ValidationFileMaximumSize);
if (!string.IsNullOrEmpty(x.DefaultValue))
validationRules.AppendFormat("{0}: {1}<br />",
- _translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.DefaultValue"),
+ translationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.DefaultValue"),
System.Net.WebUtility.HtmlEncode(x.DefaultValue));
attributeModel.ValidationRulesString = validationRules.ToString();
}
@@ -1638,7 +1563,7 @@ namespace Grand.Web.Admin.Services
var conditionValue = product.ParseProductAttributeValues(x.ConditionAttribute).FirstOrDefault();
if (conditionAttribute != null && conditionValue != null)
{
- var productAttribute = await _productAttributeService.GetProductAttributeById(conditionAttribute.ProductAttributeId);
+ var productAttribute = await productAttributeService.GetProductAttributeById(conditionAttribute.ProductAttributeId);
var _paname = productAttribute != null ? productAttribute.Name : "";
attributeModel.ConditionString =
$"{System.Net.WebUtility.HtmlEncode(_paname)}: {System.Net.WebUtility.HtmlEncode(conditionValue.Name)}";
@@ -1655,13 +1580,13 @@ namespace Grand.Web.Admin.Services
//insert mapping
var productAttributeMapping = model.ToEntity();
//predefined values
- var predefinedValues = (await _productAttributeService.GetProductAttributeById(model.ProductAttributeId)).PredefinedProductAttributeValues;
+ var predefinedValues = (await productAttributeService.GetProductAttributeById(model.ProductAttributeId)).PredefinedProductAttributeValues;
foreach (var predefinedValue in predefinedValues)
{
var pav = predefinedValue.ToEntity();
//locales
pav.Locales.Clear();
- var languages = await _languageService.GetAllLanguages(true);
+ var languages = await languageService.GetAllLanguages(true);
//localization
foreach (var lang in languages)
{
@@ -1672,18 +1597,18 @@ namespace Grand.Web.Admin.Services
productAttributeMapping.ProductAttributeValues.Add(pav);
}
- await _productAttributeService.InsertProductAttributeMapping(productAttributeMapping, model.ProductId);
+ await productAttributeService.InsertProductAttributeMapping(productAttributeMapping, model.ProductId);
}
public virtual async Task UpdateProductAttributeMappingModel(ProductModel.ProductAttributeMappingModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
if (product != null)
{
var productAttributeMapping = product.ProductAttributeMappings.FirstOrDefault(x => x.Id == model.Id);
if (productAttributeMapping != null)
{
productAttributeMapping = model.ToEntity(productAttributeMapping);
- await _productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
+ await productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
}
}
}
@@ -1709,7 +1634,7 @@ namespace Grand.Web.Admin.Services
productAttributeMapping.ValidationFileAllowedExtensions = model.ValidationFileAllowedExtensions;
productAttributeMapping.ValidationFileMaximumSize = model.ValidationFileMaximumSize;
productAttributeMapping.DefaultValue = model.DefaultValue;
- await _productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
+ await productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
}
public virtual async Task<ProductAttributeConditionModel> PrepareProductAttributeConditionModel(Product product, ProductAttributeMapping productAttributeMapping)
{
@@ -1730,7 +1655,7 @@ namespace Grand.Web.Admin.Services
.ToList();
foreach (var attribute in attributes)
{
- var pam = await _productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
+ var pam = await productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
var attributeModel = new ProductAttributeConditionModel.ProductAttributeModel {
Id = attribute.Id,
ProductAttributeId = attribute.ProductAttributeId,
@@ -1869,7 +1794,7 @@ namespace Grand.Web.Admin.Services
}
}
productAttributeMapping.ConditionAttribute = customAttributes;
- await _productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
+ await productAttributeService.UpdateProductAttributeMapping(productAttributeMapping, model.ProductId);
}
public virtual async Task<ProductModel.ProductAttributeValueModel> PrepareProductAttributeValueModel(Product product, ProductAttributeMapping productAttributeMapping)
{
@@ -1882,7 +1807,7 @@ namespace Grand.Web.Admin.Services
ColorSquaresRgb = "#000000",
//image squares
DisplayImageSquaresPicture = productAttributeMapping.AttributeControlTypeId == AttributeControlType.ImageSquares,
- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
+ PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
//default qantity for associated product
Quantity = 1
};
@@ -1894,7 +1819,7 @@ namespace Grand.Web.Admin.Services
Id = x.Id,
ProductId = product.Id,
PictureId = x.PictureId,
- PictureUrl = await _pictureService.GetPictureUrl(x.PictureId),
+ PictureUrl = await pictureService.GetPictureUrl(x.PictureId),
DisplayOrder = x.DisplayOrder
});
}
@@ -1908,19 +1833,19 @@ namespace Grand.Web.Admin.Services
Product associatedProduct = null;
if (x.AttributeValueTypeId == AttributeValueType.AssociatedToProduct)
{
- associatedProduct = await _productService.GetProductById(x.AssociatedProductId);
+ associatedProduct = await productService.GetProductById(x.AssociatedProductId);
}
- var pictureThumbnailUrl = await _pictureService.GetPictureUrl(string.IsNullOrEmpty(x.PictureId) ? x.ImageSquaresPictureId : x.PictureId, 100, false);
+ var pictureThumbnailUrl = await pictureService.GetPictureUrl(string.IsNullOrEmpty(x.PictureId) ? x.ImageSquaresPictureId : x.PictureId, 100, false);
if (string.IsNullOrEmpty(pictureThumbnailUrl))
- pictureThumbnailUrl = await _pictureService.GetPictureUrl("", 1);
+ pictureThumbnailUrl = await pictureService.GetPictureUrl("", 1);
items.Add(new ProductModel.ProductAttributeValueModel {
Id = x.Id,
ProductAttributeMappingId = productAttributeMapping.Id, //TODO - check x.ProductAttributeMappingId,
AttributeValueTypeId = x.AttributeValueTypeId,
- AttributeValueTypeName = x.AttributeValueTypeId.GetTranslationEnum(_translationService, _workContext),
+ AttributeValueTypeName = x.AttributeValueTypeId.GetTranslationEnum(translationService, workContext),
AssociatedProductId = x.AssociatedProductId,
AssociatedProductName = associatedProduct != null ? associatedProduct.Name : "",
Name = productAttributeMapping.AttributeControlTypeId != AttributeControlType.ColorSquares ? x.Name : $"{x.Name} - {x.ColorSquaresRgb}",
@@ -1931,7 +1856,7 @@ namespace Grand.Web.Admin.Services
WeightAdjustment = x.WeightAdjustment,
WeightAdjustmentStr = x.AttributeValueTypeId == AttributeValueType.Simple ? x.WeightAdjustment.ToString("G29") : "",
Cost = x.Cost,
- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
+ PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
Quantity = x.Quantity,
IsPreSelected = x.IsPreSelected,
DisplayOrder = x.DisplayOrder,
@@ -1944,12 +1869,12 @@ namespace Grand.Web.Admin.Services
}
public virtual async Task<ProductModel.ProductAttributeValueModel> PrepareProductAttributeValueModel(ProductAttributeMapping pa, ProductAttributeValue pav)
{
- var associatedProduct = await _productService.GetProductById(pav.AssociatedProductId);
+ var associatedProduct = await productService.GetProductById(pav.AssociatedProductId);
var model = new ProductModel.ProductAttributeValueModel {
ProductAttributeMappingId = pa.Id, //TODO - check pav.ProductAttributeMappingId,
AttributeValueTypeId = pav.AttributeValueTypeId,
- AttributeValueTypeName = pav.AttributeValueTypeId.GetTranslationEnum(_translationService, _workContext),
+ AttributeValueTypeName = pav.AttributeValueTypeId.GetTranslationEnum(translationService, workContext),
AssociatedProductId = pav.AssociatedProductId,
AssociatedProductName = associatedProduct != null ? associatedProduct.Name : "",
Name = pav.Name,
@@ -1960,7 +1885,7 @@ namespace Grand.Web.Admin.Services
PriceAdjustment = pav.PriceAdjustment,
WeightAdjustment = pav.WeightAdjustment,
Cost = pav.Cost,
- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
+ PrimaryStoreCurrencyCode = (await currencyService.GetCurrencyById(currencySettings.PrimaryStoreCurrencyId))?.CurrencyCode,
Quantity = pav.Quantity,
IsPreSelected = pav.IsPreSelected,
DisplayOrder = pav.DisplayOrder,
@@ -1989,7 +1914,7 @@ namespace Grand.Web.Admin.Services
PictureId = model.PictureId,
Locales = model.Locales.ToTranslationProperty()
};
- await _productAttributeService.InsertProductAttributeValue(pav, model.ProductId, model.ProductAttributeMappingId);
+ await productAttributeService.InsertProductAttributeValue(pav, model.ProductId, model.ProductAttributeMappingId);
}
public virtual async Task UpdateProductAttributeValueModel(ProductAttributeValue pav, ProductModel.ProductAttributeValueModel model)
{
@@ -2007,7 +1932,7 @@ namespace Grand.Web.Admin.Services
pav.PictureId = model.PictureId;
pav.Locales = model.Locales.ToTranslationProperty();
- await _productAttributeService.UpdateProductAttributeValue(pav, model.ProductId, model.ProductAttributeMappingId);
+ await productAttributeService.UpdateProductAttributeValue(pav, model.ProductId, model.ProductAttributeMappingId);
}
public virtual async Task<ProductModel.ProductAttributeValueModel.AssociateProductToAttributeValueModel> PrepareAssociateProductToAttributeValueModel()
{
@@ -2019,7 +1944,7 @@ namespace Grand.Web.Admin.Services
var items = new List<ProductModel.ProductAttributeCombinationModel>();
foreach (var x in product.ProductAttributeCombinations)
{
- var attributes = await _productAttributeFormatter.FormatAttributes(product, x.Attributes, _workContext.CurrentCustomer, "<br />", true, true, true, false, true, true);
+ var attributes = await productAttributeFormatter.FormatAttributes(product, x.Attributes, workContext.CurrentCustomer, "<br />", true, true, true, false, true, true);
var pacModel = new ProductModel.ProductAttributeCombinationModel {
Id = x.Id,
ProductId = product.Id,
@@ -2042,7 +1967,7 @@ namespace Grand.Web.Admin.Services
{
var model = new ProductAttributeCombinationModel();
var wim = new List<ProductAttributeCombinationModel.WarehouseInventoryModel>();
- foreach (var warehouse in await _warehouseService.GetAllWarehouses())
+ foreach (var warehouse in await warehouseService.GetAllWarehouses())
{
var pwiModel = new ProductAttributeCombinationModel.WarehouseInventoryModel {
WarehouseId = warehouse.Id,
@@ -2065,7 +1990,7 @@ namespace Grand.Web.Admin.Services
model.UseMultipleWarehouses = product.UseMultipleWarehouses;
model.WarehouseInventoryModels = wim;
model.ProductId = product.Id;
- model.Attributes = await _productAttributeFormatter.FormatAttributes(product, combination.Attributes, _workContext.CurrentCustomer, "<br />", true, true, true, false);
+ model.Attributes = await productAttributeFormatter.FormatAttributes(product, combination.Attributes, workContext.CurrentCustomer, "<br />", true, true, true, false);
if (model.UseMultipleWarehouses)
{
foreach (var _winv in combination.WarehouseInventory)
@@ -2090,7 +2015,7 @@ namespace Grand.Web.Admin.Services
var warnings = new List<string>();
async Task PrepareCombinationWarehouseInventory(ProductAttributeCombination combination)
{
- var warehouses = await _warehouseService.GetAllWarehouses();
+ var warehouses = await warehouseService.GetAllWarehouses();
foreach (var warehouse in warehouses)
{
@@ -2237,13 +2162,13 @@ namespace Grand.Web.Admin.Services
combination.StockQuantity = combination.WarehouseInventory.Sum(x => x.StockQuantity);
combination.ReservedQuantity = combination.WarehouseInventory.Sum(x => x.ReservedQuantity);
}
- await _productAttributeService.InsertProductAttributeCombination(combination, product.Id);
+ await productAttributeService.InsertProductAttributeCombination(combination, product.Id);
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)
{
product.StockQuantity = product.ProductAttributeCombinations.Sum(x => x.StockQuantity);
product.ReservedQuantity = product.ProductAttributeCombinations.Sum(x => x.ReservedQuantity);
- await _inventoryManageService.UpdateStockProduct(product, false);
+ await inventoryManageService.UpdateStockProduct(product, false);
}
}
}
@@ -2273,14 +2198,14 @@ namespace Grand.Web.Admin.Services
await OutOfStockNotifications(product, combination, prevCombination);
//update combination
- await _productAttributeService.UpdateProductAttributeCombination(combination, product.Id);
+ await productAttributeService.UpdateProductAttributeCombination(combination, product.Id);
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)
{
- var pr = await _productService.GetProductById(model.ProductId);
+ var pr = await productService.GetProductById(model.ProductId);
pr.StockQuantity = pr.ProductAttributeCombinations.Sum(x => x.StockQuantity);
pr.ReservedQuantity = pr.ProductAttributeCombinations.Sum(x => x.ReservedQuantity);
- await _inventoryManageService.UpdateStockProduct(pr, false);
+ await inventoryManageService.UpdateStockProduct(pr, false);
}
}
return warnings;
@@ -2314,14 +2239,14 @@ namespace Grand.Web.Admin.Services
OverriddenPrice = null,
NotifyAdminForQuantityBelow = 1
};
- await _productAttributeService.InsertProductAttributeCombination(combination, product.Id);
+ await productAttributeService.InsertProductAttributeCombination(combination, product.Id);
}
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)
{
product.StockQuantity = product.ProductAttributeCombinations.Sum(x => x.StockQuantity);
product.ReservedQuantity = product.ProductAttributeCombinations.Sum(x => x.ReservedQuantity);
- await _inventoryManageService.UpdateStockProduct(product, false);
+ await inventoryManageService.UpdateStockProduct(product, false);
}
}
@@ -2329,7 +2254,7 @@ namespace Grand.Web.Admin.Services
{
foreach (var combination in product.ProductAttributeCombinations)
{
- await _productAttributeService.DeleteProductAttributeCombination(combination, product.Id);
+ await productAttributeService.DeleteProductAttributeCombination(combination, product.Id);
}
}
@@ -2341,18 +2266,18 @@ namespace Grand.Web.Admin.Services
string storeName;
if (!string.IsNullOrEmpty(x.StoreId))
{
- var store = await _storeService.GetStoreById(x.StoreId);
+ var store = await storeService.GetStoreById(x.StoreId);
storeName = store != null ? store.Shortcut : "Deleted";
}
else
{
- storeName = _translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.Store.All");
+ storeName = translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.Store.All");
}
var priceModel = new ProductModel.ProductAttributeCombinationTierPricesModel {
Id = x.Id,
CustomerGroupId = x.CustomerGroupId,
- CustomerGroup = !string.IsNullOrEmpty(x.CustomerGroupId) ? (await _groupService.GetCustomerGroupById(x.CustomerGroupId)).Name : _translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.CustomerGroup.All"),
+ CustomerGroup = !string.IsNullOrEmpty(x.CustomerGroupId) ? (await groupService.GetCustomerGroupById(x.CustomerGroupId)).Name : translationService.GetResource("Admin.Catalog.Products.TierPrices.Fields.CustomerGroup.All"),
StoreId = x.StoreId,
Store = storeName,
Price = x.Price,
@@ -2364,15 +2289,9 @@ namespace Grand.Web.Admin.Services
}
public virtual async Task InsertProductAttributeCombinationTierPricesModel(Product product, ProductAttributeCombination productAttributeCombination, ProductModel.ProductAttributeCombinationTierPricesModel model)
{
- if (!string.IsNullOrEmpty(model.CustomerGroupId))
- model.CustomerGroupId = model.CustomerGroupId.Trim();
- else
- model.CustomerGroupId = "";
+ model.CustomerGroupId = !string.IsNullOrEmpty(model.CustomerGroupId) ? model.CustomerGroupId.Trim() : "";
- if (!string.IsNullOrEmpty(model.StoreId))
- model.StoreId = model.StoreId.Trim();
- else
- model.StoreId = "";
+ model.StoreId = !string.IsNullOrEmpty(model.StoreId) ? model.StoreId.Trim() : "";
if (productAttributeCombination != null)
{
@@ -2383,20 +2302,13 @@ namespace Grand.Web.Admin.Services
CustomerGroupId = model.CustomerGroupId
};
productAttributeCombination.TierPrices.Add(pctp);
- await _productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
+ await productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
}
}
public virtual async Task UpdateProductAttributeCombinationTierPricesModel(Product product, ProductAttributeCombination productAttributeCombination, ProductModel.ProductAttributeCombinationTierPricesModel model)
{
- if (!string.IsNullOrEmpty(model.CustomerGroupId))
- model.CustomerGroupId = model.CustomerGroupId.Trim();
- else
- model.CustomerGroupId = "";
-
- if (!string.IsNullOrEmpty(model.StoreId))
- model.StoreId = model.StoreId.Trim();
- else
- model.StoreId = "";
+ model.CustomerGroupId = !string.IsNullOrEmpty(model.CustomerGroupId) ? model.CustomerGroupId.Trim() : "";
+ model.StoreId = !string.IsNullOrEmpty(model.StoreId) ? model.StoreId.Trim() : "";
if (productAttributeCombination != null)
{
@@ -2407,14 +2319,14 @@ namespace Grand.Web.Admin.Services
tierPrice.Quantity = model.Quantity;
tierPrice.StoreId = model.StoreId;
tierPrice.CustomerGroupId = model.CustomerGroupId;
- await _productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
+ await productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
}
}
}
public virtual async Task DeleteProductAttributeCombinationTierPrices(Product product, ProductAttributeCombination productAttributeCombination, ProductCombinationTierPrices tierPrice)
{
productAttributeCombination.TierPrices.Remove(tierPrice);
- await _productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
+ await productAttributeService.UpdateProductAttributeCombination(productAttributeCombination, product.Id);
}
//Pictures
@@ -2423,12 +2335,12 @@ namespace Grand.Web.Admin.Services
var items = new List<ProductModel.ProductPictureModel>();
foreach (var x in product.ProductPictures.OrderBy(x => x.DisplayOrder))
{
- var picture = await _pictureService.GetPictureById(x.PictureId);
+ var picture = await pictureService.GetPictureById(x.PictureId);
var m = new ProductModel.ProductPictureModel {
Id = x.Id,
ProductId = product.Id,
PictureId = x.PictureId,
- PictureUrl = picture != null ? await _pictureService.GetPictureUrl(picture) : null,
+ PictureUrl = picture != null ? await pictureService.GetPictureUrl(picture) : null,
AltAttribute = picture?.AltAttribute,
TitleAttribute = picture?.TitleAttribute,
DisplayOrder = x.DisplayOrder,
@@ -2442,12 +2354,12 @@ namespace Grand.Web.Admin.Services
public virtual async Task<(ProductModel.ProductPictureModel model, Picture Picture)> PrepareProductPictureModel(Product product, ProductPicture productPicture)
{
- var picture = await _pictureService.GetPictureById(productPicture.PictureId);
+ var picture = await pictureService.GetPictureById(productPicture.PictureId);
var model = new ProductModel.ProductPictureModel {
Id = productPicture.Id,
ProductId = product.Id,
PictureId = productPicture.PictureId,
- PictureUrl = picture != null ? await _pictureService.GetPictureUrl(picture) : null,
+ PictureUrl = picture != null ? await pictureService.GetPictureUrl(picture) : null,
AltAttribute = picture?.AltAttribute,
TitleAttribute = picture?.TitleAttribute,
DisplayOrder = productPicture.DisplayOrder,
@@ -2463,53 +2375,53 @@ namespace Grand.Web.Admin.Services
if (picture == null)
throw new ArgumentException("No picture found with the specified id");
- if (product.ProductPictures.Where(x => x.PictureId == picture.Id).Count() > 0)
+ if (product.ProductPictures.Any(x => x.PictureId == picture.Id))
return;
- await _productService.InsertProductPicture(new ProductPicture {
+ await productService.InsertProductPicture(new ProductPicture {
PictureId = picture.Id,
DisplayOrder = displayOrder
}, product.Id);
- await _pictureService.SetSeoFilename(picture, _pictureService.GetPictureSeName(product.Name));
+ await pictureService.SetSeoFilename(picture, pictureService.GetPictureSeName(product.Name));
}
public virtual async Task UpdateProductPicture(ProductModel.ProductPictureModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
var productPicture = product.ProductPictures.FirstOrDefault(x => x.Id == model.Id);
if (productPicture == null)
throw new ArgumentException("No product picture found with the specified id");
- var picture = await _pictureService.GetPictureById(productPicture.PictureId);
+ var picture = await pictureService.GetPictureById(productPicture.PictureId);
if (picture == null)
throw new ArgumentException("No picture found with the specified id");
productPicture.DisplayOrder = model.DisplayOrder;
- await _productService.UpdateProductPicture(productPicture, product.Id);
+ await productService.UpdateProductPicture(productPicture, product.Id);
//Update picture fields
- await _pictureService.UpdatePictureField(picture, x => x.AltAttribute, model.AltAttribute);
- await _pictureService.UpdatePictureField(picture, x => x.TitleAttribute, model.TitleAttribute);
- await _pictureService.UpdatePictureField(picture, x => x.Locales, model.Locales.ToTranslationProperty());
- await _pictureService.UpdatePictureField(picture, x => x.Style, model.Style);
- await _pictureService.UpdatePictureField(picture, x => x.ExtraField, model.ExtraField);
+ await pictureService.UpdatePictureField(picture, x => x.AltAttribute, model.AltAttribute);
+ await pictureService.UpdatePictureField(picture, x => x.TitleAttribute, model.TitleAttribute);
+ await pictureService.UpdatePictureField(picture, x => x.Locales, model.Locales.ToTranslationProperty());
+ await pictureService.UpdatePictureField(picture, x => x.Style, model.Style);
+ await pictureService.UpdatePictureField(picture, x => x.ExtraField, model.ExtraField);
}
public virtual async Task DeleteProductPicture(ProductModel.ProductPictureModel model)
{
- var product = await _productService.GetProductById(model.ProductId, true);
+ var product = await productService.GetProductById(model.ProductId, true);
var productPicture = product.ProductPictures.FirstOrDefault(x => x.Id == model.Id);
if (productPicture == null)
throw new ArgumentException("No product picture found with the specified id");
var pictureId = productPicture.PictureId;
- await _productService.DeleteProductPicture(productPicture, product.Id);
+ await productService.DeleteProductPicture(productPicture, product.Id);
- var picture = await _pictureService.GetPictureById(pictureId);
+ var picture = await pictureService.GetPictureById(pictureId);
if (picture != null)
- await _pictureService.DeletePicture(picture);
+ await pictureService.DeletePicture(picture);
}
//Product specification
public virtual async Task<IList<ProductSpecificationAttributeModel>> PrepareProductSpecificationAttributeModel(Product product)
@@ -2522,7 +2434,7 @@ namespace Grand.Web.Admin.Services
AttributeTypeId = (int)x.AttributeTypeId,
AttributeId = x.SpecificationAttributeId,
ProductId = product.Id,
- AttributeTypeName = x.AttributeTypeId.GetTranslationEnum(_translationService, _workContext),
+ AttributeTypeName = x.AttributeTypeId.GetTranslationEnum(translationService, workContext),
AllowFiltering = x.AllowFiltering,
ShowOnProductPage = x.ShowOnProductPage,
DisplayOrder = x.DisplayOrder,
@@ -2532,7 +2444,7 @@ namespace Grand.Web.Admin.Services
switch (x.AttributeTypeId)
{
case SpecificationAttributeType.Option:
- var specificationAttribute = await _specificationAttributeService.GetSpecificationAttributeById(x.SpecificationAttributeId);
+ var specificationAttribute = await specificationAttributeService.GetSpecificationAttributeById(x.SpecificationAttributeId);
if (specificationAttribute != null)
{
psaModel.AttributeName = specificationAttribute.Name;
@@ -2565,18 +2477,18 @@ namespace Grand.Web.Admin.Services
}
var psa = model.ToEntity();
- await _specificationAttributeService.InsertProductSpecificationAttribute(psa, product.Id);
+ await specificationAttributeService.InsertProductSpecificationAttribute(psa, product.Id);
product.ProductSpecificationAttributes.Add(psa);
}
public virtual async Task UpdateProductSpecificationAttributeModel(Product product, ProductSpecificationAttribute psa, ProductModel.AddProductSpecificationAttributeModel model)
{
psa = model.ToEntity(psa);
- await _specificationAttributeService.UpdateProductSpecificationAttribute(psa, model.ProductId);
+ await specificationAttributeService.UpdateProductSpecificationAttribute(psa, model.ProductId);
}
public virtual async Task DeleteProductSpecificationAttribute(Product product, ProductSpecificationAttribute psa)
{
product.ProductSpecificationAttributes.Remove(psa);
- await _specificationAttributeService.DeleteProductSpecificationAttribute(psa, product.Id);
+ await specificationAttributeService.DeleteProductSpecificationAttribute(psa, product.Id);
}
}
}
diff --git a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
index dd68c0e54..1b01ec664 100644
--- a/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/VendorViewModelService.cs
@@ -23,50 +23,30 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Admin.Services
{
- public class VendorViewModelService : IVendorViewModelService
+ public class VendorViewModelService(
+ IDiscountService discountService,
+ IVendorService vendorService,
+ ICustomerService customerService,
+ ITranslationService translationService,
+ IDateTimeService dateTimeService,
+ ICountryService countryService,
+ IStoreService storeService,
+ ISlugService slugService,
+ IPictureService pictureService,
+ IMediator mediator,
+ VendorSettings vendorSettings,
+ ILanguageService languageService,
+ SeoSettings seoSettings)
+ : IVendorViewModelService
{
- private readonly IDiscountService _discountService;
- private readonly IVendorService _vendorService;
- private readonly ICustomerService _customerService;
- private readonly ITranslationService _translationService;
- private readonly IDateTimeService _dateTimeService;
- private readonly ICountryService _countryService;
- private readonly IStoreService _storeService;
- private readonly ISlugService _slugService;
- private readonly IPictureService _pictureService;
- private readonly IMediator _mediator;
- private readonly ILanguageService _languageService;
- private readonly SeoSettings _seoSettings;
- private readonly VendorSettings _vendorSettings;
-
- public VendorViewModelService(IDiscountService discountService, IVendorService vendorService, ICustomerService customerService, ITranslationService translationService,
- IDateTimeService dateTimeService, ICountryService countryService, IStoreService storeService, ISlugService slugService,
- IPictureService pictureService, IMediator mediator, VendorSettings vendorSettings, ILanguageService languageService,
- SeoSettings seoSettings)
- {
- _discountService = discountService;
- _vendorService = vendorService;
- _customerService = customerService;
- _translationService = translationService;
- _dateTimeService = dateTimeService;
- _countryService = countryService;
- _storeService = storeService;
- _slugService = slugService;
- _pictureService = pictureService;
- _mediator = mediator;
- _languageService = languageService;
- _vendorSettings = vendorSettings;
- _seoSettings = seoSettings;
- }
-
public virtual async Task PrepareDiscountModel(VendorModel model, Vendor vendor, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException(nameof(model));
- model.AvailableDiscounts = (await _discountService
+ model.AvailableDiscounts = (await discountService
.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true))
- .Select(d => d.ToModel(_dateTimeService))
+ .Select(d => d.ToModel(dateTimeService))
.ToList();
if (!excludeProperties && vendor != null)
@@ -84,32 +64,27 @@ namespace Grand.Web.Admin.Services
if (vendorReview == null)
throw new ArgumentNullException(nameof(vendorReview));
- var vendor = await _vendorService.GetVendorById(vendorReview.VendorId);
- var customer = await _customerService.GetCustomerById(vendorReview.CustomerId);
+ var vendor = await vendorService.GetVendorById(vendorReview.VendorId);
+ var customer = await customerService.GetCustomerById(vendorReview.CustomerId);
model.Id = vendorReview.Id;
model.VendorId = vendorReview.VendorId;
model.VendorName = vendor.Name;
model.CustomerId = vendorReview.CustomerId;
- model.CustomerInfo = customer != null ? !string.IsNullOrEmpty(customer.Email) ? customer.Email : _translationService.GetResource("Admin.Customers.Guest") : "";
+ model.CustomerInfo = customer != null ? !string.IsNullOrEmpty(customer.Email) ? customer.Email : translationService.GetResource("Admin.Customers.Guest") : "";
model.Rating = vendorReview.Rating;
- model.CreatedOn = _dateTimeService.ConvertToUserTime(vendorReview.CreatedOnUtc, DateTimeKind.Utc);
+ model.CreatedOn = dateTimeService.ConvertToUserTime(vendorReview.CreatedOnUtc, DateTimeKind.Utc);
if (!excludeProperties)
{
model.Title = vendorReview.Title;
- if (formatReviewText)
- model.ReviewText = FormatText.ConvertText(vendorReview.ReviewText);
- else
- model.ReviewText = vendorReview.ReviewText;
+ model.ReviewText = formatReviewText ? FormatText.ConvertText(vendorReview.ReviewText) : vendorReview.ReviewText;
model.IsApproved = vendorReview.IsApproved;
}
}
public virtual async Task PrepareVendorAddressModel(VendorModel model, Vendor vendor)
{
-
- if (model.Address == null)
- model.Address = new Models.Common.AddressModel();
+ model.Address ??= new Models.Common.AddressModel();
model.Address.FirstNameEnabled = false;
model.Address.FirstNameRequired = false;
@@ -117,29 +92,29 @@ namespace Grand.Web.Admin.Services
model.Address.LastNameRequired = false;
model.Address.EmailEnabled = false;
model.Address.EmailRequired = false;
- model.Address.CompanyEnabled = _vendorSettings.AddressSettings.CompanyEnabled;
- model.Address.CountryEnabled = _vendorSettings.AddressSettings.CountryEnabled;
- model.Address.StateProvinceEnabled = _vendorSettings.AddressSettings.StateProvinceEnabled;
- model.Address.CityEnabled = _vendorSettings.AddressSettings.CityEnabled;
- model.Address.CityRequired = _vendorSettings.AddressSettings.CityRequired;
- model.Address.StreetAddressEnabled = _vendorSettings.AddressSettings.StreetAddressEnabled;
- model.Address.StreetAddressRequired = _vendorSettings.AddressSettings.StreetAddressRequired;
- model.Address.StreetAddress2Enabled = _vendorSettings.AddressSettings.StreetAddress2Enabled;
- model.Address.ZipPostalCodeEnabled = _vendorSettings.AddressSettings.ZipPostalCodeEnabled;
- model.Address.ZipPostalCodeRequired = _vendorSettings.AddressSettings.ZipPostalCodeRequired;
- model.Address.PhoneEnabled = _vendorSettings.AddressSettings.PhoneEnabled;
- model.Address.PhoneRequired = _vendorSettings.AddressSettings.PhoneRequired;
- model.Address.FaxEnabled = _vendorSettings.AddressSettings.FaxEnabled;
- model.Address.FaxRequired = _vendorSettings.AddressSettings.FaxRequired;
- model.Address.NoteEnabled = _vendorSettings.AddressSettings.NoteEnabled;
+ model.Address.CompanyEnabled = vendorSettings.AddressSettings.CompanyEnabled;
+ model.Address.CountryEnabled = vendorSettings.AddressSettings.CountryEnabled;
+ model.Address.StateProvinceEnabled = vendorSettings.AddressSettings.StateProvinceEnabled;
+ model.Address.CityEnabled = vendorSettings.AddressSettings.CityEnabled;
+ model.Address.CityRequired = vendorSettings.AddressSettings.CityRequired;
+ model.Address.StreetAddressEnabled = vendorSettings.AddressSettings.StreetAddressEnabled;
+ model.Address.StreetAddressRequired = vendorSettings.AddressSettings.StreetAddressRequired;
+ model.Address.StreetAddress2Enabled = vendorSettings.AddressSettings.StreetAddress2Enabled;
+ model.Address.ZipPostalCodeEnabled = vendorSettings.AddressSettings.ZipPostalCodeEnabled;
+ model.Address.ZipPostalCodeRequired = vendorSettings.AddressSettings.ZipPostalCodeRequired;
+ model.Address.PhoneEnabled = vendorSettings.AddressSettings.PhoneEnabled;
+ model.Address.PhoneRequired = vendorSettings.AddressSettings.PhoneRequired;
+ model.Address.FaxEnabled = vendorSettings.AddressSettings.FaxEnabled;
+ model.Address.FaxRequired = vendorSettings.AddressSettings.FaxRequired;
+ model.Address.NoteEnabled = vendorSettings.AddressSettings.NoteEnabled;
model.Address.AddressTypeEnabled = false;
//address
- model.Address.AvailableCountries.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Address.SelectCountry"), Value = "" });
- foreach (var c in await _countryService.GetAllCountries(showHidden: true))
+ model.Address.AvailableCountries.Add(new SelectListItem { Text = translationService.GetResource("Admin.Address.SelectCountry"), Value = "" });
+ foreach (var c in await countryService.GetAllCountries(showHidden: true))
model.Address.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id, Selected = vendor != null && c.Id == vendor.Address.CountryId });
- var states = !string.IsNullOrEmpty(model.Address.CountryId) ? (await _countryService.GetCountryById(model.Address.CountryId))?.StateProvinces : new List<StateProvince>();
+ var states = !string.IsNullOrEmpty(model.Address.CountryId) ? (await countryService.GetCountryById(model.Address.CountryId))?.StateProvinces : new List<StateProvince>();
if (states.Count > 0)
{
foreach (var s in states)
@@ -155,7 +130,7 @@ namespace Grand.Web.Admin.Services
Value = ""
});
- foreach (var s in await _storeService.GetAllStores())
+ foreach (var s in await storeService.GetAllStores())
{
model.AvailableStores.Add(new SelectListItem
{
@@ -173,7 +148,7 @@ namespace Grand.Web.Admin.Services
model.PageSize = 6;
model.Active = true;
model.AllowCustomersToSelectPageSize = true;
- model.PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions;
+ model.PageSizeOptions = vendorSettings.DefaultVendorPageSizeOptions;
//default value
model.Active = true;
@@ -187,7 +162,7 @@ namespace Grand.Web.Admin.Services
}
public virtual async Task<IList<VendorModel.AssociatedCustomerInfo>> AssociatedCustomers(string vendorId)
{
- return (await _customerService
+ return (await customerService
.GetAllCustomers(vendorId: vendorId))
.Select(c => new VendorModel.AssociatedCustomerInfo {
Id = c.Id,
@@ -199,10 +174,10 @@ namespace Grand.Web.Admin.Services
{
var vendor = model.ToEntity();
vendor.Address = model.Address.ToEntity();
- await _vendorService.InsertVendor(vendor);
+ await vendorService.InsertVendor(vendor);
//discounts
- var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true);
+ var allDiscounts = await discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true);
foreach (var discount in allDiscounts)
{
if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id))
@@ -210,14 +185,14 @@ namespace Grand.Web.Admin.Services
}
//search engine name
- model.SeName = await vendor.ValidateSeName(model.SeName, vendor.Name, true, _seoSettings, _slugService, _languageService);
- vendor.Locales = await model.Locales.ToTranslationProperty(vendor, x => x.Name, _seoSettings, _slugService, _languageService);
+ model.SeName = await vendor.ValidateSeName(model.SeName, vendor.Name, true, seoSettings, slugService, languageService);
+ vendor.Locales = await model.Locales.ToTranslationProperty(vendor, x => x.Name, seoSettings, slugService, languageService);
vendor.SeName = model.SeName;
- await _vendorService.UpdateVendor(vendor);
+ await vendorService.UpdateVendor(vendor);
//update picture seo file name
- await _pictureService.UpdatePictureSeoNames(vendor.PictureId, vendor.Name);
- await _slugService.SaveSlug(vendor, model.SeName, "");
+ await pictureService.UpdatePictureSeoNames(vendor.PictureId, vendor.Name);
+ await slugService.SaveSlug(vendor, model.SeName, "");
return vendor;
}
@@ -225,12 +200,12 @@ namespace Grand.Web.Admin.Services
{
var prevPictureId = vendor.PictureId;
vendor = model.ToEntity(vendor);
- vendor.Locales = await model.Locales.ToTranslationProperty(vendor, x => x.Name, _seoSettings, _slugService, _languageService);
- model.SeName = await vendor.ValidateSeName(model.SeName, vendor.Name, true, _seoSettings, _slugService, _languageService);
+ vendor.Locales = await model.Locales.ToTranslationProperty(vendor, x => x.Name, seoSettings, slugService, languageService);
+ model.SeName = await vendor.ValidateSeName(model.SeName, vendor.Name, true, seoSettings, slugService, languageService);
vendor.Address = model.Address.ToEntity(vendor.Address);
//discounts
- var allDiscounts = await _discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true);
+ var allDiscounts = await discountService.GetAllDiscounts(DiscountType.AssignedToVendors, showHidden: true);
foreach (var discount in allDiscounts)
{
if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id))
@@ -249,31 +224,31 @@ namespace Grand.Web.Admin.Services
vendor.SeName = model.SeName;
- await _vendorService.UpdateVendor(vendor);
+ await vendorService.UpdateVendor(vendor);
//search engine name
- await _slugService.SaveSlug(vendor, model.SeName, "");
+ await slugService.SaveSlug(vendor, model.SeName, "");
//delete an old picture (if deleted or updated)
if (!string.IsNullOrEmpty(prevPictureId) && prevPictureId != vendor.PictureId)
{
- var prevPicture = await _pictureService.GetPictureById(prevPictureId);
+ var prevPicture = await pictureService.GetPictureById(prevPictureId);
if (prevPicture != null)
- await _pictureService.DeletePicture(prevPicture);
+ await pictureService.DeletePicture(prevPicture);
}
//update picture seo file name
- await _pictureService.UpdatePictureSeoNames(vendor.PictureId, vendor.Name);
+ await pictureService.UpdatePictureSeoNames(vendor.PictureId, vendor.Name);
return vendor;
}
public virtual async Task DeleteVendor(Vendor vendor)
{
//clear associated customer references
- var associatedCustomers = await _customerService.GetAllCustomers(vendorId: vendor.Id);
+ var associatedCustomers = await customerService.GetAllCustomers(vendorId: vendor.Id);
foreach (var customer in associatedCustomers)
{
customer.VendorId = "";
- await _customerService.UpdateCustomer(customer);
+ await customerService.UpdateCustomer(customer);
}
- await _vendorService.DeleteVendor(vendor);
+ await vendorService.DeleteVendor(vendor);
}
public virtual IList<VendorModel.VendorNote> PrepareVendorNote(Vendor vendor)
{
@@ -286,14 +261,14 @@ namespace Grand.Web.Admin.Services
Id = vendorNote.Id,
VendorId = vendor.Id,
Note = vendorNote.Note,
- CreatedOn = _dateTimeService.ConvertToUserTime(vendorNote.CreatedOnUtc, DateTimeKind.Utc)
+ CreatedOn = dateTimeService.ConvertToUserTime(vendorNote.CreatedOnUtc, DateTimeKind.Utc)
});
}
return vendorNoteModels;
}
public virtual async Task<bool> InsertVendorNote(string vendorId, string message)
{
- var vendor = await _vendorService.GetVendorById(vendorId);
+ var vendor = await vendorService.GetVendorById(vendorId);
if (vendor == null)
return false;
@@ -303,31 +278,31 @@ namespace Grand.Web.Admin.Services
CreatedOnUtc = DateTime.UtcNow
};
vendor.VendorNotes.Add(vendorNote);
- await _vendorService.UpdateVendor(vendor);
+ await vendorService.UpdateVendor(vendor);
return true;
}
public virtual async Task DeleteVendorNote(string id, string vendorId)
{
- var vendor = await _vendorService.GetVendorById(vendorId);
+ var vendor = await vendorService.GetVendorById(vendorId);
if (vendor == null)
throw new ArgumentException("No vendor found with the specified id");
var vendorNote = vendor.VendorNotes.FirstOrDefault(vn => vn.Id == id);
if (vendorNote == null)
throw new ArgumentException("No vendor note found with the specified id");
- await _vendorService.DeleteVendorNote(vendorNote, vendorId);
+ await vendorService.DeleteVendorNote(vendorNote, vendorId);
}
public virtual async Task<(IEnumerable<VendorReviewModel> vendorReviewModels, int totalCount)> PrepareVendorReviewModel(VendorReviewListModel model, int pageIndex, int pageSize)
{
DateTime? createdOnFromValue = model.CreatedOnFrom == null ? null
- : _dateTimeService.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeService.CurrentTimeZone);
+ : dateTimeService.ConvertToUtcTime(model.CreatedOnFrom.Value, dateTimeService.CurrentTimeZone);
DateTime? createdToFromValue = model.CreatedOnTo == null ? null
- : _dateTimeService.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeService.CurrentTimeZone).AddDays(1);
+ : dateTimeService.ConvertToUtcTime(model.CreatedOnTo.Value, dateTimeService.CurrentTimeZone).AddDays(1);
- IPagedList<VendorReview> vendorReviews = await _vendorService.GetAllVendorReviews("", null,
+ IPagedList<VendorReview> vendorReviews = await vendorService.GetAllVendorReviews("", null,
createdOnFromValue, createdToFromValue, model.SearchText, model.SearchVendorId, pageIndex - 1, pageSize);
var items = new List<VendorReviewModel>();
foreach (var x in vendorReviews)
@@ -344,19 +319,19 @@ namespace Grand.Web.Admin.Services
vendorReview.ReviewText = model.ReviewText;
vendorReview.IsApproved = model.IsApproved;
- await _vendorService.UpdateVendorReview(vendorReview);
+ await vendorService.UpdateVendorReview(vendorReview);
- var vendor = await _vendorService.GetVendorById(vendorReview.VendorId);
+ var vendor = await vendorService.GetVendorById(vendorReview.VendorId);
//update vendor totals
- await _vendorService.UpdateVendorReviewTotals(vendor);
+ await vendorService.UpdateVendorReviewTotals(vendor);
return vendorReview;
}
public virtual async Task DeleteVendorReview(VendorReview vendorReview)
{
- await _vendorService.DeleteVendorReview(vendorReview);
- var vendor = await _vendorService.GetVendorById(vendorReview.VendorId);
+ await vendorService.DeleteVendorReview(vendorReview);
+ var vendor = await vendorService.GetVendorById(vendorReview.VendorId);
//update vendor totals
- await _vendorService.UpdateVendorReviewTotals(vendor);
+ await vendorService.UpdateVendorReviewTotals(vendor);
}
public virtual async Task ApproveVendorReviews(IEnumerable<string> selectedIds)
{
@@ -364,18 +339,18 @@ namespace Grand.Web.Admin.Services
{
var idReview = id.Split(':').First();
var idVendor = id.Split(':').Last();
- var vendor = await _vendorService.GetVendorById(idVendor);
- var vendorReview = await _vendorService.GetVendorReviewById(idReview);
+ var vendor = await vendorService.GetVendorById(idVendor);
+ var vendorReview = await vendorService.GetVendorReviewById(idReview);
if (vendorReview != null)
{
var previousIsApproved = vendorReview.IsApproved;
vendorReview.IsApproved = true;
- await _vendorService.UpdateVendorReview(vendorReview);
- await _vendorService.UpdateVendorReviewTotals(vendor);
+ await vendorService.UpdateVendorReview(vendorReview);
+ await vendorService.UpdateVendorReviewTotals(vendor);
//raise event (only if it wasn't approved before)
if (!previousIsApproved)
- await _mediator.Publish(new VendorReviewApprovedEvent(vendorReview));
+ await mediator.Publish(new VendorReviewApprovedEvent(vendorReview));
}
}
}
@@ -386,13 +361,13 @@ namespace Grand.Web.Admin.Services
var idReview = id.Split(':').First();
var idVendor = id.Split(':').Last();
- var vendor = await _vendorService.GetVendorById(idVendor);
- var vendorReview = await _vendorService.GetVendorReviewById(idReview);
+ var vendor = await vendorService.GetVendorById(idVendor);
+ var vendorReview = await vendorService.GetVendorReviewById(idReview);
if (vendorReview != null)
{
vendorReview.IsApproved = false;
- await _vendorService.UpdateVendorReview(vendorReview);
- await _vendorService.UpdateVendorReviewTotals(vendor);
+ await vendorService.UpdateVendorReview(vendorReview);
+ await vendorService.UpdateVendorReviewTotals(vendor);
}
}
}
diff --git a/src/Web/Grand.Web.Common/DataSource/DataSourceRequest.cs b/src/Web/Grand.Web.Common/DataSource/DataSourceRequest.cs
index 3b4bc40e3..d1b340619 100644
--- a/src/Web/Grand.Web.Common/DataSource/DataSourceRequest.cs
+++ b/src/Web/Grand.Web.Common/DataSource/DataSourceRequest.cs
@@ -2,14 +2,8 @@
{
public class DataSourceRequest
{
- public int Page { get; set; }
+ public int Page { get; set; } = 1;
- public int PageSize { get; set; }
-
- public DataSourceRequest()
- {
- Page = 1;
- PageSize = 10;
- }
+ public int PageSize { get; set; } = 10;
}
}
diff --git a/src/Web/Grand.Web.Common/Models/DatePickerDropDownsModel.cs b/src/Web/Grand.Web.Common/Models/DatePickerDropDownsModel.cs
index 59bea7ef4..b9b04c05f 100644
--- a/src/Web/Grand.Web.Common/Models/DatePickerDropDownsModel.cs
+++ b/src/Web/Grand.Web.Common/Models/DatePickerDropDownsModel.cs
@@ -5,23 +5,17 @@ namespace Grand.Web.Common.Models
{
public partial class DatePickerDropDownsModel : BaseEntityModel
{
- public DatePickerDropDownsModel()
- {
- SelectListDay = new List<SelectListItem>();
- SelectListMonth = new List<SelectListItem>();
- SelectListYear = new List<SelectListItem>();
- }
public string Attribute { get; set; }
public string Day { get; set; }
- public IList<SelectListItem> SelectListDay { get; set; }
+ public IList<SelectListItem> SelectListDay { get; set; } = new List<SelectListItem>();
public string Month { get; set; }
- public IList<SelectListItem> SelectListMonth { get; set; }
+ public IList<SelectListItem> SelectListMonth { get; set; } = new List<SelectListItem>();
public string Year { get; set; }
- public IList<SelectListItem> SelectListYear { get; set; }
+ public IList<SelectListItem> SelectListYear { get; set; } = new List<SelectListItem>();
public int Begin_Year { get; set; }
diff --git a/src/Web/Grand.Web.Common/Routing/SlugRouteTransformer.cs b/src/Web/Grand.Web.Common/Routing/SlugRouteTransformer.cs
index 9e667ba2b..266cc1087 100644
--- a/src/Web/Grand.Web.Common/Routing/SlugRouteTransformer.cs
+++ b/src/Web/Grand.Web.Common/Routing/SlugRouteTransformer.cs
@@ -42,9 +42,6 @@ namespace Grand.Web.Common.Routing
public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext context, RouteValueDictionary values)
{
- if (values == null)
- return null;
-
var slug = values["SeName"];
if (slug == null)
return values;
diff --git a/src/Web/Grand.Web.Common/Security/Captcha/GoogleReCaptchaResponse.cs b/src/Web/Grand.Web.Common/Security/Captcha/GoogleReCaptchaResponse.cs
index 394e1d999..1a6f167df 100644
--- a/src/Web/Grand.Web.Common/Security/Captcha/GoogleReCaptchaResponse.cs
+++ b/src/Web/Grand.Web.Common/Security/Captcha/GoogleReCaptchaResponse.cs
@@ -3,11 +3,6 @@
public class GoogleReCaptchaResponse
{
public bool IsValid { get; set; }
- public List<string> ErrorCodes { get; set; }
-
- public GoogleReCaptchaResponse()
- {
- ErrorCodes = new List<string>();
- }
+ public List<string> ErrorCodes { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
index bf481438a..eeacb0ac5 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/DefaultHtmlGenerator.cs
@@ -428,15 +428,8 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend
if (resolvedLabelText == null && expression != null)
{
var index = expression.LastIndexOf('.');
- if (index == -1)
- {
- // Expression does not contain a dot separator.
- resolvedLabelText = expression;
- }
- else
- {
- resolvedLabelText = expression[(index + 1)..];
- }
+ // Expression does not contain a dot separator.
+ resolvedLabelText = index == -1 ? expression : expression[(index + 1)..];
}
var tagBuilder = new TagBuilder("label");
@@ -623,10 +616,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend
}
// If we got a null selectList, try to use ViewData to get the list of items.
- if (selectList == null)
- {
- selectList = GetSelectListItems(viewContext, expression);
- }
+ selectList ??= GetSelectListItems(viewContext, expression);
modelExplorer = modelExplorer ??
ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider);
@@ -937,14 +927,9 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend
var tagBuilder = new TagBuilder("div");
tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes));
- if (viewData.ModelState.IsValid)
- {
- tagBuilder.AddCssClass(HtmlHelper.ValidationSummaryValidCssClassName);
- }
- else
- {
- tagBuilder.AddCssClass(HtmlHelper.ValidationSummaryCssClassName);
- }
+ tagBuilder.AddCssClass(viewData.ModelState.IsValid
+ ? HtmlHelper.ValidationSummaryValidCssClassName
+ : HtmlHelper.ValidationSummaryCssClassName);
if (messageTag != null)
{
@@ -1279,11 +1264,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend
case InputType.Text:
default:
- var attributeValue = (string)GetModelStateValue(viewContext, fullName, typeof(string));
- if (attributeValue == null)
- {
- attributeValue = useViewData ? EvalString(viewContext, expression, format) : valueParameter;
- }
+ var attributeValue = (string)GetModelStateValue(viewContext, fullName, typeof(string)) ?? (useViewData ? EvalString(viewContext, expression, format) : valueParameter);
var addValue = true;
object typeAttributeValue;
@@ -1470,11 +1451,7 @@ namespace Grand.Web.Common.TagHelpers.Admin.Extend
IDictionary<string, object> htmlAttributeDictionary = null;
if (htmlAttributes != null)
{
- htmlAttributeDictionary = htmlAttributes as IDictionary<string, object>;
- if (htmlAttributeDictionary == null)
- {
- htmlAttributeDictionary = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
- }
+ htmlAttributeDictionary = htmlAttributes as IDictionary<string, object> ?? HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
}
return htmlAttributeDictionary;
diff --git a/src/Web/Grand.Web.Common/TagHelpers/ResourceManager.cs b/src/Web/Grand.Web.Common/TagHelpers/ResourceManager.cs
index 3e4de8bc8..2d81aba67 100644
--- a/src/Web/Grand.Web.Common/TagHelpers/ResourceManager.cs
+++ b/src/Web/Grand.Web.Common/TagHelpers/ResourceManager.cs
@@ -5,20 +5,13 @@ namespace Grand.Web.Common.TagHelpers
{
public class ResourceManager : IResourceManager
{
- private readonly List<(IHtmlContent content, int order)> _headScripts;
- private readonly List<(IHtmlContent content, int order)> _headerScripts;
- private readonly List<(IHtmlContent content, int order)> _footScripts;
+ private readonly List<(IHtmlContent content, int order)> _headScripts = new();
+ private readonly List<(IHtmlContent content, int order)> _headerScripts = new();
+ private readonly List<(IHtmlContent content, int order)> _footScripts = new();
private List<IHtmlContent> _templatesHeader;
private List<IHtmlContent> _templatesFooter;
- private readonly List<LinkEntry> _links;
+ private readonly List<LinkEntry> _links = new();
- public ResourceManager()
- {
- _links = new List<LinkEntry>();
- _headScripts = new List<(IHtmlContent content, int order)>();
- _headerScripts = new List<(IHtmlContent content, int order)>();
- _footScripts = new List<(IHtmlContent content, int order)>();
- }
public IEnumerable<IHtmlContent> GetRegisteredHeadScripts()
{
return _headScripts.OrderBy(x => x.order).Select(x => x.content);
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/BulkEditListModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/BulkEditListModel.cs
index 2e511cfea..e7e2879df 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/BulkEditListModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/BulkEditListModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.Catalog
{
public class BulkEditListModel : BaseModel
{
- public BulkEditListModel()
- {
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.BulkEdit.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -30,6 +25,6 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeCombinationModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeCombinationModel.cs
index c19924cd1..0d2704cf4 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeCombinationModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeCombinationModel.cs
@@ -12,14 +12,6 @@ namespace Grand.Web.Vendor.Models.Catalog
{
public string Id { get; set; }
- public ProductAttributeCombinationModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- Warnings = new List<string>();
- WarehouseInventoryModels = new List<WarehouseInventoryModel>();
- ProductPictureModels = new List<ProductModel.ProductPictureModel>();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.AttributeCombinations.Fields.StockQuantity")]
public int StockQuantity { get; set; }
@@ -53,37 +45,32 @@ namespace Grand.Web.Vendor.Models.Catalog
public string PictureId { get; set; }
public string PictureThumbnailUrl { get; set; }
- public IList<ProductModel.ProductPictureModel> ProductPictureModels { get; set; }
+ public IList<ProductModel.ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductModel.ProductPictureModel>();
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
public string ProductId { get; set; }
public string Attributes { get; set; }
public bool UseMultipleWarehouses { get; set; }
- public IList<WarehouseInventoryModel> WarehouseInventoryModels { get; set; }
+ public IList<WarehouseInventoryModel> WarehouseInventoryModels { get; set; } = new List<WarehouseInventoryModel>();
#region Nested classes
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductAttributeId { get; set; }
public string Name { get; set; }
public string TextPrompt { get; set; }
public bool IsRequired { get; set; }
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeConditionModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeConditionModel.cs
index a06fffd70..94c4981d7 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeConditionModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeConditionModel.cs
@@ -9,17 +9,12 @@ namespace Grand.Web.Vendor.Models.Catalog
{
public class ProductAttributeConditionModel : BaseModel, IProductValidVendor
{
- public ProductAttributeConditionModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.Attributes.Condition.EnableCondition")]
public bool EnableCondition { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.Attributes.Condition.Attributes")]
public string SelectedProductAttributeId { get; set; }
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
@@ -30,11 +25,6 @@ namespace Grand.Web.Vendor.Models.Catalog
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductAttributeId { get; set; }
public string Name { get; set; }
@@ -45,7 +35,7 @@ namespace Grand.Web.Vendor.Models.Catalog
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeModel.cs
index 588c2a9bb..d52eab15e 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductAttributeModel.cs
@@ -19,11 +19,6 @@ namespace Grand.Web.Vendor.Models.Catalog
public class PredefinedProductAttributeValueModel : BaseEntityModel, ILocalizedModel<PredefinedProductAttributeValueLocalizedModel>
{
- public PredefinedProductAttributeValueModel()
- {
- Locales = new List<PredefinedProductAttributeValueLocalizedModel>();
- }
-
public string ProductAttributeId { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.Name")]
@@ -51,7 +46,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.DisplayOrder")]
public int DisplayOrder { get; set; }
- public IList<PredefinedProductAttributeValueLocalizedModel> Locales { get; set; }
+ public IList<PredefinedProductAttributeValueLocalizedModel> Locales { get; set; } = new List<PredefinedProductAttributeValueLocalizedModel>();
}
public class PredefinedProductAttributeValueLocalizedModel : ILocalizedModelLocal
{
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductListModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductListModel.cs
index 25bffa34b..e8f4835ea 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductListModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductListModel.cs
@@ -7,13 +7,6 @@ namespace Grand.Web.Vendor.Models.Catalog
{
public class ProductListModel : BaseModel
{
- public ProductListModel()
- {
- AvailableWarehouses = new List<SelectListItem>();
- AvailableProductTypes = new List<SelectListItem>();
- AvailablePublishedOptions = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.List.SearchCategory")]
@@ -39,8 +32,8 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.List.GoDirectlyToSku")]
public string GoDirectlyToSku { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
- public IList<SelectListItem> AvailablePublishedOptions { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePublishedOptions { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductModel.cs b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductModel.cs
index 5ea1a0b5c..b719116b5 100644
--- a/src/Web/Grand.Web.Vendor/Models/Catalog/ProductModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Catalog/ProductModel.cs
@@ -9,24 +9,6 @@ namespace Grand.Web.Vendor.Models.Catalog
{
public class ProductModel : BaseEntityModel, ILocalizedModel<ProductLocalizedModel>
{
- public ProductModel()
- {
- Locales = new List<ProductLocalizedModel>();
- ProductPictureModels = new List<ProductPictureModel>();
- CopyProductModel = new CopyProductModel();
- AvailableBasepriceUnits = new List<SelectListItem>();
- AvailableBasepriceBaseUnits = new List<SelectListItem>();
- AvailableProductLayouts = new List<SelectListItem>();
- AvailableTaxCategories = new List<SelectListItem>();
- AvailableDeliveryDates = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailableProductAttributes = new List<SelectListItem>();
- AvailableUnits = new List<SelectListItem>();
- AddPictureModel = new ProductPictureModel();
- ProductWarehouseInventoryModels = new List<ProductWarehouseInventoryModel>();
- CalendarModel = new GenerateCalendarModel();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.ID")]
public override string Id { get; set; }
@@ -50,7 +32,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.ProductLayout")]
public string ProductLayoutId { get; set; }
- public IList<SelectListItem> AvailableProductLayouts { get; set; }
+ public IList<SelectListItem> AvailableProductLayouts { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Name")]
public string Name { get; set; }
@@ -132,7 +114,7 @@ namespace Grand.Web.Vendor.Models.Catalog
public int RecurringTotalCycles { get; set; }
//calendar
- public GenerateCalendarModel CalendarModel { get; set; }
+ public GenerateCalendarModel CalendarModel { get; set; } = new();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.IsShipEnabled")]
public bool IsShipEnabled { get; set; }
@@ -148,14 +130,14 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.DeliveryDate")]
public string DeliveryDateId { get; set; }
- public IList<SelectListItem> AvailableDeliveryDates { get; set; }
+ public IList<SelectListItem> AvailableDeliveryDates { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.IsTaxExempt")]
public bool IsTaxExempt { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.TaxCategory")]
public string TaxCategoryId { get; set; }
- public IList<SelectListItem> AvailableTaxCategories { get; set; }
+ public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.IsTelecommunicationsOrBroadcastingOrElectronicServices")]
public bool IsTele { get; set; }
@@ -168,7 +150,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Warehouse")]
public string WarehouseId { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.StockQuantity")]
public int StockQuantity { get; set; }
@@ -257,12 +239,13 @@ namespace Grand.Web.Vendor.Models.Catalog
public double BasepriceAmount { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.BasepriceUnit")]
public string BasepriceUnitId { get; set; }
- public IList<SelectListItem> AvailableBasepriceUnits { get; set; }
+ public IList<SelectListItem> AvailableBasepriceUnits { get; set; } = new List<SelectListItem>();
+
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.BasepriceBaseAmount")]
public double BasepriceBaseAmount { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.BasepriceBaseUnit")]
public string BasepriceBaseUnitId { get; set; }
- public IList<SelectListItem> AvailableBasepriceBaseUnits { get; set; }
+ public IList<SelectListItem> AvailableBasepriceBaseUnits { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.MarkAsNew")]
public bool MarkAsNew { get; set; }
@@ -275,7 +258,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Unit")]
public string UnitId { get; set; }
- public IList<SelectListItem> AvailableUnits { get; set; }
+ public IList<SelectListItem> AvailableUnits { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.Fields.Weight")]
public double Weight { get; set; }
@@ -325,31 +308,26 @@ namespace Grand.Web.Vendor.Models.Catalog
public string BaseDimensionIn { get; set; }
public string BaseWeightIn { get; set; }
- public IList<ProductLocalizedModel> Locales { get; set; }
-
+ public IList<ProductLocalizedModel> Locales { get; set; } = new List<ProductLocalizedModel>();
+
//product attributes
- public IList<SelectListItem> AvailableProductAttributes { get; set; }
+ public IList<SelectListItem> AvailableProductAttributes { get; set; } = new List<SelectListItem>();
//pictures
- public ProductPictureModel AddPictureModel { get; set; }
- public IList<ProductPictureModel> ProductPictureModels { get; set; }
+ public ProductPictureModel AddPictureModel { get; set; } = new();
+ public IList<ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductPictureModel>();
//multiple warehouses
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductWarehouseInventory")]
- public IList<ProductWarehouseInventoryModel> ProductWarehouseInventoryModels { get; set; }
+ public IList<ProductWarehouseInventoryModel> ProductWarehouseInventoryModels { get; set; } = new List<ProductWarehouseInventoryModel>();
//copy product
- public CopyProductModel CopyProductModel { get; set; }
+ public CopyProductModel CopyProductModel { get; set; } = new();
#region Nested classes
public class AddProductModel : BaseModel
{
- public AddProductModel()
- {
- AvailableProductTypes = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Catalog.Products.List.SearchProductName")]
public string SearchProductName { get; set; }
@@ -365,8 +343,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.List.SearchProductType")]
public int SearchProductTypeId { get; set; }
- public IList<SelectListItem> AvailableProductTypes { get; set; }
-
+ public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();
}
@@ -377,12 +354,6 @@ namespace Grand.Web.Vendor.Models.Catalog
public class AddProductSpecificationAttributeModel : BaseModel, IProductValidVendor
{
- public AddProductSpecificationAttributeModel()
- {
- AvailableAttributes = new List<SelectListItem>();
- AvailableOptions = new List<SelectListItem>();
- }
-
public string Id { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.SpecificationAttributes.Fields.SpecificationAttribute")]
@@ -410,17 +381,12 @@ namespace Grand.Web.Vendor.Models.Catalog
public int DisplayOrder { get; set; }
public string ProductId { get; set; }
- public IList<SelectListItem> AvailableAttributes { get; set; }
- public IList<SelectListItem> AvailableOptions { get; set; }
+ public IList<SelectListItem> AvailableAttributes { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableOptions { get; set; } = new List<SelectListItem>();
}
public class ProductPictureModel : BaseEntityModel, ILocalizedModel<ProductPictureModel.ProductPictureLocalizedModel>, IProductValidVendor
{
- public ProductPictureModel()
- {
- Locales = new List<ProductPictureLocalizedModel>();
- }
-
public string ProductId { get; set; }
[UIHint("MultiPicture")]
@@ -445,7 +411,7 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.Pictures.Fields.ExtraField")]
public string ExtraField { get; set; }
- public IList<ProductPictureLocalizedModel> Locales { get; set; }
+ public IList<ProductPictureLocalizedModel> Locales { get; set; } = new List<ProductPictureLocalizedModel>();
public class ProductPictureLocalizedModel : ILocalizedModelLocal
{
@@ -599,15 +565,11 @@ namespace Grand.Web.Vendor.Models.Catalog
public class TierPriceModel : BaseEntityModel, IProductValidVendor
{
- public TierPriceModel()
- {
- AvailableCurrencies = new List<SelectListItem>();
- }
public string ProductId { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.TierPrices.Fields.CurrencyCode")]
public string CurrencyCode { get; set; }
- public IList<SelectListItem> AvailableCurrencies { get; set; }
+ public IList<SelectListItem> AvailableCurrencies { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.TierPrices.Fields.Quantity")]
public int Quantity { get; set; }
@@ -734,16 +696,12 @@ namespace Grand.Web.Vendor.Models.Catalog
public class ProductAttributeMappingModel : BaseEntityModel, IProductValidVendor
{
- public ProductAttributeMappingModel()
- {
- AvailableProductAttribute = new List<SelectListItem>();
- }
public string ProductId { get; set; }
public string ProductAttributeId { get; set; }
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.Attributes.Fields.Attribute")]
public string ProductAttribute { get; set; }
- public IList<SelectListItem> AvailableProductAttribute { get; set; }
+ public IList<SelectListItem> AvailableProductAttribute { get; set; } = new List<SelectListItem>();
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.Attributes.Fields.TextPrompt")]
public string TextPrompt { get; set; }
@@ -808,12 +766,6 @@ namespace Grand.Web.Vendor.Models.Catalog
public class ProductAttributeValueModel : BaseEntityModel, ILocalizedModel<ProductAttributeValueLocalizedModel>, IProductValidVendor
{
- public ProductAttributeValueModel()
- {
- ProductPictureModels = new List<ProductPictureModel>();
- Locales = new List<ProductAttributeValueLocalizedModel>();
- }
-
public string ProductAttributeMappingId { get; set; }
public string ProductId { get; set; }
@@ -870,8 +822,8 @@ namespace Grand.Web.Vendor.Models.Catalog
[GrandResourceDisplayName("Vendor.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Picture")]
public string PictureThumbnailUrl { get; set; }
- public IList<ProductPictureModel> ProductPictureModels { get; set; }
- public IList<ProductAttributeValueLocalizedModel> Locales { get; set; }
+ public IList<ProductPictureModel> ProductPictureModels { get; set; } = new List<ProductPictureModel>();
+ public IList<ProductAttributeValueLocalizedModel> Locales { get; set; } = new List<ProductAttributeValueLocalizedModel>();
#region Nested classes
diff --git a/src/Web/Grand.Web.Vendor/Models/Common/AddressModel.cs b/src/Web/Grand.Web.Vendor/Models/Common/AddressModel.cs
index 219560106..8e3cfbcf9 100644
--- a/src/Web/Grand.Web.Vendor/Models/Common/AddressModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Common/AddressModel.cs
@@ -11,13 +11,6 @@ namespace Grand.Web.Vendor.Models.Common
{
public class AddressModel : BaseEntityModel
{
- public AddressModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- CustomAddressAttributes = new List<AddressAttributeModel>();
- }
-
[GrandResourceDisplayName("Vendor.Address.Fields.AddressName")]
public string Name { get; set; }
@@ -76,13 +69,13 @@ namespace Grand.Web.Vendor.Models.Common
//formatted custom address attributes
public string FormattedCustomAddressAttributes { get; set; }
- public IList<AddressAttributeModel> CustomAddressAttributes { get; set; }
+ public IList<AddressAttributeModel> CustomAddressAttributes { get; set; } = new List<AddressAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public bool NameEnabled { get; set; }
@@ -120,11 +113,6 @@ namespace Grand.Web.Vendor.Models.Common
public class AddressAttributeModel : BaseEntityModel
{
- public AddressAttributeModel()
- {
- Values = new List<AddressAttributeValueModel>();
- }
-
public string Name { get; set; }
public bool IsRequired { get; set; }
@@ -136,7 +124,7 @@ namespace Grand.Web.Vendor.Models.Common
public AttributeControlType AttributeControlType { get; set; }
- public IList<AddressAttributeValueModel> Values { get; set; }
+ public IList<AddressAttributeValueModel> Values { get; set; } = new List<AddressAttributeValueModel>();
}
public class AddressAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web.Vendor/Models/Common/LoginModel.cs b/src/Web/Grand.Web.Vendor/Models/Common/LoginModel.cs
index e25504f5b..d92c5ae82 100644
--- a/src/Web/Grand.Web.Vendor/Models/Common/LoginModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Common/LoginModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Vendor.Models.Common
{
public class LoginModel : BaseModel
{
- public LoginModel()
- {
- Captcha = new CaptchaModel();
- }
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.Login.Fields.Email")]
public string Email { get; set; }
@@ -27,6 +23,6 @@ namespace Grand.Web.Vendor.Models.Common
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnListModel.cs b/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnListModel.cs
index ccf8cead8..316fd8d84 100644
--- a/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnListModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnListModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.MerchandiseReturn
{
public class MerchandiseReturnListModel : BaseModel
{
- public MerchandiseReturnListModel()
- {
- MerchandiseReturnStatus = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Admin.Orders.MerchandiseReturns.List.SearchCustomerEmail")]
public string SearchCustomerEmail { get; set; }
@@ -29,6 +24,6 @@ namespace Grand.Web.Vendor.Models.MerchandiseReturn
[UIHint("DateNullable")]
public DateTime? EndDate { get; set; }
- public IList<SelectListItem> MerchandiseReturnStatus { get; set; }
+ public IList<SelectListItem> MerchandiseReturnStatus { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnModel.cs b/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnModel.cs
index c1e0ba86f..20d0b20a5 100644
--- a/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/MerchandiseReturn/MerchandiseReturnModel.cs
@@ -6,11 +6,6 @@ namespace Grand.Web.Vendor.Models.MerchandiseReturn
{
public class MerchandiseReturnModel : BaseEntityModel
{
- public MerchandiseReturnModel()
- {
- Items = new List<MerchandiseReturnItemModel>();
- }
-
[GrandResourceDisplayName("Vendor.Orders.MerchandiseReturns.Fields.ID")]
public override string Id { get; set; }
@@ -56,7 +51,7 @@ namespace Grand.Web.Vendor.Models.MerchandiseReturn
[GrandResourceDisplayName("Vendor.Orders.MerchandiseReturns.Fields.PickupAddress")]
public AddressModel PickupAddress { get; set; }
- public List<MerchandiseReturnItemModel> Items { get; set; }
+ public List<MerchandiseReturnItemModel> Items { get; set; } = new();
[GrandResourceDisplayName("Vendor.Orders.MerchandiseReturns.NotifyCustomer")]
public bool NotifyCustomer { get; set; }
diff --git a/src/Web/Grand.Web.Vendor/Models/Orders/OrderListModel.cs b/src/Web/Grand.Web.Vendor/Models/Orders/OrderListModel.cs
index 794fe5f4e..d1ee5c2d4 100644
--- a/src/Web/Grand.Web.Vendor/Models/Orders/OrderListModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Orders/OrderListModel.cs
@@ -7,17 +7,6 @@ namespace Grand.Web.Vendor.Models.Orders
{
public class OrderListModel : BaseModel
{
- public OrderListModel()
- {
- AvailableOrderStatuses = new List<SelectListItem>();
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableShippingStatuses = new List<SelectListItem>();
- AvailableWarehouses = new List<SelectListItem>();
- AvailablePaymentMethods = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- AvailableOrderTags = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Orders.List.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -67,12 +56,12 @@ namespace Grand.Web.Vendor.Models.Orders
[GrandResourceDisplayName("Vendor.Orders.List.OrderTagId")]
public string OrderTag { get; set; }
- public IList<SelectListItem> AvailableOrderStatuses { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableShippingStatuses { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
- public IList<SelectListItem> AvailablePaymentMethods { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableOrderTags { get; set; }
+ public IList<SelectListItem> AvailableOrderStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableShippingStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailablePaymentMethods { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableOrderTags { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Orders/OrderModel.cs b/src/Web/Grand.Web.Vendor/Models/Orders/OrderModel.cs
index 0038e21fe..1471e9f17 100644
--- a/src/Web/Grand.Web.Vendor/Models/Orders/OrderModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Orders/OrderModel.cs
@@ -10,11 +10,6 @@ namespace Grand.Web.Vendor.Models.Orders
{
public class OrderModel : BaseEntityModel
{
- public OrderModel()
- {
- Items = new List<OrderItemModel>();
- }
-
//identifiers
[GrandResourceDisplayName("Vendor.Orders.Fields.ID")]
public override string Id { get; set; }
@@ -80,7 +75,7 @@ namespace Grand.Web.Vendor.Models.Orders
//items
public bool HasDownloadableProducts { get; set; }
- public IList<OrderItemModel> Items { get; set; }
+ public IList<OrderItemModel> Items { get; set; } = new List<OrderItemModel>();
//creation date
[GrandResourceDisplayName("Vendor.Orders.Fields.CreatedOn")]
@@ -95,11 +90,6 @@ namespace Grand.Web.Vendor.Models.Orders
public class OrderItemModel : BaseEntityModel
{
- public OrderItemModel()
- {
- MerchandiseReturnIds = new List<string>();
- PurchasedGiftVoucherIds = new List<string>();
- }
public string ProductId { get; set; }
public string ProductName { get; set; }
public string VendorName { get; set; }
@@ -131,8 +121,8 @@ namespace Grand.Web.Vendor.Models.Orders
public string AttributeInfo { get; set; }
public string RecurringInfo { get; set; }
- public IList<string> MerchandiseReturnIds { get; set; }
- public IList<string> PurchasedGiftVoucherIds { get; set; }
+ public IList<string> MerchandiseReturnIds { get; set; } = new List<string>();
+ public IList<string> PurchasedGiftVoucherIds { get; set; } = new List<string>();
public bool IsDownload { get; set; }
public int DownloadCount { get; set; }
diff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs
index 0728c5f5a..39ba65f2d 100644
--- a/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Report/BestCustomersReportModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.Report
{
public class BestCustomersReportModel : BaseModel
{
- public BestCustomersReportModel()
- {
- AvailablePaymentStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -23,6 +18,6 @@ namespace Grand.Web.Vendor.Models.Report
[GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.PaymentStatus")]
public int PaymentStatusId { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs
index 88dc482aa..fd98e5d93 100644
--- a/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Report/BestsellersReportModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Vendor.Models.Report
{
public class BestsellersReportModel : BaseModel
{
- public BestsellersReportModel()
- {
- AvailablePaymentStatuses = new List<SelectListItem>();
- AvailableCountries = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Reports.Bestsellers.Store")]
public string StoreId { get; set; }
@@ -29,7 +23,7 @@ namespace Grand.Web.Vendor.Models.Report
[GrandResourceDisplayName("Vendor.Reports.Bestsellers.BillingCountry")]
public string BillingCountryId { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs
index 9a973f2e1..8ab90dacb 100644
--- a/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Report/CountryReportModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.Report
{
public class CountryReportModel : BaseModel
{
- public CountryReportModel()
- {
- AvailablePaymentStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Reports.Country.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -22,6 +17,6 @@ namespace Grand.Web.Vendor.Models.Report
[GrandResourceDisplayName("Vendor.Reports.Country.PaymentStatus")]
public int PaymentStatusId { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs b/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs
index c9ad7ee76..45ae4e6cd 100644
--- a/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Report/CustomerReportsModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.Report
{
public class CustomerReportsModel : BaseModel
{
- public CustomerReportsModel()
- {
- AvailablePaymentStatuses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -23,6 +18,6 @@ namespace Grand.Web.Vendor.Models.Report
[GrandResourceDisplayName("Vendor.Reports.Customer.BestBy.PaymentStatus")]
public int PaymentStatusId { get; set; }
- public IList<SelectListItem> AvailablePaymentStatuses { get; set; }
+ public IList<SelectListItem> AvailablePaymentStatuses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Shipment/AddShipmentModel.cs b/src/Web/Grand.Web.Vendor/Models/Shipment/AddShipmentModel.cs
index a2d3900db..e4988f7c4 100644
--- a/src/Web/Grand.Web.Vendor/Models/Shipment/AddShipmentModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Shipment/AddShipmentModel.cs
@@ -2,17 +2,12 @@
public class AddShipmentModel
{
- public AddShipmentModel()
- {
- Items = new List<ShipmentItemModel>();
- }
-
public string OrderId { get; set; }
public string TrackingNumber { get; set; }
public string AdminComment { get; set; }
- public IList<ShipmentItemModel> Items { get; set; }
-
+ public IList<ShipmentItemModel> Items { get; set; } = new List<ShipmentItemModel>();
+
public class ShipmentItemModel
{
public string OrderItemId { get; set; }
diff --git a/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentListModel.cs b/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentListModel.cs
index b9877d35f..62b1a1c46 100644
--- a/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentListModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentListModel.cs
@@ -7,11 +7,6 @@ namespace Grand.Web.Vendor.Models.Shipment
{
public class ShipmentListModel : BaseModel
{
- public ShipmentListModel()
- {
- AvailableWarehouses = new List<SelectListItem>();
- }
-
[GrandResourceDisplayName("Vendor.Orders.Shipments.List.StartDate")]
[UIHint("DateNullable")]
public DateTime? StartDate { get; set; }
@@ -35,7 +30,6 @@ namespace Grand.Web.Vendor.Models.Shipment
[GrandResourceDisplayName("Vendor.Orders.Shipments.List.Warehouse")]
public string WarehouseId { get; set; }
- public IList<SelectListItem> AvailableWarehouses { get; set; }
-
+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentModel.cs b/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentModel.cs
index 13d7485f6..5b3505838 100644
--- a/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Shipment/ShipmentModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Vendor.Models.Shipment
{
public class ShipmentModel : BaseEntityModel
{
- public ShipmentModel()
- {
- ShipmentStatusEvents = new List<ShipmentStatusEventModel>();
- Items = new List<ShipmentItemModel>();
- }
[GrandResourceDisplayName("Vendor.Orders.Shipments.ID")]
public override string Id { get; set; }
public int ShipmentNumber { get; set; }
@@ -37,9 +32,9 @@ namespace Grand.Web.Vendor.Models.Shipment
[GrandResourceDisplayName("Vendor.Orders.Shipments.AdminComment")]
public string AdminComment { get; set; }
- public List<ShipmentItemModel> Items { get; set; }
+ public List<ShipmentItemModel> Items { get; set; } = new();
- public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; }
+ public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; } = new List<ShipmentStatusEventModel>();
//shipment notes
[GrandResourceDisplayName("Vendor.Orders.Shipments.ShipmentNotes.Fields.DisplayToCustomer")]
@@ -54,11 +49,6 @@ namespace Grand.Web.Vendor.Models.Shipment
public class ShipmentItemModel : BaseEntityModel
{
- public ShipmentItemModel()
- {
- AvailableWarehouses = new List<WarehouseInfo>();
- }
-
public string OrderItemId { get; set; }
public string ProductId { get; set; }
[GrandResourceDisplayName("Vendor.Orders.Shipments.Products.ProductName")]
@@ -83,7 +73,7 @@ namespace Grand.Web.Vendor.Models.Shipment
public string ShippedFromWarehouse { get; set; }
public bool AllowToChooseWarehouse { get; set; }
//used before a shipment is created
- public List<WarehouseInfo> AvailableWarehouses { get; set; }
+ public List<WarehouseInfo> AvailableWarehouses { get; set; } = new();
public string WarehouseId { get; set; }
#region Nested Classes
diff --git a/src/Web/Grand.Web.Vendor/Models/Vendor/VendorModel.cs b/src/Web/Grand.Web.Vendor/Models/Vendor/VendorModel.cs
index e66c31735..9a412886f 100644
--- a/src/Web/Grand.Web.Vendor/Models/Vendor/VendorModel.cs
+++ b/src/Web/Grand.Web.Vendor/Models/Vendor/VendorModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Vendor.Models.Vendor
{
public class VendorModel : BaseEntityModel, ILocalizedModel<VendorLocalizedModel>
{
- public VendorModel()
- {
- Locales = new List<VendorLocalizedModel>();
- Address = new AddressModel();
- }
-
[GrandResourceDisplayName("Vendor.Fields.Name")]
public string Name { get; set; }
@@ -50,10 +44,9 @@ namespace Grand.Web.Vendor.Models.Vendor
[GrandResourceDisplayName("Vendor.Fields.PageSizeOptions")]
public string PageSizeOptions { get; set; }
- public IList<VendorLocalizedModel> Locales { get; set; }
+ public IList<VendorLocalizedModel> Locales { get; set; } = new List<VendorLocalizedModel>();
- public AddressModel Address { get; set; }
-
+ public AddressModel Address { get; set; } = new();
}
public class VendorLocalizedModel : ILocalizedModelLocal, ISlugModelLocal
diff --git a/src/Web/Grand.Web/Features/Models/Blogs/GetBlogPostList.cs b/src/Web/Grand.Web/Features/Models/Blogs/GetBlogPostList.cs
index 93122efec..79b83ca86 100644
--- a/src/Web/Grand.Web/Features/Models/Blogs/GetBlogPostList.cs
+++ b/src/Web/Grand.Web/Features/Models/Blogs/GetBlogPostList.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Features.Models.Blogs
{
public class GetBlogPostList: IRequest<BlogPostListModel>
{
- public GetBlogPostList()
- {
- Command = new BlogPagingFilteringModel();
- }
- public BlogPagingFilteringModel Command { get; set; }
+ public BlogPagingFilteringModel Command { get; set; } = new();
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Customers/GetDocuments.cs b/src/Web/Grand.Web/Features/Models/Customers/GetDocuments.cs
index 902d7b9e0..732f603df 100644
--- a/src/Web/Grand.Web/Features/Models/Customers/GetDocuments.cs
+++ b/src/Web/Grand.Web/Features/Models/Customers/GetDocuments.cs
@@ -7,12 +7,8 @@ namespace Grand.Web.Features.Models.Customers
{
public class GetDocuments : IRequest<DocumentsModel>
{
- public GetDocuments()
- {
- Command = new DocumentPagingModel();
- }
public Customer Customer { get; set; }
public Language Language { get; set; }
- public DocumentPagingModel Command { get; set; }
+ public DocumentPagingModel Command { get; set; } = new();
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Customers/GetParseCustomAttributes.cs b/src/Web/Grand.Web/Features/Models/Customers/GetParseCustomAttributes.cs
index fd5e100e5..6489e8e63 100644
--- a/src/Web/Grand.Web/Features/Models/Customers/GetParseCustomAttributes.cs
+++ b/src/Web/Grand.Web/Features/Models/Customers/GetParseCustomAttributes.cs
@@ -6,13 +6,8 @@ namespace Grand.Web.Features.Models.Customers
{
public class GetParseCustomAttributes : IRequest<IList<CustomAttribute>>
{
- public GetParseCustomAttributes()
- {
- CustomerCustomAttribute = new List<CustomAttribute>();
- }
-
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
- public List<CustomAttribute> CustomerCustomAttribute { get; set; }
+ public List<CustomAttribute> CustomerCustomAttribute { get; set; } = new();
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Orders/GetCustomerOrderList.cs b/src/Web/Grand.Web/Features/Models/Orders/GetCustomerOrderList.cs
index 0b817d8fc..41f2c414f 100644
--- a/src/Web/Grand.Web/Features/Models/Orders/GetCustomerOrderList.cs
+++ b/src/Web/Grand.Web/Features/Models/Orders/GetCustomerOrderList.cs
@@ -8,13 +8,9 @@ namespace Grand.Web.Features.Models.Orders
{
public class GetCustomerOrderList : IRequest<CustomerOrderListModel>
{
- public GetCustomerOrderList()
- {
- Command = new OrderPagingModel();
- }
public Customer Customer { get; set; }
public Store Store { get; set; }
public Language Language { get; set; }
- public OrderPagingModel Command { get; set; }
+ public OrderPagingModel Command { get; set; } = new();
}
}
diff --git a/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs b/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
index 183ef5e60..0e2ce7aaf 100644
--- a/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
@@ -5,15 +5,11 @@ namespace Grand.Web.Models.Blogs
{
public class AddBlogCommentModel : BaseEntityModel
{
- public AddBlogCommentModel()
- {
- Captcha = new CaptchaModel();
- }
[GrandResourceDisplayName("Blog.Comments.CommentText")]
public string CommentText { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
index 363da9ec9..010159a35 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
@@ -5,16 +5,10 @@ namespace Grand.Web.Models.Blogs
{
public class BlogPostListModel : BaseModel
{
- public BlogPostListModel()
- {
- PagingFilteringContext = new BlogPagingFilteringModel();
- BlogPosts = new List<BlogPostModel>();
- PictureModel = new PictureModel();
- }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
public string WorkingLanguageId { get; set; }
- public BlogPagingFilteringModel PagingFilteringContext { get; set; }
- public IList<BlogPostModel> BlogPosts { get; set; }
+ public BlogPagingFilteringModel PagingFilteringContext { get; set; } = new();
+ public IList<BlogPostModel> BlogPosts { get; set; } = new List<BlogPostModel>();
public string SearchKeyword { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
index 4b132d7fb..adedfe28f 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
@@ -5,27 +5,19 @@ namespace Grand.Web.Models.Blogs
{
public class BlogPostModel : BaseEntityModel
{
- public BlogPostModel()
- {
- Tags = new List<string>();
- Comments = new List<BlogCommentModel>();
- AddNewComment = new AddBlogCommentModel();
- PictureModel = new PictureModel();
- }
public string MetaKeywords { get; set; }
public string MetaDescription { get; set; }
public string MetaTitle { get; set; }
public string SeName { get; set; }
public string Title { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
public string Body { get; set; }
public string BodyOverview { get; set; }
public bool AllowComments { get; set; }
public int NumberOfComments { get; set; }
public DateTime CreatedOn { get; set; }
- public IList<string> Tags { get; set; }
- public IList<BlogCommentModel> Comments { get; set; }
- public AddBlogCommentModel AddNewComment { get; set; }
-
+ public IList<string> Tags { get; set; } = new List<string>();
+ public IList<BlogCommentModel> Comments { get; set; } = new List<BlogCommentModel>();
+ public AddBlogCommentModel AddNewComment { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
index 74fda05c5..f4f1386e9 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
@@ -4,11 +4,6 @@ namespace Grand.Web.Models.Blogs
{
public class BlogPostTagListModel : BaseModel
{
- public BlogPostTagListModel()
- {
- Tags = new List<BlogPostTagModel>();
- }
-
public int GetFontSize(BlogPostTagModel blogPostTag)
{
var itemWeights = new List<double>();
@@ -65,6 +60,6 @@ namespace Grand.Web.Models.Blogs
}
- public IList<BlogPostTagModel> Tags { get; set; }
+ public IList<BlogPostTagModel> Tags { get; set; } = new List<BlogPostTagModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
index 445e9c02e..44779cba2 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
@@ -4,12 +4,8 @@ namespace Grand.Web.Models.Blogs
{
public class BlogPostYearModel : BaseModel
{
- public BlogPostYearModel()
- {
- Months = new List<BlogPostMonthModel>();
- }
public int Year { get; set; }
- public IList<BlogPostMonthModel> Months { get; set; }
+ public IList<BlogPostMonthModel> Months { get; set; } = new List<BlogPostMonthModel>();
}
public class BlogPostMonthModel : BaseModel
{
diff --git a/src/Web/Grand.Web/Models/Blogs/HomePageBlogItemsModel.cs b/src/Web/Grand.Web/Models/Blogs/HomePageBlogItemsModel.cs
index c1ce804b0..2f864a782 100644
--- a/src/Web/Grand.Web/Models/Blogs/HomePageBlogItemsModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/HomePageBlogItemsModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Models.Blogs
{
public class HomePageBlogItemsModel: BaseModel
{
- public HomePageBlogItemsModel()
- {
- Items = new List<BlogItemModel>();
- }
-
- public IList<BlogItemModel> Items { get; set; }
+ public IList<BlogItemModel> Items { get; set; } = new List<BlogItemModel>();
public class BlogItemModel : BaseModel
{
diff --git a/src/Web/Grand.Web/Models/Catalog/BrandListModel.cs b/src/Web/Grand.Web/Models/Catalog/BrandListModel.cs
index 5bc1f518c..5524f9ae2 100644
--- a/src/Web/Grand.Web/Models/Catalog/BrandListModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/BrandListModel.cs
@@ -2,11 +2,6 @@
public class BrandListModel
{
- public BrandListModel()
- {
- PagingModel = new BrandPagingModel();
- BrandsModel = new List<BrandModel>();
- }
- public BrandPagingModel PagingModel { get; set; }
- public IList<BrandModel> BrandsModel { get; set; }
+ public BrandPagingModel PagingModel { get; set; } = new();
+ public IList<BrandModel> BrandsModel { get; set; } = new List<BrandModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/BrandModel.cs b/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
index a8531cd4f..755a0eddd 100644
--- a/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
@@ -5,13 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class BrandModel : BaseEntityModel
{
- public BrandModel()
- {
- PictureModel = new PictureModel();
- Products = new List<ProductOverviewModel>();
- PagingFilteringContext = new CatalogPagingFilteringModel();
- }
-
public string Name { get; set; }
public string Description { get; set; }
public string BottomDescription { get; set; }
@@ -20,9 +13,9 @@ namespace Grand.Web.Models.Catalog
public string MetaTitle { get; set; }
public string SeName { get; set; }
public string Icon { get; set; }
- public PictureModel PictureModel { get; set; }
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
- public IList<ProductOverviewModel> Products { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
}
public class BrandBriefInfoModel : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
index 7daec1d93..af5f0e029 100644
--- a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
@@ -13,15 +13,6 @@ namespace Grand.Web.Models.Catalog
{
#region Constructors
- public CatalogPagingFilteringModel()
- {
- AvailableSortOptions = new List<SelectListItem>();
- AvailableViewModes = new List<SelectListItem>();
- PageSizeOptions = new List<SelectListItem>();
- SpecificationFilter = new SpecificationFilterModel();
- RatingOptions = new List<SelectListItem>();
- }
-
#endregion
#region Properties
@@ -29,16 +20,16 @@ namespace Grand.Web.Models.Catalog
/// <summary>
/// Specification filter model
/// </summary>
- public SpecificationFilterModel SpecificationFilter { get; set; }
+ public SpecificationFilterModel SpecificationFilter { get; set; } = new();
public bool AllowProductSorting { get; set; }
- public IList<SelectListItem> AvailableSortOptions { get; set; }
+ public IList<SelectListItem> AvailableSortOptions { get; set; } = new List<SelectListItem>();
public bool AllowProductViewModeChanging { get; set; }
- public IList<SelectListItem> AvailableViewModes { get; set; }
+ public IList<SelectListItem> AvailableViewModes { get; set; } = new List<SelectListItem>();
public bool AllowCustomersToSelectPageSize { get; set; }
- public IList<SelectListItem> PageSizeOptions { get; set; }
+ public IList<SelectListItem> PageSizeOptions { get; set; } = new List<SelectListItem>();
/// <summary>
/// Order by
@@ -53,8 +44,8 @@ namespace Grand.Web.Models.Catalog
/// <summary>
/// Rating list options
/// </summary>
- public IList<SelectListItem> RatingOptions { get; set; }
-
+ public IList<SelectListItem> RatingOptions { get; set; } = new List<SelectListItem>();
+
/// <summary>
/// View mode
/// </summary>
@@ -69,12 +60,6 @@ namespace Grand.Web.Models.Catalog
{
#region Ctor
- public SpecificationFilterModel()
- {
- AlreadyFilteredItems = new List<SpecificationFilterItem>();
- NotFilteredItems = new List<SpecificationFilterItem>();
- }
-
#endregion
#region Utilities
@@ -214,8 +199,8 @@ namespace Grand.Web.Models.Catalog
#region Properties
public bool Enabled { get; set; }
- public IList<SpecificationFilterItem> AlreadyFilteredItems { get; set; }
- public IList<SpecificationFilterItem> NotFilteredItems { get; set; }
+ public IList<SpecificationFilterItem> AlreadyFilteredItems { get; set; } = new List<SpecificationFilterItem>();
+ public IList<SpecificationFilterItem> NotFilteredItems { get; set; } = new List<SpecificationFilterItem>();
public string RemoveFilterUrl { get; set; }
#endregion
diff --git a/src/Web/Grand.Web/Models/Catalog/CategoryListModel.cs b/src/Web/Grand.Web/Models/Catalog/CategoryListModel.cs
index 5cf133eda..0f7e27165 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategoryListModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategoryListModel.cs
@@ -2,11 +2,6 @@
public class CategoryListModel
{
- public CategoryListModel()
- {
- PagingModel = new CategoryPagingModel();
- CategoriesModel = new List<CategoryModel>();
- }
- public CategoryPagingModel PagingModel { get; set; }
- public IList<CategoryModel> CategoriesModel { get; set; }
+ public CategoryPagingModel PagingModel { get; set; } = new();
+ public IList<CategoryModel> CategoriesModel { get; set; } = new List<CategoryModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs b/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
index f3a2573af..5023c4dae 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
@@ -5,15 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class CategoryModel : BaseEntityModel
{
- public CategoryModel()
- {
- PictureModel = new PictureModel();
- FeaturedProducts = new List<ProductOverviewModel>();
- Products = new List<ProductOverviewModel>();
- PagingFilteringContext = new CatalogPagingFilteringModel();
- SubCategories = new List<SubCategoryModel>();
- CategoryBreadcrumb = new List<CategoryModel>();
- }
public string ParentCategoryId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
@@ -25,26 +16,23 @@ namespace Grand.Web.Models.Catalog
public string Flag { get; set; }
public string FlagStyle { get; set; }
public string Icon { get; set; }
- public PictureModel PictureModel { get; set; }
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
public bool DisplayCategoryBreadcrumb { get; set; }
- public IList<CategoryModel> CategoryBreadcrumb { get; set; }
- public IList<SubCategoryModel> SubCategories { get; set; }
- public IList<ProductOverviewModel> FeaturedProducts { get; set; }
- public IList<ProductOverviewModel> Products { get; set; }
- #region Nested Classes
+ public IList<CategoryModel> CategoryBreadcrumb { get; set; } = new List<CategoryModel>();
+ public IList<SubCategoryModel> SubCategories { get; set; } = new List<SubCategoryModel>();
+ public IList<ProductOverviewModel> FeaturedProducts { get; set; } = new List<ProductOverviewModel>();
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
+
+ #region Nested Classes
public class SubCategoryModel : BaseEntityModel
{
- public SubCategoryModel()
- {
- PictureModel = new PictureModel();
- }
public string Name { get; set; }
public string SeName { get; set; }
public string Description { get; set; }
public string Flag { get; set; }
public string FlagStyle { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
}
#endregion
diff --git a/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
index 72c8e040f..7e8dcc0ad 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
@@ -4,13 +4,8 @@ namespace Grand.Web.Models.Catalog
{
public class CategoryNavigationModel : BaseModel
{
- public CategoryNavigationModel()
- {
- Categories = new List<CategorySimpleModel>();
- }
-
public string CurrentCategoryId { get; set; }
- public List<CategorySimpleModel> Categories { get; set; }
+ public List<CategorySimpleModel> Categories { get; set; } = new();
public class CategoryLineModel : BaseModel
{
diff --git a/src/Web/Grand.Web/Models/Catalog/CategorySimpleModel.cs b/src/Web/Grand.Web/Models/Catalog/CategorySimpleModel.cs
index f47b678ce..c03d7882e 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategorySimpleModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategorySimpleModel.cs
@@ -4,10 +4,6 @@ namespace Grand.Web.Models.Catalog
{
public class CategorySimpleModel : BaseEntityModel
{
- public CategorySimpleModel()
- {
- SubCategories = new List<CategorySimpleModel>();
- }
public string Name { get; set; }
public string Flag { get; set; }
public string FlagStyle { get; set; }
@@ -16,6 +12,6 @@ namespace Grand.Web.Models.Catalog
public string SeName { get; set; }
public int? NumberOfProducts { get; set; }
public bool IncludeInMenu { get; set; }
- public List<CategorySimpleModel> SubCategories { get; set; }
+ public List<CategorySimpleModel> SubCategories { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/CollectionListModel.cs b/src/Web/Grand.Web/Models/Catalog/CollectionListModel.cs
index f688abffa..5f77c0e7f 100644
--- a/src/Web/Grand.Web/Models/Catalog/CollectionListModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CollectionListModel.cs
@@ -2,11 +2,6 @@
public class CollectionListModel
{
- public CollectionListModel()
- {
- PagingModel = new CollectionPagingModel();
- CollectionModel = new List<CollectionModel>();
- }
- public CollectionPagingModel PagingModel { get; set; }
- public IList<CollectionModel> CollectionModel { get; set; }
+ public CollectionPagingModel PagingModel { get; set; } = new();
+ public IList<CollectionModel> CollectionModel { get; set; } = new List<CollectionModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs b/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
index 830309571..cf1f194a7 100644
--- a/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
@@ -5,14 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class CollectionModel : BaseEntityModel
{
- public CollectionModel()
- {
- PictureModel = new PictureModel();
- FeaturedProducts = new List<ProductOverviewModel>();
- Products = new List<ProductOverviewModel>();
- PagingFilteringContext = new CatalogPagingFilteringModel();
- }
-
public string Name { get; set; }
public string Description { get; set; }
public string BottomDescription { get; set; }
@@ -21,9 +13,9 @@ namespace Grand.Web.Models.Catalog
public string MetaTitle { get; set; }
public string SeName { get; set; }
public string Icon { get; set; }
- public PictureModel PictureModel { get; set; }
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
- public IList<ProductOverviewModel> FeaturedProducts { get; set; }
- public IList<ProductOverviewModel> Products { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
+ public IList<ProductOverviewModel> FeaturedProducts { get; set; } = new List<ProductOverviewModel>();
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
index 97249475f..09fd76659 100644
--- a/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Catalog
{
public class CollectionNavigationModel : BaseModel
{
- public CollectionNavigationModel()
- {
- Collections = new List<CollectionBriefInfoModel>();
- }
-
- public IList<CollectionBriefInfoModel> Collections { get; set; }
+ public IList<CollectionBriefInfoModel> Collections { get; set; } = new List<CollectionBriefInfoModel>();
public int TotalCollections { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs b/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
index 5c2629d4f..dff64bfb2 100644
--- a/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
@@ -4,11 +4,7 @@ namespace Grand.Web.Models.Catalog
{
public class CompareProductsModel : BaseEntityModel
{
- public CompareProductsModel()
- {
- Products = new List<ProductOverviewModel>();
- }
- public IList<ProductOverviewModel> Products { get; set; }
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
public bool IncludeShortDescriptionInCompareProducts { get; set; }
public bool IncludeFullDescriptionInCompareProducts { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs b/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
index 0a80f26a3..154c5071d 100644
--- a/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
@@ -5,14 +5,8 @@ namespace Grand.Web.Models.Catalog
{
public class CustomerOutOfStockSubscriptionsModel
{
- public CustomerOutOfStockSubscriptionsModel()
- {
- Subscriptions = new List<OutOfStockSubscriptionModel>();
- PagerModel = new PagerModel();
- }
-
- public IList<OutOfStockSubscriptionModel> Subscriptions { get; set; }
- public PagerModel PagerModel { get; set; }
+ public IList<OutOfStockSubscriptionModel> Subscriptions { get; set; } = new List<OutOfStockSubscriptionModel>();
+ public PagerModel PagerModel { get; set; } = new();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/Catalog/MenuModel.cs b/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
index 73a3504a4..e8b6a4015 100644
--- a/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
@@ -4,18 +4,10 @@ namespace Grand.Web.Models.Catalog
{
public class MenuModel : BaseModel
{
- public MenuModel()
- {
- Categories = new List<CategorySimpleModel>();
- Pages = new List<MenuPageModel>();
- Brands = new List<MenuBrandModel>();
- Collections = new List<MenuCollectionModel> ();
- }
-
- public IList<CategorySimpleModel> Categories { get; set; }
- public IList<MenuPageModel> Pages { get; set; }
- public IList<MenuBrandModel> Brands { get; set; }
- public IList<MenuCollectionModel> Collections { get; set; }
+ public IList<CategorySimpleModel> Categories { get; set; } = new List<CategorySimpleModel>();
+ public IList<MenuPageModel> Pages { get; set; } = new List<MenuPageModel>();
+ public IList<MenuBrandModel> Brands { get; set; } = new List<MenuBrandModel>();
+ public IList<MenuCollectionModel> Collections { get; set; } = new List<MenuCollectionModel> ();
public bool BlogEnabled { get; set; }
public bool NewProductsEnabled { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
index adf111ca1..95ad96106 100644
--- a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
@@ -4,11 +4,6 @@ namespace Grand.Web.Models.Catalog
{
public class PopularProductTagsModel : BaseModel
{
- public PopularProductTagsModel()
- {
- Tags = new List<ProductTagModel>();
- }
-
#region Utilities
protected virtual int GetFontSize(double weight, double mean, double stdDev)
@@ -76,7 +71,7 @@ namespace Grand.Web.Models.Catalog
public int TotalTags { get; set; }
- public IList<ProductTagModel> Tags { get; set; }
+ public IList<ProductTagModel> Tags { get; set; } = new List<ProductTagModel>();
#endregion
}
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
index 98b46f95b..ee2b663ae 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class ProductAskQuestionSimpleModel : BaseEntityModel
{
- public ProductAskQuestionSimpleModel()
- {
- Captcha = new CaptchaModel();
- }
[GrandResourceDisplayName("Products.AskQuestion.Email")]
public string AskQuestionEmail { get; set; }
@@ -22,7 +18,6 @@ namespace Grand.Web.Models.Catalog
public string AskQuestionMessage { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
-
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
index dfd14ec6b..a07d2cbb1 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
@@ -4,12 +4,6 @@ namespace Grand.Web.Models.Catalog
{
public class ProductDetailsAttributeChangeModel : BaseEntityModel
{
- public ProductDetailsAttributeChangeModel()
- {
- EnabledAttributeMappingIds = new List<string>();
- DisabledAttributeMappingids = new List<string>();
- NotAvailableAttributeMappingids = new List<string>();
- }
public string Gtin { get; set; }
public string Mpn { get; set; }
public string Sku { get; set; }
@@ -17,9 +11,9 @@ namespace Grand.Web.Models.Catalog
public string StockAvailability { get; set; }
public bool DisplayOutOfStockSubscription { get; set; }
public string ButtonTextOutOfStockSubscription { get; set; }
- public IList<string> EnabledAttributeMappingIds { get; set; }
- public IList<string> DisabledAttributeMappingids { get; set; }
- public IList<string> NotAvailableAttributeMappingids { get; set; }
+ public IList<string> EnabledAttributeMappingIds { get; set; } = new List<string>();
+ public IList<string> DisabledAttributeMappingids { get; set; } = new List<string>();
+ public IList<string> NotAvailableAttributeMappingids { get; set; } = new List<string>();
public string PictureFullSizeUrl { get; set; }
public string PictureDefaultSizeUrl { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
index 21d593048..6ae14a708 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
@@ -10,31 +10,10 @@ namespace Grand.Web.Models.Catalog
{
public class ProductDetailsModel : BaseEntityModel
{
- public ProductDetailsModel()
- {
- DefaultPictureModel = new PictureModel();
- PictureModels = new List<PictureModel>();
- GiftVoucher = new GiftVoucherModel();
- ProductPrice = new ProductPriceModel();
- AddToCart = new AddToCartModel();
- ProductAttributes = new List<ProductAttributeModel>();
- AssociatedProducts = new List<ProductDetailsModel>();
- BrandModel = new BrandBriefInfoModel();
- VendorModel = new VendorBriefInfoModel();
- Breadcrumb = new ProductBreadcrumbModel();
- ProductTags = new List<ProductTagModel>();
- ProductSpecifications = new List<ProductSpecificationModel>();
- ProductCollections = new List<CollectionModel>();
- ProductReviewOverview = new ProductReviewOverviewModel();
- TierPrices = new List<TierPriceModel>();
- Parameters = new List<SelectListItem>();
- ProductBundleModels = new List<ProductBundleModel>();
- ProductWarehouses = new List<ProductWarehouseModel>();
- }
//picture(s)
public bool DefaultPictureZoomEnabled { get; set; }
- public PictureModel DefaultPictureModel { get; set; }
- public IList<PictureModel> PictureModels { get; set; }
+ public PictureModel DefaultPictureModel { get; set; } = new();
+ public IList<PictureModel> PictureModels { get; set; } = new List<PictureModel>();
public ProductType ProductType { get; set; }
public string Name { get; set; }
public string ShortDescription { get; set; }
@@ -50,16 +29,16 @@ namespace Grand.Web.Models.Catalog
public string Mpn { get; set; }
public bool ShowGtin { get; set; }
public string Gtin { get; set; }
- public BrandBriefInfoModel BrandModel { get; set; }
+ public BrandBriefInfoModel BrandModel { get; set; } = new();
public bool ShowVendor { get; set; }
- public VendorBriefInfoModel VendorModel { get; set; }
+ public VendorBriefInfoModel VendorModel { get; set; } = new();
public bool HasSampleDownload { get; set; }
- public GiftVoucherModel GiftVoucher { get; set; }
+ public GiftVoucherModel GiftVoucher { get; set; } = new();
public bool IsShipEnabled { get; set; }
public bool NotReturnable { get; set; }
public bool IsFreeShipping { get; set; }
public bool AllowToSelectWarehouse { get; set; }
- public IList<ProductWarehouseModel> ProductWarehouses { get; set; }
+ public IList<ProductWarehouseModel> ProductWarehouses { get; set; } = new List<ProductWarehouseModel>();
public double AdditionalShippingCharge { get; set; }
public string AdditionalShippingChargeStr { get; set; }
public bool FreeShippingNotificationEnabled { get; set; }
@@ -68,7 +47,7 @@ namespace Grand.Web.Models.Catalog
public int Interval { get; set; }
public IntervalUnit IntervalUnit { get; set; }
public bool IncBothDate { get; set; }
- public List<SelectListItem> Parameters { get; set; }
+ public List<SelectListItem> Parameters { get; set; } = new();
public DateTime StartDate { get; set; }
public DateTime? RentalStartDateUtc { get; set; }
public DateTime? RentalEndDateUtc { get; set; }
@@ -80,19 +59,22 @@ namespace Grand.Web.Models.Catalog
public ProductAskQuestionSimpleModel ProductAskQuestion { get; set; }
public bool CompareProductsEnabled { get; set; }
public string PageShareCode { get; set; }
- public ProductPriceModel ProductPrice { get; set; }
- public AddToCartModel AddToCart { get; set; }
- public ProductBreadcrumbModel Breadcrumb { get; set; }
- public IList<ProductTagModel> ProductTags { get; set; }
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
- public IList<ProductSpecificationModel> ProductSpecifications { get; set; }
- public IList<CollectionModel> ProductCollections { get; set; }
- public ProductReviewOverviewModel ProductReviewOverview { get; set; }
- public IList<TierPriceModel> TierPrices { get; set; }
+ public ProductPriceModel ProductPrice { get; set; } = new();
+ public AddToCartModel AddToCart { get; set; } = new();
+ public ProductBreadcrumbModel Breadcrumb { get; set; } = new();
+ public IList<ProductTagModel> ProductTags { get; set; } = new List<ProductTagModel>();
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
+ public IList<ProductSpecificationModel> ProductSpecifications { get; set; } = new List<ProductSpecificationModel>();
+ public IList<CollectionModel> ProductCollections { get; set; } = new List<CollectionModel>();
+ public ProductReviewOverviewModel ProductReviewOverview { get; set; } = new();
+
+ public IList<TierPriceModel> TierPrices { get; set; } = new List<TierPriceModel>();
+
//a list of associated products. For example, "Grouped" products could have several child "simple" products
- public IList<ProductDetailsModel> AssociatedProducts { get; set; }
+ public IList<ProductDetailsModel> AssociatedProducts { get; set; } = new List<ProductDetailsModel>();
+
//bundle product
- public IList<ProductBundleModel> ProductBundleModels { get; set; }
+ public IList<ProductBundleModel> ProductBundleModels { get; set; } = new List<ProductBundleModel>();
public bool DisplayDiscontinuedMessage { get; set; }
public string CurrentStoreName { get; set; }
public double StartPrice { get; set; }
@@ -105,30 +87,23 @@ namespace Grand.Web.Models.Catalog
#region Nested Classes
public class ProductBreadcrumbModel : BaseModel
{
- public ProductBreadcrumbModel()
- {
- CategoryBreadcrumb = new List<CategorySimpleModel>();
- }
public int Id { get; set; }
public bool Enabled { get; set; }
public string ProductId { get; set; }
public string ProductName { get; set; }
public string ProductSeName { get; set; }
- public IList<CategorySimpleModel> CategoryBreadcrumb { get; set; }
+ public IList<CategorySimpleModel> CategoryBreadcrumb { get; set; } = new List<CategorySimpleModel>();
}
public class AddToCartModel : BaseModel
{
- public AddToCartModel()
- {
- this.AllowedQuantities = new List<SelectListItem>();
- }
public string ProductId { get; set; }
//qty
[GrandResourceDisplayName("Products.Qty")]
public int EnteredQuantity { get; set; }
public string MinimumQuantityNotification { get; set; }
- public List<SelectListItem> AllowedQuantities { get; set; }
+ public List<SelectListItem> AllowedQuantities { get; set; } = new();
+
//price entered by customers
[GrandResourceDisplayName("Products.EnterProductPrice")]
public bool EnteredPrice { get; set; }
@@ -152,11 +127,6 @@ namespace Grand.Web.Models.Catalog
public class ProductPriceModel : BaseModel
{
- public ProductPriceModel()
- {
- AppliedDiscounts = new List<ApplyDiscount>();
- }
-
/// <summary>
/// The currency (in 3-letter ISO 4217 format) of the offer price
/// </summary>
@@ -183,7 +153,7 @@ namespace Grand.Web.Models.Catalog
public string BasePricePAngV { get; set; }
- public List<ApplyDiscount> AppliedDiscounts { get; set; }
+ public List<ApplyDiscount> AppliedDiscounts { get; set; } = new();
public TierPrice PreferredTierPrice { get; set; }
}
@@ -214,12 +184,6 @@ namespace Grand.Web.Models.Catalog
public class ProductAttributeModel : BaseEntityModel
{
- public ProductAttributeModel()
- {
- AllowedFileExtensions = new List<string>();
- Values = new List<ProductAttributeValueModel>();
- }
-
public string ProductId { get; set; }
public string ProductAttributeId { get; set; }
public string Name { get; set; }
@@ -251,37 +215,28 @@ namespace Grand.Web.Models.Catalog
/// <summary>
/// Allowed file extensions for customer uploaded files
/// </summary>
- public IList<string> AllowedFileExtensions { get; set; }
+ public IList<string> AllowedFileExtensions { get; set; } = new List<string>();
+
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseEntityModel
{
- public ProductAttributeValueModel()
- {
- ImageSquaresPictureModel = new PictureModel();
- PictureModel = new PictureModel();
- }
public string Name { get; set; }
public string ColorSquaresRgb { get; set; }
//picture model is used with "image square" attribute type
- public PictureModel ImageSquaresPictureModel { get; set; }
+ public PictureModel ImageSquaresPictureModel { get; set; } = new();
public string PriceAdjustment { get; set; }
public double PriceAdjustmentValue { get; set; }
public string StockAvailability { get; set; }
public bool IsPreSelected { get; set; }
//picture model is used when we want to override a default product picture when some attribute is selected
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
}
public class ProductBundleModel : BaseModel
{
- public ProductBundleModel()
- {
- ProductAttributes = new List<ProductAttributeModel>();
- }
-
public string ProductId { get; set; }
public string Name { get; set; }
public string SeName { get; set; }
@@ -293,7 +248,7 @@ namespace Grand.Web.Models.Catalog
public string Price { get; set; }
public double PriceValue { get; set; }
public PictureModel DefaultPictureModel { get; set; }
- public IList<ProductAttributeModel> ProductAttributes { get; set; }
+ public IList<ProductAttributeModel> ProductAttributes { get; set; } = new List<ProductAttributeModel>();
}
public class ProductWarehouseModel : BaseModel
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
index 1908cfdde..083d9aeb7 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class ProductEmailAFriendModel : BaseModel
{
- public ProductEmailAFriendModel()
- {
- Captcha = new CaptchaModel();
- }
public string ProductId { get; set; }
public string ProductName { get; set; }
@@ -27,6 +23,6 @@ namespace Grand.Web.Models.Catalog
public bool SuccessfullySent { get; set; }
public string Result { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
index b90a3cd48..b26b73193 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
@@ -8,16 +8,6 @@ namespace Grand.Web.Models.Catalog
{
public class ProductOverviewModel : BaseEntityModel
{
- public ProductOverviewModel()
- {
- ProductPrice = new ProductPriceModel();
- DefaultPictureModel = new PictureModel();
- SecondPictureModel = new PictureModel();
- SpecificationAttributeModels = new List<ProductSpecificationModel>();
- ProductAttributeModels = new List<ProductAttributeModel>();
- ReviewOverviewModel = new ProductReviewOverviewModel();
- }
-
public string Name { get; set; }
public string ShortDescription { get; set; }
public string FullDescription { get; set; }
@@ -39,30 +29,25 @@ namespace Grand.Web.Models.Catalog
public TaxDisplayType TaxDisplayType { get; set; }
//price
- public ProductPriceModel ProductPrice { get; set; }
+ public ProductPriceModel ProductPrice { get; set; } = new();
//picture
- public PictureModel DefaultPictureModel { get; set; }
- public PictureModel SecondPictureModel { get; set; }
+ public PictureModel DefaultPictureModel { get; set; } = new();
+ public PictureModel SecondPictureModel { get; set; } = new();
//specification attributes
- public IList<ProductSpecificationModel> SpecificationAttributeModels { get; set; }
+ public IList<ProductSpecificationModel> SpecificationAttributeModels { get; set; } = new List<ProductSpecificationModel>();
//product attributes
- public IList<ProductAttributeModel> ProductAttributeModels { get; set; }
+ public IList<ProductAttributeModel> ProductAttributeModels { get; set; } = new List<ProductAttributeModel>();
//price
- public ProductReviewOverviewModel ReviewOverviewModel { get; set; }
+ public ProductReviewOverviewModel ReviewOverviewModel { get; set; } = new();
#region Nested Classes
public class ProductPriceModel : BaseModel
{
- public ProductPriceModel()
- {
- AppliedDiscounts = new List<ApplyDiscount>();
- }
-
public string OldPrice { get; set; }
public double OldPriceValue { get; set; }
public string CatalogPrice { get; set; }
@@ -81,40 +66,29 @@ namespace Grand.Web.Models.Catalog
public DateTime? PreOrderDateTimeUtc { get; set; }
public bool ForceRedirectionAfterAddingToCart { get; set; }
- public List<ApplyDiscount> AppliedDiscounts { get; set; }
+ public List<ApplyDiscount> AppliedDiscounts { get; set; } = new();
public TierPrice PreferredTierPrice { get; set; }
}
public class ProductAttributeModel : BaseModel
{
- public ProductAttributeModel()
- {
- Values = new List<ProductAttributeValueModel>();
- }
-
public string Name { get; set; }
public string SeName { get; set; }
public string TextPrompt { get; set; }
public bool IsRequired { get; set; }
public AttributeControlType AttributeControlType { get; set; }
- public IList<ProductAttributeValueModel> Values { get; set; }
+ public IList<ProductAttributeValueModel> Values { get; set; } = new List<ProductAttributeValueModel>();
}
public class ProductAttributeValueModel : BaseModel
{
- public ProductAttributeValueModel()
- {
- ImageSquaresPictureModel = new PictureModel();
- PictureModel = new PictureModel();
- }
-
public string Name { get; set; }
public string ColorSquaresRgb { get; set; }
//picture model is used with "image square" attribute type
- public PictureModel ImageSquaresPictureModel { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel ImageSquaresPictureModel { get; set; } = new();
+ public PictureModel PictureModel { get; set; } = new();
}
#endregion
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
index fe6d20011..6fafb9549 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
@@ -17,22 +17,16 @@ namespace Grand.Web.Models.Catalog
public class ProductReviewsModel : BaseModel
{
- public ProductReviewsModel()
- {
- Items = new List<ProductReviewModel>();
- AddProductReview = new AddProductReviewModel();
- Captcha = new CaptchaModel();
- }
public string ProductId { get; set; }
public bool CaptchaValid { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
public string ProductName { get; set; }
public string ProductSeName { get; set; }
- public IList<ProductReviewModel> Items { get; set; }
- public AddProductReviewModel AddProductReview { get; set; }
+ public IList<ProductReviewModel> Items { get; set; } = new List<ProductReviewModel>();
+ public AddProductReviewModel AddProductReview { get; set; } = new();
public ProductReviewOverviewModel ProductReviewOverviewModel { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
index a601b1c40..21a6aa26a 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
@@ -4,17 +4,11 @@ namespace Grand.Web.Models.Catalog
{
public class ProductsByTagModel : BaseEntityModel
{
- public ProductsByTagModel()
- {
- Products = new List<ProductOverviewModel>();
- PagingFilteringContext = new CatalogPagingFilteringModel();
- }
-
public string TagName { get; set; }
public string TagSeName { get; set; }
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
- public IList<ProductOverviewModel> Products { get; set; }
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
index f4fdb8acc..dd02438df 100644
--- a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Models.Catalog
{
public class SearchBoxModel : BaseModel
{
- public SearchBoxModel()
- {
- AvailableCategories = new List<SelectListItem>();
- }
public bool AutoCompleteEnabled { get; set; }
public bool VoiceNavigatioEnabled { get; set; }
@@ -16,6 +12,6 @@ namespace Grand.Web.Models.Catalog
public int SearchTermMinimumLength { get; set; }
public string SearchCategoryId { get; set; }
public bool Box { get; set; }
- public IList<SelectListItem> AvailableCategories { get; set; }
+ public IList<SelectListItem> AvailableCategories { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/SearchModel.cs b/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
index e6d195144..45cc7cbc0 100644
--- a/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
@@ -6,15 +6,6 @@ namespace Grand.Web.Models.Catalog
{
public class SearchModel : BaseModel
{
- public SearchModel()
- {
- PagingFilteringContext = new CatalogPagingFilteringModel();
- Products = new List<ProductOverviewModel>();
- AvailableCategories = new List<SelectListItem>();
- AvailableCollections = new List<SelectListItem>();
- AvailableVendors = new List<SelectListItem>();
- }
-
public string Warning { get; set; }
public bool NoResults { get; set; }
@@ -68,12 +59,12 @@ namespace Grand.Web.Models.Catalog
public bool asv { get; set; }
public bool Box { get; set; }
- public IList<SelectListItem> AvailableCategories { get; set; }
- public IList<SelectListItem> AvailableCollections { get; set; }
- public IList<SelectListItem> AvailableVendors { get; set; }
+ public IList<SelectListItem> AvailableCategories { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableCollections { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
- public IList<ProductOverviewModel> Products { get; set; }
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorListModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorListModel.cs
index e8f046db7..59bc67f18 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorListModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorListModel.cs
@@ -2,11 +2,6 @@
public class VendorListModel
{
- public VendorListModel()
- {
- PagingModel = new VendorPagingModel();
- VendorsModel = new List<VendorModel>();
- }
- public VendorPagingModel PagingModel { get; set; }
- public IList<VendorModel> VendorsModel { get; set; }
+ public VendorPagingModel PagingModel { get; set; } = new();
+ public IList<VendorModel> VendorsModel { get; set; } = new List<VendorModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
index f66d717c7..c994dfcc5 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
@@ -6,13 +6,6 @@ namespace Grand.Web.Models.Catalog
{
public class VendorModel : BaseEntityModel
{
- public VendorModel()
- {
- Products = new List<ProductOverviewModel>();
- PagingFilteringContext = new CatalogPagingFilteringModel();
- Address = new VendorAddressModel();
- }
-
public string Name { get; set; }
public string Description { get; set; }
public string MetaKeywords { get; set; }
@@ -21,10 +14,10 @@ namespace Grand.Web.Models.Catalog
public string SeName { get; set; }
public bool AllowCustomersToContactVendors { get; set; }
public bool RenderCaptcha { get; set; }
- public VendorAddressModel Address { get; set; }
+ public VendorAddressModel Address { get; set; } = new();
public PictureModel PictureModel { get; set; }
- public CatalogPagingFilteringModel PagingFilteringContext { get; set; }
+ public CatalogPagingFilteringModel PagingFilteringContext { get; set; } = new();
public VendorReviewOverviewModel VendorReviewOverview { get; set; }
- public IList<ProductOverviewModel> Products { get; set; }
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
index eb94103d7..2a8a7fbfc 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Catalog
{
public class VendorNavigationModel : BaseModel
{
- public VendorNavigationModel()
- {
- Vendors = new List<VendorBriefInfoModel>();
- }
-
- public IList<VendorBriefInfoModel> Vendors { get; set; }
+ public IList<VendorBriefInfoModel> Vendors { get; set; } = new List<VendorBriefInfoModel>();
public int TotalVendors { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
index 537ff6635..ebc0779c9 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
@@ -5,13 +5,8 @@ namespace Grand.Web.Models.Checkout
{
public class CheckoutBillingAddressModel : BaseModel
{
- public CheckoutBillingAddressModel()
- {
- ExistingAddresses = new List<AddressModel>();
- BillingNewAddress = new AddressModel();
- }
- public IList<AddressModel> ExistingAddresses { get; set; }
- public AddressModel BillingNewAddress { get; set; }
+ public IList<AddressModel> ExistingAddresses { get; set; } = new List<AddressModel>();
+ public AddressModel BillingNewAddress { get; set; } = new();
public bool NewAddressPreselected { get; set; }
public string BillingAddressId { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
index 5271c4c4e..4a0132cf0 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
@@ -5,33 +5,20 @@ namespace Grand.Web.Models.Checkout
{
public class CheckoutConfirmModel : BaseModel
{
- public CheckoutConfirmModel()
- {
- Warnings = new List<string>();
- OrderReviewData = new OrderReviewDataModel();
- }
-
public bool TermsOfServiceOnOrderConfirmPage { get; set; }
public string MinOrderTotalWarning { get; set; }
- public IList<string> Warnings { get; set; }
- public OrderReviewDataModel OrderReviewData { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
+ public OrderReviewDataModel OrderReviewData { get; set; } = new();
public class OrderReviewDataModel : BaseModel
{
- public OrderReviewDataModel()
- {
- BillingAddress = new AddressModel();
- ShippingAddress = new AddressModel();
- PickupAddress = new AddressModel();
- }
-
- public AddressModel BillingAddress { get; set; }
+ public AddressModel BillingAddress { get; set; } = new();
public bool IsShippable { get; set; }
- public AddressModel ShippingAddress { get; set; }
+ public AddressModel ShippingAddress { get; set; } = new();
public bool SelectedPickUpInStore { get; set; }
- public AddressModel PickupAddress { get; set; }
+ public AddressModel PickupAddress { get; set; } = new();
public string ShippingMethod { get; set; }
public string ShippingAdditionDescription { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
index 46317b912..e3e5edd4e 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Checkout
{
public class CheckoutPaymentMethodModel : BaseModel
{
- public CheckoutPaymentMethodModel()
- {
- PaymentMethods = new List<PaymentMethodModel>();
- }
-
- public IList<PaymentMethodModel> PaymentMethods { get; set; }
+ public IList<PaymentMethodModel> PaymentMethods { get; set; } = new List<PaymentMethodModel>();
public bool DisplayLoyaltyPoints { get; set; }
public int LoyaltyPointsBalance { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
index 6ac5d2736..a7f749be8 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
@@ -5,21 +5,13 @@ namespace Grand.Web.Models.Checkout
{
public class CheckoutShippingAddressModel : BaseModel
{
- public CheckoutShippingAddressModel()
- {
- ExistingAddresses = new List<AddressModel>();
- ShippingNewAddress = new AddressModel();
- Warnings = new List<string>();
- PickupPoints = new List<CheckoutPickupPointModel>();
- }
-
- public IList<AddressModel> ExistingAddresses { get; set; }
- public IList<string> Warnings { get; set; }
- public AddressModel ShippingNewAddress { get; set; }
+ public IList<AddressModel> ExistingAddresses { get; set; } = new List<AddressModel>();
+ public IList<string> Warnings { get; set; } = new List<string>();
+ public AddressModel ShippingNewAddress { get; set; } = new();
public string ShippingAddressId { get; set; }
public string PickupPointId { get; set; }
public bool NewAddressPreselected { get; set; }
- public IList<CheckoutPickupPointModel> PickupPoints { get; set; }
+ public IList<CheckoutPickupPointModel> PickupPoints { get; set; } = new List<CheckoutPickupPointModel>();
public bool BillToTheSameAddress { get; set; }
public bool AllowPickUpInStore { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
index dfc33a40e..8d2269a78 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
@@ -5,17 +5,11 @@ namespace Grand.Web.Models.Checkout
{
public class CheckoutShippingMethodModel : BaseModel
{
- public CheckoutShippingMethodModel()
- {
- ShippingMethods = new List<ShippingMethodModel>();
- Warnings = new List<string>();
- }
-
- public IList<ShippingMethodModel> ShippingMethods { get; set; }
+ public IList<ShippingMethodModel> ShippingMethods { get; set; } = new List<ShippingMethodModel>();
public string ShippingOption { get; set; }
public IDictionary<string, string> Data{ get; set; }
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs b/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
index 1ff01925f..d389fbf9b 100644
--- a/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
+++ b/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Models.Common
{
public class AddressAttributeModel : BaseEntityModel
{
- public AddressAttributeModel()
- {
- Values = new List<AddressAttributeValueModel>();
- }
-
public string Name { get; set; }
public bool IsRequired { get; set; }
@@ -21,7 +16,7 @@ namespace Grand.Web.Models.Common
public AttributeControlType AttributeControlType { get; set; }
- public IList<AddressAttributeValueModel> Values { get; set; }
+ public IList<AddressAttributeValueModel> Values { get; set; } = new List<AddressAttributeValueModel>();
}
public class AddressAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Common/AddressModel.cs b/src/Web/Grand.Web/Models/Common/AddressModel.cs
index c7bdc0729..e46a02ace 100644
--- a/src/Web/Grand.Web/Models/Common/AddressModel.cs
+++ b/src/Web/Grand.Web/Models/Common/AddressModel.cs
@@ -10,13 +10,6 @@ namespace Grand.Web.Models.Common
{
public class AddressModel : BaseEntityModel
{
- public AddressModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- CustomAddressAttributes = new List<AddressAttributeModel>();
- }
-
public bool NameEnabled { get; set; }
[GrandResourceDisplayName("Address.Fields.AddressName")]
@@ -89,12 +82,12 @@ namespace Grand.Web.Models.Common
[GrandResourceDisplayName("Address.Fields.Note")]
public string Note { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public string FormattedCustomAddressAttributes { get; set; }
- public IList<AddressAttributeModel> CustomAddressAttributes { get; set; }
+ public IList<AddressAttributeModel> CustomAddressAttributes { get; set; } = new List<AddressAttributeModel>();
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
public IList<CustomAttributeModel> SelectedAttributes { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/FooterModel.cs b/src/Web/Grand.Web/Models/Common/FooterModel.cs
index 50cb63366..d683c349a 100644
--- a/src/Web/Grand.Web/Models/Common/FooterModel.cs
+++ b/src/Web/Grand.Web/Models/Common/FooterModel.cs
@@ -4,11 +4,6 @@ namespace Grand.Web.Models.Common
{
public class FooterModel : BaseModel
{
- public FooterModel()
- {
- Pages = new List<FooterPageModel>();
- }
-
public string StoreName { get; set; }
public string CompanyName { get; set; }
public string CompanyEmail { get; set; }
@@ -37,7 +32,7 @@ namespace Grand.Web.Models.Common
public string WorkingLanguageId { get; set; }
- public IList<FooterPageModel> Pages { get; set; }
+ public IList<FooterPageModel> Pages { get; set; } = new List<FooterPageModel>();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/Common/SitemapModel.cs b/src/Web/Grand.Web/Models/Common/SitemapModel.cs
index 258b6ed3d..fe5dcca6a 100644
--- a/src/Web/Grand.Web/Models/Common/SitemapModel.cs
+++ b/src/Web/Grand.Web/Models/Common/SitemapModel.cs
@@ -8,21 +8,12 @@ namespace Grand.Web.Models.Common
{
public class SitemapModel : BaseModel
{
- public SitemapModel()
- {
- Products = new List<ProductOverviewModel>();
- Categories = new List<CategoryModel>();
- Brands = new List<BrandModel>();
- Pages = new List<PageModel>();
- BlogPosts = new List<BlogPostModel>();
- KnowledgebaseArticles = new List<KnowledgebaseItemModel>();
- }
- public IList<ProductOverviewModel> Products { get; set; }
- public IList<CategoryModel> Categories { get; set; }
- public IList<BrandModel> Brands { get; set; }
- public IList<PageModel> Pages { get; set; }
- public IList<BlogPostModel> BlogPosts { get; set; }
- public IList<KnowledgebaseItemModel> KnowledgebaseArticles { get; set; }
+ public IList<ProductOverviewModel> Products { get; set; } = new List<ProductOverviewModel>();
+ public IList<CategoryModel> Categories { get; set; } = new List<CategoryModel>();
+ public IList<BrandModel> Brands { get; set; } = new List<BrandModel>();
+ public IList<PageModel> Pages { get; set; } = new List<PageModel>();
+ public IList<BlogPostModel> BlogPosts { get; set; } = new List<BlogPostModel>();
+ public IList<KnowledgebaseItemModel> KnowledgebaseArticles { get; set; } = new List<KnowledgebaseItemModel>();
public bool NewsEnabled { get; set; }
public bool BlogEnabled { get; set; }
diff --git a/src/Web/Grand.Web/Models/Contact/ContactAttributeChangeModel.cs b/src/Web/Grand.Web/Models/Contact/ContactAttributeChangeModel.cs
index b4914a0ec..b478722f7 100644
--- a/src/Web/Grand.Web/Models/Contact/ContactAttributeChangeModel.cs
+++ b/src/Web/Grand.Web/Models/Contact/ContactAttributeChangeModel.cs
@@ -5,10 +5,6 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Models.Contact;
public class ContactAttributeChangeModel
{
- public ContactAttributeChangeModel()
- {
- Attributes = new List<CustomAttributeModel>();
- }
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
- public IList<CustomAttributeModel> Attributes { get; set; }
+ public IList<CustomAttributeModel> Attributes { get; set; } = new List<CustomAttributeModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Contact/ContactUsModel.cs b/src/Web/Grand.Web/Models/Contact/ContactUsModel.cs
index d0d7635df..103878286 100644
--- a/src/Web/Grand.Web/Models/Contact/ContactUsModel.cs
+++ b/src/Web/Grand.Web/Models/Contact/ContactUsModel.cs
@@ -10,13 +10,6 @@ namespace Grand.Web.Models.Contact
{
public class ContactUsModel : BaseModel
{
- public ContactUsModel()
- {
- ContactAttributes = new List<ContactAttributeModel>();
- ContactAttribute = new List<CustomAttribute>();
- Attributes = new List<CustomAttributeModel>();
- Captcha = new CaptchaModel();
- }
[GrandResourceDisplayName("ContactUs.Email")]
public string Email { get; set; }
[GrandResourceDisplayName("ContactUs.Subject")]
@@ -29,19 +22,17 @@ namespace Grand.Web.Models.Contact
public bool SuccessfullySent { get; set; }
public string Result { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
+
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
- public IList<CustomAttributeModel> Attributes { get; set; }
+ public IList<CustomAttributeModel> Attributes { get; set; } = new List<CustomAttributeModel>();
+
public string ContactAttributeInfo { get; set; }
- public IList<CustomAttribute> ContactAttribute { get; set; }
- public IList<ContactAttributeModel> ContactAttributes { get; set; }
+ public IList<CustomAttribute> ContactAttribute { get; set; } = new List<CustomAttribute>();
+ public IList<ContactAttributeModel> ContactAttributes { get; set; } = new List<ContactAttributeModel>();
+
public class ContactAttributeModel : BaseEntityModel
{
- public ContactAttributeModel()
- {
- AllowedFileExtensions = new List<string>();
- Values = new List<ContactAttributeValueModel>();
- }
public string Name { get; set; }
public string DefaultValue { get; set; }
public string TextPrompt { get; set; }
@@ -61,9 +52,10 @@ namespace Grand.Web.Models.Contact
/// <summary>
/// Allowed file extensions for customer uploaded files
/// </summary>
- public IList<string> AllowedFileExtensions { get; set; }
+ public IList<string> AllowedFileExtensions { get; set; } = new List<string>();
+
public AttributeControlType AttributeControlType { get; set; }
- public IList<ContactAttributeValueModel> Values { get; set; }
+ public IList<ContactAttributeValueModel> Values { get; set; } = new List<ContactAttributeValueModel>();
}
public class ContactAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Course/CourseModel.cs b/src/Web/Grand.Web/Models/Course/CourseModel.cs
index 6d2d85a44..47a22e8ab 100644
--- a/src/Web/Grand.Web/Models/Course/CourseModel.cs
+++ b/src/Web/Grand.Web/Models/Course/CourseModel.cs
@@ -4,12 +4,6 @@ namespace Grand.Web.Models.Course
{
public class CourseModel : BaseEntityModel
{
- public CourseModel()
- {
- Subjects = new List<Subject>();
- Lessons = new List<Lesson>();
- }
-
public string Name { get; set; }
public string Level { get; set; }
public string ShortDescription { get; set; }
@@ -19,8 +13,8 @@ namespace Grand.Web.Models.Course
public string MetaTitle { get; set; }
public string SeName { get; set; }
public string PictureUrl { get; set; }
- public IList<Subject> Subjects { get; set; }
- public IList<Lesson> Lessons { get; set; }
+ public IList<Subject> Subjects { get; set; } = new List<Subject>();
+ public IList<Lesson> Lessons { get; set; } = new List<Lesson>();
public bool Approved { get; set; }
public class Subject : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Customer/CoursesModel.cs b/src/Web/Grand.Web/Models/Customer/CoursesModel.cs
index ba70dd759..c2d6b7873 100644
--- a/src/Web/Grand.Web/Models/Customer/CoursesModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CoursesModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Customer
{
public class CoursesModel : BaseModel
{
- public CoursesModel()
- {
- CourseList = new List<Course>();
- }
-
- public List<Course> CourseList { get; set; }
+ public List<Course> CourseList { get; set; } = new();
public string CustomerId { get; set; }
public class Course : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
index d2ffc0da9..7ad073e2c 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Models.Customer
{
public class CustomerAddressEditModel : BaseModel
{
- public CustomerAddressEditModel()
- {
- Address = new AddressModel();
- }
- public AddressModel Address { get; set; }
+ public AddressModel Address { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
index 9e70ec7a3..4bcd68977 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Models.Customer
{
public class CustomerAddressListModel : BaseModel
{
- public CustomerAddressListModel()
- {
- Addresses = new List<AddressModel>();
- }
-
- public IList<AddressModel> Addresses { get; set; }
+ public IList<AddressModel> Addresses { get; set; } = new List<AddressModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
index 46baeedea..ec2acb129 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Models.Customer
{
public class CustomerAttributeModel : BaseEntityModel
{
- public CustomerAttributeModel()
- {
- Values = new List<CustomerAttributeValueModel>();
- }
-
public string Name { get; set; }
public bool IsRequired { get; set; }
@@ -22,8 +17,7 @@ namespace Grand.Web.Models.Customer
public AttributeControlType AttributeControlType { get; set; }
- public IList<CustomerAttributeValueModel> Values { get; set; }
-
+ public IList<CustomerAttributeValueModel> Values { get; set; } = new List<CustomerAttributeValueModel>();
}
public class CustomerAttributeValueModel : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAuctionsModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAuctionsModel.cs
index 5d4c94bc4..52d3d4bf8 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAuctionsModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAuctionsModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Customer
{
public class CustomerAuctionsModel : BaseModel
{
- public CustomerAuctionsModel()
- {
- ProductBidList = new List<ProductBidTuple>();
- }
-
- public List<ProductBidTuple> ProductBidList { get; set; }
+ public List<ProductBidTuple> ProductBidList { get; set; } = new();
public string CustomerId { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
index f0e3dd899..60f55b78c 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Customer
{
public class CustomerDownloadableProductsModel : BaseModel
{
- public CustomerDownloadableProductsModel()
- {
- Items = new List<DownloadableProductsModel>();
- }
-
- public IList<DownloadableProductsModel> Items { get; set; }
+ public IList<DownloadableProductsModel> Items { get; set; } = new List<DownloadableProductsModel>();
#region Nested classes
public class DownloadableProductsModel : BaseModel
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
index 851b986b5..bb1852cc6 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
@@ -13,16 +13,6 @@ namespace Grand.Web.Models.Customer
{
public class CustomerInfoModel : BaseModel
{
- public CustomerInfoModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- AssociatedExternalAuthRecords = new List<AssociatedExternalAuthModel>();
- CustomerAttributes = new List<CustomerAttributeModel>();
- SelectedAttributes = new List<CustomAttributeModel>();
- NewsletterCategories = new List<NewsletterSimpleCategory>();
- }
-
[MaxLength(FieldSizeLimits.EmailMaxLength)]
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.Fields.Email")]
@@ -112,13 +102,13 @@ namespace Grand.Web.Models.Customer
[GrandResourceDisplayName("Account.Fields.Country")]
public string CountryId { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
public bool StateProvinceEnabled { get; set; }
public bool StateProvinceRequired { get; set; }
[GrandResourceDisplayName("Account.Fields.StateProvince")]
public string StateProvinceId { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public bool PhoneEnabled { get; set; }
public bool PhoneRequired { get; set; }
@@ -152,15 +142,16 @@ namespace Grand.Web.Models.Customer
//external authentication
[GrandResourceDisplayName("Account.AssociatedExternalAuth")]
- public IList<AssociatedExternalAuthModel> AssociatedExternalAuthRecords { get; set; }
+ public IList<AssociatedExternalAuthModel> AssociatedExternalAuthRecords { get; set; } = new List<AssociatedExternalAuthModel>();
+
public int NumberOfExternalAuthenticationProviders { get; set; }
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
- public IList<CustomAttributeModel> SelectedAttributes { get; set; }
-
- public IList<CustomerAttributeModel> CustomerAttributes { get; set; }
+ public IList<CustomAttributeModel> SelectedAttributes { get; set; } = new List<CustomAttributeModel>();
+
+ public IList<CustomerAttributeModel> CustomerAttributes { get; set; } = new List<CustomerAttributeModel>();
- public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; }
+ public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; } = new List<NewsletterSimpleCategory>();
#region Nested classes
@@ -174,14 +165,10 @@ namespace Grand.Web.Models.Customer
public class TwoFactorAuthenticationModel : BaseModel
{
- public TwoFactorAuthenticationModel()
- {
- CustomValues = new Dictionary<string, string>();
- }
public TwoFactorAuthenticationType TwoFactorAuthenticationType { get; set; }
public string SecretKey { get; set; }
public string Code { get; set; }
- public IDictionary<string, string> CustomValues { get; set; }
+ public IDictionary<string, string> CustomValues { get; set; } = new Dictionary<string, string>();
}
public class TwoFactorAuthorizationModel : BaseModel
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerNotesModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerNotesModel.cs
index 2722e3927..c66cd8e8a 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerNotesModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerNotesModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Customer
{
public class CustomerNotesModel : BaseModel
{
- public CustomerNotesModel()
- {
- CustomerNoteList = new List<CustomerNote>();
- }
-
- public List<CustomerNote> CustomerNoteList { get; set; }
+ public List<CustomerNote> CustomerNoteList { get; set; } = new();
public string CustomerId { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
index f4b8df021..5ec481b85 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
@@ -22,11 +22,6 @@ namespace Grand.Web.Models.Customer
public string CustomerId { get; set; }
public string CustomerInfo { get; set; }
- public IList<CustomerProductReviewModel> Reviews { get; set; }
-
- public CustomerProductReviewsModel()
- {
- Reviews = new List<CustomerProductReviewModel>();
- }
+ public IList<CustomerProductReviewModel> Reviews { get; set; } = new List<CustomerProductReviewModel>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Customer/DocumentsModel.cs b/src/Web/Grand.Web/Models/Customer/DocumentsModel.cs
index 68d8116a3..2be0c459b 100644
--- a/src/Web/Grand.Web/Models/Customer/DocumentsModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/DocumentsModel.cs
@@ -4,14 +4,8 @@ namespace Grand.Web.Models.Customer
{
public class DocumentsModel : BaseModel
{
- public DocumentsModel()
- {
- DocumentList = new List<Document>();
- PagingContext = new DocumentPagingModel();
- }
-
- public List<Document> DocumentList { get; set; }
- public DocumentPagingModel PagingContext { get; set; }
+ public List<Document> DocumentList { get; set; } = new();
+ public DocumentPagingModel PagingContext { get; set; } = new();
public string CustomerId { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Customer/LoginModel.cs b/src/Web/Grand.Web/Models/Customer/LoginModel.cs
index 823dd4d92..f79a21883 100644
--- a/src/Web/Grand.Web/Models/Customer/LoginModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/LoginModel.cs
@@ -7,10 +7,6 @@ namespace Grand.Web.Models.Customer
{
public class LoginModel : BaseModel
{
- public LoginModel()
- {
- Captcha = new CaptchaModel();
- }
public bool CheckoutAsGuest { get; set; }
[MaxLength(FieldSizeLimits.EmailMaxLength)]
@@ -30,6 +26,6 @@ namespace Grand.Web.Models.Customer
[GrandResourceDisplayName("Account.Login.Fields.RememberMe")]
public bool RememberMe { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs b/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
index e89259726..b1ba18928 100644
--- a/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
@@ -6,16 +6,12 @@ namespace Grand.Web.Models.Customer
{
public class PasswordRecoveryModel : BaseModel
{
- public PasswordRecoveryModel()
- {
- Captcha = new CaptchaModel();
- }
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.PasswordRecovery.Email")]
public string Email { get; set; }
public string Result { get; set; }
public bool Send { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Customer/RegisterModel.cs b/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
index 05c4d891a..bbadd79fe 100644
--- a/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
@@ -12,15 +12,6 @@ namespace Grand.Web.Models.Customer
{
public class RegisterModel : BaseModel
{
- public RegisterModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- CustomerAttributes = new List<CustomerAttributeModel>();
- SelectedAttributes = new List<CustomAttributeModel>();
- NewsletterCategories = new List<NewsletterSimpleCategory>();
- Captcha = new CaptchaModel();
- }
[MaxLength(FieldSizeLimits.EmailMaxLength)]
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.Fields.Email")]
@@ -119,13 +110,13 @@ namespace Grand.Web.Models.Customer
[GrandResourceDisplayName("Account.Fields.Country")]
public string CountryId { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
public bool StateProvinceEnabled { get; set; }
public bool StateProvinceRequired { get; set; }
[GrandResourceDisplayName("Account.Fields.StateProvince")]
public string StateProvinceId { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
public bool PhoneEnabled { get; set; }
public bool PhoneRequired { get; set; }
@@ -154,12 +145,12 @@ namespace Grand.Web.Models.Customer
public bool DisplayVatNumber { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
-
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
+
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
- public IList<CustomAttributeModel> SelectedAttributes { get; set; }
-
- public IList<CustomerAttributeModel> CustomerAttributes { get; set; }
- public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; }
+ public IList<CustomAttributeModel> SelectedAttributes { get; set; } = new List<CustomAttributeModel>();
+
+ public IList<CustomerAttributeModel> CustomerAttributes { get; set; } = new List<CustomerAttributeModel>();
+ public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; } = new List<NewsletterSimpleCategory>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Install/InstallModel.cs b/src/Web/Grand.Web/Models/Install/InstallModel.cs
index e2e06a470..3ebcf5cb6 100644
--- a/src/Web/Grand.Web/Models/Install/InstallModel.cs
+++ b/src/Web/Grand.Web/Models/Install/InstallModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Models.Install
{
public class InstallModel : BaseModel
{
- public InstallModel()
- {
- AvailableLanguages = new List<SelectListItem>();
- AvailableCollation = new List<SelectListItem>();
- AvailableProviders = new List<SelectListItem>();
- }
public string SelectedLanguage { get; set; }
[DataType(DataType.EmailAddress)]
@@ -33,9 +27,9 @@ namespace Grand.Web.Models.Install
public bool InstallSampleData { get; set; }
public bool Installed { get; set; }
public string Collation { get; set; }
- public List<SelectListItem> AvailableLanguages { get; set; }
- public List<SelectListItem> AvailableCollation { get; set; }
- public List<SelectListItem> AvailableProviders { get; set; }
+ public List<SelectListItem> AvailableLanguages { get; set; } = new();
+ public List<SelectListItem> AvailableCollation { get; set; } = new();
+ public List<SelectListItem> AvailableProviders { get; set; } = new();
public string CompanyName { get; set; }
public string CompanyAddress { get; set; }
public string CompanyPhoneNumber { get; set; }
diff --git a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleModel.cs b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleModel.cs
index cfa32accf..1390d4828 100644
--- a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleModel.cs
+++ b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleModel.cs
@@ -4,14 +4,6 @@ namespace Grand.Web.Models.Knowledgebase
{
public class KnowledgebaseArticleModel : BaseEntityModel
{
- public KnowledgebaseArticleModel()
- {
- RelatedArticles = new List<KnowledgebaseArticleModel>();
- CategoryBreadcrumb = new List<KnowledgebaseCategoryModel>();
- Comments = new List<KnowledgebaseArticleCommentModel>();
- AddNewComment = new AddKnowledgebaseArticleCommentModel();
- Captcha = new CaptchaModel();
- }
public string ArticleId { get; set; }
public string Name { get; set; }
@@ -29,14 +21,14 @@ namespace Grand.Web.Models.Knowledgebase
public bool AllowComments { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
-
- public IList<KnowledgebaseArticleModel> RelatedArticles { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
+
+ public IList<KnowledgebaseArticleModel> RelatedArticles { get; set; } = new List<KnowledgebaseArticleModel>();
- public List<KnowledgebaseCategoryModel> CategoryBreadcrumb { get; set; }
+ public List<KnowledgebaseCategoryModel> CategoryBreadcrumb { get; set; } = new();
- public AddKnowledgebaseArticleCommentModel AddNewComment { get; set; }
+ public AddKnowledgebaseArticleCommentModel AddNewComment { get; set; } = new();
- public IList<KnowledgebaseArticleCommentModel> Comments { get; set; }
+ public IList<KnowledgebaseArticleCommentModel> Comments { get; set; } = new List<KnowledgebaseArticleCommentModel>();
}
}
diff --git a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseHomePageModel.cs b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseHomePageModel.cs
index efc4ad5cb..3ef66d998 100644
--- a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseHomePageModel.cs
+++ b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseHomePageModel.cs
@@ -4,8 +4,8 @@ namespace Grand.Web.Models.Knowledgebase
{
public class KnowledgebaseHomePageModel : BaseEntityModel
{
- public List<KnowledgebaseItemModel> Items { get; set; }
- public List<KnowledgebaseCategoryModel> Categories { get; set; }
+ public List<KnowledgebaseItemModel> Items { get; set; } = new();
+ public List<KnowledgebaseCategoryModel> Categories { get; set; } = new();
public string CurrentCategoryId { get; set; }
public string CurrentCategoryDescription { get; set; }
public string CurrentCategoryMetaTitle { get; set; }
@@ -13,14 +13,7 @@ namespace Grand.Web.Models.Knowledgebase
public string CurrentCategoryMetaKeywords { get; set; }
public string CurrentCategoryName { get; set; }
public string CurrentCategorySeName { get; set; }
- public List<KnowledgebaseCategoryModel> CategoryBreadcrumb { get; set; }
+ public List<KnowledgebaseCategoryModel> CategoryBreadcrumb { get; set; } = new();
public string SearchKeyword { get; set; }
-
- public KnowledgebaseHomePageModel()
- {
- Items = new List<KnowledgebaseItemModel>();
- Categories = new List<KnowledgebaseCategoryModel>();
- CategoryBreadcrumb = new List<KnowledgebaseCategoryModel>();
- }
}
}
diff --git a/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs b/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
index d0b40707b..f93dbaa29 100644
--- a/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
+++ b/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
@@ -5,10 +5,6 @@ namespace Grand.Web.Models.News
{
public class AddNewsCommentModel : BaseModel
{
- public AddNewsCommentModel()
- {
- Captcha = new CaptchaModel();
- }
public string Id { get; set; }
[GrandResourceDisplayName("News.Comments.CommentTitle")]
@@ -18,6 +14,6 @@ namespace Grand.Web.Models.News
public string CommentText { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs b/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
index 62f92bf19..035d9bace 100644
--- a/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
+++ b/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
@@ -5,24 +5,14 @@ namespace Grand.Web.Models.News
{
public class HomePageNewsItemsModel : BaseModel
{
- public HomePageNewsItemsModel()
- {
- NewsItems = new List<NewsItemModel>();
- }
-
- public IList<NewsItemModel> NewsItems { get; set; }
+ public IList<NewsItemModel> NewsItems { get; set; } = new List<NewsItemModel>();
public class NewsItemModel : BaseModel
{
- public NewsItemModel()
- {
- PictureModel = new PictureModel();
- }
-
public string Id { get; set; }
public string SeName { get; set; }
public string Title { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
public string Short { get; set; }
public string Full { get; set; }
public DateTime CreatedOn { get; set; }
diff --git a/src/Web/Grand.Web/Models/News/NewsItemListModel.cs b/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
index b5e6da568..ed887fc77 100644
--- a/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
@@ -5,26 +5,16 @@ namespace Grand.Web.Models.News
{
public class NewsItemListModel : BaseModel
{
- public NewsItemListModel()
- {
- PagingFilteringContext = new NewsPagingFilteringModel();
- NewsItems = new List<NewsItemModel>();
- }
-
public string WorkingLanguageId { get; set; }
- public NewsPagingFilteringModel PagingFilteringContext { get; set; }
- public IList<NewsItemModel> NewsItems { get; set; }
+ public NewsPagingFilteringModel PagingFilteringContext { get; set; } = new();
+ public IList<NewsItemModel> NewsItems { get; set; } = new List<NewsItemModel>();
public class NewsItemModel : BaseModel
{
- public NewsItemModel()
- {
- PictureModel = new PictureModel();
- }
public string Id { get; set; }
public string SeName { get; set; }
public string Title { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
public string Short { get; set; }
public string Full { get; set; }
public DateTime CreatedOn { get; set; }
diff --git a/src/Web/Grand.Web/Models/News/NewsItemModel.cs b/src/Web/Grand.Web/Models/News/NewsItemModel.cs
index 4fdb0721c..4245a3cb4 100644
--- a/src/Web/Grand.Web/Models/News/NewsItemModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsItemModel.cs
@@ -5,26 +5,19 @@ namespace Grand.Web.Models.News
{
public class NewsItemModel : BaseEntityModel
{
- public NewsItemModel()
- {
- Comments = new List<NewsCommentModel>();
- AddNewComment = new AddNewsCommentModel();
- PictureModel = new PictureModel();
- }
public string NewsItemId { get; set; }
public string MetaKeywords { get; set; }
public string MetaDescription { get; set; }
public string MetaTitle { get; set; }
public string SeName { get; set; }
public string Title { get; set; }
- public PictureModel PictureModel { get; set; }
+ public PictureModel PictureModel { get; set; } = new();
public string Short { get; set; }
public string Full { get; set; }
public bool AllowComments { get; set; }
public int NumberOfComments { get; set; }
public DateTime CreatedOn { get; set; }
- public IList<NewsCommentModel> Comments { get; set; }
- public AddNewsCommentModel AddNewComment { get; set; }
-
+ public IList<NewsCommentModel> Comments { get; set; } = new List<NewsCommentModel>();
+ public AddNewsCommentModel AddNewComment { get; set; } = new();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs b/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs
index c74549ca6..5ac36e491 100644
--- a/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs
+++ b/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs
@@ -4,13 +4,9 @@ namespace Grand.Web.Models.Newsletter
{
public class NewsletterCategoryModel : BaseModel
{
- public NewsletterCategoryModel()
- {
- NewsletterCategories = new List<NewsletterSimpleCategory>();
- }
public string NewsletterEmailId { get; set; }
public string[] Category { get; set; }
- public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; }
+ public IList<NewsletterSimpleCategory> NewsletterCategories { get; set; } = new List<NewsletterSimpleCategory>();
}
public class NewsletterSimpleCategory
{
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
index 9c0debd3e..8a5d755ed 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Models.Orders
{
public class CustomerLoyaltyPointsModel : BaseModel
{
- public CustomerLoyaltyPointsModel()
- {
- LoyaltyPoints = new List<LoyaltyPointsHistoryModel>();
- }
-
- public IList<LoyaltyPointsHistoryModel> LoyaltyPoints { get; set; }
+ public IList<LoyaltyPointsHistoryModel> LoyaltyPoints { get; set; } = new List<LoyaltyPointsHistoryModel>();
public int LoyaltyPointsBalance { get; set; }
public string LoyaltyPointsAmount { get; set; }
public int MinimumLoyaltyPointsBalance { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
index 122bf6bbd..1a6f2b02c 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
@@ -4,12 +4,7 @@ namespace Grand.Web.Models.Orders
{
public class CustomerMerchandiseReturnsModel : BaseModel
{
- public CustomerMerchandiseReturnsModel()
- {
- Items = new List<MerchandiseReturnModel>();
- }
-
- public IList<MerchandiseReturnModel> Items { get; set; }
+ public IList<MerchandiseReturnModel> Items { get; set; } = new List<MerchandiseReturnModel>();
#region Nested classes
public class MerchandiseReturnModel : BaseEntityModel
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
index 577f744aa..963050fd6 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
@@ -4,13 +4,8 @@ namespace Grand.Web.Models.Orders
{
public class CustomerOrderListModel : BaseModel
{
- public CustomerOrderListModel()
- {
- Orders = new List<OrderDetailsModel>();
- PagingContext = new OrderPagingModel();
- }
- public OrderPagingModel PagingContext { get; set; }
- public IList<OrderDetailsModel> Orders { get; set; }
+ public OrderPagingModel PagingContext { get; set; } = new();
+ public IList<OrderDetailsModel> Orders { get; set; } = new List<OrderDetailsModel>();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
index 1f28100cf..26447ee29 100644
--- a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
@@ -6,14 +6,7 @@ namespace Grand.Web.Models.Orders
{
public class MerchandiseReturnDetailsModel : BaseModel
{
- public MerchandiseReturnDetailsModel()
- {
- MerchandiseReturnItems = new List<MerchandiseReturnItemModel>();
- PickupAddress = new AddressModel();
- MerchandiseReturnNotes = new List<MerchandiseReturnNote>();
- }
-
- public IList<MerchandiseReturnItemModel> MerchandiseReturnItems { get; set; }
+ public IList<MerchandiseReturnItemModel> MerchandiseReturnItems { get; set; } = new List<MerchandiseReturnItemModel>();
public string Comments { get; set; }
@@ -29,11 +22,11 @@ namespace Grand.Web.Models.Orders
public bool ShowPickupAddress { get; set; }
- public AddressModel PickupAddress { get; set; }
+ public AddressModel PickupAddress { get; set; } = new();
public DateTime PickupDate { get; set; }
- public IList<MerchandiseReturnNote> MerchandiseReturnNotes { get; set; }
+ public IList<MerchandiseReturnNote> MerchandiseReturnNotes { get; set; } = new List<MerchandiseReturnNote>();
public bool ShowAddMerchandiseReturnNote { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
index 0af87853e..e1073b5c9 100644
--- a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
@@ -6,23 +6,14 @@ namespace Grand.Web.Models.Orders
{
public class MerchandiseReturnModel : BaseModel
{
- public MerchandiseReturnModel()
- {
- Items = new List<OrderItemModel>();
- AvailableReturnReasons = new List<MerchandiseReturnReasonModel>();
- AvailableReturnActions = new List<MerchandiseReturnActionModel>();
- ExistingAddresses = new List<AddressModel>();
- MerchandiseReturnNewAddress = new AddressModel();
- }
-
public string OrderId { get; set; }
public int OrderNumber { get; set; }
public string OrderCode { get; set; }
- public IList<OrderItemModel> Items { get; set; }
-
- public IList<MerchandiseReturnReasonModel> AvailableReturnReasons { get; set; }
+ public IList<OrderItemModel> Items { get; set; } = new List<OrderItemModel>();
+
+ public IList<MerchandiseReturnReasonModel> AvailableReturnReasons { get; set; } = new List<MerchandiseReturnReasonModel>();
- public IList<MerchandiseReturnActionModel> AvailableReturnActions { get; set; }
+ public IList<MerchandiseReturnActionModel> AvailableReturnActions { get; set; } = new List<MerchandiseReturnActionModel>();
[GrandResourceDisplayName("MerchandiseReturns.Comments")]
public string Comments { get; set; }
@@ -33,11 +24,11 @@ namespace Grand.Web.Models.Orders
public string Error { get; set; }
- public IList<AddressModel> ExistingAddresses { get; set; }
+ public IList<AddressModel> ExistingAddresses { get; set; } = new List<AddressModel>();
public bool NewAddressPreselected { get; set; }
- public AddressModel MerchandiseReturnNewAddress { get; set; }
+ public AddressModel MerchandiseReturnNewAddress { get; set; } = new();
public string PickupAddressId { get; set; }
public bool ShowPickupAddress { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
index f31f71068..40a3ddab9 100644
--- a/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
@@ -6,19 +6,6 @@ namespace Grand.Web.Models.Orders
{
public class OrderDetailsModel : BaseEntityModel
{
- public OrderDetailsModel()
- {
- TaxRates = new List<TaxRate>();
- GiftVouchers = new List<GiftVoucher>();
- Items = new List<OrderItemModel>();
- OrderNotes = new List<OrderNote>();
- Shipments = new List<ShipmentBriefModel>();
-
- BillingAddress = new AddressModel();
- ShippingAddress = new AddressModel();
- PickupAddress = new AddressModel();
- CustomValues = new Dictionary<string, object>();
- }
public bool PdfInvoiceDisabled { get; set; }
public bool UserCanCancelUnpaidOrder { get; set; }
@@ -33,14 +20,14 @@ namespace Grand.Web.Models.Orders
public bool IsShippable { get; set; }
public bool PickUpInStore { get; set; }
- public AddressModel PickupAddress { get; set; }
+ public AddressModel PickupAddress { get; set; } = new();
public string ShippingStatus { get; set; }
- public AddressModel ShippingAddress { get; set; }
+ public AddressModel ShippingAddress { get; set; } = new();
public string ShippingMethod { get; set; }
public string ShippingAdditionDescription { get; set; }
- public IList<ShipmentBriefModel> Shipments { get; set; }
+ public IList<ShipmentBriefModel> Shipments { get; set; } = new List<ShipmentBriefModel>();
- public AddressModel BillingAddress { get; set; }
+ public AddressModel BillingAddress { get; set; } = new();
public string VatNumber { get; set; }
public int OrderNumber { get; set; }
@@ -48,7 +35,7 @@ namespace Grand.Web.Models.Orders
public string PaymentMethod { get; set; }
public string PaymentMethodStatus { get; set; }
public bool CanRePostProcessPayment { get; set; }
- public Dictionary<string, object> CustomValues { get; set; }
+ public Dictionary<string, object> CustomValues { get; set; } = new();
public bool OrderIncludingTax { get; set; }
public string OrderSubtotal { get; set; }
public string OrderSubTotalDiscount { get; set; }
@@ -58,7 +45,7 @@ namespace Grand.Web.Models.Orders
public bool PricesIncludeTax { get; set; }
public string Tax { get; set; }
- public IList<TaxRate> TaxRates { get; set; }
+ public IList<TaxRate> TaxRates { get; set; } = new List<TaxRate>();
public bool DisplayTax { get; set; }
public bool DisplayTaxRates { get; set; }
@@ -67,12 +54,12 @@ namespace Grand.Web.Models.Orders
public string RedeemedLoyaltyPointsAmount { get; set; }
public string OrderTotal { get; set; }
- public IList<GiftVoucher> GiftVouchers { get; set; }
+ public IList<GiftVoucher> GiftVouchers { get; set; } = new List<GiftVoucher>();
public bool ShowSku { get; set; }
- public IList<OrderItemModel> Items { get; set; }
+ public IList<OrderItemModel> Items { get; set; } = new List<OrderItemModel>();
- public IList<OrderNote> OrderNotes { get; set; }
+ public IList<OrderNote> OrderNotes { get; set; } = new List<OrderNote>();
public bool ShowAddOrderNote { get; set; }
@@ -80,16 +67,12 @@ namespace Grand.Web.Models.Orders
public class OrderItemModel : BaseEntityModel
{
- public OrderItemModel()
- {
- Picture = new PictureModel();
- }
public Guid OrderItemGuid { get; set; }
public string Sku { get; set; }
public string ProductId { get; set; }
public string ProductName { get; set; }
public string ProductSeName { get; set; }
- public PictureModel Picture { get; set; }
+ public PictureModel Picture { get; set; } = new();
public string UnitPrice { get; set; }
public bool UnitPriceIncludingTax { get; set; }
public double UnitPriceValue { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
index 737c7a4ca..c3859bc80 100644
--- a/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
@@ -5,21 +5,15 @@ namespace Grand.Web.Models.Orders
{
public class ShipmentDetailsModel : BaseEntityModel
{
- public ShipmentDetailsModel()
- {
- ShipmentStatusEvents = new List<ShipmentStatusEventModel>();
- Items = new List<ShipmentItemModel>();
- ShipmentNotes = new List<ShipmentNote>();
- }
public int ShipmentNumber { get; set; }
public string TrackingNumber { get; set; }
public string TrackingNumberUrl { get; set; }
public DateTime? ShippedDate { get; set; }
public DateTime? DeliveryDate { get; set; }
- public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; }
+ public IList<ShipmentStatusEventModel> ShipmentStatusEvents { get; set; } = new List<ShipmentStatusEventModel>();
public bool ShowSku { get; set; }
- public IList<ShipmentItemModel> Items { get; set; }
- public IList<ShipmentNote> ShipmentNotes { get; set; }
+ public IList<ShipmentItemModel> Items { get; set; } = new List<ShipmentItemModel>();
+ public IList<ShipmentNote> ShipmentNotes { get; set; } = new List<ShipmentNote>();
public OrderModel Order { get; set; }
#region Nested Classes
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
index 91285bc4a..37b1e29ea 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
@@ -6,17 +6,12 @@ namespace Grand.Web.Models.ShoppingCart
{
public class AddToCartModel : BaseModel
{
- public AddToCartModel()
- {
- Picture = new PictureModel();
- }
-
public string ProductId { get; set; }
public string ProductName { get; set; }
public string ProductSeName { get; set; }
public string AttributeDescription { get; set; }
public string ReservationInfo { get; set; }
- public PictureModel Picture { get; set; }
+ public PictureModel Picture { get; set; } = new();
public int Quantity { get; set; }
public int ItemQuantity { get; set; }
public string Price { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/CheckoutAttributeSelectedModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/CheckoutAttributeSelectedModel.cs
index 27b1ab02a..12d4b3873 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/CheckoutAttributeSelectedModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/CheckoutAttributeSelectedModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Models.ShoppingCart;
public class CheckoutAttributeSelectedModel
{
- public CheckoutAttributeSelectedModel()
- {
- Attributes = new List<CustomAttributeModel>();
- }
[ModelBinder(BinderType = typeof(CustomAttributesBinder))]
- public IList<CustomAttributeModel> Attributes { get; set; }
+ public IList<CustomAttributeModel> Attributes { get; set; } = new List<CustomAttributeModel>();
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
index a6a058a7d..c0da9d76c 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
@@ -6,12 +6,6 @@ namespace Grand.Web.Models.ShoppingCart
{
public class EstimateShippingModel : BaseModel
{
- public EstimateShippingModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- }
-
public bool Enabled { get; set; }
[GrandResourceDisplayName("ShoppingCart.EstimateShipping.Country")]
@@ -21,21 +15,15 @@ namespace Grand.Web.Models.ShoppingCart
[GrandResourceDisplayName("ShoppingCart.EstimateShipping.ZipPostalCode")]
public string ZipPostalCode { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
}
public class EstimateShippingResultModel : BaseModel
{
- public EstimateShippingResultModel()
- {
- ShippingOptions = new List<ShippingOptionModel>();
- Warnings = new List<string>();
- }
-
- public IList<ShippingOptionModel> ShippingOptions { get; set; }
+ public IList<ShippingOptionModel> ShippingOptions { get; set; } = new List<ShippingOptionModel>();
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
#region Nested Classes
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
index a5b099657..0207b6c59 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Models.ShoppingCart
{
public class MiniShoppingCartModel : BaseModel
{
- public MiniShoppingCartModel()
- {
- Items = new List<ShoppingCartItemModel>();
- }
-
- public IList<ShoppingCartItemModel> Items { get; set; }
+ public IList<ShoppingCartItemModel> Items { get; set; } = new List<ShoppingCartItemModel>();
public int TotalProducts { get; set; }
public string SubTotal { get; set; }
public bool SubTotalIncludingTax { get; set; }
@@ -25,11 +20,6 @@ namespace Grand.Web.Models.ShoppingCart
public class ShoppingCartItemModel : BaseEntityModel
{
- public ShoppingCartItemModel()
- {
- Picture = new PictureModel();
- }
-
public string ProductId { get; set; }
public string ProductName { get; set; }
@@ -43,7 +33,7 @@ namespace Grand.Web.Models.ShoppingCart
public string AttributeInfo { get; set; }
- public PictureModel Picture { get; set; }
+ public PictureModel Picture { get; set; } = new();
}
#endregion
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
index e4ef802ab..f7f5bbc45 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
@@ -5,12 +5,7 @@ namespace Grand.Web.Models.ShoppingCart
{
public class MiniWishlistModel : BaseModel
{
- public MiniWishlistModel()
- {
- Items = new List<WishlistItemModel>();
- }
-
- public IList<WishlistItemModel> Items { get; set; }
+ public IList<WishlistItemModel> Items { get; set; } = new List<WishlistItemModel>();
public int TotalProducts { get; set; }
public bool ShowProductImages { get; set; }
@@ -20,11 +15,6 @@ namespace Grand.Web.Models.ShoppingCart
public class WishlistItemModel : BaseEntityModel
{
- public WishlistItemModel()
- {
- Picture = new PictureModel();
- }
-
public string ProductId { get; set; }
public string ProductName { get; set; }
@@ -41,7 +31,7 @@ namespace Grand.Web.Models.ShoppingCart
public string AttributeInfo { get; set; }
- public PictureModel Picture { get; set; }
+ public PictureModel Picture { get; set; } = new();
}
#endregion
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
index 4384e3ed8..7412e6d57 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
@@ -4,12 +4,6 @@ namespace Grand.Web.Models.ShoppingCart
{
public class OrderTotalsModel : BaseModel
{
- public OrderTotalsModel()
- {
- TaxRates = new List<TaxRate>();
- GiftVouchers = new List<GiftVoucher>();
- Discounts = new HashSet<string>();
- }
public bool IsEditable { get; set; }
public string SubTotal { get; set; }
@@ -27,12 +21,12 @@ namespace Grand.Web.Models.ShoppingCart
public double PaymentMethodAdditionalFeeValue { get; set; }
public string Tax { get; set; }
- public IList<TaxRate> TaxRates { get; set; }
+ public IList<TaxRate> TaxRates { get; set; } = new List<TaxRate>();
public bool DisplayTax { get; set; }
public bool DisplayTaxRates { get; set; }
- public IList<GiftVoucher> GiftVouchers { get; set; }
+ public IList<GiftVoucher> GiftVouchers { get; set; } = new List<GiftVoucher>();
public string OrderTotalDiscount { get; set; }
public double OrderTotalDiscountValue { get; set; }
@@ -45,7 +39,7 @@ namespace Grand.Web.Models.ShoppingCart
public string OrderTotal { get; set; }
public double OrderTotalValue { get; set; }
- public HashSet<string> Discounts { get; set; }
+ public HashSet<string> Discounts { get; set; } = new();
#region Nested classes
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
index 095e60cf5..bd8c3173a 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
@@ -7,46 +7,32 @@ namespace Grand.Web.Models.ShoppingCart
{
public class ShoppingCartModel : BaseModel
{
- public ShoppingCartModel()
- {
- Items = new List<ShoppingCartItemModel>();
- Warnings = new List<string>();
- DiscountBox = new DiscountBoxModel();
- GiftVoucherBox = new GiftVoucherBoxModel();
- CheckoutAttributes = new List<CheckoutAttributeModel>();
- }
public bool ShowSku { get; set; }
public bool ShowProductImages { get; set; }
public bool IsEditable { get; set; }
public bool IsAllowOnHold { get; set; }
public bool TermsOfServicePopup { get; set; }
- public IList<ShoppingCartItemModel> Items { get; set; }
+ public IList<ShoppingCartItemModel> Items { get; set; } = new List<ShoppingCartItemModel>();
public string CheckoutAttributeInfo { get; set; }
- public IList<CheckoutAttributeModel> CheckoutAttributes { get; set; }
+ public IList<CheckoutAttributeModel> CheckoutAttributes { get; set; } = new List<CheckoutAttributeModel>();
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
public string MinOrderSubtotalWarning { get; set; }
public bool ShowCheckoutAsGuestButton { get; set; }
public bool IsGuest { get; set; }
public bool TermsOfServiceOnShoppingCartPage { get; set; }
public bool TermsOfServiceOnOrderConfirmPage { get; set; }
- public DiscountBoxModel DiscountBox { get; set; }
- public GiftVoucherBoxModel GiftVoucherBox { get; set; }
+ public DiscountBoxModel DiscountBox { get; set; } = new();
+ public GiftVoucherBoxModel GiftVoucherBox { get; set; } = new();
+
#region Nested Classes
public class ShoppingCartItemModel : BaseEntityModel
{
- public ShoppingCartItemModel()
- {
- Picture = new PictureModel();
- AllowedQuantities = new List<SelectListItem>();
- Discounts = new HashSet<string>();
- Warnings = new List<string>();
- }
public string Sku { get; set; }
public bool IsCart { get; set; }
- public PictureModel Picture { get; set; }
+ public PictureModel Picture { get; set; } = new();
public string ProductId { get; set; }
public string ProductName { get; set; }
public string ProductSeName { get; set; }
@@ -65,9 +51,9 @@ namespace Grand.Web.Models.ShoppingCart
public double SubTotalValue { get; set; }
public string Discount { get; set; }
public int DiscountedQty { get; set; }
- public HashSet<string> Discounts { get; set; }
+ public HashSet<string> Discounts { get; set; } = new();
public int Quantity { get; set; }
- public List<SelectListItem> AllowedQuantities { get; set; }
+ public List<SelectListItem> AllowedQuantities { get; set; } = new();
public string AttributeInfo { get; set; }
public string RecurringInfo { get; set; }
public bool AllowItemEditing { get; set; }
@@ -75,17 +61,11 @@ namespace Grand.Web.Models.ShoppingCart
public string ReservationInfo { get; set; }
public string AuctionInfo { get; set; }
public string Parameter { get; set; }
- public IList<string> Warnings { get; set; }
+ public IList<string> Warnings { get; set; } = new List<string>();
}
public class CheckoutAttributeModel : BaseEntityModel
{
- public CheckoutAttributeModel()
- {
- AllowedFileExtensions = new List<string>();
- Values = new List<CheckoutAttributeValueModel>();
- }
-
public string Name { get; set; }
public string DefaultValue { get; set; }
@@ -97,11 +77,11 @@ namespace Grand.Web.Models.ShoppingCart
/// <summary>
/// Allowed file extensions for customer uploaded files
/// </summary>
- public IList<string> AllowedFileExtensions { get; set; }
+ public IList<string> AllowedFileExtensions { get; set; } = new List<string>();
public AttributeControlType AttributeControlType { get; set; }
- public IList<CheckoutAttributeValueModel> Values { get; set; }
+ public IList<CheckoutAttributeValueModel> Values { get; set; } = new List<CheckoutAttributeValueModel>();
}
public class CheckoutAttributeValueModel : BaseEntityModel
@@ -117,11 +97,7 @@ namespace Grand.Web.Models.ShoppingCart
public class DiscountBoxModel : BaseModel
{
- public DiscountBoxModel()
- {
- AppliedDiscountsWithCodes = new List<DiscountInfoModel>();
- }
- public List<DiscountInfoModel> AppliedDiscountsWithCodes { get; set; }
+ public List<DiscountInfoModel> AppliedDiscountsWithCodes { get; set; } = new();
public bool Display { get; set; }
public string Message { get; set; }
public bool IsApplied { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
index c509ad350..f93d8d79f 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
@@ -5,11 +5,6 @@ namespace Grand.Web.Models.ShoppingCart
{
public class WishlistEmailAFriendModel : BaseModel
{
- public WishlistEmailAFriendModel()
- {
- Captcha = new CaptchaModel();
- }
-
[GrandResourceDisplayName("Wishlist.EmailAFriend.FriendEmail")]
public string FriendEmail { get; set; }
@@ -22,6 +17,6 @@ namespace Grand.Web.Models.ShoppingCart
public bool SuccessfullySent { get; set; }
public string Result { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
index 591c07834..2789af6c7 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
@@ -6,12 +6,6 @@ namespace Grand.Web.Models.ShoppingCart
{
public class WishlistModel : BaseModel
{
- public WishlistModel()
- {
- Items = new List<ShoppingCartItemModel>();
- Warnings = new List<string>();
- }
-
public Guid CustomerGuid { get; set; }
public string CustomerFullname { get; set; }
@@ -26,23 +20,17 @@ namespace Grand.Web.Models.ShoppingCart
public bool DisplayAddToCart { get; set; }
- public IList<ShoppingCartItemModel> Items { get; set; }
+ public IList<ShoppingCartItemModel> Items { get; set; } = new List<ShoppingCartItemModel>();
- public IList<string> Warnings { get; set; }
-
- #region Nested Classes
+ public IList<string> Warnings { get; set; } = new List<string>();
+
+ #region Nested Classes
public class ShoppingCartItemModel : BaseEntityModel
{
- public ShoppingCartItemModel()
- {
- Picture = new PictureModel();
- AllowedQuantities = new List<SelectListItem>();
- Warnings = new List<string>();
- }
public string Sku { get; set; }
- public PictureModel Picture {get;set;}
+ public PictureModel Picture {get;set;} = new();
public string ProductId { get; set; }
@@ -59,8 +47,8 @@ namespace Grand.Web.Models.ShoppingCart
public string Discount { get; set; }
public int Quantity { get; set; }
- public List<SelectListItem> AllowedQuantities { get; set; }
-
+ public List<SelectListItem> AllowedQuantities { get; set; } = new();
+
public string AttributeInfo { get; set; }
public string RecurringInfo { get; set; }
@@ -68,8 +56,7 @@ namespace Grand.Web.Models.ShoppingCart
public string RentalInfo { get; set; }
public bool AllowItemEditing { get; set; }
- public IList<string> Warnings { get; set; }
-
+ public IList<string> Warnings { get; set; } = new List<string>();
}
#endregion
diff --git a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
index 5d0bb707c..edbada9b4 100644
--- a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
@@ -6,14 +6,7 @@ namespace Grand.Web.Models.Vendors
{
public class ApplyVendorModel : BaseModel
{
-
- public ApplyVendorModel()
- {
- Address = new VendorAddressModel();
- Captcha = new CaptchaModel();
- }
-
- public VendorAddressModel Address { get; set; }
+ public VendorAddressModel Address { get; set; } = new();
[GrandResourceDisplayName("Vendors.ApplyAccount.Name")]
public string Name { get; set; }
@@ -23,7 +16,7 @@ namespace Grand.Web.Models.Vendors
[GrandResourceDisplayName("Vendors.ApplyAccount.Description")]
public string Description { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
public bool TermsOfServiceEnabled { get; set; }
public bool TermsOfServicePopup { get; set; }
public bool DisableFormInput { get; set; }
diff --git a/src/Web/Grand.Web/Models/Vendors/ContactVendorModel.cs b/src/Web/Grand.Web/Models/Vendors/ContactVendorModel.cs
index 04f3d5eea..45092b9ac 100644
--- a/src/Web/Grand.Web/Models/Vendors/ContactVendorModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/ContactVendorModel.cs
@@ -6,10 +6,6 @@ namespace Grand.Web.Models.Vendors
{
public class ContactVendorModel : BaseModel
{
- public ContactVendorModel()
- {
- Captcha = new CaptchaModel();
- }
public string VendorId { get; set; }
public string VendorName { get; set; }
@@ -31,6 +27,6 @@ namespace Grand.Web.Models.Vendors
public string Result { get; set; }
public bool DisplayCaptcha { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
index 863fd15e7..8cdd38d57 100644
--- a/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
@@ -7,12 +7,6 @@ namespace Grand.Web.Models.Vendors
{
public class VendorAddressModel : BaseEntityModel
{
- public VendorAddressModel()
- {
- AvailableCountries = new List<SelectListItem>();
- AvailableStates = new List<SelectListItem>();
- }
-
public bool CompanyEnabled { get; set; }
public bool CompanyRequired { get; set; }
[GrandResourceDisplayName("Account.VendorInfo.Company")]
@@ -54,7 +48,7 @@ namespace Grand.Web.Models.Vendors
public string FaxNumber { get; set; }
[GrandResourceDisplayName("Account.VendorInfo.Note")]
public string Note { get; set; }
- public IList<SelectListItem> AvailableCountries { get; set; }
- public IList<SelectListItem> AvailableStates { get; set; }
+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();
+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
index e0d48a7ed..48b1ad001 100644
--- a/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
@@ -16,22 +16,16 @@ namespace Grand.Web.Models.Vendors
public class VendorReviewsModel : BaseModel
{
- public VendorReviewsModel()
- {
- Items = new List<VendorReviewModel>();
- AddVendorReview = new AddVendorReviewModel();
- Captcha = new CaptchaModel();
- }
public string VendorId { get; set; }
public string VendorName { get; set; }
public string VendorSeName { get; set; }
- public IList<VendorReviewModel> Items { get; set; }
- public AddVendorReviewModel AddVendorReview { get; set; }
+ public IList<VendorReviewModel> Items { get; set; } = new List<VendorReviewModel>();
+ public AddVendorReviewModel AddVendorReview { get; set; } = new();
public VendorReviewOverviewModel VendorReviewOverview { get; set; }
- public ICaptchaValidModel Captcha { get; set; }
+ public ICaptchaValidModel Captcha { get; set; } = new CaptchaModel();
}
public class VendorReviewModel : BaseEntityModel