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.

Grand.Web - refactor (#352)

Krzysztof Pajakb9c1757a96f4
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index 10344e3d6..90ef5dcd1 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -2647,7 +2647,7 @@
<Value>Amount</Value>
</Resource>
<Resource Name="Admin.Catalog.Products.Bids.CantDeleteWithOrder" Area="Admin">
- <Value>Cannot delete bid wiht order id</Value>
+ <Value>Cannot delete bid with order id</Value>
</Resource>
<Resource Name="Admin.Catalog.Products.Bids.CustomerId" Area="Admin">
<Value>Customer Id</Value>
@@ -5326,7 +5326,7 @@
<Value>Tax display type</Value>
</Resource>
<Resource Name="Admin.Configuration.Themes.Failed" Area="Admin">
- <Value>Failed to upload theme. Make sure you are not uploading already existing one. If so, try deleting it manualy before resubmitting.</Value>
+ <Value>Failed to upload theme. Make sure you are not uploading already existing one. If so, try deleting it manually before resubmitting.</Value>
</Resource>
<Resource Name="Admin.Configuration.Themes.Upload" Area="Admin">
<Value>Upload theme</Value>
@@ -5551,7 +5551,7 @@
<Value>Customer</Value>
</Resource>
<Resource Name="Admin.Content.Knowledgebase.ActivityLogType" Area="Admin">
- <Value>Acitivty log type</Value>
+ <Value>Activity log type</Value>
</Resource>
<Resource Name="Admin.Content.Knowledgebase.CreateKnowledgebaseArticle" Area="Admin">
<Value>Create article</Value>
@@ -5662,7 +5662,7 @@
<Value>Article updated</Value>
</Resource>
<Resource Name="Admin.Content.Knowledgebase.KnowledgebaseCategory.ActivityLog" Area="Admin">
- <Value>Acitivity log</Value>
+ <Value>Activity log</Value>
</Resource>
<Resource Name="Admin.Content.Knowledgebase.KnowledgebaseCategory.Added" Area="Admin">
<Value>Category added</Value>
@@ -6694,7 +6694,7 @@
<Value>Owner</Value>
</Resource>
<Resource Name="Admin.Customers.Customers.Fields.Owner.Hint" Area="Admin">
- <Value>If it's a subaccount, here is the e-mail adddress of parent account (owner account).</Value>
+ <Value>If it's a subaccount, here is the e-mail address of parent account (owner account).</Value>
</Resource>
<Resource Name="Admin.Customers.Customers.Fields.Password" Area="Admin">
<Value>Password</Value>
@@ -7087,7 +7087,7 @@
<Value>Active</Value>
</Resource>
<Resource Name="Admin.Customers.SalesEmployee.Fields.Commission" Area="Admin">
- <Value>Commisssion</Value>
+ <Value>Commission</Value>
</Resource>
<Resource Name="Admin.Customers.SalesEmployee.Fields.Commission.IsCommissionValid" Area="Admin">
<Value>Commission`s rate is no valid</Value>
@@ -7870,7 +7870,7 @@
<Value>Calculate by plugin</Value>
</Resource>
<Resource Name="Admin.Marketing.Discounts.Fields.CalculateByPlugin.hint" Area="Admin">
- <Value>Discoutns may be calculated by external plugins. If you have one, enable the setting and choose it from the list.</Value>
+ <Value>Discounts may be calculated by external plugins. If you have one, enable the setting and choose it from the list.</Value>
</Resource>
<Resource Name="Admin.Marketing.Discounts.Fields.CouponCode" Area="Admin">
<Value>Coupon code</Value>
@@ -9457,7 +9457,7 @@
<Value>Push notifications</Value>
</Resource>
<Resource Name="Admin.PushNotifications.Error.NoReceivers" Area="Admin">
- <Value>No receviers yet. Wait for someone to register for push notifications.</Value>
+ <Value>No receivers yet. Wait for someone to register for push notifications.</Value>
</Resource>
<Resource Name="Admin.PushNotifications.Fields.ClickUrl" Area="Admin">
<Value>Click Url</Value>
@@ -10213,7 +10213,7 @@
<Value>'Address type' enabled</Value>
</Resource>
<Resource Name="Admin.Settings.Customer.AddressFormFields.AddressTypeEnabled.Hint" Area="Admin">
- <Value>If checked, customers are able to select the type of the adress - Any, Billing, Shipping</Value>
+ <Value>If checked, customers are able to select the type of the address - Any, Billing, Shipping</Value>
</Resource>
<Resource Name="Admin.Settings.Customer.AddressFormFields.CityEnabled" Area="Admin">
<Value>'City' enabled</Value>
@@ -10713,7 +10713,7 @@
<Value>Pinterest page URL</Value>
</Resource>
<Resource Name="Admin.Settings.GeneralCommon.PopupForTermsOfServiceLinks" Area="Admin">
- <Value>Open terms of service link in popus</Value>
+ <Value>Open terms of service link in popup</Value>
</Resource>
<Resource Name="Admin.Settings.generalcommon.premiumthemes" Area="Admin">
<Value>Customize your store with one of our premium themes</Value>
@@ -11928,7 +11928,7 @@
<Value>Greenwich Mean Time (GMT/UTC)</Value>
</Resource>
<Resource Name="Admin.System.SystemInfo.WebRootPath" Area="Admin">
- <Value>Absolute path to the directory that contains the web-servable application content files</Value>
+ <Value>Absolute path to the directory that contains the web-server application content files</Value>
</Resource>
<Resource Name="Admin.System.UserApi.Email" Area="Admin">
<Value>Email</Value>
diff --git a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
index 96e6b64e9..6d39ef093 100644
--- a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs
@@ -3,9 +3,9 @@ using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
-using Grand.Infrastructure;
using Grand.Domain.Blogs;
using Grand.Domain.Localization;
+using Grand.Infrastructure;
using Grand.Web.Commands.Models.Blogs;
using MediatR;
@@ -48,7 +48,7 @@ namespace Grand.Web.Commands.Handler.Blogs
StoreId = _workContext.CurrentStore.Id,
CommentText = request.Model.AddNewComment.CommentText,
CreatedOnUtc = DateTime.UtcNow,
- BlogPostTitle = request.BlogPost.Title,
+ BlogPostTitle = request.BlogPost.Title
};
await _blogService.InsertBlogComment(comment);
diff --git a/src/Web/Grand.Web/Commands/Handler/Common/ContactAttributeChangeCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Common/ContactAttributeChangeCommandHandler.cs
index 3c6300a86..662e869b0 100644
--- a/src/Web/Grand.Web/Commands/Handler/Common/ContactAttributeChangeCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Common/ContactAttributeChangeCommandHandler.cs
@@ -34,13 +34,11 @@ namespace Grand.Web.Commands.Handler.Common
foreach (var attribute in attributes)
{
var conditionMet = await _contactAttributeParser.IsConditionMet(attribute, customAttributes);
- if (conditionMet.HasValue)
- {
- if (conditionMet.Value)
- enabledAttributeIds.Add(attribute.Id);
- else
- disabledAttributeIds.Add(attribute.Id);
- }
+ if (!conditionMet.HasValue) continue;
+ if (conditionMet.Value)
+ enabledAttributeIds.Add(attribute.Id);
+ else
+ disabledAttributeIds.Add(attribute.Id);
}
return (enabledAttributeIds, disabledAttributeIds);
@@ -89,7 +87,7 @@ namespace Grand.Web.Commands.Handler.Common
.ToList())
{
customAttributes = _contactAttributeParser.AddContactAttribute(customAttributes,
- attribute, selectedAttributeId.ToString()).ToList();
+ attribute, selectedAttributeId).ToList();
}
}
break;
@@ -113,7 +111,7 @@ namespace Grand.Web.Commands.Handler.Common
DateTime? selectedDate = null;
try
{
- selectedDate = new DateTime(Int32.Parse(year), Int32.Parse(month), Int32.Parse(date));
+ selectedDate = new DateTime(int.Parse(year), int.Parse(month), int.Parse(date));
}
catch
{
@@ -139,8 +137,6 @@ namespace Grand.Web.Commands.Handler.Common
}
}
break;
- default:
- break;
}
}
diff --git a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsCommandHandler.cs
index cb71cca93..01e13256f 100644
--- a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsCommandHandler.cs
@@ -1,5 +1,6 @@
using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Marketing.Contacts;
+using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Messages;
@@ -29,7 +30,7 @@ namespace Grand.Web.Commands.Handler.Common
{
var model = request.Model ?? new ContactUsModel {
Email = request.Customer.Email,
- FullName = request.Customer.GetFullName(),
+ FullName = request.Customer.GetFullName()
};
model.SubjectEnabled = _commonSettings.SubjectFieldOnContactUsForm;
@@ -55,7 +56,7 @@ namespace Grand.Web.Commands.Handler.Common
AttributeControlType = attribute.AttributeControlType,
DefaultValue = request.Model?.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value ?? attribute.DefaultValue
};
- if (attribute.AttributeControlType == Domain.Catalog.AttributeControlType.Datepicker)
+ if (attribute.AttributeControlType == AttributeControlType.Datepicker)
{
int.TryParse(request.Model?.Attributes.FirstOrDefault(x => x.Key == attribute.Id+ "_day")?.Value, out var selectedDay);
int.TryParse(request.Model?.Attributes.FirstOrDefault(x => x.Key == attribute.Id+ "_month")?.Value,out var selectedMonth);
@@ -90,8 +91,8 @@ namespace Grand.Web.Commands.Handler.Common
Id = attributeValue.Id,
Name = attributeValue.GetTranslation(x => x.Name, request.Language.Id),
ColorSquaresRgb = attributeValue.ColorSquaresRgb,
- IsPreSelected = string.IsNullOrEmpty(preSelected) ? attributeValue.IsPreSelected : (preSelected.Contains(attributeValue.Id)),
- DisplayOrder = attributeValue.DisplayOrder,
+ IsPreSelected = string.IsNullOrEmpty(preSelected) ? attributeValue.IsPreSelected : preSelected.Contains(attributeValue.Id),
+ DisplayOrder = attributeValue.DisplayOrder
};
attributeModel.Values.Add(attributeValueModel);
}
diff --git a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs
index eb35ca3ad..991dfbc85 100644
--- a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs
@@ -127,7 +127,7 @@ namespace Grand.Web.Commands.Handler.Common
.ToList())
{
customAttributes = _contactAttributeParser.AddContactAttribute(customAttributes,
- attribute, selectedAttributeId.ToString()).ToList();
+ attribute, selectedAttributeId).ToList();
}
}
break;
@@ -137,7 +137,7 @@ namespace Grand.Web.Commands.Handler.Common
var ctrlAttributes = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- var enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customAttributes = _contactAttributeParser.AddContactAttribute(customAttributes,
attribute, enteredText).ToList();
}
@@ -151,7 +151,7 @@ namespace Grand.Web.Commands.Handler.Common
DateTime? selectedDate = null;
try
{
- selectedDate = new DateTime(Int32.Parse(year), Int32.Parse(month), Int32.Parse(date));
+ selectedDate = new DateTime(int.Parse(year), int.Parse(month), int.Parse(date));
}
catch { }
if (selectedDate.HasValue)
@@ -173,8 +173,6 @@ namespace Grand.Web.Commands.Handler.Common
}
}
break;
- default:
- break;
}
}
//validate conditional attributes (if specified)
@@ -200,32 +198,30 @@ namespace Grand.Web.Commands.Handler.Common
foreach (var a2 in attributes2)
{
var conditionMet = await _contactAttributeParser.IsConditionMet(a2, customAttributes);
- if (a2.IsRequired && ((conditionMet.HasValue && conditionMet.Value) || !conditionMet.HasValue))
+ if (!a2.IsRequired ||
+ ((!conditionMet.HasValue || !conditionMet.Value) && conditionMet.HasValue)) continue;
+ var found = false;
+ //selected checkout attributes
+ foreach (var a1 in attributes1)
{
- var found = false;
- //selected checkout attributes
- foreach (var a1 in attributes1)
- {
- if (a1.Id == a2.Id)
+ if (a1.Id != a2.Id) continue;
+ var attributeValuesStr = customAttributes.Where(x => x.Key == a1.Id).Select(x => x.Value).ToList();
+ foreach (var str1 in attributeValuesStr)
+ if (!string.IsNullOrEmpty(str1.Trim()))
{
- var attributeValuesStr = customAttributes.Where(x => x.Key == a1.Id).Select(x => x.Value).ToList();
- foreach (var str1 in attributeValuesStr)
- if (!string.IsNullOrEmpty(str1.Trim()))
- {
- found = true;
- break;
- }
+ found = true;
+ break;
}
- }
+ }
- //if not found
- if (!found)
- {
- if (!string.IsNullOrEmpty(a2.GetTranslation(a => a.TextPrompt, _workContext.WorkingLanguage.Id)))
- warnings.Add(a2.GetTranslation(a => a.TextPrompt, _workContext.WorkingLanguage.Id));
- else
- warnings.Add(string.Format(_translationService.GetResource("ContactUs.SelectAttribute"), a2.GetTranslation(a => a.Name, _workContext.WorkingLanguage.Id)));
- }
+ //if not found
+ if (!found)
+ {
+ warnings.Add(
+ !string.IsNullOrEmpty(a2.GetTranslation(a => a.TextPrompt, _workContext.WorkingLanguage.Id))
+ ? a2.GetTranslation(a => a.TextPrompt, _workContext.WorkingLanguage.Id)
+ : string.Format(_translationService.GetResource("ContactUs.SelectAttribute"),
+ a2.GetTranslation(a => a.Name, _workContext.WorkingLanguage.Id)));
}
}
@@ -237,8 +233,7 @@ namespace Grand.Web.Commands.Handler.Common
if (ca.ValidationMinLength.HasValue)
{
- if (ca.AttributeControlType == AttributeControlType.TextBox ||
- ca.AttributeControlType == AttributeControlType.MultilineTextbox)
+ if (ca.AttributeControlType is AttributeControlType.TextBox or AttributeControlType.MultilineTextbox)
{
var conditionMet = await _contactAttributeParser.IsConditionMet(ca, customAttributes);
if (ca.IsRequired && ((conditionMet.HasValue && conditionMet.Value) || !conditionMet.HasValue))
@@ -256,24 +251,21 @@ namespace Grand.Web.Commands.Handler.Common
}
//maximum length
- if (ca.ValidationMaxLength.HasValue)
+ if (!ca.ValidationMaxLength.HasValue) continue;
{
- if (ca.AttributeControlType == AttributeControlType.TextBox ||
- ca.AttributeControlType == AttributeControlType.MultilineTextbox)
- {
- var conditionMet = await _contactAttributeParser.IsConditionMet(ca, customAttributes);
- if (ca.IsRequired && ((conditionMet.HasValue && conditionMet.Value) || !conditionMet.HasValue))
+ if (ca.AttributeControlType != AttributeControlType.TextBox &&
+ ca.AttributeControlType != AttributeControlType.MultilineTextbox) continue;
+ var conditionMet = await _contactAttributeParser.IsConditionMet(ca, customAttributes);
+ if (!ca.IsRequired || ((!conditionMet.HasValue || !conditionMet.Value) && conditionMet.HasValue))
+ continue;
+ var valuesStr = customAttributes.Where(x => x.Key == ca.Id).Select(x => x.Value).ToList();
+ var enteredText = valuesStr.FirstOrDefault();
+ var enteredTextLength = string.IsNullOrEmpty(enteredText) ? 0 : enteredText.Length;
+
+ if (ca.ValidationMaxLength.Value < enteredTextLength)
{
- var valuesStr = customAttributes.Where(x => x.Key == ca.Id).Select(x => x.Value).ToList();
- var enteredText = valuesStr.FirstOrDefault();
- var enteredTextLength = string.IsNullOrEmpty(enteredText) ? 0 : enteredText.Length;
-
- if (ca.ValidationMaxLength.Value < enteredTextLength)
- {
- warnings.Add(string.Format(_translationService.GetResource("ContactUs.TextboxMaximumLength"), ca.GetTranslation(a => a.Name, _workContext.WorkingLanguage.Id), ca.ValidationMaxLength.Value));
- }
+ warnings.Add(string.Format(_translationService.GetResource("ContactUs.TextboxMaximumLength"), ca.GetTranslation(a => a.Name, _workContext.WorkingLanguage.Id), ca.ValidationMaxLength.Value));
}
- }
}
}
@@ -313,7 +305,7 @@ namespace Grand.Web.Commands.Handler.Common
Name = attributeValue.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
ColorSquaresRgb = attributeValue.ColorSquaresRgb,
IsPreSelected = attributeValue.IsPreSelected,
- DisplayOrder = attributeValue.DisplayOrder,
+ DisplayOrder = attributeValue.DisplayOrder
};
attributeModel.Values.Add(attributeValueModel);
}
@@ -354,7 +346,7 @@ namespace Grand.Web.Commands.Handler.Common
{
if (selectedContactAttributes != null && selectedContactAttributes.Any())
{
- var enteredText = selectedContactAttributes.Where(x => x.Key == attribute.Id).Select(x => x.Value).ToList(); ;
+ var enteredText = selectedContactAttributes.Where(x => x.Key == attribute.Id).Select(x => x.Value).ToList();
if (enteredText.Any())
attributeModel.DefaultValue = enteredText[0];
}
@@ -368,9 +360,8 @@ namespace Grand.Web.Commands.Handler.Common
var selectedDateStr = selectedContactAttributes.Where(x => x.Key == attribute.Id).Select(x => x.Value).ToList();
if (selectedDateStr.Any())
{
- DateTime selectedDate;
if (DateTime.TryParseExact(selectedDateStr[0], "D", CultureInfo.CurrentCulture,
- DateTimeStyles.None, out selectedDate))
+ DateTimeStyles.None, out var selectedDate))
{
//successfully parsed
attributeModel.SelectedDay = selectedDate.Day;
@@ -393,8 +384,6 @@ namespace Grand.Web.Commands.Handler.Common
}
}
break;
- default:
- break;
}
model.Add(attributeModel);
diff --git a/src/Web/Grand.Web/Commands/Handler/Courses/CourseLessonApprovedCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Courses/CourseLessonApprovedCommandHandler.cs
index eac9e0302..7e2ff9006 100644
--- a/src/Web/Grand.Web/Commands/Handler/Courses/CourseLessonApprovedCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Courses/CourseLessonApprovedCommandHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Domain.Courses;
-using Grand.Business.Core.Interfaces.Marketing.Courses;
+using Grand.Business.Core.Interfaces.Marketing.Courses;
+using Grand.Domain.Courses;
using Grand.Web.Commands.Models.Courses;
using MediatR;
@@ -19,7 +19,7 @@ namespace Grand.Web.Commands.Handler.Courses
var action = await _courseActionService.GetCourseAction(request.Customer.Id, request.Lesson.Id);
if (action == null)
{
- await _courseActionService.InsertAsync(new CourseAction() {
+ await _courseActionService.InsertAsync(new CourseAction {
CustomerId = request.Customer.Id,
CourseId = request.Course.Id,
LessonId = request.Lesson.Id,
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
index 5c442322c..2ad974ee8 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/CustomerRegisteredCommandHandler.cs
@@ -172,7 +172,7 @@ namespace Grand.Web.Commands.Handler.Customers
ZipPostalCode = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.ZipPostalCode),
PhoneNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Phone),
FaxNumber = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Fax),
- CreatedOnUtc = request.Customer.CreatedOnUtc,
+ CreatedOnUtc = request.Customer.CreatedOnUtc
};
if (await IsAddressValid(defaultAddress))
@@ -239,7 +239,7 @@ namespace Grand.Web.Commands.Handler.Customers
if (_addressSettings.ZipPostalCodeEnabled &&
_addressSettings.ZipPostalCodeRequired &&
- String.IsNullOrWhiteSpace(address.ZipPostalCode))
+ string.IsNullOrWhiteSpace(address.ZipPostalCode))
return false;
@@ -257,7 +257,7 @@ namespace Grand.Web.Commands.Handler.Customers
var states = country.StateProvinces;
if (states.Any())
{
- if (String.IsNullOrEmpty(address.StateProvinceId))
+ if (string.IsNullOrEmpty(address.StateProvinceId))
return false;
var state = states.FirstOrDefault(x => x.Id == address.StateProvinceId);
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
index 7d80a37b6..2b77f001a 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/SubAccountAddCommandHandler.cs
@@ -49,12 +49,13 @@ namespace Grand.Web.Commands.Handler.Customers
protected async Task<Customer> PrepareCustomer(SubAccountAddCommand request)
{
- var customer = new Customer();
- customer.OwnerId = request.Customer.Id;
- customer.CustomerGuid = Guid.NewGuid();
- customer.StoreId = request.Store.Id;
- customer.CreatedOnUtc = DateTime.UtcNow;
- customer.LastActivityDateUtc = DateTime.UtcNow;
+ var customer = new Customer {
+ OwnerId = request.Customer.Id,
+ CustomerGuid = Guid.NewGuid(),
+ StoreId = request.Store.Id,
+ CreatedOnUtc = DateTime.UtcNow,
+ LastActivityDateUtc = DateTime.UtcNow
+ };
await _customerService.InsertCustomer(customer);
return customer;
diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
index ca2ea4791..c208d13f5 100644
--- a/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Customers/UpdateCustomerInfoCommandHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Authentication;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Authentication;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Marketing.Newsletters;
@@ -20,7 +20,6 @@ namespace Grand.Web.Commands.Handler.Customers
private readonly IVatService _checkVatService;
private readonly INewsLetterSubscriptionService _newsLetterSubscriptionService;
private readonly ICustomerService _customerService;
- private readonly IMediator _mediator;
private readonly CustomerSettings _customerSettings;
private readonly TaxSettings _taxSettings;
@@ -32,7 +31,6 @@ namespace Grand.Web.Commands.Handler.Customers
IVatService checkVatService,
INewsLetterSubscriptionService newsLetterSubscriptionService,
ICustomerService customerService,
- IMediator mediator,
CustomerSettings customerSettings,
TaxSettings taxSettings)
{
@@ -42,7 +40,6 @@ namespace Grand.Web.Commands.Handler.Customers
_checkVatService = checkVatService;
_newsLetterSubscriptionService = newsLetterSubscriptionService;
_customerService = customerService;
- _mediator = mediator;
_customerSettings = customerSettings;
_taxSettings = taxSettings;
}
@@ -103,7 +100,7 @@ namespace Grand.Web.Commands.Handler.Customers
if (prevVatNumber != request.Model.VatNumber)
{
- var vat = (await _checkVatService.GetVatNumberStatus(request.Model.VatNumber));
+ var vat = await _checkVatService.GetVatNumberStatus(request.Model.VatNumber);
await _userFieldService.SaveField(request.Customer,
SystemCustomerFieldNames.VatNumberStatusId,
(int)vat.status);
diff --git a/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
index 3a50e4bf4..a35f99f04 100644
--- a/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/News/InsertNewsCommentCommandHandler.cs
@@ -1,9 +1,9 @@
using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
-using Grand.Infrastructure;
using Grand.Domain.Localization;
using Grand.Domain.News;
+using Grand.Infrastructure;
using Grand.Web.Commands.Models.News;
using MediatR;
@@ -41,7 +41,7 @@ namespace Grand.Web.Commands.Handler.News
StoreId = _workContext.CurrentStore.Id,
CommentTitle = request.Model.AddNewComment.CommentTitle,
CommentText = request.Model.AddNewComment.CommentText,
- CreatedOnUtc = DateTime.UtcNow,
+ CreatedOnUtc = DateTime.UtcNow
};
request.NewsItem.NewsComments.Add(comment);
diff --git a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
index e8034a3f9..9ca8fb1c1 100644
--- a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscribeNewsletterHandler.cs
@@ -2,8 +2,8 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Marketing.Newsletters;
using Grand.Business.Core.Interfaces.Messages;
-using Grand.Infrastructure;
using Grand.Domain.Messages;
+using Grand.Infrastructure;
using Grand.SharedKernel.Extensions;
using Grand.Web.Commands.Models.Newsletter;
using Grand.Web.Models.Newsletter;
@@ -97,13 +97,13 @@ namespace Grand.Web.Commands.Handler.Newsletter
private async Task<NewsletterCategoryModel> PrepareNewsletterCategory(string id)
{
- var model = new NewsletterCategoryModel();
- model.NewsletterEmailId = id;
+ var model = new NewsletterCategoryModel {
+ NewsletterEmailId = id
+ };
var categories = await _newsletterCategoryService.GetNewsletterCategoriesByStore(_workContext.CurrentStore.Id);
foreach (var item in categories)
{
- model.NewsletterCategories.Add(new NewsletterSimpleCategory()
- {
+ model.NewsletterCategories.Add(new NewsletterSimpleCategory {
Id = item.Id,
Name = item.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
Description = item.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),
diff --git a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscriptionCategoryHandler.cs b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscriptionCategoryHandler.cs
index bd446aaba..2a75be2fe 100644
--- a/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscriptionCategoryHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Newsletter/SubscriptionCategoryHandler.cs
@@ -17,8 +17,8 @@ namespace Grand.Web.Commands.Handler.Newsletter
public async Task<(string message, bool success)> Handle(SubscriptionCategoryCommand request,
CancellationToken cancellationToken)
{
- bool success = false;
- string message = string.Empty;
+ var success = false;
+ var message = string.Empty;
var newsletterEmailId = request.Model.NewsletterEmailId;
if (!string.IsNullOrEmpty(newsletterEmailId))
diff --git a/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
index 7f9d50b96..4b50c429a 100644
--- a/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Orders/MerchandiseReturnSubmitCommandHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Messages;
@@ -58,7 +58,7 @@ namespace Grand.Web.Commands.Handler.Orders
MerchandiseReturnStatus = MerchandiseReturnStatus.Pending,
CreatedOnUtc = DateTime.UtcNow,
UpdatedOnUtc = DateTime.UtcNow,
- PickupAddress = request.Address,
+ PickupAddress = request.Address
};
if (request.Model.PickupDate.HasValue)
diff --git a/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
index d837fbd98..27b0eb4d3 100644
--- a/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Products/InsertProductReviewCommandHandler.cs
@@ -1,8 +1,8 @@
using Grand.Business.Core.Commands.Catalog;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
+using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Domain.Catalog;
using Grand.Domain.Localization;
using Grand.Domain.Orders;
@@ -41,19 +41,18 @@ namespace Grand.Web.Commands.Handler.Products
{
//save review
var rating = request.Model.AddProductReview.Rating;
- if (rating < 1 || rating > 5)
+ if (rating is < 1 or > 5)
rating = _catalogSettings.DefaultProductRatingValue;
var isApproved = !_catalogSettings.ProductReviewsMustBeApproved;
var confirmPurchased =
- (await _mediator.Send(new GetOrderQuery()
- {
+ (await _mediator.Send(new GetOrderQuery {
CustomerId = request.Customer.Id,
StoreId = request.Store.Id,
ProductId = request.Product.Id,
Os = (int)OrderStatusSystem.Complete,
PageSize = 1
- })).Any();
+ }, cancellationToken)).Any();
var productReview = new ProductReview
{
@@ -67,7 +66,7 @@ namespace Grand.Web.Commands.Handler.Products
HelpfulNoTotal = 0,
IsApproved = isApproved,
ConfirmedPurchase = confirmPurchased,
- CreatedOnUtc = DateTime.UtcNow,
+ CreatedOnUtc = DateTime.UtcNow
};
await _productReviewService.InsertProductReview(productReview);
@@ -78,7 +77,7 @@ namespace Grand.Web.Commands.Handler.Products
}
//update product totals
- await _mediator.Send(new UpdateProductReviewTotalsCommand() { Product = request.Product });
+ await _mediator.Send(new UpdateProductReviewTotalsCommand { Product = request.Product }, cancellationToken);
//notify store owner
if (_catalogSettings.NotifyStoreOwnerAboutNewProductReviews)
diff --git a/src/Web/Grand.Web/Commands/Handler/ShoppingCart/SaveCheckoutAttributesCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/ShoppingCart/SaveCheckoutAttributesCommandHandler.cs
index 466de754f..b877ef6ea 100644
--- a/src/Web/Grand.Web/Commands/Handler/ShoppingCart/SaveCheckoutAttributesCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/ShoppingCart/SaveCheckoutAttributesCommandHandler.cs
@@ -82,7 +82,7 @@ namespace Grand.Web.Commands.Handler.ShoppingCart
.ToList())
{
customAttributes = _checkoutAttributeParser.AddCheckoutAttribute(customAttributes,
- attribute, selectedAttributeId.ToString()).ToList();
+ attribute, selectedAttributeId).ToList();
}
}
break;
@@ -93,7 +93,7 @@ namespace Grand.Web.Commands.Handler.ShoppingCart
var ctrlAttributes = request.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- string enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customAttributes = _checkoutAttributeParser.AddCheckoutAttribute(customAttributes,
attribute, enteredText).ToList();
}
@@ -111,8 +111,6 @@ namespace Grand.Web.Commands.Handler.ShoppingCart
}
}
break;
- default:
- break;
}
}
diff --git a/src/Web/Grand.Web/Commands/Handler/Vendors/ContactVendorCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Vendors/ContactVendorCommandHandler.cs
index 4ec03b2f2..5c1b20958 100644
--- a/src/Web/Grand.Web/Commands/Handler/Vendors/ContactVendorCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Vendors/ContactVendorCommandHandler.cs
@@ -1,7 +1,7 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Messages;
-using Grand.Infrastructure;
using Grand.Domain.Common;
+using Grand.Infrastructure;
using Grand.SharedKernel.Extensions;
using Grand.Web.Commands.Models.Vendors;
using Grand.Web.Models.Common;
diff --git a/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
index a721a8c77..16dd4a2ae 100644
--- a/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Vendors/InsertVendorReviewCommandHandler.cs
@@ -1,8 +1,8 @@
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
-using Grand.Infrastructure;
using Grand.Domain.Localization;
using Grand.Domain.Vendors;
+using Grand.Infrastructure;
using Grand.Web.Commands.Models.Vendors;
using MediatR;
@@ -34,10 +34,10 @@ namespace Grand.Web.Commands.Handler.Vendors
public async Task<VendorReview> Handle(InsertVendorReviewCommand request, CancellationToken cancellationToken)
{
//save review
- int rating = request.Model.AddVendorReview.Rating;
- if (rating < 1 || rating > 5)
+ var rating = request.Model.AddVendorReview.Rating;
+ if (rating is < 1 or > 5)
rating = _vendorSettings.DefaultVendorRatingValue;
- bool isApproved = !_vendorSettings.VendorReviewsMustBeApproved;
+ var isApproved = !_vendorSettings.VendorReviewsMustBeApproved;
var vendorReview = new VendorReview
{
@@ -49,7 +49,7 @@ namespace Grand.Web.Commands.Handler.Vendors
HelpfulYesTotal = 0,
HelpfulNoTotal = 0,
IsApproved = isApproved,
- CreatedOnUtc = DateTime.UtcNow,
+ CreatedOnUtc = DateTime.UtcNow
};
await _vendorService.InsertVendorReview(vendorReview);
diff --git a/src/Web/Grand.Web/Commands/Handler/Vendors/SetVendorReviewHelpfulnessCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Vendors/SetVendorReviewHelpfulnessCommandHandler.cs
index 919222218..ccf539aba 100644
--- a/src/Web/Grand.Web/Commands/Handler/Vendors/SetVendorReviewHelpfulnessCommandHandler.cs
+++ b/src/Web/Grand.Web/Commands/Handler/Vendors/SetVendorReviewHelpfulnessCommandHandler.cs
@@ -33,7 +33,7 @@ namespace Grand.Web.Commands.Handler.Vendors
{
VendorReviewId = request.Review.Id,
CustomerId = request.Customer.Id,
- WasHelpful = request.Washelpful,
+ WasHelpful = request.Washelpful
};
request.Review.VendorReviewHelpfulnessEntries.Add(prh);
if (!request.Customer.HasContributions)
diff --git a/src/Web/Grand.Web/Commands/Models/Common/ContactUsSendCommand.cs b/src/Web/Grand.Web/Commands/Models/Common/ContactUsSendCommand.cs
index 1d80930e6..bf59070a2 100644
--- a/src/Web/Grand.Web/Commands/Models/Common/ContactUsSendCommand.cs
+++ b/src/Web/Grand.Web/Commands/Models/Common/ContactUsSendCommand.cs
@@ -1,8 +1,6 @@
using Grand.Domain.Stores;
-using Grand.Web.Common.Models;
using Grand.Web.Models.Common;
using MediatR;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Commands.Models.Common
{
diff --git a/src/Web/Grand.Web/Components/BlogCategories.cs b/src/Web/Grand.Web/Components/BlogCategories.cs
index 0dd98c987..8ba680b95 100644
--- a/src/Web/Grand.Web/Components/BlogCategories.cs
+++ b/src/Web/Grand.Web/Components/BlogCategories.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Blogs;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class BlogCategoriesViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/BlogMonths.cs b/src/Web/Grand.Web/Components/BlogMonths.cs
index e5a9dcc0f..8f5e4941e 100644
--- a/src/Web/Grand.Web/Components/BlogMonths.cs
+++ b/src/Web/Grand.Web/Components/BlogMonths.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Blogs;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class BlogMonthsViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/BlogPostProducts.cs b/src/Web/Grand.Web/Components/BlogPostProducts.cs
index 7263719dd..56619f1d3 100644
--- a/src/Web/Grand.Web/Components/BlogPostProducts.cs
+++ b/src/Web/Grand.Web/Components/BlogPostProducts.cs
@@ -49,8 +49,7 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Components/BlogTags.cs b/src/Web/Grand.Web/Components/BlogTags.cs
index 183e42b1f..50c0b48c8 100644
--- a/src/Web/Grand.Web/Components/BlogTags.cs
+++ b/src/Web/Grand.Web/Components/BlogTags.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Blogs;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class BlogTagsViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/CategoryFeaturedProducts.cs b/src/Web/Grand.Web/Components/CategoryFeaturedProducts.cs
index 8c7677788..b71a1400f 100644
--- a/src/Web/Grand.Web/Components/CategoryFeaturedProducts.cs
+++ b/src/Web/Grand.Web/Components/CategoryFeaturedProducts.cs
@@ -31,15 +31,13 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetCategoryFeaturedProducts() {
+ var model = await _mediator.Send(new GetCategoryFeaturedProducts {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Any())
- return Content("");
- return View(model);
+ return !model.Any() ? Content("") : View(model);
}
#endregion
diff --git a/src/Web/Grand.Web/Components/CategoryNavigation.cs b/src/Web/Grand.Web/Components/CategoryNavigation.cs
index 523a06aa1..88558e073 100644
--- a/src/Web/Grand.Web/Components/CategoryNavigation.cs
+++ b/src/Web/Grand.Web/Components/CategoryNavigation.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class CategoryNavigationViewComponent : BaseViewComponent
{
@@ -21,7 +21,7 @@ namespace Grand.Web.ViewComponents
public async Task<IViewComponentResult> InvokeAsync(string currentCategoryId, string currentProductId)
{
- var model = await _mediator.Send(new GetCategoryNavigation() {
+ var model = await _mediator.Send(new GetCategoryNavigation {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
diff --git a/src/Web/Grand.Web/Components/CollectionFeaturedProducts.cs b/src/Web/Grand.Web/Components/CollectionFeaturedProducts.cs
index 77c48cb99..d2e773466 100644
--- a/src/Web/Grand.Web/Components/CollectionFeaturedProducts.cs
+++ b/src/Web/Grand.Web/Components/CollectionFeaturedProducts.cs
@@ -29,15 +29,13 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetCollectionFeaturedProducts() {
+ var model = await _mediator.Send(new GetCollectionFeaturedProducts {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Any())
- return Content("");
- return View(model);
+ return !model.Any() ? Content("") : View(model);
}
#endregion
diff --git a/src/Web/Grand.Web/Components/CollectionNavigation.cs b/src/Web/Grand.Web/Components/CollectionNavigation.cs
index f3d321b2e..2e3bcce77 100644
--- a/src/Web/Grand.Web/Components/CollectionNavigation.cs
+++ b/src/Web/Grand.Web/Components/CollectionNavigation.cs
@@ -1,11 +1,11 @@
-using Grand.Infrastructure;
-using Grand.Domain.Catalog;
+using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class CollectionNavigationViewComponent : BaseViewComponent
{
@@ -28,17 +28,14 @@ namespace Grand.Web.ViewComponents
if (_catalogSettings.CollectionsBlockItemsToDisplay == 0)
return Content("");
- var model = await _mediator.Send(new GetCollectionNavigation() {
+ var model = await _mediator.Send(new GetCollectionNavigation {
CurrentCollectionId = currentCollectionId,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Collections.Any())
- return Content("");
-
- return View(model);
+ return !model.Collections.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/CrossSellProducts.cs b/src/Web/Grand.Web/Components/CrossSellProducts.cs
index 137763bec..0a8a1c65f 100644
--- a/src/Web/Grand.Web/Components/CrossSellProducts.cs
+++ b/src/Web/Grand.Web/Components/CrossSellProducts.cs
@@ -55,12 +55,11 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
ProductThumbPictureSize = productThumbPictureSize,
Products = products,
- ForceRedirectionAfterAddingToCart = true,
+ ForceRedirectionAfterAddingToCart = true
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/CustomerNavigation.cs b/src/Web/Grand.Web/Components/CustomerNavigation.cs
index cf43d23f4..95021b435 100644
--- a/src/Web/Grand.Web/Components/CustomerNavigation.cs
+++ b/src/Web/Grand.Web/Components/CustomerNavigation.cs
@@ -20,7 +20,7 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(int selectedTabId = 0)
{
- var model = await _mediator.Send(new GetNavigation() {
+ var model = await _mediator.Send(new GetNavigation {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
SelectedTabId = selectedTabId,
diff --git a/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs b/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs
index 7f088f21a..9d5c49a13 100644
--- a/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs
+++ b/src/Web/Grand.Web/Components/CustomerRecommendedProducts.cs
@@ -1,7 +1,7 @@
using Grand.Business.Core.Queries.Catalog;
-using Grand.Infrastructure;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
@@ -41,18 +41,17 @@ namespace Grand.Web.Components
if (!_catalogSettings.RecommendedProductsEnabled)
return Content("");
- var products = await _mediator.Send(new GetRecommendedProductsQuery() { CustomerGroupIds = _workContext.CurrentCustomer.GetCustomerGroupIds(),
+ var products = await _mediator.Send(new GetRecommendedProductsQuery { CustomerGroupIds = _workContext.CurrentCustomer.GetCustomerGroupIds(),
StoreId = _workContext.CurrentStore.Id });
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/EmailWishlist.cs b/src/Web/Grand.Web/Components/EmailWishlist.cs
index dfd44cf3f..e3b7459e7 100644
--- a/src/Web/Grand.Web/Components/EmailWishlist.cs
+++ b/src/Web/Grand.Web/Components/EmailWishlist.cs
@@ -8,7 +8,7 @@ using Grand.Web.Common.Security.Captcha;
using Grand.Web.Models.ShoppingCart;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class EmailWishlistViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/EstimateShipping.cs b/src/Web/Grand.Web/Components/EstimateShipping.cs
index 8bf163094..10c947f62 100644
--- a/src/Web/Grand.Web/Components/EstimateShipping.cs
+++ b/src/Web/Grand.Web/Components/EstimateShipping.cs
@@ -1,12 +1,12 @@
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Infrastructure;
using Grand.Domain.Orders;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.ShoppingCart;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class EstimateShippingViewComponent : BaseViewComponent
{
@@ -25,18 +25,14 @@ namespace Grand.Web.ViewComponents
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart);
- var model = await _mediator.Send(new GetEstimateShipping()
- {
+ var model = await _mediator.Send(new GetEstimateShipping {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Enabled)
- return Content("");
-
- return View(model);
+ return !model.Enabled ? Content("") : View(model);
}
}
diff --git a/src/Web/Grand.Web/Components/ExternalMethods.cs b/src/Web/Grand.Web/Components/ExternalMethods.cs
index 3bd253f7c..a77b72625 100644
--- a/src/Web/Grand.Web/Components/ExternalMethods.cs
+++ b/src/Web/Grand.Web/Components/ExternalMethods.cs
@@ -4,7 +4,7 @@ using Grand.Web.Common.Components;
using Grand.Web.Models.Customer;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class ExternalMethodsViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/Footer.cs b/src/Web/Grand.Web/Components/Footer.cs
index 257c15797..f0eb286cf 100644
--- a/src/Web/Grand.Web/Components/Footer.cs
+++ b/src/Web/Grand.Web/Components/Footer.cs
@@ -1,8 +1,7 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Business.Core.Utilities.Common.Security;
-using Grand.Infrastructure;
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
@@ -11,11 +10,12 @@ using Grand.Domain.News;
using Grand.Domain.Stores;
using Grand.Domain.Tax;
using Grand.Domain.Vendors;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Models.Common;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class FooterViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/GetCoordinate.cs b/src/Web/Grand.Web/Components/GetCoordinate.cs
index 911ecbfe5..1837628ab 100644
--- a/src/Web/Grand.Web/Components/GetCoordinate.cs
+++ b/src/Web/Grand.Web/Components/GetCoordinate.cs
@@ -1,10 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Domain.Customers;
+using Grand.Domain.Customers;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Models.Common;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class GetCoordinateViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/HomePageBestSellers.cs b/src/Web/Grand.Web/Components/HomePageBestSellers.cs
index 594a431ec..421a89afb 100644
--- a/src/Web/Grand.Web/Components/HomePageBestSellers.cs
+++ b/src/Web/Grand.Web/Components/HomePageBestSellers.cs
@@ -1,11 +1,12 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.System.Reports;
+using Grand.Domain.Catalog;
+using Grand.Domain.Payments;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
-using Grand.Domain.Catalog;
using Grand.Web.Common.Components;
-using Grand.Web.Features.Models.Products;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Products;
using MediatR;
using Microsoft.AspNetCore.Mvc;
@@ -60,7 +61,7 @@ namespace Grand.Web.Components
var report = await _cacheBase.GetAsync(string.Format(CacheKeyConst.HOMEPAGE_BESTSELLERS_IDS_KEY, _workContext.CurrentStore.Id), async () =>
await _orderReportService.BestSellersReport(
createdFromUtc: fromdate,
- ps: Domain.Payments.PaymentStatus.Paid,
+ ps: PaymentStatus.Paid,
storeId: _workContext.CurrentStore.Id,
pageSize: _catalogSettings.NumberOfBestsellersOnHomepage));
@@ -78,10 +79,9 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
ProductThumbPictureSize = productThumbPictureSize,
- Products = products.Take(_catalogSettings.NumberOfBestsellersOnHomepage),
+ Products = products.Take(_catalogSettings.NumberOfBestsellersOnHomepage)
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/HomePageBlog.cs b/src/Web/Grand.Web/Components/HomePageBlog.cs
index 3a4a6be28..831560a44 100644
--- a/src/Web/Grand.Web/Components/HomePageBlog.cs
+++ b/src/Web/Grand.Web/Components/HomePageBlog.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Blogs;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class HomePageBlogViewComponent : BaseViewComponent
{
diff --git a/src/Web/Grand.Web/Components/HomePageBrands.cs b/src/Web/Grand.Web/Components/HomePageBrands.cs
index 557c9da08..a98707060 100644
--- a/src/Web/Grand.Web/Components/HomePageBrands.cs
+++ b/src/Web/Grand.Web/Components/HomePageBrands.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class HomePageBrandsViewComponent : BaseViewComponent
{
@@ -21,16 +21,13 @@ namespace Grand.Web.ViewComponents
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetHomepageBrands() {
+ var model = await _mediator.Send(new GetHomepageBrands {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Any())
- return Content("");
-
- return View(model);
+ return !model.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/HomePageCategories.cs b/src/Web/Grand.Web/Components/HomePageCategories.cs
index 44c68ae98..8d4653532 100644
--- a/src/Web/Grand.Web/Components/HomePageCategories.cs
+++ b/src/Web/Grand.Web/Components/HomePageCategories.cs
@@ -31,16 +31,13 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetHomepageCategory() {
+ var model = await _mediator.Send(new GetHomepageCategory {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Any())
- return Content("");
-
- return View(model);
+ return !model.Any() ? Content("") : View(model);
}
#endregion
diff --git a/src/Web/Grand.Web/Components/HomePageCollections.cs b/src/Web/Grand.Web/Components/HomePageCollections.cs
index 90e82683d..9b65138fb 100644
--- a/src/Web/Grand.Web/Components/HomePageCollections.cs
+++ b/src/Web/Grand.Web/Components/HomePageCollections.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class HomePageCollectionsViewComponent : BaseViewComponent
{
@@ -21,16 +21,13 @@ namespace Grand.Web.ViewComponents
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetHomepageCollections() {
+ var model = await _mediator.Send(new GetHomepageCollections {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Any())
- return Content("");
-
- return View(model);
+ return !model.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/HomePageNewProducts.cs b/src/Web/Grand.Web/Components/HomePageNewProducts.cs
index 7d4413dcc..3622cf02f 100644
--- a/src/Web/Grand.Web/Components/HomePageNewProducts.cs
+++ b/src/Web/Grand.Web/Components/HomePageNewProducts.cs
@@ -1,10 +1,10 @@
-using Grand.Infrastructure;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Components
{
@@ -39,7 +39,7 @@ namespace Grand.Web.Components
if (!_catalogSettings.NewProductsOnHomePage)
return Content("");
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = (await _mediator.Send(new GetSearchProductsQuery {
Customer = _workContext.CurrentCustomer,
StoreId = _workContext.CurrentStore.Id,
VisibleIndividuallyOnly = true,
@@ -51,12 +51,12 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/HomePageNews.cs b/src/Web/Grand.Web/Components/HomePageNews.cs
index f7d7d7432..ebb53ce1d 100644
--- a/src/Web/Grand.Web/Components/HomePageNews.cs
+++ b/src/Web/Grand.Web/Components/HomePageNews.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.News;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class HomePageNewsViewComponent : BaseViewComponent
{
@@ -23,10 +23,7 @@ namespace Grand.Web.ViewComponents
return Content("");
var model = await _mediator.Send(new GetHomePageNewsItems());
- if (!model.NewsItems.Any())
- return Content("");
-
- return View(model);
+ return !model.NewsItems.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/HomePageProducts.cs b/src/Web/Grand.Web/Components/HomePageProducts.cs
index 092bcad06..78ddebc64 100644
--- a/src/Web/Grand.Web/Components/HomePageProducts.cs
+++ b/src/Web/Grand.Web/Components/HomePageProducts.cs
@@ -1,10 +1,9 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Domain.Catalog;
-using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Web.Common.Components;
-using Grand.Web.Features.Models.Products;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Products;
using MediatR;
using Microsoft.AspNetCore.Mvc;
@@ -17,7 +16,6 @@ namespace Grand.Web.Components
private readonly IProductService _productService;
private readonly IMediator _mediator;
private readonly ICacheBase _cacheBase;
- private readonly IWorkContext _workContext;
private readonly CatalogSettings _catalogSettings;
#endregion
@@ -27,13 +25,11 @@ namespace Grand.Web.Components
IProductService productService,
IMediator mediator,
ICacheBase cacheBase,
- IWorkContext workContext,
CatalogSettings catalogSettings)
{
_productService = productService;
_mediator = mediator;
_cacheBase = cacheBase;
- _workContext = workContext;
_catalogSettings = catalogSettings;
}
@@ -51,13 +47,12 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/KnowledgebaseCategories.cs b/src/Web/Grand.Web/Components/KnowledgebaseCategories.cs
index 8c08ce87e..6d90cd730 100644
--- a/src/Web/Grand.Web/Components/KnowledgebaseCategories.cs
+++ b/src/Web/Grand.Web/Components/KnowledgebaseCategories.cs
@@ -1,12 +1,12 @@
-using Grand.Infrastructure;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Domain.Knowledgebase;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Models.Knowledgebase;
using Microsoft.AspNetCore.Mvc;
-using Grand.Business.Core.Extensions;
-using Grand.Business.Core.Interfaces.Cms;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class KnowledgebaseCategories : BaseViewComponent
{
@@ -30,21 +30,19 @@ namespace Grand.Web.ViewComponents
foreach (var category in categories)
{
- if (string.IsNullOrEmpty(category.ParentCategoryId))
+ if (!string.IsNullOrEmpty(category.ParentCategoryId)) continue;
+ var newNode = new KnowledgebaseCategoryModel
{
- var newNode = new KnowledgebaseCategoryModel
- {
- Id = category.Id,
- Name = category.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id),
- Children = new List<KnowledgebaseCategoryModel>(),
- IsCurrent = model.CurrentCategoryId == category.Id,
- SeName = category.GetTranslation(y => y.SeName, _workContext.WorkingLanguage.Id)
- };
+ Id = category.Id,
+ Name = category.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id),
+ Children = new List<KnowledgebaseCategoryModel>(),
+ IsCurrent = model.CurrentCategoryId == category.Id,
+ SeName = category.GetTranslation(y => y.SeName, _workContext.WorkingLanguage.Id)
+ };
- FillChildNodes(newNode, categories, model.CurrentCategoryId);
+ FillChildNodes(newNode, categories, model.CurrentCategoryId);
- model.Categories.Add(newNode);
- }
+ model.Categories.Add(newNode);
}
return View(model);
@@ -78,11 +76,9 @@ namespace Grand.Web.ViewComponents
public void MarkParentsAsCurrent(KnowledgebaseCategoryModel node)
{
- if (node.Parent != null)
- {
- node.Parent.IsCurrent = true;
- MarkParentsAsCurrent(node.Parent);
- }
+ if (node.Parent == null) return;
+ node.Parent.IsCurrent = true;
+ MarkParentsAsCurrent(node.Parent);
}
}
}
diff --git a/src/Web/Grand.Web/Components/KnowledgebaseHomepageArticles.cs b/src/Web/Grand.Web/Components/KnowledgebaseHomepageArticles.cs
index 3586fca80..84fe62b96 100644
--- a/src/Web/Grand.Web/Components/KnowledgebaseHomepageArticles.cs
+++ b/src/Web/Grand.Web/Components/KnowledgebaseHomepageArticles.cs
@@ -1,10 +1,10 @@
-using Grand.Infrastructure;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Domain.Knowledgebase;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Models.Knowledgebase;
using Microsoft.AspNetCore.Mvc;
-using Grand.Business.Core.Extensions;
-using Grand.Business.Core.Interfaces.Cms;
namespace Grand.Web.Components
{
diff --git a/src/Web/Grand.Web/Components/Menu.cs b/src/Web/Grand.Web/Components/Menu.cs
index ebfbdde7d..1271783c1 100644
--- a/src/Web/Grand.Web/Components/Menu.cs
+++ b/src/Web/Grand.Web/Components/Menu.cs
@@ -6,7 +6,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class MenuViewComponent : BaseViewComponent
{
@@ -29,8 +29,7 @@ namespace Grand.Web.ViewComponents
if (!await _permissionService.Authorize(StandardPermission.PublicStoreAllowNavigation, _workContext.CurrentCustomer))
return Content("");
- var model = await _mediator.Send(new GetMenu()
- {
+ var model = await _mediator.Send(new GetMenu {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
diff --git a/src/Web/Grand.Web/Components/PageBlock.cs b/src/Web/Grand.Web/Components/PageBlock.cs
index 641f3a83c..4e69f82d1 100644
--- a/src/Web/Grand.Web/Components/PageBlock.cs
+++ b/src/Web/Grand.Web/Components/PageBlock.cs
@@ -27,11 +27,8 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(string systemName)
{
- var model = await _mediator.Send(new GetPageBlock() { SystemName = systemName });
- if (model == null)
- return Content("");
-
- return View(model);
+ var model = await _mediator.Send(new GetPageBlock { SystemName = systemName });
+ return model == null ? Content("") : View(model);
}
#endregion
diff --git a/src/Web/Grand.Web/Components/Partial.cs b/src/Web/Grand.Web/Components/Partial.cs
index 2e3f7e87d..b7a9b8f77 100644
--- a/src/Web/Grand.Web/Components/Partial.cs
+++ b/src/Web/Grand.Web/Components/Partial.cs
@@ -1,15 +1,10 @@
using Grand.Web.Common.Components;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class PartialViewComponent : BaseViewComponent
{
-
- public PartialViewComponent()
- {
- }
-
public IViewComponentResult Invoke(string partialName, object additionalData = null)
{
return View(partialName, additionalData);
diff --git a/src/Web/Grand.Web/Components/PersonalizedProducts.cs b/src/Web/Grand.Web/Components/PersonalizedProducts.cs
index b5e782c69..02bf18aef 100644
--- a/src/Web/Grand.Web/Components/PersonalizedProducts.cs
+++ b/src/Web/Grand.Web/Components/PersonalizedProducts.cs
@@ -1,6 +1,6 @@
using Grand.Business.Core.Queries.Catalog;
-using Grand.Infrastructure;
using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
@@ -39,17 +39,16 @@ namespace Grand.Web.Components
if (!_catalogSettings.PersonalizedProductsEnabled || _catalogSettings.PersonalizedProductsNumber == 0)
return Content("");
- var products = await _mediator.Send(new GetPersonalizedProductsQuery() { CustomerId = _workContext.CurrentCustomer.Id, ProductsNumber = _catalogSettings.PersonalizedProductsNumber });
+ var products = await _mediator.Send(new GetPersonalizedProductsQuery { CustomerId = _workContext.CurrentCustomer.Id, ProductsNumber = _catalogSettings.PersonalizedProductsNumber });
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/PopularProductTags.cs b/src/Web/Grand.Web/Components/PopularProductTags.cs
index 2e19df2c8..7b5789841 100644
--- a/src/Web/Grand.Web/Components/PopularProductTags.cs
+++ b/src/Web/Grand.Web/Components/PopularProductTags.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class PopularProductTagsViewComponent : BaseViewComponent
{
@@ -19,15 +19,11 @@ namespace Grand.Web.ViewComponents
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetPopularProductTags() {
+ var model = await _mediator.Send(new GetPopularProductTags {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
- if (!model.Tags.Any())
- return Content("");
-
- return View(model);
-
+ return !model.Tags.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/ProductEmailAFriend.cs b/src/Web/Grand.Web/Components/ProductEmailAFriend.cs
index 230d7c187..247d976ce 100644
--- a/src/Web/Grand.Web/Components/ProductEmailAFriend.cs
+++ b/src/Web/Grand.Web/Components/ProductEmailAFriend.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Domain.Catalog;
using Grand.Infrastructure;
using Grand.Web.Common.Components;
@@ -40,15 +40,16 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(string productId)
{
var product = await _productService.GetProductById(productId);
- if (product == null || !product.Published || !_catalogSettings.EmailAFriendEnabled)
+ if (product is not { Published: true } || !_catalogSettings.EmailAFriendEnabled)
return Content("");
- var model = new ProductEmailAFriendModel();
- model.ProductId = product.Id;
- model.ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);
- model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id);
- model.YourEmailAddress = _workContext.CurrentCustomer.Email;
- model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage;
+ var model = new ProductEmailAFriendModel {
+ ProductId = product.Id,
+ ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id),
+ YourEmailAddress = _workContext.CurrentCustomer.Email,
+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnEmailProductToFriendPage
+ };
return View(model);
diff --git a/src/Web/Grand.Web/Components/ProductReviews.cs b/src/Web/Grand.Web/Components/ProductReviews.cs
index 8e282d0fb..348e3a51b 100644
--- a/src/Web/Grand.Web/Components/ProductReviews.cs
+++ b/src/Web/Grand.Web/Components/ProductReviews.cs
@@ -1,6 +1,6 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Infrastructure;
using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
@@ -38,11 +38,10 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(string productId)
{
var product = await _productService.GetProductById(productId);
- if (product == null || !product.Published || !product.AllowCustomerReviews)
+ if (product is not { Published: true } || !product.AllowCustomerReviews)
return Content("");
- var model = await _mediator.Send(new GetProductReviews()
- {
+ var model = await _mediator.Send(new GetProductReviews {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Product = product,
diff --git a/src/Web/Grand.Web/Components/ProductsAlsoPurchased.cs b/src/Web/Grand.Web/Components/ProductsAlsoPurchased.cs
index 10264589b..e33795837 100644
--- a/src/Web/Grand.Web/Components/ProductsAlsoPurchased.cs
+++ b/src/Web/Grand.Web/Components/ProductsAlsoPurchased.cs
@@ -1,11 +1,11 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.System.Reports;
+using Grand.Domain.Catalog;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
-using Grand.Domain.Catalog;
using Grand.Web.Common.Components;
-using Grand.Web.Features.Models.Products;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Products;
using MediatR;
using Microsoft.AspNetCore.Mvc;
@@ -64,12 +64,11 @@ namespace Grand.Web.Components
return Content("");
//prepare model
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/PushNotificationsRegistration.cs b/src/Web/Grand.Web/Components/PushNotificationsRegistration.cs
index f7137de45..6deb43e89 100644
--- a/src/Web/Grand.Web/Components/PushNotificationsRegistration.cs
+++ b/src/Web/Grand.Web/Components/PushNotificationsRegistration.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure;
-using Grand.Domain.PushNotifications;
+using Grand.Domain.PushNotifications;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Models.PushNotifications;
using Microsoft.AspNetCore.Mvc;
@@ -31,15 +31,13 @@ namespace Grand.Web.Components
DatabaseUrl = _pushNotificationsSettings.DatabaseUrl,
AppId = _pushNotificationsSettings.AppId
};
- if (_pushNotificationsSettings.Enabled)
- {
- if (!_pushNotificationsSettings.AllowGuestNotifications && string.IsNullOrEmpty(_workContext.CurrentCustomer.Email))
- return Content("");
+ if (!_pushNotificationsSettings.Enabled) return Content("");
+
+ if (!_pushNotificationsSettings.AllowGuestNotifications && string.IsNullOrEmpty(_workContext.CurrentCustomer.Email))
+ return Content("");
- return View(model);
- }
+ return View(model);
- return Content("");
}
}
}
diff --git a/src/Web/Grand.Web/Components/RecentlyViewedProductsBlock.cs b/src/Web/Grand.Web/Components/RecentlyViewedProductsBlock.cs
index 88126f29e..cda35163b 100644
--- a/src/Web/Grand.Web/Components/RecentlyViewedProductsBlock.cs
+++ b/src/Web/Grand.Web/Components/RecentlyViewedProductsBlock.cs
@@ -1,6 +1,6 @@
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Infrastructure;
using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
@@ -47,8 +47,7 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = preparePictureModel,
PreparePriceModel = preparePriceModel.GetValueOrDefault(),
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Components/RecommendedProducts.cs b/src/Web/Grand.Web/Components/RecommendedProducts.cs
index 505e57910..391ff6e4f 100644
--- a/src/Web/Grand.Web/Components/RecommendedProducts.cs
+++ b/src/Web/Grand.Web/Components/RecommendedProducts.cs
@@ -43,7 +43,7 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Components/RelatedProducts.cs b/src/Web/Grand.Web/Components/RelatedProducts.cs
index ddac5b00e..785d6dced 100644
--- a/src/Web/Grand.Web/Components/RelatedProducts.cs
+++ b/src/Web/Grand.Web/Components/RelatedProducts.cs
@@ -39,7 +39,7 @@ namespace Grand.Web.Components
//load products
var products = await _productService.GetProductsByIds(productIds);
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Components/SearchBox.cs b/src/Web/Grand.Web/Components/SearchBox.cs
index 09dab97a7..df778eb6e 100644
--- a/src/Web/Grand.Web/Components/SearchBox.cs
+++ b/src/Web/Grand.Web/Components/SearchBox.cs
@@ -4,7 +4,7 @@ using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class SearchBoxViewComponent : BaseViewComponent
{
@@ -21,7 +21,7 @@ namespace Grand.Web.ViewComponents
public async Task<IViewComponentResult> InvokeAsync()
{
- var model = await _mediator.Send(new GetSearchBox() {
+ var model = await _mediator.Send(new GetSearchBox {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Language = _workContext.WorkingLanguage
diff --git a/src/Web/Grand.Web/Components/SimilarProducts.cs b/src/Web/Grand.Web/Components/SimilarProducts.cs
index 17aaba970..995576cc1 100644
--- a/src/Web/Grand.Web/Components/SimilarProducts.cs
+++ b/src/Web/Grand.Web/Components/SimilarProducts.cs
@@ -42,7 +42,7 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
diff --git a/src/Web/Grand.Web/Components/SuggestedProducts.cs b/src/Web/Grand.Web/Components/SuggestedProducts.cs
index dff179bc0..8a4d620bd 100644
--- a/src/Web/Grand.Web/Components/SuggestedProducts.cs
+++ b/src/Web/Grand.Web/Components/SuggestedProducts.cs
@@ -1,6 +1,6 @@
using Grand.Business.Core.Queries.Catalog;
-using Grand.Infrastructure;
using Grand.Domain.Catalog;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Products;
using MediatR;
@@ -39,8 +39,7 @@ namespace Grand.Web.Components
if (!_catalogSettings.SuggestedProductsEnabled || _catalogSettings.SuggestedProductsNumber == 0)
return Content("");
- var products = await _mediator.Send(new GetSuggestedProductsQuery()
- {
+ var products = await _mediator.Send(new GetSuggestedProductsQuery {
CustomerTagIds = _workContext.CurrentCustomer.CustomerTags.ToArray(),
ProductsNumber = _catalogSettings.SuggestedProductsNumber
});
@@ -48,13 +47,12 @@ namespace Grand.Web.Components
if (!products.Any())
return Content("");
- var model = await _mediator.Send(new GetProductOverview()
- {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
ProductThumbPictureSize = productThumbPictureSize,
- Products = products,
+ Products = products
});
return View(model);
diff --git a/src/Web/Grand.Web/Components/VendorContact.cs b/src/Web/Grand.Web/Components/VendorContact.cs
index 5839feba4..d07f8a7aa 100644
--- a/src/Web/Grand.Web/Components/VendorContact.cs
+++ b/src/Web/Grand.Web/Components/VendorContact.cs
@@ -47,7 +47,7 @@ namespace Grand.Web.Components
return Content("");
var vendor = await _vendorService.GetVendorById(vendorId);
- if (vendor == null || !vendor.Active || vendor.Deleted)
+ if (vendor is not { Active: true } || vendor.Deleted)
return Content("");
var model = new ContactVendorModel {
diff --git a/src/Web/Grand.Web/Components/VendorNavigation.cs b/src/Web/Grand.Web/Components/VendorNavigation.cs
index 33f8dd35b..a5b4d7fad 100644
--- a/src/Web/Grand.Web/Components/VendorNavigation.cs
+++ b/src/Web/Grand.Web/Components/VendorNavigation.cs
@@ -1,11 +1,11 @@
-using Grand.Infrastructure;
-using Grand.Domain.Vendors;
+using Grand.Domain.Vendors;
+using Grand.Infrastructure;
using Grand.Web.Common.Components;
using Grand.Web.Features.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class VendorNavigationViewComponent : BaseViewComponent
{
@@ -28,14 +28,11 @@ namespace Grand.Web.ViewComponents
if (_vendorSettings.VendorsBlockItemsToDisplay == 0)
return Content("");
- var model = await _mediator.Send(new GetVendorNavigation() {
+ var model = await _mediator.Send(new GetVendorNavigation {
Language = _workContext.WorkingLanguage
});
- if (!model.Vendors.Any())
- return Content("");
-
- return View(model);
+ return !model.Vendors.Any() ? Content("") : View(model);
}
}
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Components/VendorReviews.cs b/src/Web/Grand.Web/Components/VendorReviews.cs
index 722a7654d..4a59bbd10 100644
--- a/src/Web/Grand.Web/Components/VendorReviews.cs
+++ b/src/Web/Grand.Web/Components/VendorReviews.cs
@@ -1,5 +1,4 @@
using Grand.Business.Core.Interfaces.Common.Directory;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Domain.Vendors;
using Grand.Infrastructure;
@@ -17,7 +16,6 @@ namespace Grand.Web.Components
private readonly IGroupService _groupService;
private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
- private readonly ITranslationService _translationService;
private readonly VendorSettings _vendorSettings;
#endregion
@@ -29,14 +27,12 @@ namespace Grand.Web.Components
IGroupService groupService,
IWorkContext workContext,
IMediator mediator,
- ITranslationService translationService,
VendorSettings vendorSettings)
{
_vendorService = vendorService;
_groupService = groupService;
_workContext = workContext;
_mediator = mediator;
- _translationService = translationService;
_vendorSettings = vendorSettings;
}
@@ -47,10 +43,10 @@ namespace Grand.Web.Components
public async Task<IViewComponentResult> InvokeAsync(string vendorId)
{
var vendor = await _vendorService.GetVendorById(vendorId);
- if (vendor == null || !vendor.Active || !vendor.AllowCustomerReviews)
+ if (vendor is not { Active: true } || !vendor.AllowCustomerReviews)
return Content("");
- var model = await _mediator.Send(new GetVendorReviews() { Vendor = vendor });
+ var model = await _mediator.Send(new GetVendorReviews { Vendor = vendor });
//only registered users can leave reviews
if (await _groupService.IsGuest(_workContext.CurrentCustomer) && !_vendorSettings.AllowAnonymousUsersToReviewVendor)
diff --git a/src/Web/Grand.Web/Components/Widget.cs b/src/Web/Grand.Web/Components/Widget.cs
index 7103236fc..3b1fb8ff4 100644
--- a/src/Web/Grand.Web/Components/Widget.cs
+++ b/src/Web/Grand.Web/Components/Widget.cs
@@ -7,7 +7,7 @@ using Grand.Web.Events.Cache;
using Grand.Web.Models.Cms;
using Microsoft.AspNetCore.Mvc;
-namespace Grand.Web.ViewComponents
+namespace Grand.Web.Components
{
public class WidgetViewComponent : BaseViewComponent
{
@@ -49,11 +49,12 @@ namespace Grand.Web.ViewComponents
if (!cachedModel.Any())
return Content("");
- if (additionalData != null)
- foreach (var item in cachedModel)
- {
- item.AdditionalData = additionalData;
- }
+ if (additionalData == null) return View(cachedModel);
+
+ foreach (var item in cachedModel)
+ {
+ item.AdditionalData = additionalData;
+ }
return View(cachedModel);
}
diff --git a/src/Web/Grand.Web/Controllers/AccountController.cs b/src/Web/Grand.Web/Controllers/AccountController.cs
index 7ab6771f2..aced5c3f5 100644
--- a/src/Web/Grand.Web/Controllers/AccountController.cs
+++ b/src/Web/Grand.Web/Controllers/AccountController.cs
@@ -1,13 +1,13 @@
-using Grand.Business.Core.Interfaces.Authentication;
+using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Authentication;
using Grand.Business.Core.Interfaces.Common.Addresses;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Interfaces.Customers;
+using Grand.Business.Core.Interfaces.Messages;
using Grand.Business.Core.Queries.Customers;
using Grand.Business.Core.Utilities.Customers;
-using Grand.Business.Core.Interfaces.Messages;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Stores;
@@ -85,10 +85,11 @@ namespace Grand.Web.Controllers
[ClosedStore(true)]
public virtual IActionResult Login(bool? checkoutAsGuest)
{
- var model = new LoginModel();
- model.UsernamesEnabled = _customerSettings.UsernamesEnabled;
- model.CheckoutAsGuest = checkoutAsGuest.GetValueOrDefault();
- model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnLoginPage;
+ var model = new LoginModel {
+ UsernamesEnabled = _customerSettings.UsernamesEnabled,
+ CheckoutAsGuest = checkoutAsGuest.GetValueOrDefault(),
+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnLoginPage
+ };
return View(model);
}
@@ -177,10 +178,10 @@ namespace Grand.Web.Controllers
if (_customerSettings.TwoFactorAuthenticationType != TwoFactorAuthenticationType.AppVerification)
{
- await _mediator.Send(new GetTwoFactorAuthentication() {
+ await _mediator.Send(new GetTwoFactorAuthentication {
Customer = customer,
Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
}
@@ -276,8 +277,9 @@ namespace Grand.Web.Controllers
[PublicStore(true)]
public virtual IActionResult PasswordRecovery()
{
- var model = new PasswordRecoveryModel();
- model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnPasswordRecoveryPage;
+ var model = new PasswordRecoveryModel {
+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnPasswordRecoveryPage
+ };
return View(model);
}
@@ -293,23 +295,21 @@ namespace Grand.Web.Controllers
ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_translationService));
}
- if (ModelState.IsValid)
+ if (!ModelState.IsValid) return View(model);
+
+ var customer = await _customerService.GetCustomerByEmail(model.Email);
+ if (customer is { Active: true, Deleted: false })
{
- var customer = await _customerService.GetCustomerByEmail(model.Email);
- if (customer != null && customer.Active && !customer.Deleted)
- {
- await _mediator.Send(new PasswordRecoverySendCommand() { Customer = customer, Store = _workContext.CurrentStore, Language = _workContext.WorkingLanguage, Model = model });
-
- model.Result = _translationService.GetResource("Account.PasswordRecovery.EmailHasBeenSent");
- model.Send = true;
- }
- else
- {
- model.Result = _translationService.GetResource("Account.PasswordRecovery.EmailNotFound");
- }
+ await _mediator.Send(new PasswordRecoverySendCommand { Customer = customer, Store = _workContext.CurrentStore, Language = _workContext.WorkingLanguage, Model = model });
- return View(model);
+ model.Result = _translationService.GetResource("Account.PasswordRecovery.EmailHasBeenSent");
+ model.Send = true;
+ }
+ else
+ {
+ model.Result = _translationService.GetResource("Account.PasswordRecovery.EmailNotFound");
}
+
return View(model);
}
@@ -320,7 +320,7 @@ namespace Grand.Web.Controllers
if (customer == null)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetPasswordRecoveryConfirm() { Customer = customer, Token = token });
+ var model = await _mediator.Send(new GetPasswordRecoveryConfirm { Customer = customer, Token = token });
return View(model);
}
@@ -350,24 +350,22 @@ namespace Grand.Web.Controllers
return View(model);
}
- if (ModelState.IsValid)
+ if (!ModelState.IsValid) return View(model);
+
+ var response = await _customerManagerService.ChangePassword(new ChangePasswordRequest(email,
+ false, _customerSettings.DefaultPasswordFormat, model.NewPassword));
+ if (response.Success)
{
- var response = await _customerManagerService.ChangePassword(new ChangePasswordRequest(email,
- false, _customerSettings.DefaultPasswordFormat, model.NewPassword));
- if (response.Success)
- {
- await _userFieldService.SaveField(customer, SystemCustomerFieldNames.PasswordRecoveryToken, "");
+ await _userFieldService.SaveField(customer, SystemCustomerFieldNames.PasswordRecoveryToken, "");
- model.DisablePasswordChanging = true;
- model.Result = _translationService.GetResource("Account.PasswordRecovery.PasswordHasBeenChanged");
- }
- else
- {
- model.Result = response.Errors.FirstOrDefault();
- }
-
- return View(model);
+ model.DisablePasswordChanging = true;
+ model.Result = _translationService.GetResource("Account.PasswordRecovery.PasswordHasBeenChanged");
}
+ else
+ {
+ model.Result = response.Errors.FirstOrDefault();
+ }
+
return View(model);
}
@@ -389,7 +387,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
}
- var model = await _mediator.Send(new GetRegister() {
+ var model = await _mediator.Send(new GetRegister {
Customer = _workContext.CurrentCustomer,
ExcludeProperties = false,
Language = _workContext.WorkingLanguage,
@@ -418,7 +416,7 @@ namespace Grand.Web.Controllers
}
//custom customer attributes
- var customerAttributes = await _mediator.Send(new GetParseCustomAttributes() { SelectedAttributes = model.SelectedAttributes });
+ var customerAttributes = await _mediator.Send(new GetParseCustomAttributes { SelectedAttributes = model.SelectedAttributes });
var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes);
foreach (var error in customerAttributeWarnings)
{
@@ -431,7 +429,7 @@ namespace Grand.Web.Controllers
ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_translationService));
}
- if (ModelState.IsValid && ModelState.ErrorCount == 0)
+ if (ModelState is { IsValid: true, ErrorCount: 0 })
{
if (_customerSettings.UsernamesEnabled && model.Username != null)
{
@@ -445,7 +443,7 @@ namespace Grand.Web.Controllers
var registrationResult = await _customerManagerService.RegisterCustomer(registrationRequest);
if (registrationResult.Success)
{
- await _mediator.Send(new CustomerRegisteredCommand() {
+ await _mediator.Send(new CustomerRegisteredCommand {
Customer = _workContext.CurrentCustomer,
CustomerAttributes = customerAttributes,
Model = model,
@@ -499,7 +497,7 @@ namespace Grand.Web.Controllers
}
//If we got this far, something failed, redisplay form
- model = await _mediator.Send(new GetRegister() {
+ model = await _mediator.Send(new GetRegister {
Customer = _workContext.CurrentCustomer,
ExcludeProperties = true,
Language = _workContext.WorkingLanguage,
@@ -529,8 +527,6 @@ namespace Grand.Web.Controllers
case UserRegistrationType.EmailValidation:
resultText = _translationService.GetResource("Account.Register.Result.EmailValidation");
break;
- default:
- break;
}
var model = new RegisterResultModel {
Result = resultText
@@ -547,23 +543,20 @@ namespace Grand.Web.Controllers
var usernameAvailable = false;
var statusText = _translationService.GetResource("Account.CheckUsernameAvailability.NotAvailable");
- if (_customerSettings.UsernamesEnabled && !String.IsNullOrWhiteSpace(username))
+ if (!_customerSettings.UsernamesEnabled || string.IsNullOrWhiteSpace(username))
+ return Json(new { Available = usernameAvailable, Text = statusText });
+
+ if (_workContext.CurrentCustomer is { Username: { } } &&
+ _workContext.CurrentCustomer.Username.Equals(username, StringComparison.OrdinalIgnoreCase))
{
- if (_workContext.CurrentCustomer != null &&
- _workContext.CurrentCustomer.Username != null &&
- _workContext.CurrentCustomer.Username.Equals(username, StringComparison.OrdinalIgnoreCase))
- {
- statusText = _translationService.GetResource("Account.CheckUsernameAvailability.CurrentUsername");
- }
- else
- {
- var customer = await _customerService.GetCustomerByUsername(username);
- if (customer == null)
- {
- statusText = _translationService.GetResource("Account.CheckUsernameAvailability.Available");
- usernameAvailable = true;
- }
- }
+ statusText = _translationService.GetResource("Account.CheckUsernameAvailability.CurrentUsername");
+ }
+ else
+ {
+ var customer = await _customerService.GetCustomerByUsername(username);
+ if (customer != null) return Json(new { Available = usernameAvailable, Text = statusText });
+ statusText = _translationService.GetResource("Account.CheckUsernameAvailability.Available");
+ usernameAvailable = true;
}
return Json(new { Available = usernameAvailable, Text = statusText });
@@ -578,7 +571,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var cToken = await customer.GetUserField<string>(_userFieldService, SystemCustomerFieldNames.AccountActivationToken);
- if (String.IsNullOrEmpty(cToken))
+ if (string.IsNullOrEmpty(cToken))
return RedirectToRoute("HomePage");
if (!cToken.Equals(token, StringComparison.OrdinalIgnoreCase))
@@ -608,11 +601,11 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsRegistered(_workContext.CurrentCustomer))
return Challenge();
- var model = await _mediator.Send(new GetInfo() {
+ var model = await _mediator.Send(new GetInfo {
Customer = _workContext.CurrentCustomer,
ExcludeProperties = false,
Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
return View(model);
}
@@ -626,7 +619,7 @@ namespace Grand.Web.Controllers
return Challenge();
//custom customer attributes
- var customerAttributes = await _mediator.Send(new GetParseCustomAttributes() { SelectedAttributes = model.SelectedAttributes, CustomerCustomAttribute = _workContext.CurrentCustomer.Attributes.ToList() });
+ var customerAttributes = await _mediator.Send(new GetParseCustomAttributes { SelectedAttributes = model.SelectedAttributes, CustomerCustomAttribute = _workContext.CurrentCustomer.Attributes.ToList() });
var customerAttributeWarnings = await customerAttributeParser.GetAttributeWarnings(customerAttributes);
foreach (var error in customerAttributeWarnings)
@@ -638,7 +631,7 @@ namespace Grand.Web.Controllers
{
if (ModelState is { IsValid: true, ErrorCount: 0 })
{
- await _mediator.Send(new UpdateCustomerInfoCommand() {
+ await _mediator.Send(new UpdateCustomerInfoCommand {
Customer = _workContext.CurrentCustomer,
CustomerAttributes = customerAttributes,
Model = model,
@@ -654,7 +647,7 @@ namespace Grand.Web.Controllers
}
//If we got this far, something failed, redisplay form
- model = await _mediator.Send(new GetInfo() {
+ model = await _mediator.Send(new GetInfo {
Model = model,
Customer = _workContext.CurrentCustomer,
ExcludeProperties = true,
@@ -681,14 +674,14 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.Action("Info"),
+ redirect = Url.Action("Info")
});
}
await openAuthenticationService.DeleteExternalAuthentication(ear);
return Json(new
{
- redirect = Url.Action("Info"),
+ redirect = Url.Action("Info")
});
}
@@ -715,7 +708,7 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsRegistered(_workContext.CurrentCustomer))
return Challenge();
- var model = await _mediator.Send(new GetAddressList() {
+ var model = await _mediator.Send(new GetAddressList {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -734,15 +727,16 @@ namespace Grand.Web.Controllers
//find address (ensure that it belongs to the current customer)
var address = customer.Addresses.FirstOrDefault(a => a.Id == addressId);
- if (address != null)
- {
- customer.RemoveAddress(address);
- await _customerService.DeleteAddress(address, customer.Id);
- }
+ if (address == null)
+ return Json(new {
+ redirect = Url.RouteUrl("CustomerAddresses")
+ });
+ customer.RemoveAddress(address);
+ await _customerService.DeleteAddress(address, customer.Id);
return Json(new
{
- redirect = Url.RouteUrl("CustomerAddresses"),
+ redirect = Url.RouteUrl("CustomerAddresses")
});
}
@@ -754,7 +748,7 @@ namespace Grand.Web.Controllers
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
var model = new CustomerAddressEditModel {
- Address = await _mediator.Send(new GetAddressModel() {
+ Address = await _mediator.Send(new GetAddressModel {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
Model = null,
@@ -781,14 +775,14 @@ namespace Grand.Web.Controllers
var customer = _workContext.CurrentCustomer;
//custom address attributes
- var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes() { SelectedAttributes = model.Address.SelectedAttributes });
+ var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.Address.SelectedAttributes });
var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes);
foreach (var error in customAttributeWarnings)
{
ModelState.AddModelError("", error);
}
- if (ModelState.IsValid && ModelState.ErrorCount == 0)
+ if (ModelState is { IsValid: true, ErrorCount: 0 })
{
var address = model.Address.ToEntity(_workContext.CurrentCustomer, addressSettings);
address.Attributes = customAttributes;
@@ -801,7 +795,7 @@ namespace Grand.Web.Controllers
}
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
//If we got this far, something failed, redisplay form
- model.Address = await _mediator.Send(new GetAddressModel() {
+ model.Address = await _mediator.Send(new GetAddressModel {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
Model = model.Address,
@@ -828,7 +822,7 @@ namespace Grand.Web.Controllers
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
var model = new CustomerAddressEditModel();
- model.Address = await _mediator.Send(new GetAddressModel() {
+ model.Address = await _mediator.Send(new GetAddressModel {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
Model = model.Address,
@@ -858,7 +852,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("CustomerAddresses");
//custom address attributes
- var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes() { SelectedAttributes = model.Address.SelectedAttributes });
+ var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.Address.SelectedAttributes });
var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes);
foreach (var error in customAttributeWarnings)
{
@@ -880,7 +874,7 @@ namespace Grand.Web.Controllers
}
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
//If we got this far, something failed, redisplay form
- model.Address = await _mediator.Send(new GetAddressModel() {
+ model.Address = await _mediator.Send(new GetAddressModel {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
Model = model.Address,
@@ -906,17 +900,14 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideDownloadableProductsTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetDownloadableProducts() { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore, Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetDownloadableProducts { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore, Language = _workContext.WorkingLanguage });
return View(model);
}
public virtual async Task<IActionResult> UserAgreement(Guid orderItemId)
{
- var model = await _mediator.Send(new GetUserAgreement() { OrderItemId = orderItemId }); ;
- if (model == null)
- return RedirectToRoute("HomePage");
-
- return View(model);
+ var model = await _mediator.Send(new GetUserAgreement { OrderItemId = orderItemId });
+ return model == null ? RedirectToRoute("HomePage") : View(model);
}
#endregion
@@ -930,7 +921,7 @@ namespace Grand.Web.Controllers
var model = new ChangePasswordModel();
- var passwordIsExpired = await _mediator.Send(new GetPasswordIsExpiredQuery() { Customer = _workContext.CurrentCustomer });
+ var passwordIsExpired = await _mediator.Send(new GetPasswordIsExpiredQuery { Customer = _workContext.CurrentCustomer });
if (passwordIsExpired)
ModelState.AddModelError(string.Empty, _translationService.GetResource("Account.ChangePassword.PasswordIsExpired"));
@@ -946,25 +937,24 @@ namespace Grand.Web.Controllers
var customer = _workContext.CurrentCustomer;
- if (ModelState.IsValid)
+ if (!ModelState.IsValid) return View(model);
+
+ var changePasswordRequest = new ChangePasswordRequest(customer.Email,
+ true, _customerSettings.DefaultPasswordFormat, model.NewPassword, model.OldPassword);
+ var changePasswordResult = await _customerManagerService.ChangePassword(changePasswordRequest);
+ if (changePasswordResult.Success)
{
- var changePasswordRequest = new ChangePasswordRequest(customer.Email,
- true, _customerSettings.DefaultPasswordFormat, model.NewPassword, model.OldPassword);
- var changePasswordResult = await _customerManagerService.ChangePassword(changePasswordRequest);
- if (changePasswordResult.Success)
- {
- //sign in
- await _authenticationService.SignIn(customer, true);
+ //sign in
+ await _authenticationService.SignIn(customer, true);
- model.Result = _translationService.GetResource("Account.ChangePassword.Success");
- return View(model);
- }
-
- //errors
- foreach (var error in changePasswordResult.Errors)
- ModelState.AddModelError("", error);
+ model.Result = _translationService.GetResource("Account.ChangePassword.Success");
+ return View(model);
}
+ //errors
+ foreach (var error in changePasswordResult.Errors)
+ ModelState.AddModelError("", error);
+
//If we got this far, something failed, redisplay form
return View(model);
}
@@ -996,45 +986,44 @@ namespace Grand.Web.Controllers
if (!_customerSettings.AllowUsersToDeleteAccount)
return RedirectToRoute("CustomerInfo");
- if (ModelState.IsValid)
- {
- var loginResult = await _customerManagerService.LoginCustomer(_customerSettings.UsernamesEnabled ? _workContext.CurrentCustomer.Username : _workContext.CurrentCustomer.Email, model.Password);
+ if (!ModelState.IsValid) return View(model);
+
+ var loginResult = await _customerManagerService.LoginCustomer(_customerSettings.UsernamesEnabled ? _workContext.CurrentCustomer.Username : _workContext.CurrentCustomer.Email, model.Password);
- switch (loginResult)
+ switch (loginResult)
+ {
+ case CustomerLoginResults.Successful:
{
- case CustomerLoginResults.Successful:
- {
- //delete account
- await _mediator.Send(new DeleteAccountCommand() { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString(), });
+ //delete account
+ await _mediator.Send(new DeleteAccountCommand { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString() });
- //standard logout
- await _authenticationService.SignOut();
+ //standard logout
+ await _authenticationService.SignOut();
- //Show successfull message
- Success(_translationService.GetResource("Account.Delete.Success"));
+ //Show success full message
+ Success(_translationService.GetResource("Account.Delete.Success"));
- return RedirectToRoute("HomePage");
- }
- case CustomerLoginResults.CustomerNotExist:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.CustomerNotExist"));
- break;
- case CustomerLoginResults.Deleted:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.Deleted"));
- break;
- case CustomerLoginResults.NotActive:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.NotActive"));
- break;
- case CustomerLoginResults.NotRegistered:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.NotRegistered"));
- break;
- case CustomerLoginResults.LockedOut:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.LockedOut"));
- break;
- case CustomerLoginResults.WrongPassword:
- default:
- ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials"));
- break;
+ return RedirectToRoute("HomePage");
}
+ case CustomerLoginResults.CustomerNotExist:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.CustomerNotExist"));
+ break;
+ case CustomerLoginResults.Deleted:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.Deleted"));
+ break;
+ case CustomerLoginResults.NotActive:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.NotActive"));
+ break;
+ case CustomerLoginResults.NotRegistered:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.NotRegistered"));
+ break;
+ case CustomerLoginResults.LockedOut:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials.LockedOut"));
+ break;
+ case CustomerLoginResults.WrongPassword:
+ default:
+ ModelState.AddModelError("", _translationService.GetResource("Account.Login.WrongCredentials"));
+ break;
}
//If we got this far, something failed, redisplay form
@@ -1053,7 +1042,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideAuctionsTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetAuctions() { Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetAuctions { Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage });
return View(model);
}
@@ -1070,7 +1059,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideNotesTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetNotes() { Customer = _workContext.CurrentCustomer });
+ var model = await _mediator.Send(new GetNotes { Customer = _workContext.CurrentCustomer });
return View(model);
}
@@ -1087,7 +1076,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideDocumentsTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetDocuments() {
+ var model = await _mediator.Send(new GetDocuments {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Command = command
@@ -1108,7 +1097,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideReviewsTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetReviews() { Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetReviews { Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage });
return View(model);
}
@@ -1128,10 +1117,10 @@ namespace Grand.Web.Controllers
if (_workContext.CurrentCustomer.GetUserFieldFromEntity<bool>(SystemCustomerFieldNames.TwoFactorEnabled))
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetTwoFactorAuthentication() {
+ var model = await _mediator.Send(new GetTwoFactorAuthentication {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
return View(model);
}
@@ -1182,13 +1171,13 @@ namespace Grand.Web.Controllers
if (!_workContext.CurrentCustomer.GetUserFieldFromEntity<bool>(SystemCustomerFieldNames.TwoFactorEnabled))
return RedirectToRoute("CustomerInfo");
- _ = await _mediator.Send(new GetTwoFactorAuthentication() {
+ _ = await _mediator.Send(new GetTwoFactorAuthentication {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
- var model = new CustomerInfoModel.TwoFactorAuthorizationModel() {
+ var model = new CustomerInfoModel.TwoFactorAuthorizationModel {
TwoFactorAuthenticationType = _customerSettings.TwoFactorAuthenticationType
};
return View(model);
@@ -1244,7 +1233,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideCoursesTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetCourses() { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore });
+ var model = await _mediator.Send(new GetCourses { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore });
return View(model);
}
@@ -1264,7 +1253,7 @@ namespace Grand.Web.Controllers
if (_customerSettings.HideSubAccountsTab)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetSubAccounts() { Customer = _workContext.CurrentCustomer });
+ var model = await _mediator.Send(new GetSubAccounts { Customer = _workContext.CurrentCustomer });
return View(model);
}
@@ -1277,8 +1266,8 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsOwner(_workContext.CurrentCustomer))
return Challenge();
- var model = new SubAccountModel() {
- Active = true,
+ var model = new SubAccountModel {
+ Active = true
};
return View(model);
}
@@ -1293,24 +1282,23 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsOwner(_workContext.CurrentCustomer))
return Challenge();
- if (ModelState.IsValid)
- {
- var result = await _mediator.Send(new SubAccountAddCommand() {
- Customer = _workContext.CurrentCustomer,
- Model = model,
- Store = _workContext.CurrentStore
- });
-
- if (result.Success)
- {
- return RedirectToRoute("CustomerSubAccounts");
- }
+ if (!ModelState.IsValid) return View(model);
+
+ var result = await _mediator.Send(new SubAccountAddCommand {
+ Customer = _workContext.CurrentCustomer,
+ Model = model,
+ Store = _workContext.CurrentStore
+ });
- //errors
- foreach (var error in result.Errors)
- ModelState.AddModelError("", error);
+ if (result.Success)
+ {
+ return RedirectToRoute("CustomerSubAccounts");
}
+ //errors
+ foreach (var error in result.Errors)
+ ModelState.AddModelError("", error);
+
//If we got this far, something failed, redisplay form
return View(model);
}
@@ -1323,7 +1311,7 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsOwner(_workContext.CurrentCustomer))
return Challenge();
- var model = await _mediator.Send(new GetSubAccount() { CustomerId = id, CurrentCustomer = _workContext.CurrentCustomer });
+ var model = await _mediator.Send(new GetSubAccount { CustomerId = id, CurrentCustomer = _workContext.CurrentCustomer });
return View(model);
}
@@ -1338,23 +1326,22 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsOwner(_workContext.CurrentCustomer))
return Challenge();
- if (ModelState.IsValid)
- {
- var result = await _mediator.Send(new SubAccountEditCommand() {
- CurrentCustomer = _workContext.CurrentCustomer,
- Model = model,
- Store = _workContext.CurrentStore
- });
-
- if (result.success)
- {
- return RedirectToRoute("CustomerSubAccounts");
- }
+ if (!ModelState.IsValid) return View(model);
+
+ var result = await _mediator.Send(new SubAccountEditCommand {
+ CurrentCustomer = _workContext.CurrentCustomer,
+ Model = model,
+ Store = _workContext.CurrentStore
+ });
- //errors
- ModelState.AddModelError("", result.error);
+ if (result.success)
+ {
+ return RedirectToRoute("CustomerSubAccounts");
}
+ //errors
+ ModelState.AddModelError("", result.error);
+
//If we got this far, something failed, redisplay form
return View(model);
}
@@ -1370,25 +1357,30 @@ namespace Grand.Web.Controllers
return Challenge();
//find address (ensure that it belongs to the current customer)
- if (ModelState.IsValid)
- {
- var result = await _mediator.Send(new SubAccountDeleteCommand() {
- CurrentCustomer = _workContext.CurrentCustomer,
- CustomerId = id,
+ if (!ModelState.IsValid)
+ return Json(new {
+ redirect = Url.RouteUrl("CustomerSubAccounts"),
+ success = false,
+ error = string.Join("; ", ModelState.Values
+ .SelectMany(x => x.Errors)
+ .Select(x => x.ErrorMessage))
});
+ var result = await _mediator.Send(new SubAccountDeleteCommand {
+ CurrentCustomer = _workContext.CurrentCustomer,
+ CustomerId = id
+ });
- if (result.success)
+ if (result.success)
+ {
+ return Json(new
{
- return Json(new
- {
- redirect = Url.RouteUrl("CustomerSubAccounts"),
- success = true,
- });
- }
-
- //errors
- ModelState.AddModelError("", result.error);
+ redirect = Url.RouteUrl("CustomerSubAccounts"),
+ success = true
+ });
}
+
+ //errors
+ ModelState.AddModelError("", result.error);
return Json(new
{
redirect = Url.RouteUrl("CustomerSubAccounts"),
diff --git a/src/Web/Grand.Web/Controllers/ActionCartController.cs b/src/Web/Grand.Web/Controllers/ActionCartController.cs
index 9cb1fd409..c30a40afa 100644
--- a/src/Web/Grand.Web/Controllers/ActionCartController.cs
+++ b/src/Web/Grand.Web/Controllers/ActionCartController.cs
@@ -23,7 +23,7 @@ using System.Globalization;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class ActionCartController : BasePublicController
+ public class ActionCartController : BasePublicController
{
#region Fields
@@ -77,7 +77,7 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
@@ -87,7 +87,7 @@ namespace Grand.Web.Controllers
//we cannot add to the cart such products from category pages
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
@@ -96,16 +96,16 @@ namespace Grand.Web.Controllers
//cannot be added to the cart (requires a customer to enter price)
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
var allowedQuantities = product.ParseAllowedQuantities();
if (cartType == ShoppingCartType.ShoppingCart && allowedQuantities.Length > 0)
{
- //cannot be added to the cart (requires a customer to select a quantity from dropdownlist)
+ //cannot be added to the cart (requires a customer to select a quantity from drop down list)
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
@@ -114,7 +114,7 @@ namespace Grand.Web.Controllers
//product has some attributes
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
@@ -124,7 +124,7 @@ namespace Grand.Web.Controllers
protected string GetWarehouse(Product product)
{
return product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
- (string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
+ string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId;
}
[HttpPost]
@@ -148,7 +148,7 @@ namespace Grand.Web.Controllers
var customer = _workContext.CurrentCustomer;
- string warehouseId = GetWarehouse(product);
+ var warehouseId = GetWarehouse(product);
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, cartType);
@@ -157,14 +157,14 @@ namespace Grand.Web.Controllers
var shoppingCartItem = await _shoppingCartService.FindShoppingCartItem(cart, cartType, product.Id, warehouseId);
//if we already have the same product in the cart, then use the total quantity to validate
- var quantityToValidate = shoppingCartItem != null ? shoppingCartItem.Quantity + quantity : quantity;
+ var quantityToValidate = shoppingCartItem?.Quantity + quantity ?? quantity;
var addToCartWarnings = await _shoppingCartValidator
- .GetShoppingCartItemWarnings(customer, new ShoppingCartItem() {
+ .GetShoppingCartItemWarnings(customer, new ShoppingCartItem {
ShoppingCartTypeId = cartType,
StoreId = _workContext.CurrentStore.Id,
WarehouseId = warehouseId,
Quantity = quantityToValidate
- }, product, new ShoppingCartValidatorOptions() {
+ }, product, new ShoppingCartValidatorOptions {
GetRequiredProductWarnings = false
});
@@ -173,7 +173,7 @@ namespace Grand.Web.Controllers
//cannot be added to the cart
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
}
@@ -185,11 +185,11 @@ namespace Grand.Web.Controllers
storeId: _workContext.CurrentStore.Id,
warehouseId: warehouseId,
quantity: quantity,
- validator: new ShoppingCartValidatorOptions() {
+ validator: new ShoppingCartValidatorOptions {
GetRequiredProductWarnings = false,
- GetInventoryWarnings = (cartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist),
- GetAttributesWarnings = (cartType != ShoppingCartType.Wishlist),
- GetGiftVoucherWarnings = (cartType != ShoppingCartType.Wishlist)
+ GetInventoryWarnings = cartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist,
+ GetAttributesWarnings = cartType != ShoppingCartType.Wishlist,
+ GetGiftVoucherWarnings = cartType != ShoppingCartType.Wishlist
});
if (addToCart.warnings.Any())
@@ -197,11 +197,11 @@ namespace Grand.Web.Controllers
//cannot be added to the cart
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
- var addtoCartModel = await _mediator.Send(new GetAddToCart() {
+ var addtoCartModel = await _mediator.Send(new GetAddToCart {
Product = product,
Customer = customer,
ShoppingCartItem = addToCart.shoppingCartItem,
@@ -210,7 +210,7 @@ namespace Grand.Web.Controllers
Currency = _workContext.WorkingCurrency,
Store = _workContext.CurrentStore,
Language = _workContext.WorkingLanguage,
- TaxDisplayType = _workContext.TaxDisplayType,
+ TaxDisplayType = _workContext.TaxDisplayType
});
//added to the cart/wishlist
@@ -228,7 +228,7 @@ namespace Grand.Web.Controllers
//redirect to the wishlist page
return Json(new
{
- redirect = Url.RouteUrl("Wishlist"),
+ redirect = Url.RouteUrl("Wishlist")
});
}
@@ -258,14 +258,15 @@ namespace Grand.Web.Controllers
//redirect to the shopping cart page
return Json(new
{
- redirect = Url.RouteUrl("ShoppingCart"),
+ redirect = Url.RouteUrl("ShoppingCart")
});
}
//display notification message and update appropriate blocks
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
- shoppingCartTypes.Add(ShoppingCartType.Auctions);
+ var shoppingCartTypes = new List<ShoppingCartType> {
+ ShoppingCartType.ShoppingCart,
+ ShoppingCartType.Auctions
+ };
if (_shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
@@ -273,7 +274,7 @@ namespace Grand.Web.Controllers
(await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, shoppingCartTypes.ToArray()))
.Sum(x => x.Quantity));
- var miniShoppingCartmodel = _shoppingCartSettings.MiniShoppingCartEnabled ? await _mediator.Send(new GetMiniShoppingCart() {
+ var miniShoppingCartmodel = _shoppingCartSettings.MiniShoppingCartEnabled ? await _mediator.Send(new GetMiniShoppingCart {
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
Language = _workContext.WorkingLanguage,
@@ -306,7 +307,7 @@ namespace Grand.Web.Controllers
}
//you can't add reservation product to wishlist
- if (product.ProductTypeId == ProductType.Reservation && (ShoppingCartType)shoppingCartTypeId == ShoppingCartType.Wishlist)
+ if (product.ProductTypeId == ProductType.Reservation && shoppingCartTypeId == ShoppingCartType.Wishlist)
{
return Json(new
{
@@ -316,7 +317,7 @@ namespace Grand.Web.Controllers
}
//you can't add auction product to wishlist
- if (product.ProductTypeId == ProductType.Auction && (ShoppingCartType)shoppingCartTypeId == ShoppingCartType.Wishlist)
+ if (product.ProductTypeId == ProductType.Auction && shoppingCartTypeId == ShoppingCartType.Wishlist)
{
return Json(new
{
@@ -354,7 +355,7 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.RouteUrl("HomePage"),
+ redirect = Url.RouteUrl("HomePage")
});
}
@@ -369,7 +370,7 @@ namespace Grand.Web.Controllers
}
//product and gift voucher attributes
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
+ var attributes = await _mediator.Send(new GetParseProductAttributes { Product = product, Model = model });
//rental attributes
DateTime? rentalStartDate = null;
@@ -433,7 +434,7 @@ namespace Grand.Web.Controllers
var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
model.WarehouseId:
product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
- (string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
+ string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId;
//add to the cart
@@ -441,9 +442,9 @@ namespace Grand.Web.Controllers
productId, cartType, _workContext.CurrentStore.Id, warehouseId,
attributes, customerEnteredPriceConverted,
rentalStartDate, rentalEndDate, model.EnteredQuantity, true, model.Reservation, parameter, duration,
- new ShoppingCartValidatorOptions() {
+ new ShoppingCartValidatorOptions {
GetRequiredProductWarnings = false,
- GetInventoryWarnings = (cartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist),
+ GetInventoryWarnings = cartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist
});
addToCartWarnings.AddRange(warnings);
@@ -461,7 +462,7 @@ namespace Grand.Web.Controllers
});
}
- var addtoCartModel = await _mediator.Send(new GetAddToCart() {
+ var addtoCartModel = await _mediator.Send(new GetAddToCart {
Product = product,
Customer = _workContext.CurrentCustomer,
ShoppingCartItem = shoppingCartItem,
@@ -495,7 +496,7 @@ namespace Grand.Web.Controllers
//redirect to the wishlist page
return Json(new
{
- redirect = Url.RouteUrl("Wishlist"),
+ redirect = Url.RouteUrl("Wishlist")
});
}
@@ -507,7 +508,7 @@ namespace Grand.Web.Controllers
{
success = true,
message = string.Format(_translationService.GetResource("Products.ProductHasBeenAddedToTheWishlist.Link"), Url.RouteUrl("Wishlist")),
- updatetopwishlistsectionhtml = updatetopwishlistsectionhtml,
+ updatetopwishlistsectionhtml,
wishlistqty = qty,
model = addtoCartModel
});
@@ -525,14 +526,15 @@ namespace Grand.Web.Controllers
//redirect to the shopping cart page
return Json(new
{
- redirect = Url.RouteUrl("ShoppingCart"),
+ redirect = Url.RouteUrl("ShoppingCart")
});
}
//display notification message and update appropriate blocks
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
- shoppingCartTypes.Add(ShoppingCartType.Auctions);
+ var shoppingCartTypes = new List<ShoppingCartType> {
+ ShoppingCartType.ShoppingCart,
+ ShoppingCartType.Auctions
+ };
if (_shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
@@ -540,7 +542,7 @@ namespace Grand.Web.Controllers
(await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, shoppingCartTypes.ToArray()))
.Sum(x => x.Quantity));
- var miniShoppingCartmodel = _shoppingCartSettings.MiniShoppingCartEnabled ? await _mediator.Send(new GetMiniShoppingCart() {
+ var miniShoppingCartmodel = _shoppingCartSettings.MiniShoppingCartEnabled ? await _mediator.Send(new GetMiniShoppingCart {
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
Language = _workContext.WorkingLanguage,
@@ -623,7 +625,7 @@ namespace Grand.Web.Controllers
if (warnings.Any())
{
- string toReturn = "";
+ var toReturn = "";
foreach (var warning in warnings)
{
toReturn += warning + "</br>";
@@ -644,7 +646,7 @@ namespace Grand.Web.Controllers
_workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),
_translationService.GetResource("ActivityLog.PublicStore.AddToBid"), product.Name);
- var addtoCartModel = await _mediator.Send(new GetAddToCart() {
+ var addtoCartModel = await _mediator.Send(new GetAddToCart {
Product = product,
Customer = customer,
Quantity = 1,
@@ -652,7 +654,7 @@ namespace Grand.Web.Controllers
Currency = _workContext.WorkingCurrency,
Store = _workContext.CurrentStore,
Language = _workContext.WorkingLanguage,
- TaxDisplayType = _workContext.TaxDisplayType,
+ TaxDisplayType = _workContext.TaxDisplayType
});
return Json(new
@@ -699,17 +701,17 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.RouteUrl("HomePage"),
+ redirect = Url.RouteUrl("HomePage")
});
}
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
//prepare the model
- var model = await _mediator.Send(new GetProductDetailsPage() {
+ var model = await _mediator.Send(new GetProductDetailsPage {
Store = _workContext.CurrentStore,
Product = product,
UpdateCartItem = cart
@@ -717,8 +719,7 @@ namespace Grand.Web.Controllers
return Json(new
{
- success = true,
- model = model,
+ success = true, model
});
}
@@ -738,7 +739,7 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.RouteUrl("HomePage"),
+ redirect = Url.RouteUrl("HomePage")
});
}
@@ -785,13 +786,13 @@ namespace Grand.Web.Controllers
double? customerEnteredPriceConverted = null;
if (product.EnteredPrice)
{
- if (double.TryParse(model.CustomerEnteredPrice, out double customerEnteredPrice))
+ if (double.TryParse(model.CustomerEnteredPrice, out var customerEnteredPrice))
customerEnteredPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(customerEnteredPrice, _workContext.WorkingCurrency);
}
#endregion
//product and gift voucher attributes
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
+ var attributes = await _mediator.Send(new GetParseProductAttributes { Product = product, Model = model });
//rental attributes
DateTime? rentalStartDate = cart.RentalStartDateUtc;
@@ -802,11 +803,9 @@ namespace Grand.Web.Controllers
}
//product reservation
- var parameter = cart.Parameter;
- var duration = cart.Duration;
if (product.ProductTypeId == ProductType.Reservation)
{
- if (product.IntervalUnitId == IntervalUnit.Hour || product.IntervalUnitId == IntervalUnit.Minute)
+ if (product.IntervalUnitId is IntervalUnit.Hour or IntervalUnit.Minute)
{
if (string.IsNullOrEmpty(model.Reservation))
{
@@ -826,9 +825,8 @@ namespace Grand.Web.Controllers
message = "No reservation found"
});
}
- duration = reservation.Duration;
+
rentalStartDate = reservation.Date;
- parameter = reservation.Parameter;
}
else if (product.IntervalUnitId == IntervalUnit.Day)
{
@@ -852,7 +850,7 @@ namespace Grand.Web.Controllers
//update existing item
addToCartWarnings.AddRange(await _shoppingCartService.UpdateShoppingCartItem(_workContext.CurrentCustomer,
cart.Id, warehouseId, attributes, customerEnteredPriceConverted,
- rentalStartDate, rentalEndDate, model.EnteredQuantity, true));
+ rentalStartDate, rentalEndDate, model.EnteredQuantity));
if (addToCartWarnings.Any())
{
diff --git a/src/Web/Grand.Web/Controllers/BasePublicController.cs b/src/Web/Grand.Web/Controllers/BasePublicController.cs
index 1d00292ad..43c7593e6 100644
--- a/src/Web/Grand.Web/Controllers/BasePublicController.cs
+++ b/src/Web/Grand.Web/Controllers/BasePublicController.cs
@@ -8,22 +8,18 @@ namespace Grand.Web.Controllers
[ClosedStore]
[Language]
[Affiliate]
- public abstract partial class BasePublicController : BaseController
+ public abstract class BasePublicController : BaseController
{
- protected virtual IActionResult InvokeHttp404()
+ protected IActionResult InvokeHttp404()
{
Response.StatusCode = 404;
return new EmptyResult();
}
- protected bool IsJsonResponseView()
+ private bool IsJsonResponseView()
{
var viewJson = Request?.Headers["X-Response-View"];
- if (viewJson?.Equals("Json") ?? false)
- {
- return true;
- }
- return false;
+ return viewJson?.Equals("Json") ?? false;
}
public new IActionResult View(object model)
@@ -44,10 +40,7 @@ namespace Grand.Web.Controllers
public override RedirectToRouteResult RedirectToRoute(string routeName)
{
- if (IsJsonResponseView())
- return RedirectToRoute("Route", new { routeName });
-
- return base.RedirectToRoute(routeName);
+ return IsJsonResponseView() ? RedirectToRoute("Route", new { routeName }) : base.RedirectToRoute(routeName);
}
}
}
diff --git a/src/Web/Grand.Web/Controllers/BlogController.cs b/src/Web/Grand.Web/Controllers/BlogController.cs
index dd875b6ed..83d9eb777 100644
--- a/src/Web/Grand.Web/Controllers/BlogController.cs
+++ b/src/Web/Grand.Web/Controllers/BlogController.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
@@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
- public partial class BlogController : BasePublicController
+ public class BlogController : BasePublicController
{
#region Fields
@@ -60,7 +60,7 @@ namespace Grand.Web.Controllers
if (!_blogSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetBlogPostList() { Command = command });
+ var model = await _mediator.Send(new GetBlogPostList { Command = command });
return View("List", model);
}
public virtual async Task<IActionResult> BlogByTag(BlogPagingFilteringModel command)
@@ -68,7 +68,7 @@ namespace Grand.Web.Controllers
if (!_blogSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetBlogPostList() { Command = command });
+ var model = await _mediator.Send(new GetBlogPostList { Command = command });
return View("List", model);
}
public virtual async Task<IActionResult> BlogByMonth(BlogPagingFilteringModel command)
@@ -76,7 +76,7 @@ namespace Grand.Web.Controllers
if (!_blogSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetBlogPostList() { Command = command });
+ var model = await _mediator.Send(new GetBlogPostList { Command = command });
return View("List", model);
}
public virtual async Task<IActionResult> BlogByCategory(BlogPagingFilteringModel command)
@@ -84,7 +84,7 @@ namespace Grand.Web.Controllers
if (!_blogSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetBlogPostList() { Command = command });
+ var model = await _mediator.Send(new GetBlogPostList { Command = command });
return View("List", model);
}
public virtual async Task<IActionResult> BlogByKeyword(BlogPagingFilteringModel command)
@@ -92,7 +92,7 @@ namespace Grand.Web.Controllers
if (!_blogSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetBlogPostList() { Command = command });
+ var model = await _mediator.Send(new GetBlogPostList { Command = command });
return View("List", model);
}
public virtual async Task<IActionResult> BlogPost(string blogPostId,
@@ -112,7 +112,7 @@ namespace Grand.Web.Controllers
if (!aclService.Authorize(blogPost, _workContext.CurrentStore.Id))
return InvokeHttp404();
- var model = await _mediator.Send(new GetBlogPost() { BlogPost = blogPost });
+ var model = await _mediator.Send(new GetBlogPost { BlogPost = blogPost });
//display "edit" (manage) link
if (await permissionService.Authorize(StandardPermission.AccessAdminPanel) && await permissionService.Authorize(StandardPermission.ManageBlog))
@@ -131,7 +131,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var blogPost = await _blogService.GetBlogPostById(blogPostId);
- if (blogPost == null || !blogPost.AllowComments)
+ if (blogPost is not { AllowComments: true })
return RedirectToRoute("HomePage");
if (await _groupService.IsGuest(_workContext.CurrentCustomer) && !_blogSettings.AllowNotRegisteredUsersToLeaveComments)
@@ -147,7 +147,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- await _mediator.Send(new InsertBlogCommentCommand() { Model = model, BlogPost = blogPost });
+ await _mediator.Send(new InsertBlogCommentCommand { Model = model, BlogPost = blogPost });
//notification
await _mediator.Publish(new BlogCommentEvent(blogPost, model.AddNewComment));
@@ -158,7 +158,7 @@ namespace Grand.Web.Controllers
}
//If we got this far, something failed, redisplay form
- model = await _mediator.Send(new GetBlogPost() { BlogPost = blogPost });
+ model = await _mediator.Send(new GetBlogPost { BlogPost = blogPost });
return View("BlogPost", model);
}
#endregion
diff --git a/src/Web/Grand.Web/Controllers/CatalogController.cs b/src/Web/Grand.Web/Controllers/CatalogController.cs
index 482e59f9e..abcccc386 100644
--- a/src/Web/Grand.Web/Controllers/CatalogController.cs
+++ b/src/Web/Grand.Web/Controllers/CatalogController.cs
@@ -1,15 +1,15 @@
-using Grand.Business.Core.Interfaces.Catalog.Brands;
+using Grand.Business.Core.Events.Customers;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
-using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Interfaces.Customers;
+using Grand.Business.Core.Queries.Checkout.Orders;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Orders;
@@ -24,11 +24,10 @@ using Grand.Web.Models.Catalog;
using Grand.Web.Models.Vendors;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Controllers
{
- public partial class CatalogController : BasePublicController
+ public class CatalogController : BasePublicController
{
#region Fields
@@ -94,7 +93,7 @@ namespace Grand.Web.Controllers
private VendorReviewOverviewModel PrepareVendorReviewOverviewModel(Vendor vendor)
{
- var model = new VendorReviewOverviewModel() {
+ var model = new VendorReviewOverviewModel {
RatingSum = vendor.ApprovedRatingSum,
TotalReviews = vendor.ApprovedTotalReviews,
VendorId = vendor.Id,
@@ -141,7 +140,7 @@ namespace Grand.Web.Controllers
_translationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name);
//model
- var model = await _mediator.Send(new GetCategory() {
+ var model = await _mediator.Send(new GetCategory {
Category = category,
Command = command,
Currency = _workContext.WorkingCurrency,
@@ -151,7 +150,7 @@ namespace Grand.Web.Controllers
});
//layout
- var layoutViewPath = await _mediator.Send(new GetCategoryLayoutViewPath() { LayoutId = category.CategoryLayoutId });
+ var layoutViewPath = await _mediator.Send(new GetCategoryLayoutViewPath { LayoutId = category.CategoryLayoutId });
return View(layoutViewPath, model);
}
@@ -194,7 +193,7 @@ namespace Grand.Web.Controllers
_translationService.GetResource("ActivityLog.PublicStore.ViewBrand"), brand.Name);
//model
- var model = await _mediator.Send(new GetBrand() {
+ var model = await _mediator.Send(new GetBrand {
Command = command,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -204,14 +203,14 @@ namespace Grand.Web.Controllers
});
//template
- var layoutViewPath = await _mediator.Send(new GetBrandLayoutViewPath() { LayoutId = brand.BrandLayoutId });
+ var layoutViewPath = await _mediator.Send(new GetBrandLayoutViewPath { LayoutId = brand.BrandLayoutId });
return View(layoutViewPath, model);
}
public virtual async Task<IActionResult> BrandAll()
{
- var model = await _mediator.Send(new GetBrandAll() {
+ var model = await _mediator.Send(new GetBrandAll {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -257,7 +256,7 @@ namespace Grand.Web.Controllers
_translationService.GetResource("ActivityLog.PublicStore.ViewCollection"), collection.Name);
//model
- var model = await _mediator.Send(new GetCollection() {
+ var model = await _mediator.Send(new GetCollection {
Command = command,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -267,14 +266,14 @@ namespace Grand.Web.Controllers
});
//template
- var layoutViewPath = await _mediator.Send(new GetCollectionLayoutViewPath() { LayoutId = collection.CollectionLayoutId });
+ var layoutViewPath = await _mediator.Send(new GetCollectionLayoutViewPath { LayoutId = collection.CollectionLayoutId });
return View(layoutViewPath, model);
}
public virtual async Task<IActionResult> CollectionAll()
{
- var model = await _mediator.Send(new GetCollectionAll() {
+ var model = await _mediator.Send(new GetCollectionAll {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -305,12 +304,12 @@ namespace Grand.Web.Controllers
if (await _permissionService.Authorize(StandardPermission.AccessAdminPanel, customer) && await _permissionService.Authorize(StandardPermission.ManageCollections, customer))
DisplayEditLink(Url.Action("Edit", "Vendor", new { id = vendor.Id, area = "Admin" }));
- var model = await _mediator.Send(new GetVendor() {
+ var model = await _mediator.Send(new GetVendor {
Command = command,
Vendor = vendor,
Language = _workContext.WorkingLanguage,
Customer = _workContext.CurrentCustomer,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
//review
model.VendorReviewOverview = PrepareVendorReviewOverviewModel(vendor);
@@ -324,7 +323,7 @@ namespace Grand.Web.Controllers
if (_vendorSettings.VendorsBlockItemsToDisplay == 0)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetVendorAll() { Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetVendorAll { Language = _workContext.WorkingLanguage });
return View(model);
}
@@ -341,7 +340,7 @@ namespace Grand.Web.Controllers
[FromServices] CaptchaSettings captchaSettings)
{
var vendor = await _vendorService.GetVendorById(model.VendorId);
- if (vendor == null || !vendor.Active || !vendor.AllowCustomerReviews)
+ if (vendor is not { Active: true } || !vendor.AllowCustomerReviews)
return Content("");
//validate CAPTCHA
@@ -357,7 +356,7 @@ namespace Grand.Web.Controllers
//allow reviews only by customer that bought something from this vendor
if (_vendorSettings.VendorReviewPossibleOnlyAfterPurchasing &&
- !(await _mediator.Send(new GetOrderQuery() {
+ !(await _mediator.Send(new GetOrderQuery {
CustomerId = _workContext.CurrentCustomer.Id,
VendorId = vendor.Id,
Os = (int)OrderStatusSystem.Complete,
@@ -377,7 +376,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- var vendorReview = await _mediator.Send(new InsertVendorReviewCommand() { Vendor = vendor, Store = _workContext.CurrentStore, Model = model });
+ var vendorReview = await _mediator.Send(new InsertVendorReviewCommand { Vendor = vendor, Store = _workContext.CurrentStore, Model = model });
//activity log
_ = _customerActivityService.InsertActivity("PublicStore.AddVendorReview", vendor.Id,
_workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),
@@ -387,7 +386,7 @@ namespace Grand.Web.Controllers
if (vendorReview.IsApproved)
await _mediator.Publish(new VendorReviewApprovedEvent(vendorReview));
- model = await _mediator.Send(new GetVendorReviews() { Vendor = vendor });
+ model = await _mediator.Send(new GetVendorReviews { Vendor = vendor });
model.AddVendorReview.Title = null;
model.AddVendorReview.ReviewText = null;
@@ -402,7 +401,7 @@ namespace Grand.Web.Controllers
return Json(model);
}
- var returnmodel = await _mediator.Send(new GetVendorReviews() { Vendor = vendor });
+ var returnmodel = await _mediator.Send(new GetVendorReviews { Vendor = vendor });
returnmodel.AddVendorReview.ReviewText = model.AddVendorReview.ReviewText;
returnmodel.AddVendorReview.Title = model.AddVendorReview.Title;
returnmodel.AddVendorReview.SuccessfullyAdded = false;
@@ -443,7 +442,7 @@ namespace Grand.Web.Controllers
});
}
- vendorReview = await _mediator.Send(new SetVendorReviewHelpfulnessCommand() {
+ vendorReview = await _mediator.Send(new SetVendorReviewHelpfulnessCommand {
Customer = _workContext.CurrentCustomer,
Vendor = vendor,
Review = vendorReview,
@@ -468,7 +467,7 @@ namespace Grand.Web.Controllers
if (productTag == null)
return InvokeHttp404();
- var model = await _mediator.Send(new GetProductsByTag() {
+ var model = await _mediator.Send(new GetProductsByTag {
Command = command,
Language = _workContext.WorkingLanguage,
ProductTag = productTag,
@@ -483,7 +482,7 @@ namespace Grand.Web.Controllers
if (productTag == null)
return InvokeHttp404();
- var model = await _mediator.Send(new GetProductsByTag() {
+ var model = await _mediator.Send(new GetProductsByTag {
Command = command,
Language = _workContext.WorkingLanguage,
ProductTag = productTag,
@@ -495,7 +494,7 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> ProductTagsAll()
{
- var model = await _mediator.Send(new GetProductTagsAll() {
+ var model = await _mediator.Send(new GetProductTagsAll {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -517,11 +516,11 @@ namespace Grand.Web.Controllers
}
//Prepare model
var isSearchTermSpecified = HttpContext?.Request?.Query.ContainsKey("q");
- var searchmodel = await _mediator.Send(new GetSearch() {
+ var searchmodel = await _mediator.Send(new GetSearch {
Command = command,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
- IsSearchTermSpecified = isSearchTermSpecified.HasValue ? isSearchTermSpecified.Value : false,
+ IsSearchTermSpecified = isSearchTermSpecified ?? false,
Language = _workContext.WorkingLanguage,
Model = model,
Store = _workContext.CurrentStore
@@ -531,10 +530,10 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> SearchTermAutoComplete(string term, string categoryId, [FromServices] CatalogSettings catalogSettings)
{
- if (String.IsNullOrWhiteSpace(term) || term.Length < catalogSettings.ProductSearchTermMinimumLength)
+ if (string.IsNullOrWhiteSpace(term) || term.Length < catalogSettings.ProductSearchTermMinimumLength)
return Content("");
- var result = await _mediator.Send(new GetSearchAutoComplete() {
+ var result = await _mediator.Send(new GetSearchAutoComplete {
CategoryId = categoryId,
Term = term.Trim(),
Customer = _workContext.CurrentCustomer,
diff --git a/src/Web/Grand.Web/Controllers/CheckoutController.cs b/src/Web/Grand.Web/Controllers/CheckoutController.cs
index bba47e55a..ade3629ce 100644
--- a/src/Web/Grand.Web/Controllers/CheckoutController.cs
+++ b/src/Web/Grand.Web/Controllers/CheckoutController.cs
@@ -1,7 +1,7 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Commands.Checkout.Orders;
+using Grand.Business.Core.Commands.Checkout.Orders;
using Grand.Business.Core.Enums.Checkout;
using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Payments;
using Grand.Business.Core.Interfaces.Checkout.Shipping;
@@ -10,6 +10,7 @@ using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Customers;
+using Grand.Business.Core.Utilities.Checkout;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Orders;
@@ -25,12 +26,11 @@ using Grand.Web.Models.Checkout;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
-using Grand.Business.Core.Utilities.Checkout;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class CheckoutController : BasePublicController
+ public class CheckoutController : BasePublicController
{
#region Fields
@@ -144,7 +144,7 @@ namespace Grand.Web.Controllers
filterByCountryId = _workContext.CurrentCustomer.BillingAddress.CountryId;
}
- var paymentMethodModel = await _mediator.Send(new GetPaymentMethod() {
+ var paymentMethodModel = await _mediator.Send(new GetPaymentMethod {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -179,14 +179,8 @@ namespace Grand.Web.Controllers
}
protected virtual bool IsPostBeingDone {
- get {
- if (HttpContext.Items["grand.IsPOSTBeingDone"] == null)
- return false;
- return Convert.ToBoolean(HttpContext.Items["grand.IsPOSTBeingDone"]);
- }
- set {
- HttpContext.Items["grand.IsPOSTBeingDone"] = value;
- }
+ get => HttpContext.Items["grand.IsPOSTBeingDone"] != null && Convert.ToBoolean(HttpContext.Items["grand.IsPOSTBeingDone"]);
+ set => HttpContext.Items["grand.IsPOSTBeingDone"] = value;
}
#endregion
@@ -201,7 +195,7 @@ namespace Grand.Web.Controllers
if (!cart.Any())
return RedirectToRoute("ShoppingCart");
- if ((await _groupService.IsGuest(customer) && !_orderSettings.AnonymousCheckoutAllowed))
+ if (await _groupService.IsGuest(customer) && !_orderSettings.AnonymousCheckoutAllowed)
return Challenge();
//reset checkout data
@@ -232,7 +226,7 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> Completed(string orderId)
{
//validation
- if ((await _groupService.IsGuest(_workContext.CurrentCustomer) && !_orderSettings.AnonymousCheckoutAllowed))
+ if (await _groupService.IsGuest(_workContext.CurrentCustomer) && !_orderSettings.AnonymousCheckoutAllowed)
return Challenge();
Order order = null;
@@ -241,12 +235,9 @@ namespace Grand.Web.Controllers
order = await _orderService.GetOrderById(orderId);
}
- if (order == null)
- {
- order = (await _orderService.SearchOrders(storeId: _workContext.CurrentStore.Id,
- customerId: _workContext.CurrentCustomer.Id, pageSize: 1))
- .FirstOrDefault();
- }
+ order ??= (await _orderService.SearchOrders(storeId: _workContext.CurrentStore.Id,
+ customerId: _workContext.CurrentCustomer.Id, pageSize: 1))
+ .FirstOrDefault();
if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId)
{
@@ -263,7 +254,7 @@ namespace Grand.Web.Controllers
var model = new CheckoutCompletedModel {
OrderId = order.Id,
OrderNumber = order.OrderNumber,
- OrderCode = order.Code,
+ OrderCode = order.Code
};
return View(model);
@@ -281,7 +272,7 @@ namespace Grand.Web.Controllers
[NonAction]
protected async Task<JsonResult> LoadStepAfterBillingAddress(IList<ShoppingCartItem> cart)
{
- var shippingMethodModel = await _mediator.Send(new GetShippingMethod() {
+ var shippingMethodModel = await _mediator.Send(new GetShippingMethod {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -294,27 +285,25 @@ namespace Grand.Web.Controllers
_workContext.CurrentCustomer.GetUserFieldFromEntity<string>(
SystemCustomerFieldNames.SelectedPickupPoint, _workContext.CurrentStore.Id);
- if ((_shippingSettings.SkipShippingMethodSelectionIfOnlyOne &&
- shippingMethodModel.ShippingMethods.Count == 1) ||
- (_shippingSettings.AllowPickUpInStore && !string.IsNullOrEmpty(selectedPickupPoint)))
- {
- if (!(_shippingSettings.AllowPickUpInStore && !string.IsNullOrEmpty(selectedPickupPoint)))
- await _userFieldService.SaveField(_workContext.CurrentCustomer,
- SystemCustomerFieldNames.SelectedShippingOption,
- shippingMethodModel.ShippingMethods.First().ShippingOption,
- _workContext.CurrentStore.Id);
+ if ((!_shippingSettings.SkipShippingMethodSelectionIfOnlyOne ||
+ shippingMethodModel.ShippingMethods.Count != 1) &&
+ (!_shippingSettings.AllowPickUpInStore || string.IsNullOrEmpty(selectedPickupPoint)))
+ return Json(new {
+ update_section = new UpdateSectionJsonModel {
+ name = "shipping-method",
+ model = shippingMethodModel
+ },
+ goto_section = "shipping_method"
+ });
+ if (!(_shippingSettings.AllowPickUpInStore && !string.IsNullOrEmpty(selectedPickupPoint)))
+ await _userFieldService.SaveField(_workContext.CurrentCustomer,
+ SystemCustomerFieldNames.SelectedShippingOption,
+ shippingMethodModel.ShippingMethods.First().ShippingOption,
+ _workContext.CurrentStore.Id);
- //load next step
- return await LoadStepAfterShippingMethod(cart);
- }
+ //load next step
+ return await LoadStepAfterShippingMethod(cart);
- return Json(new {
- update_section = new UpdateSectionJsonModel {
- name = "shipping-method",
- model = shippingMethodModel
- },
- goto_section = "shipping_method"
- });
}
[NonAction]
@@ -322,8 +311,7 @@ namespace Grand.Web.Controllers
{
//Check whether payment workflow is required
//we ignore loyalty points during cart total calculation
- var isPaymentWorkflowRequired = await _mediator.Send(new GetIsPaymentWorkflowRequired()
- { Cart = cart, UseLoyaltyPoints = false });
+ var isPaymentWorkflowRequired = await _mediator.Send(new GetIsPaymentWorkflowRequired { Cart = cart, UseLoyaltyPoints = false });
if (isPaymentWorkflowRequired)
{
//filter by country
@@ -336,7 +324,7 @@ namespace Grand.Web.Controllers
}
//payment is required
- var paymentMethodModel = await _mediator.Send(new GetPaymentMethod() {
+ var paymentMethodModel = await _mediator.Send(new GetPaymentMethod {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -345,42 +333,40 @@ namespace Grand.Web.Controllers
Store = _workContext.CurrentStore
});
- if (_paymentSettings.SkipPaymentIfOnlyOne &&
- paymentMethodModel.PaymentMethods.Count == 1 && !paymentMethodModel.DisplayLoyaltyPoints)
- {
- //if we have only one payment method and loyalty points are disabled or the current customer doesn't have any loyalty points
- //so customer doesn't have to choose a payment method
+ if (!_paymentSettings.SkipPaymentIfOnlyOne ||
+ paymentMethodModel.PaymentMethods.Count != 1 || paymentMethodModel.DisplayLoyaltyPoints)
+ return Json(new {
+ update_section = new UpdateSectionJsonModel {
+ name = "payment-method",
+ model = paymentMethodModel
+ },
+ goto_section = "payment_method"
+ });
+ //if we have only one payment method and loyalty points are disabled or the current customer doesn't have any loyalty points
+ //so customer doesn't have to choose a payment method
- var selectedPaymentMethodSystemName = paymentMethodModel.PaymentMethods[0].PaymentMethodSystemName;
- await _userFieldService.SaveField(_workContext.CurrentCustomer,
- SystemCustomerFieldNames.SelectedPaymentMethod,
- selectedPaymentMethodSystemName, _workContext.CurrentStore.Id);
+ var selectedPaymentMethodSystemName = paymentMethodModel.PaymentMethods[0].PaymentMethodSystemName;
+ await _userFieldService.SaveField(_workContext.CurrentCustomer,
+ SystemCustomerFieldNames.SelectedPaymentMethod,
+ selectedPaymentMethodSystemName, _workContext.CurrentStore.Id);
- var paymentMethodInst =
- _paymentService.LoadPaymentMethodBySystemName(selectedPaymentMethodSystemName);
- if (paymentMethodInst == null ||
- !paymentMethodInst.IsPaymentMethodActive(_paymentSettings) ||
- !paymentMethodInst.IsAuthenticateStore(_workContext.CurrentStore))
- throw new Exception("Selected payment method can't be parsed");
+ var paymentMethodInst =
+ _paymentService.LoadPaymentMethodBySystemName(selectedPaymentMethodSystemName);
+ if (paymentMethodInst == null ||
+ !paymentMethodInst.IsPaymentMethodActive(_paymentSettings) ||
+ !paymentMethodInst.IsAuthenticateStore(_workContext.CurrentStore))
+ throw new Exception("Selected payment method can't be parsed");
- return await LoadStepAfterPaymentMethod(paymentMethodInst, cart);
- }
+ return await LoadStepAfterPaymentMethod(paymentMethodInst, cart);
//customer have to choose a payment method
- return Json(new {
- update_section = new UpdateSectionJsonModel {
- name = "payment-method",
- model = paymentMethodModel
- },
- goto_section = "payment_method"
- });
}
//payment is not required
await _userFieldService.SaveField<string>(_workContext.CurrentCustomer,
SystemCustomerFieldNames.SelectedPaymentMethod, null, _workContext.CurrentStore.Id);
- var confirmOrderModel = await _mediator.Send(new GetConfirmOrder() {
+ var confirmOrderModel = await _mediator.Send(new GetConfirmOrder {
Cart = cart, Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -410,7 +396,7 @@ namespace Grand.Web.Controllers
(paymentMethod.PaymentMethodType == PaymentMethodType.Redirection
&& _paymentSettings.SkipPaymentInfo))
{
- var confirmOrderModel = await _mediator.Send(new GetConfirmOrder() {
+ var confirmOrderModel = await _mediator.Send(new GetConfirmOrder {
Cart = cart, Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -424,7 +410,7 @@ namespace Grand.Web.Controllers
}
//return payment info page
- var paymenInfoModel = await _mediator.Send(new GetPaymentInfo() { PaymentMethod = paymentMethod });
+ var paymenInfoModel = await _mediator.Send(new GetPaymentInfo { PaymentMethod = paymentMethod });
return Json(new {
update_section = new UpdateSectionJsonModel {
name = "payment-info",
@@ -443,7 +429,7 @@ namespace Grand.Web.Controllers
if (!cart.Any())
return RedirectToRoute("ShoppingCart");
- if ((await _groupService.IsGuest(_workContext.CurrentCustomer) && !_orderSettings.AnonymousCheckoutAllowed))
+ if (await _groupService.IsGuest(_workContext.CurrentCustomer) && !_orderSettings.AnonymousCheckoutAllowed)
return Challenge();
//validation (each shopping cart item)
@@ -460,7 +446,7 @@ namespace Grand.Web.Controllers
var requiresShipping = cart.RequiresShipping();
var model = new CheckoutModel {
ShippingRequired = requiresShipping,
- BillingAddress = await _mediator.Send(new GetBillingAddress() {
+ BillingAddress = await _mediator.Send(new GetBillingAddress {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -468,7 +454,7 @@ namespace Grand.Web.Controllers
Store = _workContext.CurrentStore,
PrePopulateNewAddressWithCustomerFields = true
}),
- ShippingAddress = await _mediator.Send(new GetShippingAddress() {
+ ShippingAddress = await _mediator.Send(new GetShippingAddress {
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
@@ -508,7 +494,7 @@ namespace Grand.Web.Controllers
else
{
//custom address attributes
- var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes() { SelectedAttributes = model.BillingNewAddress.SelectedAttributes });
+ var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.BillingNewAddress.SelectedAttributes });
var customAttributeWarnings = await _addressAttributeParser.GetAttributeWarnings(customAttributes);
foreach (var error in customAttributeWarnings)
{
@@ -518,7 +504,7 @@ namespace Grand.Web.Controllers
if (!ModelState.IsValid)
{
//model is not valid. redisplay the form with errors
- var billingAddressModel = await _mediator.Send(new GetBillingAddress() {
+ var billingAddressModel = await _mediator.Send(new GetBillingAddress {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -573,18 +559,15 @@ namespace Grand.Web.Controllers
//load next step
if (cart.RequiresShipping())
return await LoadStepAfterBillingAddress(cart);
- else
- {
- //shipping is not required
- _workContext.CurrentCustomer.ShippingAddress = null;
- await _customerService.UpdateCustomerField(_workContext.CurrentCustomer, x => x.ShippingAddress,
- null);
+ //shipping is not required
+ _workContext.CurrentCustomer.ShippingAddress = null;
+ await _customerService.UpdateCustomerField(_workContext.CurrentCustomer, x => x.ShippingAddress,
+ null);
- await _userFieldService.SaveField<ShippingOption>(_workContext.CurrentCustomer,
- SystemCustomerFieldNames.SelectedShippingOption, null, _workContext.CurrentStore.Id);
- //load next step
- return await LoadStepAfterShippingMethod(cart);
- }
+ await _userFieldService.SaveField<ShippingOption>(_workContext.CurrentCustomer,
+ SystemCustomerFieldNames.SelectedShippingOption, null, _workContext.CurrentStore.Id);
+ //load next step
+ return await LoadStepAfterShippingMethod(cart);
}
catch (Exception exc)
{
@@ -608,12 +591,11 @@ namespace Grand.Web.Controllers
throw new Exception("Shipping is not required");
//Pick up in store?
- //var pickupInstore = false;
+ //var pickup in store = false;
if (_shippingSettings.AllowPickUpInStore)
{
if (model.PickUpInStore)
{
- //pickupInstore = true;
//customer decided to pick up in store
//no shipping address selected
_workContext.CurrentCustomer.ShippingAddress = null;
@@ -674,8 +656,7 @@ namespace Grand.Web.Controllers
else
{
//custom address attributes
- var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes()
- { SelectedAttributes = model.ShippingNewAddress.SelectedAttributes });
+ var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.ShippingNewAddress.SelectedAttributes });
var customAttributeWarnings =
await _addressAttributeParser.GetAttributeWarnings(customAttributes);
foreach (var error in customAttributeWarnings)
@@ -686,13 +667,13 @@ namespace Grand.Web.Controllers
if (!ModelState.IsValid)
{
//model is not valid. redisplay the form with errors
- var shippingAddressModel = await _mediator.Send(new GetShippingAddress() {
+ var shippingAddressModel = await _mediator.Send(new GetShippingAddress {
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
SelectedCountryId = model.ShippingNewAddress.CountryId,
- OverrideAttributes = customAttributes,
+ OverrideAttributes = customAttributes
});
shippingAddressModel.NewAddressPreselected = true;
@@ -726,7 +707,7 @@ namespace Grand.Web.Controllers
address.Attributes = customAttributes;
address.CreatedOnUtc = DateTime.UtcNow;
address.AddressType = _addressSettings.AddressTypeEnabled
- ? (model.BillToTheSameAddress ? AddressType.Any : AddressType.Shipping)
+ ? model.BillToTheSameAddress ? AddressType.Any : AddressType.Shipping
: AddressType.Any;
//other null validations
_workContext.CurrentCustomer.Addresses.Add(address);
@@ -739,7 +720,7 @@ namespace Grand.Web.Controllers
}
if (model.BillToTheSameAddress && !model.PickUpInStore &&
- (_workContext.CurrentCustomer.ShippingAddress!.AddressType != AddressType.Shipping))
+ _workContext.CurrentCustomer.ShippingAddress!.AddressType != AddressType.Shipping)
{
_workContext.CurrentCustomer.BillingAddress = _workContext.CurrentCustomer.ShippingAddress;
await _customerService.UpdateBillingAddress(_workContext.CurrentCustomer.BillingAddress,
@@ -748,27 +729,25 @@ namespace Grand.Web.Controllers
SystemCustomerFieldNames.SelectedShippingOption, null, _workContext.CurrentStore.Id);
return await LoadStepAfterBillingAddress(cart);
}
- else
- {
- var billingAddressModel = await _mediator.Send(new GetBillingAddress() {
- Cart = cart,
- Currency = _workContext.WorkingCurrency,
- Customer = _workContext.CurrentCustomer,
- Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
- SelectedCountryId = model.ShippingNewAddress.CountryId,
- });
- if (!billingAddressModel.ExistingAddresses.Any())
- billingAddressModel.NewAddressPreselected = true;
- return Json(new {
- update_section = new UpdateSectionJsonModel {
- name = "billing",
- model = billingAddressModel
- },
- goto_section = "billing"
- });
- }
+ var billingAddressModel = await _mediator.Send(new GetBillingAddress {
+ Cart = cart,
+ Currency = _workContext.WorkingCurrency,
+ Customer = _workContext.CurrentCustomer,
+ Language = _workContext.WorkingLanguage,
+ Store = _workContext.CurrentStore,
+ SelectedCountryId = model.ShippingNewAddress.CountryId
+ });
+ if (!billingAddressModel.ExistingAddresses.Any())
+ billingAddressModel.NewAddressPreselected = true;
+
+ return Json(new {
+ update_section = new UpdateSectionJsonModel {
+ name = "billing",
+ model = billingAddressModel
+ },
+ goto_section = "billing"
+ });
}
catch (Exception exc)
{
@@ -793,7 +772,7 @@ namespace Grand.Web.Controllers
throw new Exception("Shipping is not required");
//parse selected method
- //model.TryGetValue("shippingoption", out var shipping);
+ //model.TryGetValue("shipping option", out var shipping);
if (string.IsNullOrEmpty(model.ShippingOption))
throw new Exception("Selected shipping method can't be parsed");
@@ -852,7 +831,7 @@ namespace Grand.Web.Controllers
}
var message = string.Join(", ", warnings.ToArray());
- return Json(new { error = 1, message = message });
+ return Json(new { error = 1, message });
}
catch (Exception exc)
{
@@ -884,14 +863,14 @@ namespace Grand.Web.Controllers
//Check whether payment workflow is required
var isPaymentWorkflowRequired =
- await _mediator.Send(new GetIsPaymentWorkflowRequired() { Cart = cart });
+ await _mediator.Send(new GetIsPaymentWorkflowRequired { Cart = cart });
if (!isPaymentWorkflowRequired)
{
//payment is not required
await _userFieldService.SaveField<string>(_workContext.CurrentCustomer,
SystemCustomerFieldNames.SelectedPaymentMethod, null, _workContext.CurrentStore.Id);
- var confirmOrderModel = await _mediator.Send(new GetConfirmOrder() {
+ var confirmOrderModel = await _mediator.Send(new GetConfirmOrder {
Cart = cart, Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -965,7 +944,7 @@ namespace Grand.Web.Controllers
_workContext.CurrentStore.Id);
}
- var confirmOrderModel = await _mediator.Send(new GetConfirmOrder() {
+ var confirmOrderModel = await _mediator.Send(new GetConfirmOrder {
Cart = cart, Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -979,7 +958,7 @@ namespace Grand.Web.Controllers
}
//If we got this far, something failed, redisplay form
- var paymenInfoModel = await _mediator.Send(new GetPaymentInfo() { PaymentMethod = paymentMethod });
+ var paymenInfoModel = await _mediator.Send(new GetPaymentInfo { PaymentMethod = paymentMethod });
return Json(new {
update_section = new UpdateSectionJsonModel {
name = "payment-info",
@@ -1004,7 +983,7 @@ namespace Grand.Web.Controllers
await CartValidate(cart);
//prevent 2 orders being placed within an X seconds time frame
- if (!await _mediator.Send(new GetMinOrderPlaceIntervalValid() {
+ if (!await _mediator.Send(new GetMinOrderPlaceIntervalValid {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore
}))
@@ -1033,7 +1012,7 @@ namespace Grand.Web.Controllers
//redirect
return Json(new {
redirect =
- $"{storeLocation}/checkout/CompleteRedirectionPayment?paymentTransactionId={placeOrderResult.PaymentTransaction.Id}",
+ $"{storeLocation}/checkout/CompleteRedirectionPayment?paymentTransactionId={placeOrderResult.PaymentTransaction.Id}"
});
}
@@ -1043,7 +1022,7 @@ namespace Grand.Web.Controllers
}
//error
- var confirmOrderModel = await _mediator.Send(new GetConfirmOrder() {
+ var confirmOrderModel = await _mediator.Send(new GetConfirmOrder {
Cart = cart, Customer = _workContext.CurrentCustomer, Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
});
@@ -1069,8 +1048,8 @@ namespace Grand.Web.Controllers
{
try
{
- if ((await _groupService.IsGuest(_workContext.CurrentCustomer) &&
- !_orderSettings.AnonymousCheckoutAllowed))
+ if (await _groupService.IsGuest(_workContext.CurrentCustomer) &&
+ !_orderSettings.AnonymousCheckoutAllowed)
return Challenge();
var paymentTransaction = await _paymentTransactionService.GetById(paymentTransactionId);
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.cs
index dfafe0d8e..019fe8c8f 100644
--- a/src/Web/Grand.Web/Controllers/CommonController.cs
+++ b/src/Web/Grand.Web/Controllers/CommonController.cs
@@ -4,9 +4,6 @@ using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Stores;
using Grand.Business.Core.Interfaces.Marketing.Contacts;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Web.Common.Filters;
-using Grand.Web.Common.Security.Captcha;
-using Grand.Web.Common.Themes;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -18,6 +15,11 @@ using Grand.Infrastructure;
using Grand.Infrastructure.Configuration;
using Grand.Web.Commands.Models.Common;
using Grand.Web.Commands.Models.Customers;
+using Grand.Web.Common.Controllers;
+using Grand.Web.Common.Extensions;
+using Grand.Web.Common.Filters;
+using Grand.Web.Common.Security.Captcha;
+using Grand.Web.Common.Themes;
using Grand.Web.Events;
using Grand.Web.Features.Models.Common;
using Grand.Web.Models.Common;
@@ -25,12 +27,10 @@ using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Net;
-using Grand.Web.Common.Controllers;
-using Grand.Web.Common.Extensions;
namespace Grand.Web.Controllers
{
- public partial class CommonController : BasePublicController
+ public class CommonController : BasePublicController
{
#region Fields
@@ -90,10 +90,10 @@ namespace Grand.Web.Controllers
var language = (await _languageService.GetAllLanguages())
.FirstOrDefault(urlLanguage => urlLanguage.UniqueSeoCode.Equals(firstSegment, StringComparison.OrdinalIgnoreCase));
- return language != null ? language.Published : false;
+ return language?.Published ?? false;
}
- private string AddLanguageSeo(string url, Language language)
+ private static string AddLanguageSeo(string url, Language language)
{
if (language == null)
throw new ArgumentNullException(nameof(language));
@@ -206,10 +206,7 @@ namespace Grand.Web.Controllers
url = Flurl.Url.EncodeIllegalCharacters(url);
- if (permanentRedirect)
- return RedirectPermanent(url);
-
- return Redirect(url);
+ return permanentRedirect ? RedirectPermanent(url) : Redirect(url);
}
[DenySystemAccount]
@@ -257,7 +254,7 @@ namespace Grand.Web.Controllers
{
if (commonSettings.AllowToSelectStore)
{
- var selectedstore = storeService.GetAll().FirstOrDefault(x => x.Shortcut.ToLowerInvariant() == shortcut.ToLowerInvariant());
+ var selectedstore = storeService.GetAll().FirstOrDefault(x => string.Equals(x.Shortcut, shortcut, StringComparison.InvariantCultureIgnoreCase));
if (selectedstore != null)
{
await _storeHelper.SetStoreCookie(selectedstore.Id);
@@ -336,10 +333,10 @@ namespace Grand.Web.Controllers
if (storeInformationSettings.StoreClosed)
{
var closestorepage = await pageService.GetPageBySystemName("ContactUs");
- if (closestorepage == null || !closestorepage.AccessibleWhenStoreClosed)
+ if (closestorepage is not { AccessibleWhenStoreClosed: true })
return RedirectToRoute("StoreClosed");
}
- var model = await _mediator.Send(new ContactUsCommand() {
+ var model = await _mediator.Send(new ContactUsCommand {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -360,7 +357,7 @@ namespace Grand.Web.Controllers
if (storeInformationSettings.StoreClosed)
{
var closestorepage = await pageService.GetPageBySystemName("ContactUs");
- if (closestorepage == null || !closestorepage.AccessibleWhenStoreClosed)
+ if (closestorepage is not { AccessibleWhenStoreClosed: true })
return RedirectToRoute("StoreClosed");
}
@@ -372,7 +369,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- var result = await _mediator.Send(new ContactUsSendCommand() {
+ var result = await _mediator.Send(new ContactUsSendCommand {
CaptchaValid = captchaValid,
Model = model,
Store = _workContext.CurrentStore,
@@ -395,11 +392,11 @@ namespace Grand.Web.Controllers
return View(model);
}
}
- var model1 = await _mediator.Send(new ContactUsCommand() {
+ var model1 = await _mediator.Send(new ContactUsCommand {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
- Model = model,
+ Model = model
});
return View(model1);
@@ -412,7 +409,7 @@ namespace Grand.Web.Controllers
if (!commonSettings.SitemapEnabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetSitemap() {
+ var model = await _mediator.Send(new GetSitemap {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -433,7 +430,7 @@ namespace Grand.Web.Controllers
//disabled
return Json(new { stored = false });
- //save consentcookies
+ //save consent cookies
await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, "", _workContext.CurrentStore.Id);
var dictionary = new Dictionary<string, bool>();
var consentCookies = cookiePreference.GetConsentCookies();
@@ -442,7 +439,7 @@ namespace Grand.Web.Controllers
dictionary.Add(item.SystemName, accept);
}
if (dictionary.Any())
- await userFieldService.SaveField<Dictionary<string, bool>>(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, dictionary, _workContext.CurrentStore.Id);
+ await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, dictionary, _workContext.CurrentStore.Id);
//save setting - CookieAccepted
await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.CookieAccepted, true, _workContext.CurrentStore.Id);
@@ -459,7 +456,7 @@ namespace Grand.Web.Controllers
//disabled
return Json(new { html = "" });
- var model = await _mediator.Send(new GetPrivacyPreference() {
+ var model = await _mediator.Send(new GetPrivacyPreference {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore
});
@@ -467,7 +464,7 @@ namespace Grand.Web.Controllers
return Json(new
{
html = await this.RenderPartialViewToString("PrivacyPreference", model, true),
- model,
+ model
});
}
@@ -500,7 +497,7 @@ namespace Grand.Web.Controllers
dictionary.Add(item.SystemName, selectedConsentCookies.Contains(item.SystemName));
}
- await userFieldService.SaveField<Dictionary<string, bool>>(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, dictionary, _workContext.CurrentStore.Id);
+ await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, dictionary, _workContext.CurrentStore.Id);
return Json(new { success = true });
}
@@ -510,7 +507,7 @@ namespace Grand.Web.Controllers
[PublicStore(true)]
public virtual async Task<IActionResult> RobotsTextFile()
{
- var sb = await _mediator.Send(new GetRobotsTextFile() { StoreId = _workContext.CurrentStore.Id });
+ var sb = await _mediator.Send(new GetRobotsTextFile { StoreId = _workContext.CurrentStore.Id });
return Content(sb, "text/plain");
}
@@ -522,13 +519,16 @@ namespace Grand.Web.Controllers
[ClosedStore(true)]
[PublicStore(true)]
- public virtual IActionResult StoreClosed() => View();
+ public virtual IActionResult StoreClosed()
+ {
+ return View();
+ }
[HttpPost]
[DenySystemAccount]
public virtual async Task<IActionResult> ContactAttributeChange(ContactAttributeChangeModel model)
{
- var result = await _mediator.Send(new ContactAttributeChangeCommand() {
+ var result = await _mediator.Send(new ContactAttributeChangeCommand {
Attributes = model.Attributes,
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore
@@ -547,12 +547,12 @@ namespace Grand.Web.Controllers
[FromServices] IContactAttributeService contactAttributeService)
{
var attribute = await contactAttributeService.GetContactAttributeById(attributeId);
- if (attribute == null || attribute.AttributeControlType != AttributeControlType.FileUpload)
+ if (attribute is not { AttributeControlType: AttributeControlType.FileUpload })
{
return Json(new
{
success = false,
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
var form = await HttpContext.Request.ReadFormAsync();
@@ -563,15 +563,15 @@ namespace Grand.Web.Controllers
{
success = false,
message = "No file uploaded",
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
var fileBinary = httpPostedFile.GetDownloadBits();
- var qqFileNameParameter = "qqfilename";
+ const string qqFileNameParameter = "qqfilename";
var fileName = httpPostedFile.FileName;
- if (String.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
+ if (string.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
fileName = form[qqFileNameParameter].ToString();
//remove path (passed in IE)
fileName = Path.GetFileName(fileName);
@@ -579,7 +579,7 @@ namespace Grand.Web.Controllers
var contentType = httpPostedFile.ContentType;
var fileExtension = Path.GetExtension(fileName);
- if (!String.IsNullOrEmpty(fileExtension))
+ if (!string.IsNullOrEmpty(fileExtension))
fileExtension = fileExtension.ToLowerInvariant();
if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))
@@ -593,7 +593,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = _translationService.GetResource("ShoppingCart.ValidationFileAllowed"),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -610,7 +610,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = string.Format(_translationService.GetResource("ShoppingCart.MaximumUploadedFileSize"), attribute.ValidationFileMaximumSize.Value),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -636,7 +636,7 @@ namespace Grand.Web.Controllers
success = true,
message = _translationService.GetResource("ShoppingCart.FileUploaded"),
downloadUrl = Url.Action("GetFileUpload", "Download", new { downloadId = download.DownloadGuid }),
- downloadGuid = download.DownloadGuid,
+ downloadGuid = download.DownloadGuid
});
}
@@ -651,7 +651,7 @@ namespace Grand.Web.Controllers
if (!customerSettings.GeoEnabled)
return Content("");
- await _mediator.Send(new CurrentPositionCommand() { Customer = _workContext.CurrentCustomer, Model = model });
+ await _mediator.Send(new CurrentPositionCommand { Customer = _workContext.CurrentCustomer, Model = model });
return Content("");
}
diff --git a/src/Web/Grand.Web/Controllers/CountryController.cs b/src/Web/Grand.Web/Controllers/CountryController.cs
index 829510b81..d432b979f 100644
--- a/src/Web/Grand.Web/Controllers/CountryController.cs
+++ b/src/Web/Grand.Web/Controllers/CountryController.cs
@@ -1,13 +1,13 @@
-using Grand.Web.Common.Filters;
-using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Web.Models.Common;
+using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Web.Common.Filters;
using Grand.Web.Features.Models.Common;
+using Grand.Web.Models.Common;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
- public partial class CountryController : BasePublicController
+ public class CountryController : BasePublicController
{
#region Fields
@@ -35,9 +35,9 @@ namespace Grand.Web.Controllers
//this action method gets called via an ajax request
if (string.IsNullOrEmpty(countryId))
{
- return Json(new List<StateProvinceModel>() { new StateProvinceModel { id = "", name = _translationService.GetResource("Address.SelectState") } });
+ return Json(new List<StateProvinceModel> { new() { id = "", name = _translationService.GetResource("Address.SelectState") } });
}
- var model = await _mediator.Send(new GetStatesProvince() { CountryId = countryId, AddSelectStateItem = addSelectStateItem });
+ var model = await _mediator.Send(new GetStatesProvince { CountryId = countryId, AddSelectStateItem = addSelectStateItem });
return Json(model);
}
diff --git a/src/Web/Grand.Web/Controllers/CourseController.cs b/src/Web/Grand.Web/Controllers/CourseController.cs
index fa6d90852..ea6ff9bf2 100644
--- a/src/Web/Grand.Web/Controllers/CourseController.cs
+++ b/src/Web/Grand.Web/Controllers/CourseController.cs
@@ -2,9 +2,9 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Marketing.Courses;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Courses;
using Grand.Domain.Customers;
using Grand.Infrastructure;
@@ -12,11 +12,10 @@ using Grand.Web.Commands.Models.Courses;
using Grand.Web.Features.Models.Courses;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Controllers
{
- public partial class CourseController : BasePublicController
+ public class CourseController : BasePublicController
{
private readonly IPermissionService _permissionService;
private readonly IAclService _aclService;
@@ -70,19 +69,14 @@ namespace Grand.Web.Controllers
return false;
//Check whether the current user purchased the course
- if (!await _mediator.Send(new GetCheckOrder() { Course = course, Customer = customer })
+ if (!await _mediator.Send(new GetCheckOrder { Course = course, Customer = customer })
&& !await _permissionService.Authorize(StandardPermission.ManageCourses, customer))
return false;
//ACL (access control list)
- if (!_aclService.Authorize(course, customer))
- return false;
-
- //Store access
- if (!_aclService.Authorize(course, _workContext.CurrentStore.Id))
- return false;
-
- return true;
+ return _aclService.Authorize(course, customer) &&
+ //Store access
+ _aclService.Authorize(course, _workContext.CurrentStore.Id);
}
public virtual async Task<IActionResult> Details(string courseId)
@@ -106,7 +100,7 @@ namespace Grand.Web.Controllers
_translationService.GetResource("ActivityLog.PublicStore.ViewCourse"), course.Name);
//model
- var model = await _mediator.Send(new GetCourse() {
+ var model = await _mediator.Send(new GetCourse {
Course = course,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage
@@ -139,7 +133,7 @@ namespace Grand.Web.Controllers
_translationService.GetResource("ActivityLog.PublicStore.ViewLesson"), lesson.Name);
//model
- var model = await _mediator.Send(new GetLesson() {
+ var model = await _mediator.Send(new GetLesson {
Course = course,
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
@@ -172,10 +166,10 @@ namespace Grand.Web.Controllers
//use stored data
if (download.DownloadBinary == null)
- return Content(string.Format("Download data is not available any more. Download GD={0}", download.Id));
+ return Content($"Download data is not available any more. Download GD={download.Id}");
- string fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : download.Id.ToString();
- string contentType = !string.IsNullOrWhiteSpace(download.ContentType)
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : download.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType)
? download.ContentType
: "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) {
@@ -207,10 +201,10 @@ namespace Grand.Web.Controllers
//use stored data
if (download.DownloadBinary == null)
- return Content(string.Format("Download data is not available any more. Download GD={0}", download.Id));
+ return Content($"Download data is not available any more. Download GD={download.Id}");
- string fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : download.Id.ToString();
- string contentType = !string.IsNullOrWhiteSpace(download.ContentType)
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : download.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType)
? download.ContentType
: "video/mp4";
return new FileContentResult(download.DownloadBinary, contentType) {
@@ -233,7 +227,7 @@ namespace Grand.Web.Controllers
if (!await CheckPermission(course, customer))
return Json(new { result = false });
- await _mediator.Send(new CourseLessonApprovedCommand() { Course = course, Lesson = lesson, Customer = _workContext.CurrentCustomer });
+ await _mediator.Send(new CourseLessonApprovedCommand { Course = course, Lesson = lesson, Customer = _workContext.CurrentCustomer });
return Json(new { result = true });
}
diff --git a/src/Web/Grand.Web/Controllers/DownloadController.cs b/src/Web/Grand.Web/Controllers/DownloadController.cs
index c275f9899..5d453e259 100644
--- a/src/Web/Grand.Web/Controllers/DownloadController.cs
+++ b/src/Web/Grand.Web/Controllers/DownloadController.cs
@@ -13,11 +13,12 @@ using Grand.Web.Common.Filters;
using Microsoft.AspNetCore.Mvc;
using System.IO.Compression;
using System.Text.RegularExpressions;
+using OperatingSystem = Grand.Infrastructure.OperatingSystem;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class DownloadController : BasePublicController
+ public class DownloadController : BasePublicController
{
private readonly IDownloadService _downloadService;
private readonly IProductService _productService;
@@ -63,8 +64,8 @@ namespace Grand.Web.Controllers
if (download.DownloadBinary == null)
return Content("Download data is not available any more.");
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -124,53 +125,46 @@ namespace Grand.Web.Controllers
if (product.ProductTypeId != ProductType.BundledProduct)
{
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
- else
+
+ using var memoryStream = new MemoryStream();
+ using (var ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
- using (var memoryStream = new MemoryStream())
+ var fileName = (!string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id) + download.Extension;
+ if (OperatingSystem.IsWindows())
+ {
+ await System.IO.File.WriteAllBytesAsync(@"App_Data\Download\" + fileName, download.DownloadBinary);
+ ziparchive.CreateEntryFromFile(@"App_Data\Download\" + fileName, fileName);
+ }
+ else
{
- using (var ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
+ await System.IO.File.WriteAllBytesAsync(@"App_Data/Download/" + fileName, download.DownloadBinary);
+ ziparchive.CreateEntryFromFile(@"App_Data/Download/" + fileName, fileName);
+ }
+ foreach (var bundle in product.BundleProducts)
+ {
+ var p1 = await _productService.GetProductById(bundle.ProductId);
+ if (p1 is not { IsDownload: true }) continue;
+
+ var d1 = await _downloadService.GetDownloadById(p1.DownloadId);
+ if (d1 is not { UseDownloadUrl: false }) continue;
+ fileName = (!string.IsNullOrWhiteSpace(d1.Filename) ? d1.Filename : p1.Id) + d1.Extension;
+ if (OperatingSystem.IsWindows())
+ {
+ await System.IO.File.WriteAllBytesAsync(@"App_Data\Download\" + fileName, d1.DownloadBinary);
+ ziparchive.CreateEntryFromFile(@"App_Data\Download\" + fileName, fileName);
+ }
+ else
{
- string fileName = (!String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id.ToString()) + download.Extension;
- if (Grand.Infrastructure.OperatingSystem.IsWindows())
- {
- System.IO.File.WriteAllBytes(@"App_Data\Download\" + fileName, download.DownloadBinary);
- ziparchive.CreateEntryFromFile(@"App_Data\Download\" + fileName, fileName);
- }
- else
- {
- System.IO.File.WriteAllBytes(@"App_Data/Download/" + fileName, download.DownloadBinary);
- ziparchive.CreateEntryFromFile(@"App_Data/Download/" + fileName, fileName);
- }
- foreach (var bundle in product.BundleProducts)
- {
- var p1 = await _productService.GetProductById(bundle.ProductId);
- if (p1 != null && p1.IsDownload)
- {
- var d1 = await _downloadService.GetDownloadById(p1.DownloadId);
- if (d1 != null && !d1.UseDownloadUrl)
- {
- fileName = (!String.IsNullOrWhiteSpace(d1.Filename) ? d1.Filename : p1.Id.ToString()) + d1.Extension;
- if (Grand.Infrastructure.OperatingSystem.IsWindows())
- {
- System.IO.File.WriteAllBytes(@"App_Data\Download\" + fileName, d1.DownloadBinary);
- ziparchive.CreateEntryFromFile(@"App_Data\Download\" + fileName, fileName);
- }
- else
- {
- System.IO.File.WriteAllBytes(@"App_Data/Download/" + fileName, d1.DownloadBinary);
- ziparchive.CreateEntryFromFile(@"App_Data/Download/" + fileName, fileName);
- }
- }
- }
- }
+ await System.IO.File.WriteAllBytesAsync(@"App_Data/Download/" + fileName, d1.DownloadBinary);
+ ziparchive.CreateEntryFromFile(@"App_Data/Download/" + fileName, fileName);
}
- return File(memoryStream.ToArray(), "application/zip", $"{Regex.Replace(product.Name, "[^A-Za-z0-9 _]", "")}.zip");
}
}
+ return File(memoryStream.ToArray(), "application/zip", $"{Regex.Replace(product.Name, "[^A-Za-z0-9 _]", "")}.zip");
}
public virtual async Task<IActionResult> GetLicense(Guid orderItemId)
@@ -190,7 +184,7 @@ namespace Grand.Web.Controllers
return Challenge();
}
- var download = await _downloadService.GetDownloadById(!String.IsNullOrEmpty(orderItem.LicenseDownloadId) ? orderItem.LicenseDownloadId : "");
+ var download = await _downloadService.GetDownloadById(!string.IsNullOrEmpty(orderItem.LicenseDownloadId) ? orderItem.LicenseDownloadId : "");
if (download == null)
return Content("Download is not available any more.");
@@ -202,8 +196,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : product.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -221,8 +215,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : downloadId.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : downloadId.ToString();
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -251,8 +245,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : orderNote.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : orderNote.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -286,8 +280,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : shipmentNote.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : shipmentNote.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -316,8 +310,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : customerNote.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : customerNote.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -346,8 +340,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : merchandiseReturnNote.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : merchandiseReturnNote.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
@@ -358,7 +352,7 @@ namespace Grand.Web.Controllers
return Content("Download is not available.");
var document = await documentService.GetById(documentId);
- if (document == null || !document.Published)
+ if (document is not { Published: true })
return InvokeHttp404();
if (_workContext.CurrentCustomer == null || document.CustomerId != _workContext.CurrentCustomer.Id)
@@ -376,8 +370,8 @@ namespace Grand.Web.Controllers
return Content("Download data is not available any more.");
//return result
- string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : document.Id.ToString();
- string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
+ var fileName = !string.IsNullOrWhiteSpace(download.Filename) ? download.Filename : document.Id;
+ var contentType = !string.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream";
return new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension };
}
}
diff --git a/src/Web/Grand.Web/Controllers/HomeController.cs b/src/Web/Grand.Web/Controllers/HomeController.cs
index f0c4bf523..13730b371 100644
--- a/src/Web/Grand.Web/Controllers/HomeController.cs
+++ b/src/Web/Grand.Web/Controllers/HomeController.cs
@@ -2,8 +2,11 @@
namespace Grand.Web.Controllers
{
- public partial class HomeController : BasePublicController
+ public class HomeController : BasePublicController
{
- public virtual IActionResult Index() => View();
+ public virtual IActionResult Index()
+ {
+ return View();
+ }
}
}
diff --git a/src/Web/Grand.Web/Controllers/InstallController.cs b/src/Web/Grand.Web/Controllers/InstallController.cs
index 432b25e37..3451ec252 100644
--- a/src/Web/Grand.Web/Controllers/InstallController.cs
+++ b/src/Web/Grand.Web/Controllers/InstallController.cs
@@ -1,11 +1,11 @@
-using Grand.Business.Core.Interfaces.Common.Logging;
+using Grand.Business.Core.Commands.System.Security;
+using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Commands.System.Security;
using Grand.Business.Core.Interfaces.System.Installation;
using Grand.Domain.Data;
+using Grand.Domain.Logging;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Configuration;
-using Grand.Infrastructure.Extensions;
using Grand.Infrastructure.Migrations;
using Grand.Infrastructure.Plugins;
using Grand.SharedKernel.Extensions;
@@ -19,7 +19,7 @@ using Microsoft.Extensions.Hosting;
namespace Grand.Web.Controllers
{
- public partial class InstallController : Controller
+ public class InstallController : Controller
{
#region Fields
@@ -60,29 +60,21 @@ namespace Grand.Web.Controllers
{
HttpContext.Request.Cookies.TryGetValue(LANGUAGE_COOKIE_NAME, out var language);
- if (string.IsNullOrEmpty(language))
- {
- //find by current browser culture
- if (HttpContext.Request.Headers.TryGetValue("Accept-Language", out var userLanguages))
- {
- var userLanguage = userLanguages.FirstOrDefault()?.Split(',')[0];
- if (!string.IsNullOrEmpty(userLanguage))
- {
- return userLanguage;
- }
- }
- }
-
- return language;
+ if (!string.IsNullOrEmpty(language)) return language;
+ //find by current browser culture
+ if (!HttpContext.Request.Headers.TryGetValue("Accept-Language", out var userLanguages)) return language;
+ var userLanguage = userLanguages.FirstOrDefault()?.Split(',')[0];
+ return !string.IsNullOrEmpty(userLanguage) ? userLanguage : language;
}
- protected InstallModel PrepareModel(InstallModel model)
+
+ private InstallModel PrepareModel(InstallModel model)
{
var locService = _serviceProvider.GetRequiredService<IInstallationLocalizedService>();
model ??= new InstallModel {
AdminEmail = "[email protected]",
InstallSampleData = false,
- DatabaseConnectionString = "",
+ DatabaseConnectionString = ""
};
model.AvailableProviders = Enum.GetValues(typeof(DbProvider)).Cast<DbProvider>().Select(v => new SelectListItem {
@@ -104,7 +96,7 @@ namespace Grand.Web.Controllers
model.AvailableLanguages.Add(new SelectListItem {
Value = Url.RouteUrl("InstallChangeLanguage", new { language = lang.Code }),
Text = lang.Name,
- Selected = selected,
+ Selected = selected
});
}
//prepare collation list
@@ -113,7 +105,7 @@ namespace Grand.Web.Controllers
model.AvailableCollation.Add(new SelectListItem {
Value = col.Value,
Text = col.Name,
- Selected = locService.GetCurrentLanguage().Code == col.Value,
+ Selected = locService.GetCurrentLanguage().Code == col.Value
});
}
@@ -125,16 +117,11 @@ namespace Grand.Web.Controllers
if (DataSettingsManager.DatabaseIsInstalled())
return RedirectToRoute("HomePage");
- var locService = _serviceProvider.GetRequiredService<IInstallationLocalizedService>();
-
- var installed = await _cacheBase.GetAsync("Installed", async () => { return await Task.FromResult(false); });
- if (installed)
- return View(new InstallModel() { Installed = true });
-
- return View(PrepareModel(null));
+ var installed = await _cacheBase.GetAsync("Installed", async () => await Task.FromResult(false));
+ return View(installed ? new InstallModel { Installed = true } : PrepareModel(null));
}
- protected string BuildConnectionString(IInstallationLocalizedService locService, InstallModel model)
+ private string BuildConnectionString(IInstallationLocalizedService locService, InstallModel model)
{
var connectionString = "";
@@ -155,7 +142,7 @@ namespace Grand.Web.Controllers
ModelState.AddModelError("", locService.GetResource(model.SelectedLanguage, "MongoDBServerNameRequired"));
var userNameandPassword = "";
- if (!(string.IsNullOrEmpty(model.MongoDBUsername)))
+ if (!string.IsNullOrEmpty(model.MongoDBUsername))
userNameandPassword = model.MongoDBUsername + ":" + model.MongoDBPassword + "@";
connectionString = "mongodb://" + userNameandPassword + model.MongoDBServerName + "/" + model.MongoDBDatabaseName;
@@ -221,69 +208,67 @@ namespace Grand.Web.Controllers
await CheckConnectionString(locService, connectionString, model);
- if (ModelState.IsValid)
+ if (!ModelState.IsValid) return View(PrepareModel(model));
+ try
{
- try
- {
- //save settings
- var settings = new DataSettings {
- ConnectionString = connectionString,
- DbProvider = model.DataProvider
- };
+ //save settings
+ var settings = new DataSettings {
+ ConnectionString = connectionString,
+ DbProvider = model.DataProvider
+ };
- await DataSettingsManager.SaveSettings(settings);
- DataSettingsManager.LoadSettings(reloadSettings: true);
+ await DataSettingsManager.SaveSettings(settings);
+ DataSettingsManager.LoadSettings(reloadSettings: true);
- var installationService = _serviceProvider.GetRequiredService<IInstallationService>();
- await installationService.InstallData(
- HttpContext.Request.Scheme, HttpContext.Request.Host,
- model.AdminEmail, model.AdminPassword, model.Collation,
- model.InstallSampleData, model.CompanyName, model.CompanyAddress, model.CompanyPhoneNumber, model.CompanyEmail);
+ var installationService = _serviceProvider.GetRequiredService<IInstallationService>();
+ await installationService.InstallData(
+ HttpContext.Request.Scheme, HttpContext.Request.Host,
+ model.AdminEmail, model.AdminPassword, model.Collation,
+ model.InstallSampleData, model.CompanyName, model.CompanyAddress, model.CompanyPhoneNumber, model.CompanyEmail);
- //reset cache
- DataSettingsManager.ResetCache();
+ //reset cache
+ DataSettingsManager.ResetCache();
- PluginManager.ClearPlugins();
+ PluginManager.ClearPlugins();
- var pluginsInfo = PluginManager.ReferencedPlugins.ToList();
+ var pluginsInfo = PluginManager.ReferencedPlugins.ToList();
- foreach (var pluginInfo in pluginsInfo)
+ foreach (var pluginInfo in pluginsInfo)
+ {
+ try
{
- try
- {
- var plugin = pluginInfo.Instance<IPlugin>(_serviceProvider);
- await plugin.Install();
- }
- catch (Exception ex)
- {
- var _logger = _serviceProvider.GetRequiredService<ILogger>();
- await _logger.InsertLog(Domain.Logging.LogLevel.Error, "Error during installing plugin " + pluginInfo.SystemName,
- ex.Message + " " + ex.InnerException?.Message);
- }
+ var plugin = pluginInfo.Instance<IPlugin>(_serviceProvider);
+ await plugin.Install();
}
+ catch (Exception ex)
+ {
+ var _logger = _serviceProvider.GetRequiredService<ILogger>();
+ await _logger.InsertLog(LogLevel.Error, "Error during installing plugin " + pluginInfo.SystemName,
+ ex.Message + " " + ex.InnerException?.Message);
+ }
+ }
- //register default permissions
- var permissionProvider = _serviceProvider.GetRequiredService<IPermissionProvider>();
- await _mediator.Send(new InstallPermissionsCommand() { PermissionProvider = permissionProvider });
+ //register default permissions
+ var permissionProvider = _serviceProvider.GetRequiredService<IPermissionProvider>();
+ await _mediator.Send(new InstallPermissionsCommand { PermissionProvider = permissionProvider });
- //install migration process - install only header
- var migrationProcess = _serviceProvider.GetRequiredService<IMigrationProcess>();
- migrationProcess.InstallApplication();
+ //install migration process - install only header
+ var migrationProcess = _serviceProvider.GetRequiredService<IMigrationProcess>();
+ migrationProcess.InstallApplication();
- //restart application
- await _cacheBase.GetAsync("Installed", () => Task.FromResult(true));
- return View(new InstallModel() { Installed = true });
- }
- catch (Exception exception)
- {
- //reset cache
- DataSettingsManager.ResetCache();
- await _cacheBase.Clear();
+ //restart application
+ await _cacheBase.GetAsync("Installed", () => Task.FromResult(true));
+ return View(new InstallModel { Installed = true });
+ }
+ catch (Exception exception)
+ {
+ //reset cache
+ DataSettingsManager.ResetCache();
+ await _cacheBase.Clear();
- System.IO.File.Delete(CommonPath.SettingsPath);
+ System.IO.File.Delete(CommonPath.SettingsPath);
- ModelState.AddModelError("", string.Format(locService.GetResource(model.SelectedLanguage, "SetupFailed"), exception.Message + " " + exception.InnerException?.Message));
- }
+ ModelState.AddModelError("", string.Format(locService.GetResource(model.SelectedLanguage, "SetupFailed"), exception.Message + " " + exception.InnerException?.Message));
}
return View(PrepareModel(model));
}
diff --git a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs b/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
index 4b6615cdb..70e74a185 100644
--- a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
+++ b/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs
@@ -1,11 +1,12 @@
using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Customers;
using Grand.Domain.Knowledgebase;
using Grand.Domain.Localization;
@@ -14,10 +15,9 @@ using Grand.Infrastructure.Caching;
using Grand.Web.Common.Filters;
using Grand.Web.Common.Security.Captcha;
using Grand.Web.Events.Cache;
+using Grand.Web.Extensions;
using Grand.Web.Models.Knowledgebase;
using Microsoft.AspNetCore.Mvc;
-using Grand.Web.Extensions;
-using Grand.Business.Core.Interfaces.Cms;
namespace Grand.Web.Controllers
{
@@ -88,7 +88,6 @@ namespace Grand.Web.Controllers
var model = new KnowledgebaseHomePageModel();
var articles = await _knowledgebaseService.GetPublicKnowledgebaseArticlesByCategory(categoryId);
- var allCategories = _knowledgebaseService.GetPublicKnowledgebaseCategories();
articles.ForEach(x => model.Items.Add(new KnowledgebaseItemModel {
Name = x.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id),
Id = x.Id,
@@ -110,7 +109,7 @@ namespace Grand.Web.Controllers
model.CurrentCategoryName = category.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id);
model.CurrentCategorySeName = category.GetTranslation(y => y.SeName, _workContext.WorkingLanguage.Id);
- string breadcrumbCacheKey = string.Format(CacheKeyConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY, category.Id,
+ var breadcrumbCacheKey = string.Format(CacheKeyConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY, category.Id,
string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()), _workContext.CurrentStore.Id, _workContext.WorkingLanguage.Id);
model.CategoryBreadcrumb = await _cacheBase.GetAsync(breadcrumbCacheKey, async () =>
(await category.GetCategoryBreadCrumb(_knowledgebaseService, _aclService, _workContext))
@@ -215,7 +214,7 @@ namespace Grand.Web.Controllers
CustomerId = ac.CustomerId,
CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat),
CommentText = ac.CommentText,
- CreatedOn = _dateTimeService.ConvertToUserTime(ac.CreatedOnUtc, DateTimeKind.Utc),
+ CreatedOn = _dateTimeService.ConvertToUserTime(ac.CreatedOnUtc, DateTimeKind.Utc)
};
model.Comments.Add(commentModel);
}
@@ -234,7 +233,7 @@ namespace Grand.Web.Controllers
var category = await _knowledgebaseService.GetKnowledgebaseCategory(article.ParentCategoryId);
if (category != null)
{
- string breadcrumbCacheKey = string.Format(CacheKeyConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY,
+ var breadcrumbCacheKey = string.Format(CacheKeyConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY,
article.ParentCategoryId,
string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
_workContext.CurrentStore.Id,
@@ -264,7 +263,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var article = await _knowledgebaseService.GetPublicKnowledgebaseArticle(articleId);
- if (article == null || !article.AllowComments)
+ if (article is not { AllowComments: true })
return RedirectToRoute("HomePage");
if (await groupService.IsGuest(workContext.CurrentCustomer) && !_knowledgebaseSettings.AllowNotRegisteredUsersToLeaveComments)
@@ -286,7 +285,7 @@ namespace Grand.Web.Controllers
CustomerId = customer.Id,
CommentText = model.AddNewComment.CommentText,
CreatedOnUtc = DateTime.UtcNow,
- ArticleTitle = article.Name,
+ ArticleTitle = article.Name
};
await _knowledgebaseService.InsertArticleComment(comment);
diff --git a/src/Web/Grand.Web/Controllers/LetsEncryptController.cs b/src/Web/Grand.Web/Controllers/LetsEncryptController.cs
index c6251c872..c2e023da9 100644
--- a/src/Web/Grand.Web/Controllers/LetsEncryptController.cs
+++ b/src/Web/Grand.Web/Controllers/LetsEncryptController.cs
@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
[AllowAnonymous]
- public partial class LetsEncryptController : Controller
+ public class LetsEncryptController : Controller
{
private readonly CommonSettings _commonSettings;
private readonly IMediaFileStore _mediaFileStore;
diff --git a/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs b/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
index e71a5424d..563ff97f6 100644
--- a/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
+++ b/src/Web/Grand.Web/Controllers/MerchandiseReturnController.cs
@@ -1,8 +1,8 @@
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Addresses;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Domain.Common;
using Grand.Domain.Orders;
using Grand.Infrastructure;
@@ -14,14 +14,13 @@ using Grand.Web.Features.Models.Orders;
using Grand.Web.Models.Common;
using Grand.Web.Models.Orders;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class MerchandiseReturnController : BasePublicController
+ public class MerchandiseReturnController : BasePublicController
{
#region Fields
@@ -65,8 +64,7 @@ namespace Grand.Web.Controllers
{
var countryService = HttpContext.RequestServices.GetRequiredService<ICountryService>();
var countries = await countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
- addressModel = await _mediator.Send(new GetAddressModel()
- {
+ addressModel = await _mediator.Send(new GetAddressModel {
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
Customer = _workContext.CurrentCustomer,
@@ -88,7 +86,7 @@ namespace Grand.Web.Controllers
}
else
{
- var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes() { SelectedAttributes = model.MerchandiseReturnNewAddress.SelectedAttributes });
+ var customAttributes = await _mediator.Send(new GetParseCustomAddressAttributes { SelectedAttributes = model.MerchandiseReturnNewAddress.SelectedAttributes });
var addressAttributeParser = HttpContext.RequestServices.GetRequiredService<IAddressAttributeParser>();
var customAttributeWarnings = await addressAttributeParser.GetAttributeWarnings(customAttributes);
foreach (var error in customAttributeWarnings)
@@ -113,8 +111,7 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsRegistered(_workContext.CurrentCustomer))
return Challenge();
- var model = await _mediator.Send(new GetMerchandiseReturns()
- {
+ var model = await _mediator.Send(new GetMerchandiseReturns {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Language = _workContext.WorkingLanguage
@@ -129,11 +126,10 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- if (!await _mediator.Send(new IsMerchandiseReturnAllowedQuery() { Order = order }))
+ if (!await _mediator.Send(new IsMerchandiseReturnAllowedQuery { Order = order }))
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetMerchandiseReturn()
- {
+ var model = await _mediator.Send(new GetMerchandiseReturn {
Order = order,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -150,7 +146,7 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- if (!await _mediator.Send(new IsMerchandiseReturnAllowedQuery() { Order = order }))
+ if (!await _mediator.Send(new IsMerchandiseReturnAllowedQuery { Order = order }))
return RedirectToRoute("HomePage");
if (_orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate && _orderSettings.MerchandiseReturns_PickupDateRequired && model.PickupDate == null)
@@ -162,8 +158,7 @@ namespace Grand.Web.Controllers
if (ModelState is { IsValid: false })
{
- var returnModel = await _mediator.Send(new GetMerchandiseReturn()
- {
+ var returnModel = await _mediator.Send(new GetMerchandiseReturn {
Order = order,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -181,7 +176,7 @@ namespace Grand.Web.Controllers
}
else
{
- var result = await _mediator.Send(new MerchandiseReturnSubmitCommand() { Address = address, Model = model, Order = order });
+ var result = await _mediator.Send(new MerchandiseReturnSubmitCommand { Address = address, Model = model, Order = order });
if (result.rr.ReturnNumber > 0)
{
model.Result = string.Format(_translationService.GetResource("MerchandiseReturns.Submitted"), result.rr.ReturnNumber, Url.Link("MerchandiseReturnDetails", new { merchandiseReturnId = result.rr.Id }));
@@ -190,8 +185,7 @@ namespace Grand.Web.Controllers
return View(result.model);
}
- var returnModel = await _mediator.Send(new GetMerchandiseReturn()
- {
+ var returnModel = await _mediator.Send(new GetMerchandiseReturn {
Order = order,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -219,11 +213,10 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var model = await _mediator.Send(new GetMerchandiseReturnDetails()
- {
+ var model = await _mediator.Send(new GetMerchandiseReturnDetails {
Order = order,
Language = _workContext.WorkingLanguage,
- MerchandiseReturn = rr,
+ MerchandiseReturn = rr
});
return View(model);
diff --git a/src/Web/Grand.Web/Controllers/NewsController.cs b/src/Web/Grand.Web/Controllers/NewsController.cs
index b02ea8e10..caa701248 100644
--- a/src/Web/Grand.Web/Controllers/NewsController.cs
+++ b/src/Web/Grand.Web/Controllers/NewsController.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
@@ -18,7 +18,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
- public partial class NewsController : BasePublicController
+ public class NewsController : BasePublicController
{
#region Fields
@@ -66,7 +66,7 @@ namespace Grand.Web.Controllers
if (!_newsSettings.Enabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetNewsItemList() { Command = command });
+ var model = await _mediator.Send(new GetNewsItemList { Command = command });
return View(model);
}
public virtual async Task<IActionResult> NewsItem(string newsItemId)
@@ -75,15 +75,14 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var newsItem = await _newsService.GetNewsById(newsItemId);
- if (newsItem == null ||
- !newsItem.Published ||
+ if (newsItem is not { Published: true } ||
(newsItem.StartDateUtc.HasValue && newsItem.StartDateUtc.Value >= DateTime.UtcNow) ||
(newsItem.EndDateUtc.HasValue && newsItem.EndDateUtc.Value <= DateTime.UtcNow) ||
//Store acl
!_aclService.Authorize(newsItem, _workContext.CurrentStore.Id))
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetNewsItem() { NewsItem = newsItem });
+ var model = await _mediator.Send(new GetNewsItem { NewsItem = newsItem });
//display "edit" (manage) link
if (await _permissionService.Authorize(StandardPermission.AccessAdminPanel) && await _permissionService.Authorize(StandardPermission.ManageNews))
@@ -105,7 +104,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var newsItem = await _newsService.GetNewsById(newsItemId);
- if (newsItem == null || !newsItem.Published || !newsItem.AllowComments)
+ if (newsItem is not { Published: true } || !newsItem.AllowComments)
return RedirectToRoute("HomePage");
//validate CAPTCHA
@@ -121,7 +120,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- await _mediator.Send(new InsertNewsCommentCommand() { NewsItem = newsItem, Model = model });
+ await _mediator.Send(new InsertNewsCommentCommand { NewsItem = newsItem, Model = model });
//notification
await _mediator.Publish(new NewsCommentEvent(newsItem, model.AddNewComment));
@@ -136,7 +135,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("NewsItem", new { SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id) });
}
- model = await _mediator.Send(new GetNewsItem() { NewsItem = newsItem });
+ model = await _mediator.Send(new GetNewsItem { NewsItem = newsItem });
return View("NewsItem", model);
}
#endregion
diff --git a/src/Web/Grand.Web/Controllers/NewsletterController.cs b/src/Web/Grand.Web/Controllers/NewsletterController.cs
index 4c854f3d5..3d2b7bf16 100644
--- a/src/Web/Grand.Web/Controllers/NewsletterController.cs
+++ b/src/Web/Grand.Web/Controllers/NewsletterController.cs
@@ -3,13 +3,12 @@ using Grand.Web.Common.Controllers;
using Grand.Web.Common.Filters;
using Grand.Web.Models.Newsletter;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class NewsletterController : BasePublicController
+ public class NewsletterController : BasePublicController
{
private readonly IMediator _mediator;
@@ -21,25 +20,29 @@ namespace Grand.Web.Controllers
[HttpPost]
public virtual async Task<IActionResult> SubscribeNewsletter(string email, bool subscribe)
{
- var model = await _mediator.Send(new SubscribeNewsletterCommand() { Email = email, Subscribe = subscribe });
- if (model.NewsletterCategory != null)
- {
- model.ShowCategories = true;
- model.ResultCategory = await this.RenderPartialViewToString("NewsletterCategory", model.NewsletterCategory, true);
- }
+ var model = await _mediator.Send(new SubscribeNewsletterCommand { Email = email, Subscribe = subscribe });
+ if (model.NewsletterCategory == null)
+ return Json(new {
+ model.Success,
+ model.Result,
+ Showcategories = model.ShowCategories,
+ model.ResultCategory
+ });
+ model.ShowCategories = true;
+ model.ResultCategory = await this.RenderPartialViewToString("NewsletterCategory", model.NewsletterCategory, true);
return Json(new
{
- Success = model.Success,
- Result = model.Result,
+ model.Success,
+ model.Result,
Showcategories = model.ShowCategories,
- ResultCategory = model.ResultCategory,
+ model.ResultCategory
});
}
[HttpPost]
public virtual async Task<IActionResult> SaveCategories(NewsletterCategoryModel model)
{
- var result = await _mediator.Send(new SubscriptionCategoryCommand() { Model = model});
+ var result = await _mediator.Send(new SubscriptionCategoryCommand { Model = model});
return Json(new
{
Success = result.success,
@@ -50,11 +53,8 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> SubscriptionActivation(Guid token, bool active)
{
- var model = await _mediator.Send(new SubscriptionActivationCommand() { Active = active, Token = token });
- if (model == null)
- return RedirectToRoute("HomePage");
-
- return View(model);
+ var model = await _mediator.Send(new SubscriptionActivationCommand { Active = active, Token = token });
+ return model == null ? RedirectToRoute("HomePage") : View(model);
}
}
}
diff --git a/src/Web/Grand.Web/Controllers/OrderController.cs b/src/Web/Grand.Web/Controllers/OrderController.cs
index e8dd81517..6ffb6edc5 100644
--- a/src/Web/Grand.Web/Controllers/OrderController.cs
+++ b/src/Web/Grand.Web/Controllers/OrderController.cs
@@ -6,10 +6,12 @@ using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Pdf;
using Grand.Domain.Orders;
+using Grand.Domain.Payments;
using Grand.Domain.Shipping;
using Grand.Infrastructure;
using Grand.Web.Commands.Models.Orders;
using Grand.Web.Common.Filters;
+using Grand.Web.Common.Page;
using Grand.Web.Events;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Orders;
@@ -20,7 +22,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class OrderController : BasePublicController
+ public class OrderController : BasePublicController
{
#region Fields
@@ -67,14 +69,8 @@ namespace Grand.Web.Controllers
}
}
protected virtual bool IsPostBeingDone {
- get {
- if (HttpContext.Items["grand.IsPOSTBeingDone"] == null)
- return false;
- return Convert.ToBoolean(HttpContext.Items["grand.IsPOSTBeingDone"]);
- }
- set {
- HttpContext.Items["grand.IsPOSTBeingDone"] = value;
- }
+ get => HttpContext.Items["grand.IsPOSTBeingDone"] != null && Convert.ToBoolean(HttpContext.Items["grand.IsPOSTBeingDone"]);
+ set => HttpContext.Items["grand.IsPOSTBeingDone"] = value;
}
@@ -88,7 +84,7 @@ namespace Grand.Web.Controllers
if (!await _groupService.IsRegistered(_workContext.CurrentCustomer))
return Challenge();
- var model = await _mediator.Send(new GetCustomerOrderList() {
+ var model = await _mediator.Send(new GetCustomerOrderList {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
@@ -104,7 +100,7 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var model = await _mediator.Send(new GetOrderDetails() { Order = order, Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetOrderDetails { Order = order, Language = _workContext.WorkingLanguage });
return View(model);
}
@@ -116,7 +112,7 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var model = await _mediator.Send(new GetOrderDetails() { Order = order, Language = _workContext.WorkingLanguage });
+ var model = await _mediator.Send(new GetOrderDetails { Order = order, Language = _workContext.WorkingLanguage });
model.PrintMode = true;
return View("Details", model);
@@ -127,16 +123,16 @@ namespace Grand.Web.Controllers
{
var order = await _orderService.GetOrderById(orderId);
if (!await order.Access(_workContext.CurrentCustomer, _groupService)
- || order.PaymentStatusId != Domain.Payments.PaymentStatus.Pending
+ || order.PaymentStatusId != PaymentStatus.Pending
|| (order.ShippingStatusId != ShippingStatus.ShippingNotRequired && order.ShippingStatusId != ShippingStatus.Pending)
|| order.OrderStatusId != (int)OrderStatusSystem.Pending
|| !_orderSettings.UserCanCancelUnpaidOrder)
return Challenge();
- await _mediator.Send(new CancelOrderCommand() { Order = order, NotifyCustomer = true, NotifyStoreOwner = true });
+ await _mediator.Send(new CancelOrderCommand { Order = order, NotifyCustomer = true, NotifyStoreOwner = true });
- return RedirectToRoute("OrderDetails", new { orderId = orderId });
+ return RedirectToRoute("OrderDetails", new { orderId });
}
//My account / Order details page / PDF invoice
@@ -146,15 +142,14 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var orders = new List<Order>();
- orders.Add(order);
+ var orders = new List<Order> { order };
byte[] bytes;
using (var stream = new MemoryStream())
{
await pdfService.PrintOrdersToPdf(stream, orders, _workContext.WorkingLanguage.Id);
bytes = stream.ToArray();
}
- return File(bytes, "application/pdf", string.Format("order_{0}.pdf", order.Id));
+ return File(bytes, "application/pdf", $"order_{order.Id}.pdf");
}
//My account / Order details page / Add order note
@@ -174,12 +169,12 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- await _mediator.Send(new InsertOrderNoteCommand() { Order = order, OrderNote = model, Language = _workContext.WorkingLanguage });
+ await _mediator.Send(new InsertOrderNoteCommand { Order = order, OrderNote = model, Language = _workContext.WorkingLanguage });
//notification
await _mediator.Publish(new OrderNoteEvent(order, model));
- Notification(Common.Page.NotifyType.Success, _translationService.GetResource("OrderNote.Added"), true);
+ Notification(NotifyType.Success, _translationService.GetResource("OrderNote.Added"), true);
return RedirectToRoute("OrderDetails", new { orderId = model.OrderId });
}
@@ -190,9 +185,9 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var warnings = await _mediator.Send(new ReOrderCommand() { Order = order });
+ var warnings = await _mediator.Send(new ReOrderCommand { Order = order });
if (warnings.Any())
- Notification(Common.Page.NotifyType.Error, string.Join(",", warnings), true);
+ Notification(NotifyType.Error, string.Join(",", warnings), true);
return RedirectToRoute("ShoppingCart");
}
@@ -209,7 +204,7 @@ namespace Grand.Web.Controllers
var paymentTransaction = await _paymentTransactionService.GetOrderByGuid(order.OrderGuid);
if (paymentTransaction == null || !await _paymentService.CanRePostRedirectPayment(paymentTransaction))
- return RedirectToRoute("OrderDetails", new { orderId = orderId });
+ return RedirectToRoute("OrderDetails", new { orderId });
await _paymentService.PostRedirectPayment(paymentTransaction);
@@ -221,7 +216,7 @@ namespace Grand.Web.Controllers
//if no redirection has been done (to a third-party payment page)
//theoretically it's not possible
- return RedirectToRoute("OrderDetails", new { orderId = orderId });
+ return RedirectToRoute("OrderDetails", new { orderId });
}
//My account / Order details page / Shipment details page
@@ -235,7 +230,7 @@ namespace Grand.Web.Controllers
if (!await order.Access(_workContext.CurrentCustomer, _groupService))
return Challenge();
- var model = await _mediator.Send(new GetShipmentDetails() {
+ var model = await _mediator.Send(new GetShipmentDetails {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Order = order,
@@ -254,7 +249,7 @@ namespace Grand.Web.Controllers
if (!loyaltyPointsSettings.Enabled)
return RedirectToRoute("CustomerInfo");
- var model = await _mediator.Send(new GetCustomerLoyaltyPoints() {
+ var model = await _mediator.Send(new GetCustomerLoyaltyPoints {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Currency = _workContext.WorkingCurrency
diff --git a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
index 0ba5ec5ae..9f6fc0253 100644
--- a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
+++ b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Catalog;
@@ -10,13 +10,12 @@ using Grand.Web.Common.Filters;
using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Catalog;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
[DenySystemAccount]
- public partial class OutOfStockSubscriptionController : BasePublicController
+ public class OutOfStockSubscriptionController : BasePublicController
{
#region Fields
@@ -76,19 +75,20 @@ namespace Grand.Web.Controllers
if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStock)
return Content(_translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"));
- warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- (string.IsNullOrEmpty(warehouseId) ? "" : warehouseId) :
- (string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
+ warehouseId = _shoppingCartSettings.AllowToSelectWarehouse
+ ?
+ string.IsNullOrEmpty(warehouseId) ? "" : warehouseId
+ :
+ string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId)
+ ? product.WarehouseId
+ : _workContext.CurrentStore.DefaultWarehouseId;
var subscription = await _outOfStockSubscriptionService
- .FindSubscription(customer.Id, product.Id, null, _workContext.CurrentStore.Id,
- warehouseId);
+ .FindSubscription(customer.Id, product.Id, null, _workContext.CurrentStore.Id,
+ warehouseId);
- if (subscription != null)
- {
- return Content(_translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable"));
- }
- return Content(_translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"));
+ return Content(subscription != null ? _translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable") :
+ _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"));
}
[HttpPost, ActionName("SubscribePopup")]
@@ -99,20 +99,19 @@ namespace Grand.Web.Controllers
throw new ArgumentException("No product found with the specified id");
var customer = _workContext.CurrentCustomer;
- var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- model.WarehouseId :
- product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
- (string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ? model.WarehouseId :
+ product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
+ string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId :
+ _workContext.CurrentStore.DefaultWarehouseId;
if (!await _groupService.IsRegistered(customer))
- return Json(new
- {
+ return Json(new {
subscribe = false,
buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
resource = _translationService.GetResource("OutOfStockSubscriptions.OnlyRegistered")
});
- if ((product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock) &&
+ if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock &&
product.BackorderModeId == BackorderMode.NoBackorders &&
product.AllowOutOfStockSubscriptions &&
_stockQuantityService.GetTotalStockQuantity(product, warehouseId: warehouseId) <= 0)
@@ -124,13 +123,11 @@ namespace Grand.Web.Controllers
//subscription already exists
//unsubscribe
await _outOfStockSubscriptionService.DeleteSubscription(subscription);
- return Json(new
- {
+ return Json(new {
subscribe = false,
buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
resource = _translationService.GetResource("OutOfStockSubscriptions.Unsubscribed")
});
-
}
//subscription does not exist
@@ -143,62 +140,55 @@ namespace Grand.Web.Controllers
CreatedOnUtc = DateTime.UtcNow
};
await _outOfStockSubscriptionService.InsertSubscription(subscription);
- return Json(new
- {
+ return Json(new {
subscribe = true,
buttontext = _translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable"),
resource = _translationService.GetResource("OutOfStockSubscriptions.Subscribed")
});
}
- if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes &&
- product.BackorderModeId == BackorderMode.NoBackorders &&
- product.AllowOutOfStockSubscriptions)
- {
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
- var subscription = await _outOfStockSubscriptionService
- .FindSubscription(customer.Id, product.Id, attributes, _workContext.CurrentStore.Id, warehouseId);
-
- if (subscription != null)
- {
- //subscription already exists
- //unsubscribe
- await _outOfStockSubscriptionService.DeleteSubscription(subscription);
- return Json(new
- {
- subscribe = false,
- buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
- resource = _translationService.GetResource("OutOfStockSubscriptions.Unsubscribed")
- });
- }
+ if (product.ManageInventoryMethodId != ManageInventoryMethod.ManageStockByAttributes ||
+ product.BackorderModeId != BackorderMode.NoBackorders ||
+ !product.AllowOutOfStockSubscriptions)
+ return Json(new {
+ subscribe = false,
+ buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
+ resource = _translationService.GetResource("OutOfStockSubscriptions.NotAllowed")
+ });
- //subscription does not exist
- //subscribe
+ var attributes = await _mediator.Send(new GetParseProductAttributes { Product = product, Model = model });
+ var subscriptionAttributes = await _outOfStockSubscriptionService
+ .FindSubscription(customer.Id, product.Id, attributes, _workContext.CurrentStore.Id, warehouseId);
- subscription = new OutOfStockSubscription {
- CustomerId = customer.Id,
- ProductId = product.Id,
- Attributes = attributes,
- AttributeInfo = !attributes.Any() ? "" : await _productAttributeFormatter.FormatAttributes(product, attributes),
- StoreId = _workContext.CurrentStore.Id,
- WarehouseId = warehouseId,
- CreatedOnUtc = DateTime.UtcNow
- };
-
- await _outOfStockSubscriptionService.InsertSubscription(subscription);
- return Json(new
- {
- subscribe = true,
- buttontext = _translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable"),
- resource = _translationService.GetResource("OutOfStockSubscriptions.Subscribed")
+ if (subscriptionAttributes != null)
+ {
+ //subscription already exists
+ //unsubscribe
+ await _outOfStockSubscriptionService.DeleteSubscription(subscriptionAttributes);
+ return Json(new {
+ subscribe = false,
+ buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
+ resource = _translationService.GetResource("OutOfStockSubscriptions.Unsubscribed")
});
}
- return Json(new
- {
- subscribe = false,
- buttontext = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable"),
- resource = _translationService.GetResource("OutOfStockSubscriptions.NotAllowed")
+ subscriptionAttributes = new OutOfStockSubscription {
+ CustomerId = customer.Id,
+ ProductId = product.Id,
+ Attributes = attributes,
+ AttributeInfo = !attributes.Any()
+ ? ""
+ : await _productAttributeFormatter.FormatAttributes(product, attributes),
+ StoreId = _workContext.CurrentStore.Id,
+ WarehouseId = warehouseId,
+ CreatedOnUtc = DateTime.UtcNow
+ };
+
+ await _outOfStockSubscriptionService.InsertSubscription(subscriptionAttributes);
+ return Json(new {
+ subscribe = true,
+ buttontext = _translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable"),
+ resource = _translationService.GetResource("OutOfStockSubscriptions.Subscribed")
});
}
@@ -211,12 +201,13 @@ namespace Grand.Web.Controllers
return RedirectToRoute("CustomerInfo");
}
- int pageIndex = 0;
+ var pageIndex = 0;
if (pageNumber > 0)
{
pageIndex = pageNumber.Value - 1;
}
- var pageSize = 10;
+
+ const int pageSize = 10;
var customer = _workContext.CurrentCustomer;
var list = await _outOfStockSubscriptionService.GetAllSubscriptionsByCustomerId(customer.Id,
@@ -227,22 +218,24 @@ namespace Grand.Web.Controllers
foreach (var subscription in list)
{
var product = await _productService.GetProductById(subscription.ProductId);
- if (product != null)
- {
- var subscriptionModel = new CustomerOutOfStockSubscriptionsModel.OutOfStockSubscriptionModel {
- Id = subscription.Id,
- ProductId = product.Id,
- ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- AttributeDescription = !subscription.Attributes.Any() ? "" : await _productAttributeFormatter.FormatAttributes(product, subscription.Attributes),
- SeName = product.GetSeName(_workContext.WorkingLanguage.Id),
- };
- model.Subscriptions.Add(subscriptionModel);
- }
+ if (product == null) continue;
+ var subscriptionModel = new CustomerOutOfStockSubscriptionsModel.OutOfStockSubscriptionModel {
+ Id = subscription.Id,
+ ProductId = product.Id,
+ ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ AttributeDescription = !subscription.Attributes.Any()
+ ? ""
+ : await _productAttributeFormatter.FormatAttributes(product, subscription.Attributes),
+ SeName = product.GetSeName(_workContext.WorkingLanguage.Id)
+ };
+ model.Subscriptions.Add(subscriptionModel);
}
+
model.PagerModel.LoadPagedList(list);
return View(model);
}
+
[HttpPost, ActionName("CustomerSubscriptions")]
public virtual async Task<IActionResult> CustomerSubscriptions(string[] subscriptions)
{
@@ -253,12 +246,11 @@ namespace Grand.Web.Controllers
{
await _outOfStockSubscriptionService.DeleteSubscription(subscription);
}
-
}
-
+
return RedirectToRoute("CustomerOutOfStockSubscriptions");
}
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Controllers/PageController.cs b/src/Web/Grand.Web/Controllers/PageController.cs
index b140a3063..a97f3bf01 100644
--- a/src/Web/Grand.Web/Controllers/PageController.cs
+++ b/src/Web/Grand.Web/Controllers/PageController.cs
@@ -1,7 +1,6 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Business.Core.Utilities.Common.Security;
-using Grand.Infrastructure;
using Grand.Web.Common.Filters;
using Grand.Web.Features.Models.Pages;
using MediatR;
@@ -9,13 +8,12 @@ using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
- public partial class PageController : BasePublicController
+ public class PageController : BasePublicController
{
#region Fields
private readonly ITranslationService _translationService;
private readonly IPermissionService _permissionService;
- private readonly IWorkContext _workContext;
private readonly IMediator _mediator;
#endregion
@@ -25,12 +23,10 @@ namespace Grand.Web.Controllers
public PageController(
ITranslationService translationService,
IPermissionService permissionService,
- IWorkContext workContext,
IMediator mediator)
{
_translationService = translationService;
_permissionService = permissionService;
- _workContext = workContext;
_mediator = mediator;
}
@@ -43,18 +39,18 @@ namespace Grand.Web.Controllers
if (string.IsNullOrEmpty(pageId))
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetPageBlock() { PageId = pageId });
+ var model = await _mediator.Send(new GetPageBlock { PageId = pageId });
if (model == null)
return RedirectToRoute("HomePage");
//hide page if it`s set as no published
if (!model.Published
- && !(await _permissionService.Authorize(StandardPermission.AccessAdminPanel))
- && !(await _permissionService.Authorize(StandardPermission.ManagePages)))
+ && !await _permissionService.Authorize(StandardPermission.AccessAdminPanel)
+ && !await _permissionService.Authorize(StandardPermission.ManagePages))
return RedirectToRoute("HomePage");
//layout
- var layoutViewPath = await _mediator.Send(new GetPageLayoutViewPath() { LayoutId = model.PageLayoutId });
+ var layoutViewPath = await _mediator.Send(new GetPageLayoutViewPath { LayoutId = model.PageLayoutId });
//display "edit" (manage) link
if (await _permissionService.Authorize(StandardPermission.AccessAdminPanel) && await _permissionService.Authorize(StandardPermission.ManagePages))
@@ -65,12 +61,12 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> PageDetailsPopup(string systemName)
{
- var model = await _mediator.Send(new GetPageBlock() { SystemName = systemName });
+ var model = await _mediator.Send(new GetPageBlock { SystemName = systemName });
if (model == null)
return RedirectToRoute("HomePage");
//template
- var layoutViewPath = await _mediator.Send(new GetPageLayoutViewPath() { LayoutId = model.PageLayoutId });
+ var layoutViewPath = await _mediator.Send(new GetPageLayoutViewPath { LayoutId = model.PageLayoutId });
ViewBag.IsPopup = true;
return View(layoutViewPath, model);
@@ -88,22 +84,19 @@ namespace Grand.Web.Controllers
var body = string.Empty;
var error = string.Empty;
- var page = await _mediator.Send(new GetPageBlock() { PageId = id, Password = password });
+ var page = await _mediator.Send(new GetPageBlock { PageId = id, Password = password });
- if (page != null &&
- //password protected?
- page.IsPasswordProtected)
+ if (page is not { IsPasswordProtected: true })
+ return Json(new { Authenticated = authResult, Title = title, Body = body, Error = error });
+ if (page.Password != null && page.Password.Equals(password))
{
- if (page.Password != null && page.Password.Equals(password))
- {
- authResult = true;
- title = page.Title;
- body = page.Body;
- }
- else
- {
- error = _translationService.GetResource("Page.WrongPassword");
- }
+ authResult = true;
+ title = page.Title;
+ body = page.Body;
+ }
+ else
+ {
+ error = _translationService.GetResource("Page.WrongPassword");
}
return Json(new { Authenticated = authResult, Title = title, Body = body, Error = error });
}
diff --git a/src/Web/Grand.Web/Controllers/PixelController.cs b/src/Web/Grand.Web/Controllers/PixelController.cs
index faf3f341c..4f762fb1a 100644
--- a/src/Web/Grand.Web/Controllers/PixelController.cs
+++ b/src/Web/Grand.Web/Controllers/PixelController.cs
@@ -15,17 +15,16 @@ namespace Grand.Web.Controllers
[FromServices] IQueuedEmailService queuedEmailService,
string emailId)
{
- if (!string.IsNullOrEmpty(emailId))
+ if (!string.IsNullOrEmpty(emailId) && !(Request.GetTypedHeaders().Referer?.ToString() is { } referer && referer.ToLowerInvariant().Contains("admin/queuedemail/edit/".ToLowerInvariant())))
{
- if (!(Request.GetTypedHeaders().Referer?.ToString() is { } referer && referer.ToLowerInvariant().Contains("admin/queuedemail/edit/".ToLowerInvariant())))
- {
- var eueuedEmail = await queuedEmailService.GetQueuedEmailById(emailId);
- if (eueuedEmail != null && !eueuedEmail.ReadOnUtc.HasValue)
- {
- eueuedEmail.ReadOnUtc = DateTime.UtcNow;
- await queuedEmailService.UpdateQueuedEmail(eueuedEmail);
- }
- }
+ var eueuedEmail = await queuedEmailService.GetQueuedEmailById(emailId);
+ if (eueuedEmail is not { ReadOnUtc: null })
+ return File(
+ Convert.FromBase64String(
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),
+ "image/png", "pixel.png");
+ eueuedEmail.ReadOnUtc = DateTime.UtcNow;
+ await queuedEmailService.UpdateQueuedEmail(eueuedEmail);
}
return File(Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="), "image/png", "pixel.png");
}
diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.cs
index 35c9a5298..e031ac0e9 100644
--- a/src/Web/Grand.Web/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web/Controllers/ProductController.cs
@@ -1,19 +1,20 @@
using Grand.Business.Core.Events.Catalog;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Media;
using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Web.Commands.Models.Products;
+using Grand.Web.Common.Extensions;
using Grand.Web.Common.Filters;
using Grand.Web.Common.Security.Captcha;
using Grand.Web.Events;
@@ -22,11 +23,10 @@ using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-using Grand.Web.Common.Extensions;
namespace Grand.Web.Controllers
{
- public partial class ProductController : BasePublicController
+ public class ProductController : BasePublicController
{
#region Fields
@@ -106,7 +106,7 @@ namespace Grand.Web.Controllers
return InvokeHttp404();
//availability dates
- if (!product.IsAvailable() && !(product.ProductTypeId == ProductType.Auction))
+ if (!product.IsAvailable() && product.ProductTypeId != ProductType.Auction)
return InvokeHttp404();
//visible individually?
@@ -114,14 +114,11 @@ namespace Grand.Web.Controllers
{
//is this one an associated products?
var parentGroupedProduct = await _productService.GetProductById(product.ParentGroupedProductId);
- if (parentGroupedProduct == null)
- return RedirectToRoute("HomePage");
-
- return RedirectToRoute("Product", new { SeName = parentGroupedProduct.GetSeName(_workContext.WorkingLanguage.Id) });
+ return parentGroupedProduct == null ? RedirectToRoute("HomePage") : RedirectToRoute("Product", new { SeName = parentGroupedProduct.GetSeName(_workContext.WorkingLanguage.Id) });
}
//update existing shopping cart item?
ShoppingCartItem updatecartitem = null;
- if (_shoppingCartSettings.AllowCartItemEditing && !String.IsNullOrEmpty(updatecartitemid))
+ if (_shoppingCartSettings.AllowCartItemEditing && !string.IsNullOrEmpty(updatecartitemid))
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id);
@@ -139,7 +136,7 @@ namespace Grand.Web.Controllers
}
//prepare the model
- var model = await _mediator.Send(new GetProductDetailsPage() {
+ var model = await _mediator.Send(new GetProductDetailsPage {
Store = _workContext.CurrentStore,
Product = product,
IsAssociatedProduct = false,
@@ -147,7 +144,7 @@ namespace Grand.Web.Controllers
});
//product layout
- var productLayoutViewPath = await _mediator.Send(new GetProductLayoutViewPath() { ProductLayoutId = product.ProductLayoutId });
+ var productLayoutViewPath = await _mediator.Send(new GetProductLayoutViewPath { ProductLayoutId = product.ProductLayoutId });
//save as recently viewed
await _recentlyViewedProductsService.AddProductToRecentlyViewedList(customer.Id, product.Id);
@@ -181,13 +178,13 @@ namespace Grand.Web.Controllers
if (product == null)
return new JsonResult("");
- var modelProduct = await _mediator.Send(new GetProductDetailsAttributeChange() {
+ var modelProduct = await _mediator.Send(new GetProductDetailsAttributeChange {
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Model = model,
LoadPicture = loadPicture,
- Product = product,
+ Product = product
});
return Json(new
@@ -203,7 +200,7 @@ namespace Grand.Web.Controllers
disabledattributemappingids = modelProduct.DisabledAttributeMappingids.ToArray(),
notAvailableAttributeMappingids = modelProduct.NotAvailableAttributeMappingids.ToArray(),
pictureFullSizeUrl = modelProduct.PictureFullSizeUrl,
- pictureDefaultSizeUrl = modelProduct.PictureDefaultSizeUrl,
+ pictureDefaultSizeUrl = modelProduct.PictureDefaultSizeUrl
});
}
@@ -233,16 +230,16 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
- var attribute = product.ProductAttributeMappings.Where(x => x.Id == attributeId).FirstOrDefault();
- if (attribute == null || attribute.AttributeControlTypeId != AttributeControlType.FileUpload)
+ var attribute = product.ProductAttributeMappings.FirstOrDefault(x => x.Id == attributeId);
+ if (attribute is not { AttributeControlTypeId: AttributeControlType.FileUpload })
{
return Json(new
{
success = false,
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
var form = await HttpContext.Request.ReadFormAsync();
@@ -253,12 +250,12 @@ namespace Grand.Web.Controllers
{
success = false,
message = "No file uploaded",
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
var fileBinary = httpPostedFile.GetDownloadBits();
- var qqFileNameParameter = "qqfilename";
+ const string qqFileNameParameter = "qqfilename";
var fileName = httpPostedFile.FileName;
if (string.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
fileName = form[qqFileNameParameter].ToString();
@@ -268,7 +265,7 @@ namespace Grand.Web.Controllers
var contentType = httpPostedFile.ContentType;
var fileExtension = Path.GetExtension(fileName);
- if (!String.IsNullOrEmpty(fileExtension))
+ if (!string.IsNullOrEmpty(fileExtension))
fileExtension = fileExtension.ToLowerInvariant();
if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))
@@ -282,7 +279,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = _translationService.GetResource("ShoppingCart.ValidationFileAllowed"),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -298,7 +295,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = string.Format(_translationService.GetResource("ShoppingCart.MaximumUploadedFileSize"), attribute.ValidationFileMaximumSize.Value),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -323,7 +320,7 @@ namespace Grand.Web.Controllers
success = true,
message = _translationService.GetResource("ShoppingCart.FileUploaded"),
downloadUrl = Url.Action("GetFileUpload", "Download", new { downloadId = download.DownloadGuid }),
- downloadGuid = download.DownloadGuid,
+ downloadGuid = download.DownloadGuid
});
}
@@ -371,7 +368,7 @@ namespace Grand.Web.Controllers
});
//availability dates
- if (!product.IsAvailable() && !(product.ProductTypeId == ProductType.Auction))
+ if (!product.IsAvailable() && product.ProductTypeId != ProductType.Auction)
return Json(new
{
success = false,
@@ -387,17 +384,17 @@ namespace Grand.Web.Controllers
{
return Json(new
{
- redirect = Url.RouteUrl("HomePage"),
+ redirect = Url.RouteUrl("HomePage")
});
}
return Json(new
{
- redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) }),
+ redirect = Url.RouteUrl("Product", new { SeName = product.GetSeName(_workContext.WorkingLanguage.Id) })
});
}
//prepare the model
- var model = await _mediator.Send(new GetProductDetailsPage() {
+ var model = await _mediator.Send(new GetProductDetailsPage {
Store = _workContext.CurrentStore,
Product = product,
IsAssociatedProduct = false,
@@ -405,7 +402,7 @@ namespace Grand.Web.Controllers
});
//product layout
- var productLayoutViewPath = await _mediator.Send(new GetProductLayoutViewPath() { ProductLayoutId = product.ProductLayoutId });
+ var productLayoutViewPath = await _mediator.Send(new GetProductLayoutViewPath { ProductLayoutId = product.ProductLayoutId });
//save as recently viewed
await _recentlyViewedProductsService.AddProductToRecentlyViewedList(customer.Id, product.Id);
@@ -438,8 +435,8 @@ namespace Grand.Web.Controllers
var products = await _recentlyViewedProductsService.GetRecentlyViewedProducts(_workContext.CurrentCustomer.Id, _catalogSettings.RecentlyViewedProductsNumber);
//prepare model
- var model = await _mediator.Send(new GetProductOverview() {
- Products = products,
+ var model = await _mediator.Send(new GetProductOverview {
+ Products = products
});
return View(model);
@@ -456,7 +453,7 @@ namespace Grand.Web.Controllers
//load products
var products = await _productService.GetProductsByIds(productIds);
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PreparePictureModel = true,
PreparePriceModel = true,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
@@ -486,9 +483,9 @@ namespace Grand.Web.Controllers
//prepare model
- var model = await _mediator.Send(new GetProductOverview() {
+ var model = await _mediator.Send(new GetProductOverview {
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
- Products = products,
+ Products = products
});
return View(model);
@@ -510,7 +507,7 @@ namespace Grand.Web.Controllers
[FromServices] IProductReviewService productReviewService)
{
var product = await _productService.GetProductById(productId);
- if (product == null || !product.Published || !product.AllowCustomerReviews)
+ if (product is not { Published: true } || !product.AllowCustomerReviews)
return RedirectToRoute("HomePage");
//validate CAPTCHA
@@ -539,7 +536,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- var productReview = await _mediator.Send(new InsertProductReviewCommand() {
+ var productReview = await _mediator.Send(new InsertProductReviewCommand {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Model = model,
@@ -557,7 +554,7 @@ namespace Grand.Web.Controllers
if (productReview.IsApproved)
await _mediator.Publish(new ProductReviewApprovedEvent(productReview));
- model = await _mediator.Send(new GetProductReviews() {
+ model = await _mediator.Send(new GetProductReviews {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Product = product,
@@ -574,7 +571,7 @@ namespace Grand.Web.Controllers
else
{
model.AddProductReview.Result = _translationService.GetResource("Reviews.SuccessfullyAdded");
- model.ProductReviewOverviewModel = await _mediator.Send(new GetProductReviewOverview() {
+ model.ProductReviewOverviewModel = await _mediator.Send(new GetProductReviewOverview {
Product = product,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -584,7 +581,7 @@ namespace Grand.Web.Controllers
}
//If we got this far, something failed, redisplay form
- var newmodel = await _mediator.Send(new GetProductReviews() {
+ var newmodel = await _mediator.Send(new GetProductReviews {
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Product = product,
@@ -607,7 +604,6 @@ namespace Grand.Web.Controllers
[FromServices] IGroupService groupService,
[FromServices] IProductReviewService productReviewService)
{
- var product = await _productService.GetProductById(productId);
var productReview = await productReviewService.GetProductReviewById(productReviewId);
if (productReview == null)
throw new ArgumentException("No product review found with the specified id");
@@ -647,7 +643,7 @@ namespace Grand.Web.Controllers
prh = new ProductReviewHelpfulness {
ProductReviewId = productReview.Id,
CustomerId = _workContext.CurrentCustomer.Id,
- WasHelpful = washelpful,
+ WasHelpful = washelpful
};
productReview.ProductReviewHelpfulnessEntries.Add(prh);
await productReviewService.UpdateProductReview(productReview);
@@ -683,7 +679,7 @@ namespace Grand.Web.Controllers
[FromServices] IGroupService groupService)
{
var product = await _productService.GetProductById(model.ProductId);
- if (product == null || !product.Published || !_catalogSettings.EmailAFriendEnabled)
+ if (product is not { Published: true } || !_catalogSettings.EmailAFriendEnabled)
return Content("");
//validate CAPTCHA
@@ -701,12 +697,12 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
//email
- await _mediator.Send(new SendProductEmailAFriendMessageCommand() {
+ await _mediator.Send(new SendProductEmailAFriendMessageCommand {
Customer = _workContext.CurrentCustomer,
Product = product,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore,
- Model = model,
+ Model = model
});
model.ProductId = product.Id;
@@ -741,7 +737,7 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> AskQuestionOnProduct(ProductAskQuestionSimpleModel model, bool captchaValid)
{
var product = await _productService.GetProductById(model.Id);
- if (product == null || !product.Published || !_catalogSettings.AskQuestionOnProduct)
+ if (product is not { Published: true } || !_catalogSettings.AskQuestionOnProduct)
return Json(new
{
success = false,
@@ -758,45 +754,39 @@ namespace Grand.Web.Controllers
});
}
- if (ModelState.IsValid)
- {
- var productaskqestionmodel = new ProductAskQuestionModel() {
- Email = model.AskQuestionEmail,
- FullName = model.AskQuestionFullName,
- Phone = model.AskQuestionPhone,
- Message = model.AskQuestionMessage
- };
-
- // email
- await _mediator.Send(new SendProductAskQuestionMessageCommand() {
- Customer = _workContext.CurrentCustomer,
- Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
- Model = productaskqestionmodel,
- Product = product,
- RemoteIpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString()
- });
-
- //activity log
- _ = _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id,
- _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),
- _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));
- //return Json
- return Json(new
- {
- success = true,
- message = _translationService.GetResource("Products.AskQuestion.SuccessfullySent")
+ if (!ModelState.IsValid)
+
+ return Json(new {
+ success = false,
+ message = string.Join(",", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage))
});
+ var productaskqestionmodel = new ProductAskQuestionModel {
+ Email = model.AskQuestionEmail,
+ FullName = model.AskQuestionFullName,
+ Phone = model.AskQuestionPhone,
+ Message = model.AskQuestionMessage
+ };
- }
+ // email
+ await _mediator.Send(new SendProductAskQuestionMessageCommand {
+ Customer = _workContext.CurrentCustomer,
+ Language = _workContext.WorkingLanguage,
+ Store = _workContext.CurrentStore,
+ Model = productaskqestionmodel,
+ Product = product,
+ RemoteIpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString()
+ });
- // If we got this far, something failed, redisplay form
+ //activity log
+ _ = _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id,
+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),
+ _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));
+ //return Json
return Json(new
{
- success = false,
- message = string.Join(",", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage))
+ success = true,
+ message = _translationService.GetResource("Products.AskQuestion.SuccessfullySent")
});
-
}
#endregion
@@ -808,7 +798,7 @@ namespace Grand.Web.Controllers
if (!_catalogSettings.CompareProductsEnabled)
return Content("");
- var model = await _mediator.Send(new GetCompareProducts() { PictureProductThumbSize = mediaSettings.MiniCartThumbPictureSize });
+ var model = await _mediator.Send(new GetCompareProducts { PictureProductThumbSize = mediaSettings.MiniCartThumbPictureSize });
return View(model);
@@ -820,7 +810,7 @@ namespace Grand.Web.Controllers
if (!_catalogSettings.CompareProductsEnabled)
return RedirectToRoute("HomePage");
- var model = await _mediator.Send(new GetCompareProducts() { PictureProductThumbSize = mediaSettings.CartThumbPictureSize });
+ var model = await _mediator.Send(new GetCompareProducts { PictureProductThumbSize = mediaSettings.CartThumbPictureSize });
return View(model);
}
diff --git a/src/Web/Grand.Web/Controllers/PushNotificationsController.cs b/src/Web/Grand.Web/Controllers/PushNotificationsController.cs
index 3b740c5d8..fc1331ef1 100644
--- a/src/Web/Grand.Web/Controllers/PushNotificationsController.cs
+++ b/src/Web/Grand.Web/Controllers/PushNotificationsController.cs
@@ -43,27 +43,25 @@ namespace Grand.Web.Controllers
}
else
{
- if (value == "Permission denied")
- {
- var toUpdate = await _pushNotificationsService.GetPushReceiverByCustomerId(_workContext.CurrentCustomer.Id);
+ if (value != "Permission denied") return new JsonResult("");
+ var toUpdate = await _pushNotificationsService.GetPushReceiverByCustomerId(_workContext.CurrentCustomer.Id);
- if (toUpdate == null)
- {
- await _pushNotificationsService.InsertPushReceiver(new PushRegistration
- {
- CustomerId = _workContext.CurrentCustomer.Id,
- Token = "[DENIED]",
- RegisteredOn = DateTime.UtcNow,
- Allowed = false
- });
- }
- else
+ if (toUpdate == null)
+ {
+ await _pushNotificationsService.InsertPushReceiver(new PushRegistration
{
- toUpdate.Token = "[DENIED]";
- toUpdate.RegisteredOn = DateTime.UtcNow;
- toUpdate.Allowed = false;
- await _pushNotificationsService.UpdatePushReceiver(toUpdate);
- }
+ CustomerId = _workContext.CurrentCustomer.Id,
+ Token = "[DENIED]",
+ RegisteredOn = DateTime.UtcNow,
+ Allowed = false
+ });
+ }
+ else
+ {
+ toUpdate.Token = "[DENIED]";
+ toUpdate.RegisteredOn = DateTime.UtcNow;
+ toUpdate.Allowed = false;
+ await _pushNotificationsService.UpdatePushReceiver(toUpdate);
}
}
diff --git a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
index 6b9d02a85..d6a85eaa2 100644
--- a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
+++ b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs
@@ -2,13 +2,13 @@
using Grand.Business.Core.Interfaces.Checkout.CheckoutAttributes;
using Grand.Business.Core.Interfaces.Checkout.GiftVouchers;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Queries.Checkout.Orders;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -16,17 +16,16 @@ using Grand.Domain.Media;
using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Web.Commands.Models.ShoppingCart;
+using Grand.Web.Common.Extensions;
using Grand.Web.Common.Filters;
using Grand.Web.Features.Models.ShoppingCart;
+using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Grand.Web.Common.Extensions;
-using Grand.Web.Models.ShoppingCart;
namespace Grand.Web.Controllers
{
- public partial class ShoppingCartController : BasePublicController
+ public class ShoppingCartController : BasePublicController
{
#region Fields
@@ -84,9 +83,10 @@ namespace Grand.Web.Controllers
protected ShoppingCartType[] PrepareCartTypes()
{
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
- shoppingCartTypes.Add(ShoppingCartType.Auctions);
+ var shoppingCartTypes = new List<ShoppingCartType> {
+ ShoppingCartType.ShoppingCart,
+ ShoppingCartType.Auctions
+ };
if (_shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
@@ -105,7 +105,7 @@ namespace Grand.Web.Controllers
if (!await _permissionService.Authorize(StandardPermission.EnableShoppingCart))
return Content("");
- var model = await _mediator.Send(new GetMiniShoppingCart() {
+ var model = await _mediator.Send(new GetMiniShoppingCart {
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
Language = _workContext.WorkingLanguage,
@@ -123,7 +123,7 @@ namespace Grand.Web.Controllers
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);
- var checkoutAttributes = await _mediator.Send(new SaveCheckoutAttributesCommand() {
+ var checkoutAttributes = await _mediator.Send(new SaveCheckoutAttributesCommand {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Cart = cart,
@@ -136,15 +136,14 @@ namespace Grand.Web.Controllers
foreach (var attribute in attributes)
{
var conditionMet = await checkoutAttributeParser.IsConditionMet(attribute, checkoutAttributes);
- if (conditionMet.HasValue)
- {
- if (conditionMet.Value)
- enabledAttributeIds.Add(attribute.Id);
- else
- disabledAttributeIds.Add(attribute.Id);
- }
+ if (!conditionMet.HasValue) continue;
+
+ if (conditionMet.Value)
+ enabledAttributeIds.Add(attribute.Id);
+ else
+ disabledAttributeIds.Add(attribute.Id);
}
- var orderTotals = await _mediator.Send(new GetOrderTotals() {
+ var orderTotals = await _mediator.Send(new GetOrderTotals {
Cart = cart,
IsEditable = true,
Store = _workContext.CurrentStore,
@@ -159,7 +158,7 @@ namespace Grand.Web.Controllers
enabledattributeids = enabledAttributeIds.ToArray(),
disabledattributeids = disabledAttributeIds.ToArray(),
model = orderTotals,
- checkoutattributeinfo = await checkoutAttributeFormatter.FormatAttributes(checkoutAttributes, _workContext.CurrentCustomer),
+ checkoutattributeinfo = await checkoutAttributeFormatter.FormatAttributes(checkoutAttributes, _workContext.CurrentCustomer)
});
}
@@ -169,12 +168,12 @@ namespace Grand.Web.Controllers
[FromServices] IDownloadService downloadService)
{
var attribute = await _checkoutAttributeService.GetCheckoutAttributeById(attributeId);
- if (attribute == null || attribute.AttributeControlTypeId != AttributeControlType.FileUpload)
+ if (attribute is not { AttributeControlTypeId: AttributeControlType.FileUpload })
{
return Json(new
{
success = false,
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
@@ -186,13 +185,13 @@ namespace Grand.Web.Controllers
{
success = false,
message = "No file uploaded",
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
var fileBinary = httpPostedFile.GetDownloadBits();
- var qqFileNameParameter = "qqfilename";
+ const string qqFileNameParameter = "qqfilename";
var fileName = httpPostedFile.FileName;
if (string.IsNullOrEmpty(fileName) && form.ContainsKey(qqFileNameParameter))
fileName = form[qqFileNameParameter].ToString();
@@ -202,7 +201,7 @@ namespace Grand.Web.Controllers
var contentType = httpPostedFile.ContentType;
var fileExtension = Path.GetExtension(fileName);
- if (!String.IsNullOrEmpty(fileExtension))
+ if (!string.IsNullOrEmpty(fileExtension))
fileExtension = fileExtension.ToLowerInvariant();
if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))
@@ -216,7 +215,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = _translationService.GetResource("ShoppingCart.ValidationFileAllowed"),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -232,7 +231,7 @@ namespace Grand.Web.Controllers
{
success = false,
message = string.Format(_translationService.GetResource("ShoppingCart.MaximumUploadedFileSize"), attribute.ValidationFileMaximumSize.Value),
- downloadGuid = Guid.Empty,
+ downloadGuid = Guid.Empty
});
}
}
@@ -257,7 +256,7 @@ namespace Grand.Web.Controllers
success = true,
message = _translationService.GetResource("ShoppingCart.FileUploaded"),
downloadUrl = Url.Action("GetFileUpload", "Download", new { downloadId = download.DownloadGuid }),
- downloadGuid = download.DownloadGuid,
+ downloadGuid = download.DownloadGuid
});
}
@@ -267,7 +266,7 @@ namespace Grand.Web.Controllers
return RedirectToRoute("HomePage");
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
ValidateCheckoutAttributes = checkoutAttributes,
Customer = _workContext.CurrentCustomer,
@@ -284,7 +283,7 @@ namespace Grand.Web.Controllers
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
IsEditable = false,
Customer = _workContext.CurrentCustomer,
@@ -302,7 +301,7 @@ namespace Grand.Web.Controllers
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);
- var model = await _mediator.Send(new GetOrderTotals() {
+ var model = await _mediator.Send(new GetOrderTotals {
Cart = cart,
Store = _workContext.CurrentStore,
Currency = _workContext.WorkingCurrency,
@@ -322,7 +321,7 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- warnings = "No permission",
+ warnings = "No permission"
});
var cart = (await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes()))
@@ -332,7 +331,7 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- warnings = "Shopping cart item not found",
+ warnings = "Shopping cart item not found"
});
}
if (quantity <= 0)
@@ -340,7 +339,7 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- warnings = "Wrong quantity",
+ warnings = "Wrong quantity"
});
}
@@ -348,10 +347,10 @@ namespace Grand.Web.Controllers
var currSciWarnings = await _shoppingCartService.UpdateShoppingCartItem(_workContext.CurrentCustomer,
cart.Id, cart.WarehouseId, cart.Attributes, cart.EnteredPrice,
cart.RentalStartDateUtc, cart.RentalEndDateUtc,
- quantity, true);
+ quantity);
warnings.AddRange(currSciWarnings);
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes()),
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -365,7 +364,7 @@ namespace Grand.Web.Controllers
success = !warnings.Any(),
warnings = string.Join(", ", warnings),
totalproducts = string.Format(_translationService.GetResource("ShoppingCart.HeaderQuantity"), model.Items.Sum(x => x.Quantity)),
- model = model
+ model
});
}
@@ -394,8 +393,7 @@ namespace Grand.Web.Controllers
if (!await _permissionService.Authorize(StandardPermission.EnableShoppingCart))
return RedirectToRoute("HomePage");
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
+ var shoppingCartTypes = new List<ShoppingCartType> { ShoppingCartType.ShoppingCart };
if (_shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
@@ -407,7 +405,7 @@ namespace Grand.Web.Controllers
await _shoppingCartService.DeleteShoppingCartItem(_workContext.CurrentCustomer, item, ensureOnlyActiveCheckoutAttributes: true);
}
- var miniShoppingCartmodel = await _mediator.Send(new GetMiniShoppingCart() {
+ var miniShoppingCartmodel = await _mediator.Send(new GetMiniShoppingCart {
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
Language = _workContext.WorkingLanguage,
@@ -419,28 +417,26 @@ namespace Grand.Web.Controllers
return Json(new
{
totalproducts = string.Format(_translationService.GetResource("ShoppingCart.HeaderQuantity"), miniShoppingCartmodel.TotalProducts),
- sidebarshoppingcartmodel = miniShoppingCartmodel,
+ sidebarshoppingcartmodel = miniShoppingCartmodel
});
}
- else
- {
- var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
- var shoppingcartmodel = await _mediator.Send(new GetShoppingCart() {
- Cart = cart,
- Customer = _workContext.CurrentCustomer,
- Currency = _workContext.WorkingCurrency,
- Language = _workContext.WorkingLanguage,
- Store = _workContext.CurrentStore,
- TaxDisplayType = _workContext.TaxDisplayType
- });
- return Json(new
- {
- totalproducts = string.Format(_translationService.GetResource("ShoppingCart.HeaderQuantity"), miniShoppingCartmodel.TotalProducts),
- sidebarshoppingcartmodel = miniShoppingCartmodel,
- model = shoppingcartmodel,
- });
- }
+ var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
+ var shoppingcartmodel = await _mediator.Send(new GetShoppingCart {
+ Cart = cart,
+ Customer = _workContext.CurrentCustomer,
+ Currency = _workContext.WorkingCurrency,
+ Language = _workContext.WorkingLanguage,
+ Store = _workContext.CurrentStore,
+ TaxDisplayType = _workContext.TaxDisplayType
+ });
+
+ return Json(new
+ {
+ totalproducts = string.Format(_translationService.GetResource("ShoppingCart.HeaderQuantity"), miniShoppingCartmodel.TotalProducts),
+ sidebarshoppingcartmodel = miniShoppingCartmodel,
+ model = shoppingcartmodel
+ });
}
[DenySystemAccount]
@@ -453,8 +449,7 @@ namespace Grand.Web.Controllers
if (!_shoppingCartSettings.AllowOnHoldCart)
return RedirectToRoute("HomePage");
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
+ var shoppingCartTypes = new List<ShoppingCartType> { ShoppingCartType.ShoppingCart };
if (_shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
@@ -467,7 +462,7 @@ namespace Grand.Web.Controllers
await _customerService.UpdateShoppingCartItem(_workContext.CurrentCustomer.Id, item);
}
- var miniShoppingCart = await _mediator.Send(new GetMiniShoppingCart() {
+ var miniShoppingCart = await _mediator.Send(new GetMiniShoppingCart {
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
Language = _workContext.WorkingLanguage,
@@ -476,7 +471,7 @@ namespace Grand.Web.Controllers
});
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
- var shoppingcartmodel = await _mediator.Send(new GetShoppingCart() {
+ var shoppingcartmodel = await _mediator.Send(new GetShoppingCart {
Cart = cart,
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -510,7 +505,7 @@ namespace Grand.Web.Controllers
//parse and save checkout attributes
if (model?.Attributes != null && model.Attributes.Count > 0)
{
- checkoutAttributes = (await _mediator.Send(new SaveCheckoutAttributesCommand() {
+ checkoutAttributes = (await _mediator.Send(new SaveCheckoutAttributesCommand {
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
Cart = cart,
@@ -552,7 +547,7 @@ namespace Grand.Web.Controllers
discountcouponcode = discountcouponcode.ToUpper();
//we find even hidden records here. this way we can display a user-friendly message if it's expired
var discount = await _discountService.GetDiscountByCouponCode(discountcouponcode, true);
- if (discount != null && discount.RequiresCouponCode)
+ if (discount is { RequiresCouponCode: true })
{
var coupons = _workContext.CurrentCustomer.ParseAppliedCouponCodes(SystemCustomerFieldNames.DiscountCoupons);
var existsAndUsed = false;
@@ -580,7 +575,7 @@ namespace Grand.Web.Controllers
}
else
{
- if (!String.IsNullOrEmpty(validationResult.UserError))
+ if (!string.IsNullOrEmpty(validationResult.UserError))
{
//some user error
message = validationResult.UserError;
@@ -618,7 +613,7 @@ namespace Grand.Web.Controllers
isApplied = false;
}
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -632,7 +627,7 @@ namespace Grand.Web.Controllers
return Json(new
{
- model = model
+ model
});
}
@@ -642,8 +637,7 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> ApplyGiftVoucher(string giftvouchercouponcode)
{
//trim
- if (giftvouchercouponcode != null)
- giftvouchercouponcode = giftvouchercouponcode.Trim();
+ giftvouchercouponcode = giftvouchercouponcode?.Trim();
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
@@ -652,7 +646,7 @@ namespace Grand.Web.Controllers
if (!string.IsNullOrWhiteSpace(giftvouchercouponcode))
{
- var giftVoucher = (await _mediator.Send(new GetGiftVoucherQuery() { Code = giftvouchercouponcode, IsGiftVoucherActivated = true })).FirstOrDefault();
+ var giftVoucher = (await _mediator.Send(new GetGiftVoucherQuery { Code = giftvouchercouponcode, IsGiftVoucherActivated = true })).FirstOrDefault();
var isGiftVoucherValid = giftVoucher != null
&& giftVoucher.IsGiftVoucherValid(_workContext.WorkingCurrency, _workContext.CurrentStore);
@@ -677,7 +671,7 @@ namespace Grand.Web.Controllers
isApplied = false;
}
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -691,7 +685,7 @@ namespace Grand.Web.Controllers
return Json(new
{
- model = model
+ model
});
}
@@ -701,7 +695,7 @@ namespace Grand.Web.Controllers
{
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);
- var model = await _mediator.Send(new GetEstimateShippingResult() {
+ var model = await _mediator.Send(new GetEstimateShippingResult {
Cart = cart,
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
@@ -726,17 +720,16 @@ namespace Grand.Web.Controllers
foreach (var item in coupons)
{
var dd = await _discountService.GetDiscountByCouponCode(item);
- if (dd.Id == discount.Id)
- {
- //remove coupon
- var result = _workContext.CurrentCustomer.RemoveCouponCode(SystemCustomerFieldNames.DiscountCoupons, item);
- await _userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.DiscountCoupons, result);
- }
+ if (dd.Id != discount.Id) continue;
+
+ //remove coupon
+ var result = _workContext.CurrentCustomer.RemoveCouponCode(SystemCustomerFieldNames.DiscountCoupons, item);
+ await _userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.DiscountCoupons, result);
}
}
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -747,7 +740,7 @@ namespace Grand.Web.Controllers
return Json(new
{
- model = model
+ model
});
}
@@ -768,7 +761,7 @@ namespace Grand.Web.Controllers
}
var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, PrepareCartTypes());
- var model = await _mediator.Send(new GetShoppingCart() {
+ var model = await _mediator.Send(new GetShoppingCart {
Cart = cart,
Customer = _workContext.CurrentCustomer,
Currency = _workContext.WorkingCurrency,
@@ -779,7 +772,7 @@ namespace Grand.Web.Controllers
return Json(new
{
- model = model
+ model
});
}
diff --git a/src/Web/Grand.Web/Controllers/VendorController.cs b/src/Web/Grand.Web/Controllers/VendorController.cs
index 0a79b1ed8..d2a370d99 100644
--- a/src/Web/Grand.Web/Controllers/VendorController.cs
+++ b/src/Web/Grand.Web/Controllers/VendorController.cs
@@ -26,7 +26,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Grand.Web.Controllers
{
- public partial class VendorController : BasePublicController
+ public class VendorController : BasePublicController
{
#region Fields
@@ -105,7 +105,7 @@ namespace Grand.Web.Controllers
return Challenge();
var model = new ApplyVendorModel();
- if (!String.IsNullOrEmpty(_workContext.CurrentCustomer.VendorId))
+ if (!string.IsNullOrEmpty(_workContext.CurrentCustomer.VendorId))
{
//already applied for vendor account
model.DisableFormInput = true;
@@ -118,13 +118,13 @@ namespace Grand.Web.Controllers
model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled;
model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks;
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
- model.Address = await _mediator.Send(new GetVendorAddress() {
+ model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Address = null,
ExcludeProperties = false,
PrePopulateWithCustomerFields = true,
Customer = _workContext.CurrentCustomer,
- LoadCountries = () => countries,
+ LoadCountries = () => countries
});
return View(model);
@@ -148,8 +148,7 @@ namespace Grand.Web.Controllers
ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_translationService));
}
- string pictureId = string.Empty;
- string contentType = string.Empty;
+ var contentType = string.Empty;
byte[] vendorPictureBinary = null;
if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
@@ -173,9 +172,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
-
var description = FormatText.ConvertText(model.Description);
- var address = new Address();
//disabled by default
var vendor = new Vendor {
Name = model.Name,
@@ -184,9 +181,9 @@ namespace Grand.Web.Controllers
PageSize = 6,
AllowCustomersToSelectPageSize = true,
PageSizeOptions = _vendorSettings.DefaultVendorPageSizeOptions,
- AllowCustomerReviews = _vendorSettings.DefaultAllowCustomerReview,
+ AllowCustomerReviews = _vendorSettings.DefaultAllowCustomerReview
};
- model.Address.ToEntity(vendor.Address, true);
+ model.Address.ToEntity(vendor.Address);
if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType))
{
var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference: Reference.Vendor, objectId: vendor.Id);
@@ -205,7 +202,7 @@ namespace Grand.Web.Controllers
await _vendorService.UpdateVendor(vendor);
//associate to the current customer
- //but a store owner will have to manually acivate this vendor
+ //but a store owner will have to manually activate this vendor
//if he wants to grant access to admin area
_workContext.CurrentCustomer.VendorId = vendor.Id;
await _customerService.UpdateCustomerField(_workContext.CurrentCustomer.Id, x => x.VendorId, _workContext.CurrentCustomer.VendorId);
@@ -225,14 +222,14 @@ namespace Grand.Web.Controllers
model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks;
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
- model.Address = await _mediator.Send(new GetVendorAddress() {
+ model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Address = null,
Model = model.Address,
ExcludeProperties = false,
PrePopulateWithCustomerFields = true,
Customer = _workContext.CurrentCustomer,
- LoadCountries = () => countries,
+ LoadCountries = () => countries
});
return View(model);
}
@@ -253,11 +250,11 @@ namespace Grand.Web.Controllers
model.UserFields = vendor.UserFields;
model.PictureUrl = await _pictureService.GetPictureUrl(vendor.PictureId);
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
- model.Address = await _mediator.Send(new GetVendorAddress() {
+ model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Address = vendor.Address,
ExcludeProperties = false,
- LoadCountries = () => countries,
+ LoadCountries = () => countries
});
return View(model);
@@ -273,8 +270,7 @@ namespace Grand.Web.Controllers
if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo)
return RedirectToRoute("CustomerInfo");
- string pictureId = string.Empty;
- string contentType = string.Empty;
+ var contentType = string.Empty;
byte[] vendorPictureBinary = null;
if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
@@ -301,7 +297,7 @@ namespace Grand.Web.Controllers
if (prevPicture == null)
vendor.PictureId = "";
- if (ModelState.IsValid && ModelState.ErrorCount == 0)
+ if (ModelState is { IsValid: true, ErrorCount: 0 })
{
var description = FormatText.ConvertText(model.Description);
@@ -320,7 +316,7 @@ namespace Grand.Web.Controllers
//update picture seo file name
await UpdatePictureSeoNames(vendor);
- model.Address.ToEntity(vendor.Address, true);
+ model.Address.ToEntity(vendor.Address);
await _vendorService.UpdateVendor(vendor);
@@ -331,12 +327,12 @@ namespace Grand.Web.Controllers
return RedirectToAction("Info");
}
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
- model.Address = await _mediator.Send(new GetVendorAddress() {
+ model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Model = model.Address,
Address = vendor.Address,
ExcludeProperties = false,
- LoadCountries = () => countries,
+ LoadCountries = () => countries
});
return View(model);
@@ -378,7 +374,7 @@ namespace Grand.Web.Controllers
return Content("");
var vendor = await _vendorService.GetVendorById(model.VendorId);
- if (vendor == null || !vendor.Active || vendor.Deleted)
+ if (vendor is not { Active: true } || vendor.Deleted)
return Content("");
//validate CAPTCHA
@@ -391,7 +387,7 @@ namespace Grand.Web.Controllers
if (ModelState.IsValid)
{
- model = await _mediator.Send(new ContactVendorSendCommand() { Model = model, Vendor = vendor, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString() });
+ model = await _mediator.Send(new ContactVendorSendCommand { Model = model, Vendor = vendor, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString() });
return Json(model);
}
diff --git a/src/Web/Grand.Web/Controllers/WishlistController.cs b/src/Web/Grand.Web/Controllers/WishlistController.cs
index 6a9cf790c..77bc05f71 100644
--- a/src/Web/Grand.Web/Controllers/WishlistController.cs
+++ b/src/Web/Grand.Web/Controllers/WishlistController.cs
@@ -2,9 +2,10 @@
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Messages;
+using Grand.Business.Core.Utilities.Checkout;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Customers;
using Grand.Domain.Orders;
using Grand.Infrastructure;
@@ -15,11 +16,10 @@ using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.ShoppingCart;
using MediatR;
using Microsoft.AspNetCore.Mvc;
-using Grand.Business.Core.Utilities.Checkout;
namespace Grand.Web.Controllers
{
- public partial class WishlistController : BasePublicController
+ public class WishlistController : BasePublicController
{
#region Fields
@@ -71,12 +71,12 @@ namespace Grand.Web.Controllers
if (!string.IsNullOrEmpty(_workContext.CurrentStore.Id))
cart = cart.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, _workContext.CurrentStore.Id);
- var model = await _mediator.Send(new GetMiniWishlist() {
+ var model = await _mediator.Send(new GetMiniWishlist {
Cart = cart.ToList(),
Customer = _workContext.CurrentCustomer,
Language = _workContext.WorkingLanguage,
Currency = _workContext.WorkingCurrency,
- Store = _workContext.CurrentStore,
+ Store = _workContext.CurrentStore
});
return Json(model);
@@ -99,7 +99,7 @@ namespace Grand.Web.Controllers
if (!string.IsNullOrEmpty(_workContext.CurrentStore.Id))
cart = cart.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, _workContext.CurrentStore.Id);
- var model = await _mediator.Send(new GetWishlist() {
+ var model = await _mediator.Send(new GetWishlist {
Cart = cart.ToList(),
Customer = customer,
Language = _workContext.WorkingLanguage,
@@ -126,7 +126,7 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- warnings = "Shopping cart item not found",
+ warnings = "Shopping cart item not found"
});
}
if (quantity <= 0)
@@ -134,7 +134,7 @@ namespace Grand.Web.Controllers
return Json(new
{
success = false,
- warnings = "Wrong quantity ",
+ warnings = "Wrong quantity "
});
}
@@ -143,14 +143,14 @@ namespace Grand.Web.Controllers
var currSciWarnings = await _shoppingCartService.UpdateShoppingCartItem(_workContext.CurrentCustomer,
cart.Id, cart.WarehouseId, cart.Attributes, cart.EnteredPrice,
cart.RentalStartDateUtc, cart.RentalEndDateUtc,
- quantity, true);
+ quantity);
warnings.AddRange(currSciWarnings);
return Json(new
{
success = !warnings.Any(),
warnings = string.Join(", ", warnings),
- totalproducts = (await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.Wishlist)).Sum(x => x.Quantity),
+ totalproducts = (await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.Wishlist)).Sum(x => x.Quantity)
});
}
@@ -181,8 +181,8 @@ namespace Grand.Web.Controllers
itemCart.ProductId, ShoppingCartType.ShoppingCart,
_workContext.CurrentStore.Id, itemCart.WarehouseId,
itemCart.Attributes, itemCart.EnteredPrice,
- itemCart.RentalStartDateUtc, itemCart.RentalEndDateUtc, itemCart.Quantity, true,
- validator: new ShoppingCartValidatorOptions() { GetRequiredProductWarnings = false })).warnings;
+ itemCart.RentalStartDateUtc, itemCart.RentalEndDateUtc, itemCart.Quantity,
+ validator: new ShoppingCartValidatorOptions { GetRequiredProductWarnings = false })).warnings;
if (warnings.Any())
return Json(new { success = false, message = string.Join(',', warnings) });
diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
index 2fe735c52..94f750cdd 100644
--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Grand.Web.Endpoints
{
- public partial class EndpointProvider : IEndpointProvider
+ public class EndpointProvider : IEndpointProvider
{
public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)
{
@@ -113,7 +113,7 @@ namespace Grand.Web.Endpoints
pattern + "account/checkusernameavailability",
new { controller = "Account", action = "CheckUsernameAvailability" });
- //passwordrecovery
+ //password recovery
endpointRouteBuilder.MapControllerRoute("PasswordRecovery",
pattern + "passwordrecovery",
new { controller = "Account", action = "PasswordRecovery" });
@@ -451,13 +451,7 @@ namespace Grand.Web.Endpoints
private void RegisterCmsRoute(IEndpointRouteBuilder endpointRouteBuilder, string pattern)
{
-
- //widgets
- endpointRouteBuilder.MapControllerRoute("WidgetsByZone",
- $"{pattern}widgetsbyzone/",
- new { controller = "Widget", action = "WidgetsByZone" });
-
- //knowledgebase
+ //knowledge base
endpointRouteBuilder.MapControllerRoute("Knowledgebase",
pattern + "knowledgebase",
new { controller = "Knowledgebase", action = "List" });
diff --git a/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs b/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
index 4a97dc48d..42f3c7511 100644
--- a/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/SlugEndpointProvider.cs
@@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Grand.Web.Endpoints
{
- public partial class SlugEndpointProvider : IEndpointProvider
+ public class SlugEndpointProvider : IEndpointProvider
{
public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)
{
@@ -93,12 +93,9 @@ namespace Grand.Web.Endpoints
}
- public int Priority {
- get {
- //it should be the last route
- //we do not set it to -int.MaxValue so it could be overridden (if required)
- return -1000000;
- }
- }
+ public int Priority =>
+ //it should be the last route
+ //we do not set it to -int.MaxValue so it could be overridden (if required)
+ -1000000;
}
}
diff --git a/src/Web/Grand.Web/Events/Cache/BlogCategoryNotificatioHandler.cs b/src/Web/Grand.Web/Events/Cache/BlogCategoryNotificatioHandler.cs
index 559633fc3..5d3ede98f 100644
--- a/src/Web/Grand.Web/Events/Cache/BlogCategoryNotificatioHandler.cs
+++ b/src/Web/Grand.Web/Events/Cache/BlogCategoryNotificatioHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure.Caching;
-using Grand.Domain.Blogs;
+using Grand.Domain.Blogs;
+using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Events;
using MediatR;
diff --git a/src/Web/Grand.Web/Events/Cache/BlogPostNotificatioHandler.cs b/src/Web/Grand.Web/Events/Cache/BlogPostNotificatioHandler.cs
index 753a3e018..6972b5ce3 100644
--- a/src/Web/Grand.Web/Events/Cache/BlogPostNotificatioHandler.cs
+++ b/src/Web/Grand.Web/Events/Cache/BlogPostNotificatioHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure.Caching;
-using Grand.Domain.Blogs;
+using Grand.Domain.Blogs;
+using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Events;
using MediatR;
diff --git a/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs b/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
index 40a585917..2528c63dd 100644
--- a/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
+++ b/src/Web/Grand.Web/Events/Cache/CacheKeyConst.cs
@@ -165,7 +165,7 @@ namespace Grand.Web.Events.Cache
public const string CATEGORY_BREADCRUMB_KEY = "Grand.category.breadcrumb-{0}-{1}-{2}-{3}.pres";
/// <summary>
- /// Key for caching of knowledgebase category breadcrumb
+ /// Key for caching of knowledge base category breadcrumb
/// </summary>
/// <remarks>
/// {0} : category id
diff --git a/src/Web/Grand.Web/Events/Cache/NewsItemNotificatioHandler.cs b/src/Web/Grand.Web/Events/Cache/NewsItemNotificatioHandler.cs
index 73539a49d..57cc52d17 100644
--- a/src/Web/Grand.Web/Events/Cache/NewsItemNotificatioHandler.cs
+++ b/src/Web/Grand.Web/Events/Cache/NewsItemNotificatioHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure.Caching;
-using Grand.Domain.News;
+using Grand.Domain.News;
+using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Events;
using MediatR;
diff --git a/src/Web/Grand.Web/Events/Cache/VendorNotificatioHandler.cs b/src/Web/Grand.Web/Events/Cache/VendorNotificatioHandler.cs
index 88194c23e..ca3bef788 100644
--- a/src/Web/Grand.Web/Events/Cache/VendorNotificatioHandler.cs
+++ b/src/Web/Grand.Web/Events/Cache/VendorNotificatioHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Infrastructure.Caching;
-using Grand.Domain.Vendors;
+using Grand.Domain.Vendors;
+using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Events;
using MediatR;
diff --git a/src/Web/Grand.Web/Events/ContactUsEvent.cs b/src/Web/Grand.Web/Events/ContactUsEvent.cs
index 8f0312b34..c93127ea5 100644
--- a/src/Web/Grand.Web/Events/ContactUsEvent.cs
+++ b/src/Web/Grand.Web/Events/ContactUsEvent.cs
@@ -1,7 +1,6 @@
using Grand.Domain.Customers;
using Grand.Web.Models.Common;
using MediatR;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Events
{
diff --git a/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs b/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
index a2f6402a4..621b8a228 100644
--- a/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
+++ b/src/Web/Grand.Web/Events/CustomerLoggedInEventHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Events.Customers;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
-using Grand.Business.Core.Events.Customers;
using MediatR;
using Microsoft.AspNetCore.Http;
diff --git a/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs b/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
index e7b9b6e04..b6927b58b 100644
--- a/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
+++ b/src/Web/Grand.Web/Events/CustomerLoggedOutEventHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Events.Customers;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Logging;
-using Grand.Business.Core.Events.Customers;
using MediatR;
using Microsoft.AspNetCore.Http;
diff --git a/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs b/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs
index 8adaee306..f8b26de46 100644
--- a/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs
+++ b/src/Web/Grand.Web/Extensions/KnowledgebaseExtensions.cs
@@ -12,7 +12,7 @@ namespace Grand.Web.Extensions
/// Get category breadcrumb
/// </summary>
/// <param name="category">Category</param>
- /// <param name="knowledgebaseService">Knowledgebase Service</param>
+ /// <param name="knowledgebaseService">Knowledge base Service</param>
/// <param name="aclService">ACL service</param>
/// <param name="workContext">WorkContext</param>
/// <param name="showHidden">A value indicating whether to load hidden records</param>
@@ -61,15 +61,15 @@ namespace Grand.Web.Extensions
IList<KnowledgebaseCategory> allCategories,
string separator = ">>", string languageId = "")
{
- string result = string.Empty;
+ var result = string.Empty;
var breadcrumb = GetCategoryBreadCrumb(category, allCategories);
- for (int i = 0; i <= breadcrumb.Count - 1; i++)
+ for (var i = 0; i <= breadcrumb.Count - 1; i++)
{
var categoryName = breadcrumb[i].GetTranslation(x => x.Name, languageId);
- result = String.IsNullOrEmpty(result)
+ result = string.IsNullOrEmpty(result)
? categoryName
- : string.Format("{0} {1} {2}", result, separator, categoryName);
+ : $"{result} {separator} {categoryName}";
}
return result;
diff --git a/src/Web/Grand.Web/Extensions/MappingExtensions.cs b/src/Web/Grand.Web/Extensions/MappingExtensions.cs
index 64d93155d..7241a4e0f 100644
--- a/src/Web/Grand.Web/Extensions/MappingExtensions.cs
+++ b/src/Web/Grand.Web/Extensions/MappingExtensions.cs
@@ -11,7 +11,6 @@ using Grand.Web.Models.Common;
using Grand.Web.Models.Course;
using Grand.Web.Models.Pages;
using Grand.Web.Models.Vendors;
-using Microsoft.AspNetCore.Http;
using System.Globalization;
namespace Grand.Web.Extensions
@@ -111,9 +110,9 @@ namespace Grand.Web.Extensions
SystemName = entity.SystemName,
IncludeInSitemap = entity.IncludeInSitemap,
IsPasswordProtected = entity.IsPasswordProtected,
- Password = (entity.Password == password) ? password : "",
- Title = entity.IsPasswordProtected && !(entity.Password == password) ? "" : entity.GetTranslation(x => x.Title, language.Id),
- Body = entity.IsPasswordProtected && !(entity.Password == password) ? "" : entity.GetTranslation(x => x.Body, language.Id),
+ Password = entity.Password == password ? password : "",
+ Title = entity.IsPasswordProtected && entity.Password != password ? "" : entity.GetTranslation(x => x.Title, language.Id),
+ Body = entity.IsPasswordProtected && entity.Password != password ? "" : entity.GetTranslation(x => x.Body, language.Id),
MetaKeywords = entity.GetTranslation(x => x.MetaKeywords, language.Id),
MetaDescription = entity.GetTranslation(x => x.MetaDescription, language.Id),
MetaTitle = entity.GetTranslation(x => x.MetaTitle, language.Id),
@@ -199,8 +198,8 @@ namespace Grand.Web.Extensions
destination.Email = model.Email;
destination.Company = model.Company;
destination.VatNumber = model.VatNumber;
- destination.CountryId = !String.IsNullOrEmpty(model.CountryId) ? model.CountryId : "";
- destination.StateProvinceId = !String.IsNullOrEmpty(model.StateProvinceId) ? model.StateProvinceId : "";
+ destination.CountryId = !string.IsNullOrEmpty(model.CountryId) ? model.CountryId : "";
+ destination.StateProvinceId = !string.IsNullOrEmpty(model.StateProvinceId) ? model.StateProvinceId : "";
destination.City = model.City;
destination.Address1 = model.Address1;
destination.Address2 = model.Address2;
@@ -236,8 +235,8 @@ namespace Grand.Web.Extensions
model.FaxNumber = model.FaxNumber.Trim();
}
destination.Company = model.Company;
- destination.CountryId = !String.IsNullOrEmpty(model.CountryId) ? model.CountryId : "";
- destination.StateProvinceId = !String.IsNullOrEmpty(model.StateProvinceId) ? model.StateProvinceId : "";
+ destination.CountryId = !string.IsNullOrEmpty(model.CountryId) ? model.CountryId : "";
+ destination.StateProvinceId = !string.IsNullOrEmpty(model.StateProvinceId) ? model.StateProvinceId : "";
destination.City = model.City;
destination.Address1 = model.Address1;
destination.Address2 = model.Address2;
diff --git a/src/Web/Grand.Web/Extensions/OrderExtensions.cs b/src/Web/Grand.Web/Extensions/OrderExtensions.cs
index 3e397a730..659f059e1 100644
--- a/src/Web/Grand.Web/Extensions/OrderExtensions.cs
+++ b/src/Web/Grand.Web/Extensions/OrderExtensions.cs
@@ -15,11 +15,8 @@ namespace Grand.Web.Extensions
if (await groupService.IsOwner(customer) && (customer.Id == order.CustomerId || customer.Id == order.OwnerId))
return true;
- //subaccount
- if (!await groupService.IsOwner(customer) && customer.Id == order.CustomerId)
- return true;
-
- return false;
+ //sub account
+ return !await groupService.IsOwner(customer) && customer.Id == order.CustomerId;
}
public static async Task<bool> Access(this MerchandiseReturn merchandiseReturn, Customer customer, IGroupService groupService)
{
@@ -30,11 +27,8 @@ namespace Grand.Web.Extensions
if (await groupService.IsOwner(customer) && (customer.Id == merchandiseReturn.CustomerId || customer.Id == merchandiseReturn.OwnerId))
return true;
- //subaccount
- if (!await groupService.IsOwner(customer) && customer.Id == merchandiseReturn.CustomerId)
- return true;
-
- return false;
+ //sub account
+ return !await groupService.IsOwner(customer) && customer.Id == merchandiseReturn.CustomerId;
}
}
}
diff --git a/src/Web/Grand.Web/Extensions/ProductExtensions.cs b/src/Web/Grand.Web/Extensions/ProductExtensions.cs
index b7edcfa77..ce64b711b 100644
--- a/src/Web/Grand.Web/Extensions/ProductExtensions.cs
+++ b/src/Web/Grand.Web/Extensions/ProductExtensions.cs
@@ -12,7 +12,8 @@ namespace Grand.Web.Extensions
/// Get product picture (for shopping cart and order details pages)
/// </summary>
/// <param name="product">Product</param>
- /// <param name="attributes">Atributes </param>
+ /// <param name="attributes">Attributes</param>
+ /// <param name="productService">Product service</param>
/// <param name="pictureService">Picture service</param>
/// <returns>Picture</returns>
public static async Task<Picture> GetProductPicture(this Product product, IList<CustomAttribute> attributes,
@@ -46,30 +47,28 @@ namespace Grand.Web.Extensions
foreach (var attributeValue in attributeValues)
{
var attributePicture = await pictureService.GetPictureById(attributeValue.PictureId);
- if (attributePicture != null)
- {
- picture = attributePicture;
- break;
- }
+ if (attributePicture == null) continue;
+ picture = attributePicture;
+ break;
}
}
}
if (picture == null)
{
- var pp = product.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault();
+ var pp = product.ProductPictures.MinBy(x => x.DisplayOrder);
if (pp != null)
picture = await pictureService.GetPictureById(pp.PictureId);
}
- if (picture == null && !product.VisibleIndividually && !string.IsNullOrEmpty(product.ParentGroupedProductId))
+ if (picture != null || product.VisibleIndividually || string.IsNullOrEmpty(product.ParentGroupedProductId))
+ return picture;
+
+ var parentProduct = await productService.GetProductById(product.ParentGroupedProductId);
+ if (parentProduct == null) return null;
+ if (parentProduct.ProductPictures.Any())
{
- var parentProduct = await productService.GetProductById(product.ParentGroupedProductId);
- if (parentProduct != null)
- if (parentProduct.ProductPictures.Any())
- {
- picture = await pictureService.GetPictureById(parentProduct.ProductPictures.FirstOrDefault().PictureId);
+ picture = await pictureService.GetPictureById(parentProduct.ProductPictures.FirstOrDefault()!.PictureId);
- }
}
return picture;
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostCategoryHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostCategoryHandler.cs
index 4619a7de0..c2cd5ba8b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostCategoryHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostCategoryHandler.cs
@@ -1,9 +1,9 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
-using Grand.Web.Features.Models.Blogs;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Blogs;
using Grand.Web.Models.Blogs;
using MediatR;
@@ -32,8 +32,7 @@ namespace Grand.Web.Features.Handlers.Blogs
var categories = await _blogService.GetAllBlogCategories(_workContext.CurrentStore.Id);
foreach (var item in categories)
{
- model.Add(new BlogPostCategoryModel()
- {
+ model.Add(new BlogPostCategoryModel {
Id = item.Id,
Name = item.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
SeName = item.SeName,
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostHandler.cs
index 967be56a5..88a2085d3 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostHandler.cs
@@ -1,13 +1,13 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure;
using Grand.Domain.Blogs;
using Grand.Domain.Customers;
using Grand.Domain.Media;
+using Grand.Infrastructure;
using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.Blogs;
using Grand.Web.Models.Blogs;
@@ -57,22 +57,24 @@ namespace Grand.Web.Features.Handlers.Blogs
if (request.BlogPost == null)
throw new ArgumentNullException(nameof(request.BlogPost));
- var model = new BlogPostModel();
-
- model.Id = request.BlogPost.Id;
- model.MetaTitle = request.BlogPost.GetTranslation(x => x.MetaTitle, _workContext.WorkingLanguage.Id);
- model.MetaDescription = request.BlogPost.GetTranslation(x => x.MetaDescription, _workContext.WorkingLanguage.Id);
- model.MetaKeywords = request.BlogPost.GetTranslation(x => x.MetaKeywords, _workContext.WorkingLanguage.Id);
- model.SeName = request.BlogPost.GetSeName(_workContext.WorkingLanguage.Id);
- model.Title = request.BlogPost.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id);
- model.Body = request.BlogPost.GetTranslation(x => x.Body, _workContext.WorkingLanguage.Id);
- model.BodyOverview = request.BlogPost.GetTranslation(x => x.BodyOverview, _workContext.WorkingLanguage.Id);
- model.AllowComments = request.BlogPost.AllowComments;
- model.CreatedOn = _dateTimeService.ConvertToUserTime(request.BlogPost.StartDateUtc ?? request.BlogPost.CreatedOnUtc, DateTimeKind.Utc);
- model.Tags = request.BlogPost.ParseTags().ToList();
- model.NumberOfComments = request.BlogPost.CommentCount;
- model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage;
- model.UserFields = request.BlogPost.UserFields;
+ var model = new BlogPostModel {
+ Id = request.BlogPost.Id,
+ MetaTitle = request.BlogPost.GetTranslation(x => x.MetaTitle, _workContext.WorkingLanguage.Id),
+ MetaDescription = request.BlogPost.GetTranslation(x => x.MetaDescription, _workContext.WorkingLanguage.Id),
+ MetaKeywords = request.BlogPost.GetTranslation(x => x.MetaKeywords, _workContext.WorkingLanguage.Id),
+ SeName = request.BlogPost.GetSeName(_workContext.WorkingLanguage.Id),
+ Title = request.BlogPost.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id),
+ Body = request.BlogPost.GetTranslation(x => x.Body, _workContext.WorkingLanguage.Id),
+ BodyOverview = request.BlogPost.GetTranslation(x => x.BodyOverview, _workContext.WorkingLanguage.Id),
+ AllowComments = request.BlogPost.AllowComments,
+ CreatedOn = _dateTimeService.ConvertToUserTime(request.BlogPost.StartDateUtc ?? request.BlogPost.CreatedOnUtc, DateTimeKind.Utc),
+ Tags = request.BlogPost.ParseTags().ToList(),
+ NumberOfComments = request.BlogPost.CommentCount,
+ AddNewComment = {
+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnBlogCommentPage
+ },
+ UserFields = request.BlogPost.UserFields
+ };
var blogComments = await _blogService.GetBlogCommentsByBlogPostId(request.BlogPost.Id);
foreach (var bc in blogComments)
@@ -97,16 +99,16 @@ namespace Grand.Web.Features.Handlers.Blogs
FullSizeImageUrl = await _pictureService.GetPictureUrl(blogPost.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(blogPost.PictureId, _mediaSettings.BlogThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)) ?
+ picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
+ string.Format(_translationService.GetResource("Media.Blog.ImageLinkTitleFormat"), blogPost.Title),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)) ?
+ picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
+ string.Format(_translationService.GetResource("Media.Blog.ImageAlternateTextFormat"), blogPost.Title)
};
- //"title" attribute
- pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Blog.ImageLinkTitleFormat"), blogPost.Title);
- //"alt" attribute
- pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Blog.ImageAlternateTextFormat"), blogPost.Title);
model.PictureModel = pictureModel;
}
@@ -121,7 +123,7 @@ namespace Grand.Web.Features.Handlers.Blogs
CustomerId = blogComment.CustomerId,
CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat),
CommentText = blogComment.CommentText,
- CreatedOn = _dateTimeService.ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc),
+ CreatedOn = _dateTimeService.ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc)
};
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs
index 0dcd3d64e..c5d34af52 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostListHandler.cs
@@ -1,16 +1,16 @@
-using Grand.Infrastructure;
-using Grand.Domain;
-using Grand.Domain.Blogs;
-using Grand.Domain.Media;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Domain;
+using Grand.Domain.Blogs;
+using Grand.Domain.Media;
+using Grand.Infrastructure;
using Grand.Web.Features.Models.Blogs;
using Grand.Web.Models.Blogs;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Blogs
{
@@ -45,12 +45,15 @@ namespace Grand.Web.Features.Handlers.Blogs
}
public async Task<BlogPostListModel> Handle(GetBlogPostList request, CancellationToken cancellationToken)
{
- var model = new BlogPostListModel();
- model.PagingFilteringContext.Tag = request.Command.Tag;
- model.PagingFilteringContext.Month = request.Command.Month;
- model.PagingFilteringContext.CategorySeName = request.Command.CategorySeName;
- model.WorkingLanguageId = _workContext.WorkingLanguage.Id;
- model.SearchKeyword = request.Command.SearchKeyword;
+ var model = new BlogPostListModel {
+ PagingFilteringContext = {
+ Tag = request.Command.Tag,
+ Month = request.Command.Month,
+ CategorySeName = request.Command.CategorySeName
+ },
+ WorkingLanguageId = _workContext.WorkingLanguage.Id,
+ SearchKeyword = request.Command.SearchKeyword
+ };
if (request.Command.PageSize <= 0) request.Command.PageSize = _blogSettings.PostsPageSize;
if (request.Command.PageNumber <= 0) request.Command.PageNumber = 1;
@@ -128,18 +131,17 @@ namespace Grand.Web.Features.Handlers.Blogs
FullSizeImageUrl = await _pictureService.GetPictureUrl(blogPost.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(blogPost.PictureId, _mediaSettings.BlogThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)) ?
+ picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
+ string.Format(_translationService.GetResource("Media.Blog.ImageLinkTitleFormat"), blogPost.Title),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)) ?
+ picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
+ string.Format(_translationService.GetResource("Media.Blog.ImageAlternateTextFormat"), blogPost.Title)
};
- //"title" attribute
- pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Blog.ImageLinkTitleFormat"), blogPost.Title);
- //"alt" attribute
- pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Blog.ImageAlternateTextFormat"), blogPost.Title);
-
model.PictureModel = pictureModel;
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostTagListHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostTagListHandler.cs
index 3f2cef552..aafa496f2 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostTagListHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostTagListHandler.cs
@@ -1,9 +1,9 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Domain.Blogs;
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Web.Features.Models.Blogs;
+using Grand.Infrastructure;
+using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Blogs;
using Grand.Web.Models.Blogs;
using MediatR;
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostYearHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostYearHandler.cs
index fbb97e6c6..b299b95c8 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostYearHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetBlogPostYearHandler.cs
@@ -31,48 +31,44 @@ namespace Grand.Web.Features.Handlers.Blogs
var model = new List<BlogPostYearModel>();
var blogPosts = await _blogService.GetAllBlogPosts(_workContext.CurrentStore.Id);
- if (blogPosts.Any())
- {
- var months = new SortedDictionary<DateTime, int>();
+ if (!blogPosts.Any()) return model;
+ var months = new SortedDictionary<DateTime, int>();
- var blogPost = blogPosts[blogPosts.Count - 1];
- var first = blogPost.StartDateUtc ?? blogPost.CreatedOnUtc;
- while (DateTime.SpecifyKind(first, DateTimeKind.Utc) <= DateTime.UtcNow.AddMonths(1))
+ var blogPost = blogPosts[^1];
+ var first = blogPost.StartDateUtc ?? blogPost.CreatedOnUtc;
+ while (DateTime.SpecifyKind(first, DateTimeKind.Utc) <= DateTime.UtcNow.AddMonths(1))
+ {
+ var list = blogPosts.GetPostsByDate(new DateTime(first.Year, first.Month, 1), new DateTime(first.Year, first.Month, 1).AddMonths(1).AddSeconds(-1));
+ if (list.Any())
{
- var list = blogPosts.GetPostsByDate(new DateTime(first.Year, first.Month, 1), new DateTime(first.Year, first.Month, 1).AddMonths(1).AddSeconds(-1));
- if (list.Any())
- {
- var date = new DateTime(first.Year, first.Month, 1);
- months.Add(date, list.Count);
- }
-
- first = first.AddMonths(1);
+ var date = new DateTime(first.Year, first.Month, 1);
+ months.Add(date, list.Count);
}
+ first = first.AddMonths(1);
+ }
- int current = 0;
- foreach (var kvp in months)
- {
- var date = kvp.Key;
- var blogPostCount = kvp.Value;
- if (current == 0)
- current = date.Year;
-
- if (date.Year > current || !model.Any())
- {
- var yearModel = new BlogPostYearModel {
- Year = date.Year
- };
- model.Insert(0, yearModel);
- }
-
- model.First().Months.Insert(0, new BlogPostMonthModel {
- Month = date.Month,
- BlogPostCount = blogPostCount
- });
+ var current = 0;
+ foreach (var (date, blogPostCount) in months)
+ {
+ if (current == 0)
current = date.Year;
+
+ if (date.Year > current || !model.Any())
+ {
+ var yearModel = new BlogPostYearModel {
+ Year = date.Year
+ };
+ model.Insert(0, yearModel);
}
+
+ model.First().Months.Insert(0, new BlogPostMonthModel {
+ Month = date.Month,
+ BlogPostCount = blogPostCount
+ });
+
+ current = date.Year;
}
return model;
});
diff --git a/src/Web/Grand.Web/Features/Handlers/Blogs/GetHomePageBlogHandler.cs b/src/Web/Grand.Web/Features/Handlers/Blogs/GetHomePageBlogHandler.cs
index cf00103c7..84b704eca 100644
--- a/src/Web/Grand.Web/Features/Handlers/Blogs/GetHomePageBlogHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Blogs/GetHomePageBlogHandler.cs
@@ -1,14 +1,14 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Blogs;
using Grand.Domain.Media;
-using Grand.Web.Features.Models.Blogs;
+using Grand.Infrastructure;
+using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Blogs;
using Grand.Web.Models.Blogs;
using Grand.Web.Models.Media;
using MediatR;
@@ -86,11 +86,11 @@ namespace Grand.Web.Features.Handlers.Blogs
ExtraField = picture?.ExtraField
};
//"title" attribute
- pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))) ?
+ pictureModel.Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)) ?
picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
string.Format(_translationService.GetResource("Media.Blog.ImageLinkTitleFormat"), post.Title);
//"alt" attribute
- pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))) ?
+ pictureModel.AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)) ?
picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
string.Format(_translationService.GetResource("Media.Blog.ImageAlternateTextFormat"), post.Title);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs
index 384512cda..e265b2326 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandAllHandler.cs
@@ -1,16 +1,16 @@
-using Grand.Business.Core.Interfaces.Catalog.Brands;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -37,7 +37,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<BrandModel>> Handle(GetBrandAll request, CancellationToken cancellationToken)
{
- string cacheKey = string.Format(CacheKeyConst.BRAND_ALL_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.BRAND_ALL_MODEL_KEY,
request.Language.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
@@ -60,16 +60,16 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(brand.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(brand.PictureId, _mediaSettings.BrandThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Brand.ImageLinkTitleFormat"), brand.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Brand.ImageAlternateTextFormat"), brand.Name)
};
- //"title" attribute
- modelBrand.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Brand.ImageLinkTitleFormat"), brand.Name);
- //"alt" attribute
- modelBrand.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Brand.ImageAlternateTextFormat"), brand.Name);
model.Add(modelBrand);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandHandler.cs
index 252977477..dc05ec950 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandHandler.cs
@@ -35,47 +35,47 @@ namespace Grand.Web.Features.Handlers.Catalog
{
var model = request.Brand.ToModel(request.Language);
- if (request.Command != null && request.Command.OrderBy == null && request.Brand.DefaultSort >= 0)
+ if (request.Command is { OrderBy: null } && request.Brand.DefaultSort >= 0)
request.Command.OrderBy = request.Brand.DefaultSort;
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Command,
Language = request.Language,
AllowCustomersToSelectPageSize = request.Brand.AllowCustomersToSelectPageSize,
PageSizeOptions = request.Brand.PageSizeOptions,
PageSize = request.Brand.PageSize
- });
+ }, cancellationToken);
model.PagingFilteringContext = options.command;
IList<string> alreadyFilteredSpecOptionIds = await model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
- (_httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
+ (_httpContextAccessor.HttpContext?.Request.Query, _specificationAttributeService);
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = await _mediator.Send(new GetSearchProductsQuery {
LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
BrandId = request.Brand.Id,
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
- FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
+ FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : false,
FilteredSpecs = alreadyFilteredSpecOptionIds,
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
- }));
+ }, cancellationToken);
- model.Products = (await _mediator.Send(new GetProductOverview() {
+ model.Products = (await _mediator.Send(new GetProductOverview {
Products = products.products,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
- })).ToList();
+ }, cancellationToken)).ToList();
model.PagingFilteringContext.LoadPagedList(products.products);
//specs
await model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
products.filterableSpecificationAttributeOptionIds,
- _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
+ _specificationAttributeService, _httpContextAccessor.HttpContext?.Request.GetDisplayUrl(), request.Language.Id);
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandLayoutViewPathHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandLayoutViewPathHandler.cs
index 88dd6a1c6..e03005c3c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandLayoutViewPathHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetBrandLayoutViewPathHandler.cs
@@ -16,9 +16,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<string> Handle(GetBrandLayoutViewPath request, CancellationToken cancellationToken)
{
- var layout = await _brandLayoutService.GetBrandLayoutById(request.LayoutId);
- if (layout == null)
- layout = (await _brandLayoutService.GetAllBrandLayouts()).FirstOrDefault();
+ var layout = await _brandLayoutService.GetBrandLayoutById(request.LayoutId) ?? (await _brandLayoutService.GetAllBrandLayouts()).FirstOrDefault();
if (layout == null)
throw new Exception("No default layout could be loaded");
return layout.ViewPath;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryFeaturedProductsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryFeaturedProductsHandler.cs
index f9dfbd4b9..dc23c4c31 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryFeaturedProductsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryFeaturedProductsHandler.cs
@@ -1,20 +1,20 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Media;
+using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -48,7 +48,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<CategoryModel>> Handle(GetCategoryFeaturedProducts request, CancellationToken cancellationToken)
{
- string categoriesCacheKey = string.Format(CacheKeyConst.CATEGORY_FEATURED_PRODUCTS_HOMEPAGE_KEY,
+ var categoriesCacheKey = string.Format(CacheKeyConst.CATEGORY_FEATURED_PRODUCTS_HOMEPAGE_KEY,
string.Join(",", request.Customer.GetCustomerGroupIds()), request.Store.Id,
request.Language.Id);
@@ -65,16 +65,16 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(x.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(x.PictureId, _mediaSettings.CategoryThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name)
};
- //"title" attribute
- catModel.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name);
- //"alt" attribute
- catModel.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name);
catlistmodel.Add(catModel);
}
@@ -86,40 +86,40 @@ namespace Grand.Web.Features.Handlers.Catalog
{
//We cache a value indicating whether we have featured products
IPagedList<Product> featuredProducts = null;
- string cacheKey = string.Format(CacheKeyConst.CATEGORY_HAS_FEATURED_PRODUCTS_KEY, item.Id,
+ var cacheKey = string.Format(CacheKeyConst.CATEGORY_HAS_FEATURED_PRODUCTS_KEY, item.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()), request.Store.Id);
var hasFeaturedProductsCache = await _cacheBase.GetAsync<bool?>(cacheKey, async () =>
{
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CategoryIds = new List<string> { item.Id },
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
return featuredProducts.Any();
});
- if (hasFeaturedProductsCache.Value && featuredProducts == null)
+ if (hasFeaturedProductsCache.HasValue && hasFeaturedProductsCache.Value && featuredProducts == null)
{
//cache indicates that the category has featured products
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CategoryIds = new List<string> { item.Id },
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
}
if (featuredProducts != null && featuredProducts.Any())
{
- item.FeaturedProducts = (await _mediator.Send(new GetProductOverview() {
+ item.FeaturedProducts = (await _mediator.Send(new GetProductOverview {
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
- Products = featuredProducts,
- })).ToList();
+ Products = featuredProducts
+ }, cancellationToken)).ToList();
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryHandler.cs
index 464dcdfea..fe8e475fc 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryHandler.cs
@@ -1,8 +1,9 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
@@ -17,7 +18,6 @@ using Grand.Web.Models.Media;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -61,20 +61,19 @@ namespace Grand.Web.Features.Handlers.Catalog
var customer = request.Customer;
var storeId = request.Store.Id;
var languageId = request.Language.Id;
- var currency = request.Currency;
- if (request.Command != null && request.Command.OrderBy == null && request.Category.DefaultSort >= 0)
+ if (request.Command is { OrderBy: null } && request.Category.DefaultSort >= 0)
request.Command.OrderBy = request.Category.DefaultSort;
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Command,
Language = request.Language,
AllowCustomersToSelectPageSize = request.Category.AllowCustomersToSelectPageSize,
PageSizeOptions = request.Category.PageSizeOptions,
PageSize = request.Category.PageSize
- });
+ }, cancellationToken);
model.PagingFilteringContext = options.command;
//price ranges
@@ -83,7 +82,7 @@ namespace Grand.Web.Features.Handlers.Catalog
{
model.DisplayCategoryBreadcrumb = true;
- string breadcrumbCacheKey = string.Format(CacheKeyConst.CATEGORY_BREADCRUMB_KEY,
+ var breadcrumbCacheKey = string.Format(CacheKeyConst.CATEGORY_BREADCRUMB_KEY,
request.Category.Id,
string.Join(",", customer.GetCustomerGroupIds()),
storeId,
@@ -118,19 +117,19 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(x.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(x.PictureId, _mediaSettings.CategoryThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name)
};
- //"title" attribute
- subCatModel.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name);
- //"alt" attribute
- subCatModel.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name);
subCategories.Add(subCatModel);
- };
+ }
model.SubCategories = subCategories;
@@ -139,77 +138,76 @@ namespace Grand.Web.Features.Handlers.Catalog
{
//We cache a value indicating whether we have featured products
IPagedList<Product> featuredProducts = null;
- string cacheKey = string.Format(CacheKeyConst.CATEGORY_HAS_FEATURED_PRODUCTS_KEY, request.Category.Id,
+ var cacheKey = string.Format(CacheKeyConst.CATEGORY_HAS_FEATURED_PRODUCTS_KEY, request.Category.Id,
string.Join(",", customer.GetCustomerGroupIds()), storeId);
var hasFeaturedProductsCache = await _cacheBase.GetAsync<bool?>(cacheKey, async () =>
{
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CategoryIds = new List<string> { request.Category.Id },
Customer = request.Customer,
StoreId = storeId,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
return featuredProducts.Any();
});
- if (hasFeaturedProductsCache.Value && featuredProducts == null)
+ if (hasFeaturedProductsCache.HasValue && hasFeaturedProductsCache.Value && featuredProducts == null)
{
//cache indicates that the category has featured products
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CategoryIds = new List<string> { request.Category.Id },
Customer = request.Customer,
StoreId = storeId,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
}
if (featuredProducts != null && featuredProducts.Any())
{
- model.FeaturedProducts = (await _mediator.Send(new GetProductOverview() {
- Products = featuredProducts,
- })).ToList();
+ model.FeaturedProducts = (await _mediator.Send(new GetProductOverview {
+ Products = featuredProducts
+ }, cancellationToken)).ToList();
}
}
- var categoryIds = new List<string>();
- categoryIds.Add(request.Category.Id);
+ var categoryIds = new List<string> { request.Category.Id };
if (_catalogSettings.ShowProductsFromSubcategories)
{
//include subcategories
- categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds() { ParentCategoryId = request.Category.Id, Customer = request.Customer, Store = request.Store }));
+ categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds { ParentCategoryId = request.Category.Id, Customer = request.Customer, Store = request.Store }, cancellationToken));
}
//products
IList<string> alreadyFilteredSpecOptionIds = await model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds(
- _httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ _httpContextAccessor.HttpContext?.Request.Query, _specificationAttributeService);
+ var products = await _mediator.Send(new GetSearchProductsQuery {
LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
CategoryIds = categoryIds,
Customer = request.Customer,
StoreId = storeId,
VisibleIndividuallyOnly = true,
- FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
+ FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : false,
FilteredSpecs = alreadyFilteredSpecOptionIds,
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
- }));
+ }, cancellationToken);
- model.Products = (await _mediator.Send(new GetProductOverview() {
+ model.Products = (await _mediator.Send(new GetProductOverview {
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages,
- Products = products.products,
- })).ToList();
+ Products = products.products
+ }, cancellationToken)).ToList();
model.PagingFilteringContext.LoadPagedList(products.products);
//specs
await model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
products.filterableSpecificationAttributeOptionIds,
- _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
+ _specificationAttributeService, _httpContextAccessor.HttpContext?.Request.GetDisplayUrl(), request.Language.Id);
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryLayoutViewPathHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryLayoutViewPathHandler.cs
index 047bb459c..b579ef9f4 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryLayoutViewPathHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryLayoutViewPathHandler.cs
@@ -16,9 +16,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<string> Handle(GetCategoryLayoutViewPath request, CancellationToken cancellationToken)
{
- var layout = await _categoryLayoutService.GetCategoryLayoutById(request.LayoutId);
- if (layout == null)
- layout = (await _categoryLayoutService.GetAllCategoryLayouts()).FirstOrDefault();
+ var layout = await _categoryLayoutService.GetCategoryLayoutById(request.LayoutId) ?? (await _categoryLayoutService.GetAllCategoryLayouts()).FirstOrDefault();
if (layout == null)
throw new Exception("No default layout could be loaded");
return layout.ViewPath;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryNavigationHandler.cs
index 854408fb1..3535cc592 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryNavigationHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategoryNavigationHandler.cs
@@ -19,7 +19,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<CategoryNavigationModel> Handle(GetCategoryNavigation request, CancellationToken cancellationToken)
{
//get active category
- string activeCategoryId = "";
+ var activeCategoryId = "";
if (!string.IsNullOrEmpty(request.CurrentCategoryId))
{
//category details page
@@ -30,15 +30,14 @@ namespace Grand.Web.Features.Handlers.Catalog
//product details page
var productCategories = (await _productService.GetProductById(request.CurrentProductId)).ProductCategories;
if (productCategories.Any())
- activeCategoryId = productCategories.OrderBy(x => x.DisplayOrder).FirstOrDefault().CategoryId;
+ activeCategoryId = productCategories.MinBy(x => x.DisplayOrder).CategoryId;
}
- var cachedModel = await _mediator.Send(new GetCategorySimple()
- {
+ var cachedModel = await _mediator.Send(new GetCategorySimple {
Customer = request.Customer,
Language = request.Language,
Store = request.Store,
CurrentCategoryId = request.CurrentCategoryId
- });
+ }, cancellationToken);
var model = new CategoryNavigationModel
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
index 8e86d3551..dc2810b77 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCategorySimpleHandler.cs
@@ -1,16 +1,16 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Media;
-using Grand.Web.Features.Models.Catalog;
+using Grand.Infrastructure.Caching;
+using Grand.SharedKernel.Extensions;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
-using Grand.SharedKernel.Extensions;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -50,7 +50,7 @@ namespace Grand.Web.Features.Handlers.Catalog
private async Task<List<CategorySimpleModel>> PrepareCategorySimpleModels(GetCategorySimple request)
{
var currentCategory = await _categoryService.GetCategoryById(request.CurrentCategoryId);
- string cacheKey = string.Format(CacheKeyConst.CATEGORY_ALL_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.CATEGORY_ALL_MODEL_KEY,
request.Language.Id,
request.Store.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
@@ -66,7 +66,7 @@ namespace Grand.Web.Features.Handlers.Catalog
if (parentCategories.Any())
{
categories.AddRange(parentCategories);
- var parent = await _categoryService.GetCategoryById(parentCategories.FirstOrDefault().ParentCategoryId);
+ var parent = await _categoryService.GetCategoryById(parentCategories.FirstOrDefault()!.ParentCategoryId);
if (parent != null)
await PrepareCategories(parent.ParentCategoryId);
}
@@ -81,15 +81,16 @@ namespace Grand.Web.Features.Handlers.Catalog
else
await PrepareCategories("");
- return await PrepareCategorySimpleModels(request, "", true, categories.ToList());
+ return await PrepareCategorySimpleModels(request, "", categories, true);
});
}
private async Task<List<CategorySimpleModel>> PrepareCategorySimpleModels(GetCategorySimple request, string rootCategoryId,
- bool loadSubCategories = true, List<Category> allCategories = null)
+ IEnumerable<Category> allCategories, bool loadSubCategories = true)
{
var result = new List<CategorySimpleModel>();
-
+ if (allCategories == null) return result;
+
var categories = allCategories.Where(c => c.ParentCategoryId == rootCategoryId).ToList();
foreach (var category in categories)
{
@@ -110,16 +111,15 @@ namespace Grand.Web.Features.Handlers.Catalog
//product number for each category
if (_catalogSettings.ShowCategoryProductNumber)
{
- var categoryIds = new List<string>();
- categoryIds.Add(category.Id);
+ var categoryIds = new List<string> { category.Id };
//include subcategories
if (_catalogSettings.ShowCategoryProductNumberIncludingSubcategories)
- categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds() { Customer = request.Customer, Store = request.Store, ParentCategoryId = category.Id }));
+ categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds { Customer = request.Customer, Store = request.Store, ParentCategoryId = category.Id }));
categoryModel.NumberOfProducts = _productService.GetCategoryProductNumber(request.Customer, categoryIds, request.Store.Id, CommonHelper.IgnoreAcl, CommonHelper.IgnoreStoreLimitations);
}
if (loadSubCategories)
{
- var subCategories = await PrepareCategorySimpleModels(request, category.Id, loadSubCategories, allCategories);
+ var subCategories = await PrepareCategorySimpleModels(request, category.Id, allCategories);
categoryModel.SubCategories.AddRange(subCategories);
}
result.Add(categoryModel);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetChildCategoryIdsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetChildCategoryIdsHandler.cs
index 514cb57b7..e87b7d67c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetChildCategoryIdsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetChildCategoryIdsHandler.cs
@@ -1,8 +1,8 @@
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Domain.Customers;
using Grand.Infrastructure.Caching;
-using Grand.Web.Features.Models.Catalog;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using MediatR;
namespace Grand.Web.Features.Handlers.Catalog
@@ -25,7 +25,7 @@ namespace Grand.Web.Features.Handlers.Catalog
private async Task<List<string>> GetChildCategoryIds(GetChildCategoryIds request)
{
- string cacheKey = string.Format(CacheKeyConst.CATEGORY_CHILD_IDENTIFIERS_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.CATEGORY_CHILD_IDENTIFIERS_MODEL_KEY,
request.ParentCategoryId,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs
index 21de334db..03c970600 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionAllHandler.cs
@@ -1,16 +1,16 @@
-using Grand.Business.Core.Interfaces.Catalog.Collections;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Customers;
using Grand.Domain.Media;
+using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -37,7 +37,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<CollectionModel>> Handle(GetCollectionAll request, CancellationToken cancellationToken)
{
- string cacheKey = string.Format(CacheKeyConst.COLLECTION_ALL_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.COLLECTION_ALL_MODEL_KEY,
request.Language.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
@@ -60,16 +60,16 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(collection.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(collection.PictureId, _mediaSettings.CollectionThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Collection.ImageLinkTitleFormat"), modelcollection.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Collection.ImageAlternateTextFormat"), modelcollection.Name)
};
- //"title" attribute
- modelcollection.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Collection.ImageLinkTitleFormat"), modelcollection.Name);
- //"alt" attribute
- modelcollection.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Collection.ImageAlternateTextFormat"), modelcollection.Name);
model.Add(modelcollection);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionFeaturedProductsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionFeaturedProductsHandler.cs
index 25f9b378f..21d62cf60 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionFeaturedProductsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionFeaturedProductsHandler.cs
@@ -1,20 +1,20 @@
-using Grand.Business.Core.Interfaces.Catalog.Collections;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Media;
+using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -48,7 +48,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<CollectionModel>> Handle(GetCollectionFeaturedProducts request, CancellationToken cancellationToken)
{
- string collectionCacheKey = string.Format(CacheKeyConst.COLLECTION_FEATURED_PRODUCT_HOMEPAGE_KEY,
+ var collectionCacheKey = string.Format(CacheKeyConst.COLLECTION_FEATURED_PRODUCT_HOMEPAGE_KEY,
string.Join(",", request.Customer.GetCustomerGroupIds()), request.Store.Id,
request.Language.Id);
@@ -66,16 +66,16 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(x.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(x.PictureId, _mediaSettings.CategoryThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Collection.ImageLinkTitleFormat"), colModel.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Collection.ImageAlternateTextFormat"), colModel.Name)
};
- //"title" attribute
- colModel.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Collection.ImageLinkTitleFormat"), colModel.Name);
- //"alt" attribute
- colModel.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Collection.ImageAlternateTextFormat"), colModel.Name);
collectionList.Add(colModel);
}
@@ -87,41 +87,41 @@ namespace Grand.Web.Features.Handlers.Catalog
//We cache a value indicating whether we have featured products
IPagedList<Product> featuredProducts = null;
- string cacheKey = string.Format(CacheKeyConst.COLLECTION_HAS_FEATURED_PRODUCTS_KEY,
+ var cacheKey = string.Format(CacheKeyConst.COLLECTION_HAS_FEATURED_PRODUCTS_KEY,
item.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
var hasFeaturedProductsCache = await _cacheBase.GetAsync<bool?>(cacheKey, async () =>
{
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CollectionId = item.Id,
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
return featuredProducts.Any();
});
- if (hasFeaturedProductsCache.Value && featuredProducts == null)
+ if (hasFeaturedProductsCache.HasValue && hasFeaturedProductsCache.Value && featuredProducts == null)
{
//cache indicates that the collection has featured products
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
Customer = request.Customer,
CollectionId = item.Id,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
}
if (featuredProducts != null && featuredProducts.Any())
{
- item.FeaturedProducts = (await _mediator.Send(new GetProductOverview() {
- Products = featuredProducts,
- })).ToList();
+ item.FeaturedProducts = (await _mediator.Send(new GetProductOverview {
+ Products = featuredProducts
+ }, cancellationToken)).ToList();
}
}
return model;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionHandler.cs
index 0f252ac51..966953148 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionHandler.cs
@@ -42,18 +42,18 @@ namespace Grand.Web.Features.Handlers.Catalog
{
var model = request.Collection.ToModel(request.Language);
- if (request.Command != null && request.Command.OrderBy == null && request.Collection.DefaultSort >= 0)
+ if (request.Command is { OrderBy: null } && request.Collection.DefaultSort >= 0)
request.Command.OrderBy = request.Collection.DefaultSort;
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Command,
Language = request.Language,
AllowCustomersToSelectPageSize = request.Collection.AllowCustomersToSelectPageSize,
PageSizeOptions = request.Collection.PageSizeOptions,
PageSize = request.Collection.PageSize
- });
+ }, cancellationToken);
model.PagingFilteringContext = options.command;
//featured products
@@ -62,69 +62,69 @@ namespace Grand.Web.Features.Handlers.Catalog
IPagedList<Product> featuredProducts = null;
//We cache a value indicating whether we have featured products
- string cacheKey = string.Format(CacheKeyConst.COLLECTION_HAS_FEATURED_PRODUCTS_KEY,
+ var cacheKey = string.Format(CacheKeyConst.COLLECTION_HAS_FEATURED_PRODUCTS_KEY,
request.Collection.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
var hasFeaturedProductsCache = await _cacheBase.GetAsync<bool?>(cacheKey, async () =>
{
- var featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CollectionId = request.Collection.Id,
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
return featuredProducts.Any();
});
- if (hasFeaturedProductsCache.Value && featuredProducts == null)
+ if (hasFeaturedProductsCache.HasValue && hasFeaturedProductsCache.Value && featuredProducts == null)
{
//cache indicates that the collection has featured products
- featuredProducts = (await _mediator.Send(new GetSearchProductsQuery() {
+ featuredProducts = (await _mediator.Send(new GetSearchProductsQuery {
PageSize = _catalogSettings.LimitOfFeaturedProducts,
CollectionId = request.Collection.Id,
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
FeaturedProducts = true
- })).products;
+ }, cancellationToken)).products;
}
if (featuredProducts != null && featuredProducts.Any())
{
- model.FeaturedProducts = (await _mediator.Send(new GetProductOverview() {
- Products = featuredProducts,
- })).ToList();
+ model.FeaturedProducts = (await _mediator.Send(new GetProductOverview {
+ Products = featuredProducts
+ }, cancellationToken)).ToList();
}
}
IList<string> alreadyFilteredSpecOptionIds = await model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
- (_httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
+ (_httpContextAccessor.HttpContext?.Request.Query, _specificationAttributeService);
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = await _mediator.Send(new GetSearchProductsQuery {
LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
CollectionId = request.Collection.Id,
Customer = request.Customer,
StoreId = request.Store.Id,
VisibleIndividuallyOnly = true,
- FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
+ FeaturedProducts = _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : false,
FilteredSpecs = alreadyFilteredSpecOptionIds,
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
- }));
+ }, cancellationToken);
- model.Products = (await _mediator.Send(new GetProductOverview() {
+ model.Products = (await _mediator.Send(new GetProductOverview {
Products = products.products,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
- })).ToList();
+ }, cancellationToken)).ToList();
model.PagingFilteringContext.LoadPagedList(products.products);
//specs
await model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
products.filterableSpecificationAttributeOptionIds,
- _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
+ _specificationAttributeService, _httpContextAccessor.HttpContext?.Request.GetDisplayUrl(), request.Language.Id);
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionLayoutViewPathHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionLayoutViewPathHandler.cs
index bf3efe801..65895989c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionLayoutViewPathHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionLayoutViewPathHandler.cs
@@ -16,9 +16,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<string> Handle(GetCollectionLayoutViewPath request, CancellationToken cancellationToken)
{
- var layout = await _collectionLayoutService.GetCollectionLayoutById(request.LayoutId);
- if (layout == null)
- layout = (await _collectionLayoutService.GetAllCollectionLayouts()).FirstOrDefault();
+ var layout = await _collectionLayoutService.GetCollectionLayoutById(request.LayoutId) ?? (await _collectionLayoutService.GetAllCollectionLayouts()).FirstOrDefault();
if (layout == null)
throw new Exception("No default layout could be loaded");
return layout.ViewPath;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs
index 5339b9565..ab951f692 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCollectionNavigationHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Business.Core.Interfaces.Catalog.Collections;
-using Grand.Business.Core.Extensions;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Domain.Catalog;
using Grand.Domain.Customers;
-using Grand.Web.Features.Models.Catalog;
+using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
@@ -27,7 +27,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<CollectionNavigationModel> Handle(GetCollectionNavigation request, CancellationToken cancellationToken)
{
- string cacheKey = string.Format(CacheKeyConst.COLLECTION_NAVIGATION_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.COLLECTION_NAVIGATION_MODEL_KEY,
request.CurrentCollectionId, request.Language.Id, string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
var cacheModel = await _cacheBase.GetAsync(cacheKey, async () =>
@@ -47,7 +47,7 @@ namespace Grand.Web.Features.Handlers.Catalog
Name = collection.GetTranslation(x => x.Name, request.Language.Id),
Icon = collection.Icon,
SeName = collection.GetSeName(request.Language.Id),
- IsActive = currentCollection != null && currentCollection.Id == collection.Id,
+ IsActive = currentCollection != null && currentCollection.Id == collection.Id
};
model.Collections.Add(modelMan);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs
index 6e6218344..cabd8a9a4 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs
@@ -40,7 +40,7 @@ namespace Grand.Web.Features.Handlers.Catalog
{
var model = new CompareProductsModel {
IncludeShortDescriptionInCompareProducts = _catalogSettings.IncludeShortDescriptionInCompareProducts,
- IncludeFullDescriptionInCompareProducts = _catalogSettings.IncludeFullDescriptionInCompareProducts,
+ IncludeFullDescriptionInCompareProducts = _catalogSettings.IncludeFullDescriptionInCompareProducts
};
var products = new List<Product>();
@@ -48,7 +48,7 @@ namespace Grand.Web.Features.Handlers.Catalog
foreach (var id in productIds)
{
var product = await _productService.GetProductById(id);
- if (product != null && product.Published)
+ if (product is { Published: true })
products.Add(product);
}
@@ -57,11 +57,11 @@ namespace Grand.Web.Features.Handlers.Catalog
//availability dates
products = products.Where(p => p.IsAvailable()).ToList();
- (await _mediator.Send(new GetProductOverview() {
+ (await _mediator.Send(new GetProductOverview {
PrepareSpecificationAttributes = true,
Products = products,
ProductThumbPictureSize = request.PictureProductThumbSize
- })).ToList().ForEach(model.Products.Add);
+ }, cancellationToken)).ToList().ForEach(model.Products.Add);
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetFormatBasePriceHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetFormatBasePriceHandler.cs
index ef8805cb1..bfe4b1401 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetFormatBasePriceHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetFormatBasePriceHandler.cs
@@ -44,13 +44,13 @@ namespace Grand.Web.Features.Handlers.Catalog
if (referenceUnit == null)
return null;
- request.ProductPrice = request.ProductPrice.HasValue ? request.ProductPrice.Value : request.Product.Price;
+ request.ProductPrice ??= request.Product.Price;
- double basePrice = request.ProductPrice.Value /
- //do not round. otherwise, it can cause issues
- await _measureService.ConvertWeight(productAmount, productUnit, referenceUnit, false) *
- referenceAmount;
- string basePriceStr = _priceFormatter.FormatPrice(basePrice, false);
+ var basePrice = request.ProductPrice.Value /
+ //do not round. otherwise, it can cause issues
+ await _measureService.ConvertWeight(productAmount, productUnit, referenceUnit, false) *
+ referenceAmount;
+ var basePriceStr = _priceFormatter.FormatPrice(basePrice, false);
var result = string.Format(_translationService.GetResource("Products.BasePrice"),
basePriceStr, referenceAmount.ToString("G29"), referenceUnit.Name);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs
index 8991c91ca..cc44faf9b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageBrandsHandler.cs
@@ -3,9 +3,9 @@ using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Media;
using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
@@ -36,7 +36,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<BrandModel>> Handle(GetHomepageBrands request, CancellationToken cancellationToken)
{
- string brandsCacheKey = string.Format(CacheKeyConst.BRAND_HOMEPAGE_KEY, request.Store.Id, request.Language.Id);
+ var brandsCacheKey = string.Format(CacheKeyConst.BRAND_HOMEPAGE_KEY, request.Store.Id, request.Language.Id);
var model = await _cacheBase.GetAsync(brandsCacheKey, async () =>
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCategoryHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCategoryHandler.cs
index 0be4b9255..91b456cf6 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCategoryHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCategoryHandler.cs
@@ -1,16 +1,16 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -38,7 +38,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<CategoryModel>> Handle(GetHomepageCategory request, CancellationToken cancellationToken)
{
- string categoriesCacheKey = string.Format(CacheKeyConst.CATEGORY_HOMEPAGE_KEY,
+ var categoriesCacheKey = string.Format(CacheKeyConst.CATEGORY_HOMEPAGE_KEY,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id,
request.Language.Id);
@@ -46,7 +46,7 @@ namespace Grand.Web.Features.Handlers.Catalog
var model = await _cacheBase.GetAsync(categoriesCacheKey, async () =>
{
var cat = new List<CategoryModel>();
- foreach (var x in (await _categoryService.GetAllCategoriesDisplayedOnHomePage()))
+ foreach (var x in await _categoryService.GetAllCategoriesDisplayedOnHomePage())
{
var catModel = x.ToModel(request.Language);
//prepare picture model
@@ -57,16 +57,16 @@ namespace Grand.Web.Features.Handlers.Catalog
FullSizeImageUrl = await _pictureService.GetPictureUrl(x.PictureId),
ImageUrl = await _pictureService.GetPictureUrl(x.PictureId, _mediaSettings.CategoryThumbPictureSize),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.TitleAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.TitleAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name),
+ //"alt" attribute
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.GetTranslation(z => z.AltAttribute, request.Language.Id)) ?
+ picture.GetTranslation(z => z.AltAttribute, request.Language.Id) :
+ string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name)
};
- //"title" attribute
- catModel.PictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), x.Name);
- //"alt" attribute
- catModel.PictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, request.Language.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, request.Language.Id) :
- string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), x.Name);
cat.Add(catModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs
index ca80cacc7..a21e0763e 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetHomepageCollectionsHandler.cs
@@ -1,11 +1,11 @@
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Media;
+using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
@@ -36,7 +36,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<IList<CollectionModel>> Handle(GetHomepageCollections request, CancellationToken cancellationToken)
{
- string collectionsCacheKey = string.Format(CacheKeyConst.COLLECTION_HOMEPAGE_KEY, request.Store.Id, request.Language.Id);
+ var collectionsCacheKey = string.Format(CacheKeyConst.COLLECTION_HOMEPAGE_KEY, request.Store.Id, request.Language.Id);
var model = await _cacheBase.GetAsync(collectionsCacheKey, async () =>
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs
index 7f25bed74..20b60db78 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetMenuHandler.cs
@@ -1,8 +1,8 @@
-using Grand.Business.Core.Interfaces.Catalog.Brands;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
@@ -10,10 +10,9 @@ using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Localization;
using Grand.Domain.Media;
-using Grand.Domain.Stores;
using Grand.Infrastructure.Caching;
-using Grand.Web.Features.Models.Catalog;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
@@ -61,15 +60,9 @@ namespace Grand.Web.Features.Handlers.Catalog
var cacheKey = string.Format(CacheKeyConst.CATEGORIES_BY_MENU,
request.Language.Id,
request.Store.Id, string.Join(",", request.Customer.GetCustomerGroupIds()));
- var cachedCategoriesModel = await _cacheBase.GetAsync(cacheKey, async () =>
- {
- //categories
- return await PrepareCategorySimpleModels(
- language: request.Language,
- store: request.Store,
- customer: request.Customer,
- allCategories: await _categoryService.GetMenuCategories());
- });
+ var cachedCategoriesModel = await _cacheBase.GetAsync(cacheKey, async () => await PrepareCategorySimpleModels(
+ language: request.Language,
+ allCategories: await _categoryService.GetMenuCategories()));
//top menu pages
var now = DateTime.UtcNow;
@@ -82,7 +75,7 @@ namespace Grand.Web.Features.Handlers.Catalog
SeName = t.GetSeName(request.Language.Id)
}).ToList();
- string brandCacheKey = string.Format(CacheKeyConst.BRAND_NAVIGATION_MENU,
+ var brandCacheKey = string.Format(CacheKeyConst.BRAND_NAVIGATION_MENU,
request.Language.Id, request.Store.Id);
var cachedBrandModel = await _cacheBase.GetAsync(brandCacheKey, async () =>
@@ -98,7 +91,7 @@ namespace Grand.Web.Features.Handlers.Catalog
.ToList()
);
- string collectionCacheKey = string.Format(CacheKeyConst.COLLECTION_NAVIGATION_MENU,
+ var collectionCacheKey = string.Format(CacheKeyConst.COLLECTION_NAVIGATION_MENU,
request.Language.Id, request.Store.Id);
var cachedCollectionModel = await _cacheBase.GetAsync(collectionCacheKey, async () =>
@@ -134,10 +127,12 @@ namespace Grand.Web.Features.Handlers.Catalog
}
- private async Task<List<CategorySimpleModel>> PrepareCategorySimpleModels(Language language, Store store, Customer customer, string rootCategoryId = "",
- bool loadSubCategories = true, IList<Category> allCategories = null)
+ private async Task<List<CategorySimpleModel>> PrepareCategorySimpleModels(Language language,
+ IEnumerable<Category> allCategories, string rootCategoryId = "",
+ bool loadSubCategories = true)
{
var result = new List<CategorySimpleModel>();
+ if (allCategories == null) return result;
var categories = allCategories.Where(c => c.ParentCategoryId == rootCategoryId).OrderBy(x => x.DisplayOrder).ToList();
foreach (var category in categories)
{
@@ -156,7 +151,7 @@ namespace Grand.Web.Features.Handlers.Catalog
};
if (loadSubCategories)
{
- var subCategories = await PrepareCategorySimpleModels(language, store, customer, category.Id, loadSubCategories, allCategories);
+ var subCategories = await PrepareCategorySimpleModels(language, allCategories, category.Id, true);
categoryModel.SubCategories.AddRange(subCategories);
}
result.Add(categoryModel);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetPopularProductTagsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetPopularProductTagsHandler.cs
index cd351ff96..10d6393f2 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetPopularProductTagsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetPopularProductTagsHandler.cs
@@ -1,9 +1,9 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Domain.Catalog;
-using Grand.Web.Features.Models.Catalog;
+using Grand.Infrastructure.Caching;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductAttributeHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductAttributeHandler.cs
index 38cf20881..0f66bad09 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductAttributeHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductAttributeHandler.cs
@@ -17,7 +17,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<ProductAttribute> Handle(GetProductAttribute request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.Id))
- throw new ArgumentNullException("Id");
+ throw new ArgumentNullException(nameof(request.Id));
return await _productAttributeService.GetProductAttributeById(request.Id);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs
index 3d5dfe298..bd21a3160 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductTagsAllHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductsByTagHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductsByTagHandler.cs
index 8da29a118..c8d2957f6 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductsByTagHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetProductsByTagHandler.cs
@@ -30,18 +30,18 @@ namespace Grand.Web.Features.Handlers.Catalog
};
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Command,
Language = request.Language,
AllowCustomersToSelectPageSize = _catalogSettings.ProductsByTagAllowCustomersToSelectPageSize,
PageSize = _catalogSettings.ProductsByTagPageSize,
PageSizeOptions = _catalogSettings.ProductsByTagPageSizeOptions
- });
+ }, cancellationToken);
model.PagingFilteringContext = options.command;
//products
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = (await _mediator.Send(new GetSearchProductsQuery {
Customer = request.Customer,
StoreId = request.Store.Id,
ProductTag = request.ProductTag.Name,
@@ -49,12 +49,12 @@ namespace Grand.Web.Features.Handlers.Catalog
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
- })).products;
+ }, cancellationToken)).products;
- model.Products = (await _mediator.Send(new GetProductOverview() {
+ model.Products = (await _mediator.Send(new GetProductOverview {
Products = products,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
- })).ToList();
+ }, cancellationToken)).ToList();
model.PagingFilteringContext.LoadPagedList(products);
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
index de4cb0788..0b9cf7471 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchAutoCompleteHandler.cs
@@ -1,13 +1,14 @@
-using Grand.Business.Core.Interfaces.Catalog.Brands;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Tax;
using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Queries.Catalog;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
@@ -18,7 +19,6 @@ using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
using MediatR;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -87,11 +87,11 @@ namespace Grand.Web.Features.Handlers.Catalog
if (_catalogSettings.ShowProductsFromSubcategoriesInSearchBox)
{
//include subcategories
- categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds() { ParentCategoryId = request.CategoryId, Customer = request.Customer, Store = request.Store }));
+ categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds { ParentCategoryId = request.CategoryId, Customer = request.Customer, Store = request.Store }, cancellationToken));
}
}
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = (await _mediator.Send(new GetSearchProductsQuery {
Customer = request.Customer,
StoreId = storeId,
Keywords = request.Term,
@@ -101,7 +101,7 @@ namespace Grand.Web.Features.Handlers.Catalog
LanguageId = request.Language.Id,
VisibleIndividuallyOnly = true,
PageSize = productNumber
- })).products;
+ }, cancellationToken)).products;
var categories = new List<string>();
var brands = new List<string>();
@@ -115,141 +115,124 @@ namespace Grand.Web.Features.Handlers.Catalog
var pictureUrl = "";
if (_catalogSettings.ShowProductImagesInSearchAutoComplete)
{
- var picture = item.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault();
+ var picture = item.ProductPictures.MinBy(x => x.DisplayOrder);
if (picture != null)
pictureUrl = await _pictureService.GetPictureUrl(picture.PictureId, _mediaSettings.AutoCompleteSearchThumbPictureSize);
}
- var rating = await _mediator.Send(new GetProductReviewOverview() {
+ var rating = await _mediator.Send(new GetProductReviewOverview {
Language = request.Language,
Product = item,
Store = request.Store
- });
+ }, cancellationToken);
var price = displayPrices ? await PreparePrice(item, request) : (Price: string.Empty, PriceWithDiscount: string.Empty);
- model.Add(new SearchAutoCompleteModel() {
+ model.Add(new SearchAutoCompleteModel {
SearchType = "Product",
Label = item.GetTranslation(x => x.Name, request.Language.Id) ?? "",
Desc = item.GetTranslation(x => x.ShortDescription, request.Language.Id) ?? "",
PictureUrl = pictureUrl,
AllowCustomerReviews = rating.AllowCustomerReviews,
- Rating = rating.TotalReviews > 0 ? (((rating.RatingSum * 100) / rating.TotalReviews) / 5) : 0,
+ Rating = rating.TotalReviews > 0 ? rating.RatingSum * 100 / rating.TotalReviews / 5 : 0,
Price = price.Price,
PriceWithDiscount = price.PriceWithDiscount,
Url = $"{storeurl}/{item.SeName}"
});
- foreach (var category in item.ProductCategories)
- {
- categories.Add(category.CategoryId);
- }
+ categories.AddRange(item.ProductCategories.Select(category => category.CategoryId));
brands.Add(item.BrandId);
}
foreach (var item in brands.Distinct())
{
var brand = await _brandService.GetBrandById(item);
- if (brand != null && brand.Published)
- {
- var allow = true;
- if (!CommonHelper.IgnoreAcl)
- if (!_aclService.Authorize(brand, _workContext.CurrentCustomer))
- allow = false;
- if (!CommonHelper.IgnoreStoreLimitations)
- if (!_aclService.Authorize(brand, storeId))
- allow = false;
- if (allow)
- {
- var desc = "";
- if (_catalogSettings.SearchByDescription)
- desc = "&sid=true";
- model.Add(new SearchAutoCompleteModel() {
- SearchType = "Brand",
- Label = brand.GetTranslation(x => x.Name, request.Language.Id),
- Desc = "",
- PictureUrl = "",
- Url = $"{storeurl}/search?q={request.Term}&adv=true&brand={item}{desc}"
- });
- }
- }
+ if (brand is not { Published: true }) continue;
+ var allow = true;
+ if (!CommonHelper.IgnoreAcl)
+ if (!_aclService.Authorize(brand, _workContext.CurrentCustomer))
+ allow = false;
+ if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_aclService.Authorize(brand, storeId))
+ allow = false;
+ if (!allow) continue;
+
+ var desc = "";
+ if (_catalogSettings.SearchByDescription)
+ desc = "&sid=true";
+ model.Add(new SearchAutoCompleteModel {
+ SearchType = "Brand",
+ Label = brand.GetTranslation(x => x.Name, request.Language.Id),
+ Desc = "",
+ PictureUrl = "",
+ Url = $"{storeurl}/search?q={request.Term}&adv=true&brand={item}{desc}"
+ });
}
foreach (var item in categories.Distinct())
{
var category = await _categoryService.GetCategoryById(item);
- if (category != null && category.Published)
- {
- var allow = true;
- if (!CommonHelper.IgnoreAcl)
- if (!_aclService.Authorize(category, _workContext.CurrentCustomer))
- allow = false;
- if (!CommonHelper.IgnoreStoreLimitations)
- if (!_aclService.Authorize(category, storeId))
- allow = false;
- if (allow)
- {
- var desc = "";
- if (_catalogSettings.SearchByDescription)
- desc = "&sid=true";
- model.Add(new SearchAutoCompleteModel() {
- SearchType = "Category",
- Label = category.GetTranslation(x => x.Name, request.Language.Id),
- Desc = "",
- PictureUrl = "",
- Url = $"{storeurl}/search?q={request.Term}&adv=true&cid={item}{desc}"
- });
- }
- }
+ if (category is not { Published: true }) continue;
+ var allow = true;
+ if (!CommonHelper.IgnoreAcl)
+ if (!_aclService.Authorize(category, _workContext.CurrentCustomer))
+ allow = false;
+ if (!CommonHelper.IgnoreStoreLimitations)
+ if (!_aclService.Authorize(category, storeId))
+ allow = false;
+ if (!allow) continue;
+ var desc = "";
+ if (_catalogSettings.SearchByDescription)
+ desc = "&sid=true";
+ model.Add(new SearchAutoCompleteModel {
+ SearchType = "Category",
+ Label = category.GetTranslation(x => x.Name, request.Language.Id),
+ Desc = "",
+ PictureUrl = "",
+ Url = $"{storeurl}/search?q={request.Term}&adv=true&cid={item}{desc}"
+ });
}
if (_blogSettings.ShowBlogPostsInSearchAutoComplete)
{
var posts = await _blogService.GetAllBlogPosts(storeId: storeId, pageSize: productNumber, blogPostName: request.Term);
- foreach (var item in posts)
- {
- model.Add(new SearchAutoCompleteModel() {
- SearchType = "Blog",
- Label = item.GetTranslation(x => x.Title, request.Language.Id),
- Desc = "",
- PictureUrl = "",
- Url = $"{storeurl}/{item.SeName}"
- });
- }
+ model.AddRange(posts.Select(item => new SearchAutoCompleteModel {
+ SearchType = "Blog",
+ Label = item.GetTranslation(x => x.Title, request.Language.Id),
+ Desc = "",
+ PictureUrl = "",
+ Url = $"{storeurl}/{item.SeName}"
+ }));
}
//search term statistics
- if (!String.IsNullOrEmpty(request.Term) && _catalogSettings.SaveSearchAutoComplete)
+ if (string.IsNullOrEmpty(request.Term) || !_catalogSettings.SaveSearchAutoComplete) return model;
+
+ var searchTerm = await _searchTermService.GetSearchTermByKeyword(request.Term, request.Store.Id);
+ if (searchTerm != null)
{
- var searchTerm = await _searchTermService.GetSearchTermByKeyword(request.Term, request.Store.Id);
- if (searchTerm != null)
- {
- searchTerm.Count++;
- await _searchTermService.UpdateSearchTerm(searchTerm);
- }
- else
- {
- searchTerm = new SearchTerm {
- Keyword = request.Term,
- StoreId = storeId,
- Count = 1
- };
- await _searchTermService.InsertSearchTerm(searchTerm);
- }
-
+ searchTerm.Count++;
+ await _searchTermService.UpdateSearchTerm(searchTerm);
+ }
+ else
+ {
+ searchTerm = new SearchTerm {
+ Keyword = request.Term,
+ StoreId = storeId,
+ Count = 1
+ };
+ await _searchTermService.InsertSearchTerm(searchTerm);
}
return model;
}
private async Task<(string Price, string PriceWithDiscount)> PreparePrice(Product product, GetSearchAutoComplete request)
{
- string price, priceWithDiscount;
-
- double finalPriceWithoutDiscount =
- (await (_taxService.GetProductPrice(product,
- (await _pricingService.GetFinalPrice(product, request.Customer, request.Currency, includeDiscounts: false)).finalPrice))).productprice;
+ var finalPriceWithoutDiscount =
+ (await _taxService.GetProductPrice(product,
+ (await _pricingService.GetFinalPrice(product, request.Customer, request.Currency, includeDiscounts: false)).finalPrice)).productprice;
- var appliedPrice = (await _pricingService.GetFinalPrice(product, request.Customer, request.Currency, includeDiscounts: true));
+ var appliedPrice = await _pricingService.GetFinalPrice(product, request.Customer, request.Currency, includeDiscounts: true);
var finalPriceWithDiscount = (await _taxService.GetProductPrice(product, appliedPrice.finalPrice)).productprice;
- price = _priceFormatter.FormatPrice(finalPriceWithoutDiscount);
- priceWithDiscount = _priceFormatter.FormatPrice(finalPriceWithDiscount);
+ var price = _priceFormatter.FormatPrice(finalPriceWithoutDiscount);
+ var priceWithDiscount = _priceFormatter.FormatPrice(finalPriceWithDiscount);
return (price, priceWithDiscount);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
index c864913b0..64b38ee4e 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchBoxHandler.cs
@@ -45,7 +45,7 @@ namespace Grand.Web.Features.Handlers.Catalog
{
availableCategories.Add(new SelectListItem { Text = _translationService.GetResource("Common.All"), Value = "" });
foreach (var s in searchbocategories)
- availableCategories.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() });
+ availableCategories.Add(new SelectListItem { Text = s.Name, Value = s.Id });
}
var model = new SearchBoxModel {
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs
index bd8ea74fc..999260c9f 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetSearchHandler.cs
@@ -1,12 +1,12 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Collections;
using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Customers;
-using Grand.Domain;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -20,7 +20,6 @@ using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc.Rendering;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -70,12 +69,9 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<SearchModel> Handle(GetSearch request, CancellationToken cancellationToken)
{
- if (request.Model == null)
- request.Model = new SearchModel();
+ request.Model ??= new SearchModel();
- var searchTerms = request.Model.q;
- if (searchTerms == null)
- searchTerms = "";
+ var searchTerms = request.Model.q ?? "";
searchTerms = searchTerms.Trim();
if (request.Model.Box)
@@ -84,19 +80,19 @@ namespace Grand.Web.Features.Handlers.Catalog
request.Model.adv = true;
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Model.PagingFilteringContext,
Language = request.Language,
AllowCustomersToSelectPageSize = _catalogSettings.SearchPageAllowCustomersToSelectPageSize,
PageSizeOptions = _catalogSettings.SearchPagePageSizeOptions,
PageSize = _catalogSettings.SearchPageProductsPerPage
- });
+ }, cancellationToken);
request.Model.PagingFilteringContext = options.pagingFilteringModel;
request.Command = options.command;
- string cacheKey = string.Format(CacheKeyConst.SEARCH_CATEGORIES_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.SEARCH_CATEGORIES_MODEL_KEY,
request.Language.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
@@ -108,9 +104,9 @@ namespace Grand.Web.Features.Handlers.Catalog
foreach (var c in allCategories)
{
//generate full category name (breadcrumb)
- string categoryBreadcrumb = "";
+ var categoryBreadcrumb = "";
var breadcrumb = _categoryService.GetCategoryBreadCrumb(c, allCategories);
- for (int i = 0; i <= breadcrumb.Count - 1; i++)
+ for (var i = 0; i <= breadcrumb.Count - 1; i++)
{
categoryBreadcrumb += breadcrumb[i].GetTranslation(x => x.Name, request.Language.Id);
if (i != breadcrumb.Count - 1)
@@ -134,7 +130,7 @@ namespace Grand.Web.Features.Handlers.Catalog
foreach (var c in categories)
{
request.Model.AvailableCategories.Add(new SelectListItem {
- Value = c.Id.ToString(),
+ Value = c.Id,
Text = c.Breadcrumb,
Selected = request.Model.cid == c.Id
});
@@ -150,7 +146,7 @@ namespace Grand.Web.Features.Handlers.Catalog
});
foreach (var m in collections)
request.Model.AvailableCollections.Add(new SelectListItem {
- Value = m.Id.ToString(),
+ Value = m.Id,
Text = m.GetTranslation(x => x.Name, request.Language.Id),
Selected = request.Model.mid == m.Id
});
@@ -168,121 +164,115 @@ namespace Grand.Web.Features.Handlers.Catalog
});
foreach (var vendor in vendors)
request.Model.AvailableVendors.Add(new SelectListItem {
- Value = vendor.Id.ToString(),
+ Value = vendor.Id,
Text = vendor.GetTranslation(x => x.Name, request.Language.Id),
Selected = request.Model.vid == vendor.Id
});
}
}
- IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1);
-
- if (request.IsSearchTermSpecified)
+ if (!request.IsSearchTermSpecified) return request.Model;
+
+ if (searchTerms.Length < _catalogSettings.ProductSearchTermMinimumLength)
{
- if (searchTerms.Length < _catalogSettings.ProductSearchTermMinimumLength)
- {
- request.Model.Warning = string.Format(_translationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength);
- }
- else
+ request.Model.Warning = string.Format(_translationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength);
+ }
+ else
+ {
+ var categoryIds = new List<string>();
+ var collectionId = "";
+ double? minPriceConverted = null;
+ double? maxPriceConverted = null;
+ var searchInDescriptions = false;
+ var vendorId = "";
+ if (request.Model.adv)
{
- var categoryIds = new List<string>();
- string collectionId = "";
- double? minPriceConverted = null;
- double? maxPriceConverted = null;
- bool searchInDescriptions = false;
- string vendorId = "";
- if (request.Model.adv)
+ //advanced search
+ var categoryId = request.Model.cid;
+ if (!string.IsNullOrEmpty(categoryId))
{
- //advanced search
- var categoryId = request.Model.cid;
- if (!String.IsNullOrEmpty(categoryId))
- {
- categoryIds.Add(categoryId);
- //include subcategories
- categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds() { ParentCategoryId = categoryId, Customer = request.Customer, Store = request.Store }));
- }
- collectionId = request.Model.mid;
-
- //min price
- if (!string.IsNullOrEmpty(request.Model.pf))
- {
- double minPrice;
- if (double.TryParse(request.Model.pf, out minPrice))
- minPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(minPrice, request.Currency);
- }
- //max price
- if (!string.IsNullOrEmpty(request.Model.pt))
- {
- double maxPrice;
- if (double.TryParse(request.Model.pt, out maxPrice))
- maxPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, request.Currency);
- }
+ categoryIds.Add(categoryId);
+ //include subcategories
+ categoryIds.AddRange(await _mediator.Send(new GetChildCategoryIds { ParentCategoryId = categoryId, Customer = request.Customer, Store = request.Store }, cancellationToken));
+ }
+ collectionId = request.Model.mid;
- searchInDescriptions = request.Model.sid;
- if (request.Model.asv)
- vendorId = request.Model.vid;
+ //min price
+ if (!string.IsNullOrEmpty(request.Model.pf))
+ {
+ if (double.TryParse(request.Model.pf, out var minPrice))
+ minPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(minPrice, request.Currency);
+ }
+ //max price
+ if (!string.IsNullOrEmpty(request.Model.pt))
+ {
+ if (double.TryParse(request.Model.pt, out var maxPrice))
+ maxPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, request.Currency);
}
- var searchInProductTags = searchInDescriptions;
+ searchInDescriptions = request.Model.sid;
+ if (request.Model.asv)
+ vendorId = request.Model.vid;
+ }
- IList<string> alreadyFilteredSpecOptionIds = await request.Model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
- (_httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
+ var searchInProductTags = searchInDescriptions;
- //products
- var searchproducts = (await _mediator.Send(new GetSearchProductsQuery() {
- LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
- CategoryIds = categoryIds,
- CollectionId = collectionId,
- Customer = request.Customer,
- StoreId = request.Store.Id,
- VisibleIndividuallyOnly = true,
- PriceMin = minPriceConverted,
- PriceMax = maxPriceConverted,
- Keywords = searchTerms,
- SearchDescriptions = searchInDescriptions,
- SearchSku = searchInDescriptions,
- SearchProductTags = searchInProductTags,
- FilteredSpecs = alreadyFilteredSpecOptionIds,
- LanguageId = request.Language.Id,
- OrderBy = (ProductSortingEnum)request.Command.OrderBy,
- PageIndex = request.Command.PageNumber - 1,
- PageSize = request.Command.PageSize,
- VendorId = vendorId
- }));
+ IList<string> alreadyFilteredSpecOptionIds = await request.Model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
+ (_httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
- request.Model.Products = (await _mediator.Send(new GetProductOverview() {
- Products = searchproducts.products,
- PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
- })).ToList();
+ //products
+ var searchproducts = await _mediator.Send(new GetSearchProductsQuery {
+ LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
+ CategoryIds = categoryIds,
+ CollectionId = collectionId,
+ Customer = request.Customer,
+ StoreId = request.Store.Id,
+ VisibleIndividuallyOnly = true,
+ PriceMin = minPriceConverted,
+ PriceMax = maxPriceConverted,
+ Keywords = searchTerms,
+ SearchDescriptions = searchInDescriptions,
+ SearchSku = searchInDescriptions,
+ SearchProductTags = searchInProductTags,
+ FilteredSpecs = alreadyFilteredSpecOptionIds,
+ LanguageId = request.Language.Id,
+ OrderBy = (ProductSortingEnum)request.Command.OrderBy,
+ PageIndex = request.Command.PageNumber - 1,
+ PageSize = request.Command.PageSize,
+ VendorId = vendorId
+ }, cancellationToken);
- request.Model.PagingFilteringContext.LoadPagedList(searchproducts.products);
+ request.Model.Products = (await _mediator.Send(new GetProductOverview {
+ Products = searchproducts.products,
+ PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
+ }, cancellationToken)).ToList();
- //specs
- await request.Model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
- searchproducts.filterableSpecificationAttributeOptionIds,
- _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
+ request.Model.PagingFilteringContext.LoadPagedList(searchproducts.products);
- request.Model.NoResults = !request.Model.Products.Any();
+ //specs
+ await request.Model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
+ searchproducts.filterableSpecificationAttributeOptionIds,
+ _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
- //search term statistics
- if (!String.IsNullOrEmpty(searchTerms))
- {
- var searchTerm = await _searchTermService.GetSearchTermByKeyword(searchTerms, request.Store.Id);
- if (searchTerm != null)
- {
- searchTerm.Count++;
- await _searchTermService.UpdateSearchTerm(searchTerm);
- }
- else
- {
- searchTerm = new SearchTerm {
- Keyword = searchTerms,
- StoreId = request.Store.Id,
- Count = 1
- };
- await _searchTermService.InsertSearchTerm(searchTerm);
- }
- }
+ request.Model.NoResults = !request.Model.Products.Any();
+
+ //search term statistics
+ if (string.IsNullOrEmpty(searchTerms)) return request.Model;
+
+ var searchTerm = await _searchTermService.GetSearchTermByKeyword(searchTerms, request.Store.Id);
+ if (searchTerm != null)
+ {
+ searchTerm.Count++;
+ await _searchTermService.UpdateSearchTerm(searchTerm);
+ }
+ else
+ {
+ searchTerm = new SearchTerm {
+ Keyword = searchTerms,
+ StoreId = request.Store.Id,
+ Count = 1
+ };
+ await _searchTermService.InsertSearchTerm(searchTerm);
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorAllHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorAllHandler.cs
index 1b0806f70..e4c41aeaa 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorAllHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorAllHandler.cs
@@ -5,9 +5,9 @@ using Grand.Business.Core.Interfaces.Storage;
using Grand.Domain.Media;
using Grand.Domain.Vendors;
using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Common;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
@@ -64,17 +64,15 @@ namespace Grand.Web.Features.Handlers.Catalog
MetaTitle = vendor.GetTranslation(x => x.MetaTitle, request.Language.Id),
SeName = vendor.GetSeName(request.Language.Id),
AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
- UserFields = vendor.UserFields
+ UserFields = vendor.UserFields,
+ //prepare vendor address
+ Address = await _mediator.Send(new GetVendorAddress {
+ Language = request.Language,
+ Address = vendor.Address,
+ ExcludeProperties = false
+ })
};
- //prepare vendor address
- vendorModel.Address = await _mediator.Send(new GetVendorAddress()
- {
- Language = request.Language,
- Address = vendor.Address,
- ExcludeProperties = false,
- });
-
//prepare picture model
var pictureModel = new PictureModel
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
index 817f263f9..4733c5915 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorHandler.cs
@@ -1,11 +1,11 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Queries.Catalog;
using Grand.Domain.Catalog;
using Grand.Domain.Media;
using Grand.Domain.Vendors;
-using Grand.Infrastructure.Caching;
using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Common;
@@ -15,7 +15,6 @@ using Grand.Web.Models.Media;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
-using Grand.Business.Core.Queries.Catalog;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -26,8 +25,6 @@ namespace Grand.Web.Features.Handlers.Catalog
private readonly ITranslationService _translationService;
private readonly ISpecificationAttributeService _specificationAttributeService;
private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly ICacheBase _cacheBase;
-
private readonly VendorSettings _vendorSettings;
private readonly MediaSettings _mediaSettings;
private readonly CatalogSettings _catalogSettings;
@@ -41,7 +38,6 @@ namespace Grand.Web.Features.Handlers.Catalog
MediaSettings mediaSettings,
ISpecificationAttributeService specificationAttributeService,
IHttpContextAccessor httpContextAccessor,
- ICacheBase cacheBase,
CatalogSettings catalogSettings,
CaptchaSettings captchaSettings)
{
@@ -52,7 +48,6 @@ namespace Grand.Web.Features.Handlers.Catalog
_mediaSettings = mediaSettings;
_specificationAttributeService = specificationAttributeService;
_httpContextAccessor = httpContextAccessor;
- _cacheBase = cacheBase;
_catalogSettings = catalogSettings;
_captchaSettings = captchaSettings;
}
@@ -69,15 +64,14 @@ namespace Grand.Web.Features.Handlers.Catalog
SeName = request.Vendor.GetSeName(request.Language.Id),
AllowCustomersToContactVendors = _vendorSettings.AllowCustomersToContactVendors,
RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnVendorReviewPage || _captchaSettings.ShowOnContactUsPage),
- UserFields = request.Vendor.UserFields
+ UserFields = request.Vendor.UserFields,
+ Address = await _mediator.Send(new GetVendorAddress {
+ Language = request.Language,
+ Address = request.Vendor.Address,
+ ExcludeProperties = false
+ }, cancellationToken)
};
- model.Address = await _mediator.Send(new GetVendorAddress() {
- Language = request.Language,
- Address = request.Vendor.Address,
- ExcludeProperties = false,
- });
-
//prepare picture model
var pictureModel = new PictureModel {
Id = request.Vendor.PictureId,
@@ -89,21 +83,21 @@ namespace Grand.Web.Features.Handlers.Catalog
model.PictureModel = pictureModel;
//view/sorting/page size
- var options = await _mediator.Send(new GetViewSortSizeOptions() {
+ var options = await _mediator.Send(new GetViewSortSizeOptions {
Command = request.Command,
PagingFilteringModel = request.Command,
Language = request.Language,
AllowCustomersToSelectPageSize = request.Vendor.AllowCustomersToSelectPageSize,
PageSize = request.Vendor.PageSize,
PageSizeOptions = request.Vendor.PageSizeOptions
- });
+ }, cancellationToken);
model.PagingFilteringContext = options.command;
IList<string> alreadyFilteredSpecOptionIds = await model.PagingFilteringContext.SpecificationFilter.GetAlreadyFilteredSpecOptionIds
- (_httpContextAccessor.HttpContext.Request.Query, _specificationAttributeService);
+ (_httpContextAccessor.HttpContext?.Request.Query, _specificationAttributeService);
//products
- var products = (await _mediator.Send(new GetSearchProductsQuery() {
+ var products = await _mediator.Send(new GetSearchProductsQuery {
LoadFilterableSpecificationAttributeOptionIds = !_catalogSettings.IgnoreFilterableSpecAttributeOption,
Customer = request.Customer,
VendorId = request.Vendor.Id,
@@ -113,19 +107,19 @@ namespace Grand.Web.Features.Handlers.Catalog
OrderBy = (ProductSortingEnum)request.Command.OrderBy,
PageIndex = request.Command.PageNumber - 1,
PageSize = request.Command.PageSize
- }));
+ }, cancellationToken);
- model.Products = (await _mediator.Send(new GetProductOverview() {
+ model.Products = (await _mediator.Send(new GetProductOverview {
Products = products.products,
PrepareSpecificationAttributes = _catalogSettings.ShowSpecAttributeOnCatalogPages
- })).ToList();
+ }, cancellationToken)).ToList();
model.PagingFilteringContext.LoadPagedList(products.products);
//specs
await model.PagingFilteringContext.SpecificationFilter.PrepareSpecsFilters(alreadyFilteredSpecOptionIds,
products.filterableSpecificationAttributeOptionIds,
- _specificationAttributeService, _httpContextAccessor.HttpContext.Request.GetDisplayUrl(), request.Language.Id);
+ _specificationAttributeService, _httpContextAccessor.HttpContext?.Request.GetDisplayUrl(), request.Language.Id);
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorNavigationHandler.cs
index be14e6e3e..dee2415f0 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorNavigationHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetVendorNavigationHandler.cs
@@ -2,8 +2,8 @@
using Grand.Business.Core.Interfaces.Customers;
using Grand.Domain.Vendors;
using Grand.Infrastructure.Caching;
-using Grand.Web.Features.Models.Catalog;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
@@ -24,8 +24,7 @@ namespace Grand.Web.Features.Handlers.Catalog
public async Task<VendorNavigationModel> Handle(GetVendorNavigation request, CancellationToken cancellationToken)
{
- string cacheKey = CacheKeyConst.VENDOR_NAVIGATION_MODEL_KEY;
- var cacheModel = await _cacheBase.GetAsync(cacheKey, async () =>
+ var cacheModel = await _cacheBase.GetAsync(CacheKeyConst.VENDOR_NAVIGATION_MODEL_KEY, async () =>
{
var vendors = await _vendorService.GetAllVendors(pageSize: _vendorSettings.VendorsBlockItemsToDisplay);
var model = new VendorNavigationModel
@@ -39,7 +38,7 @@ namespace Grand.Web.Features.Handlers.Catalog
{
Id = vendor.Id,
Name = vendor.GetTranslation(x => x.Name, request.Language.Id),
- SeName = vendor.GetSeName(request.Language.Id),
+ SeName = vendor.GetSeName(request.Language.Id)
});
}
return model;
diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs
index cda971f17..64e78be26 100644
--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs
@@ -1,13 +1,13 @@
-using Grand.Domain.Catalog;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Catalog;
+using Grand.Infrastructure.Extensions;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Models.Catalog;
using MediatR;
-using Microsoft.AspNetCore.Mvc.Rendering;
-using Grand.Business.Core.Extensions;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
-using Grand.Infrastructure.Extensions;
+using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Features.Handlers.Catalog
{
@@ -46,28 +46,22 @@ namespace Grand.Web.Features.Handlers.Catalog
var activeOptions = Enum.GetValues(typeof(ProductSortingEnum)).Cast<int>()
.Except(_catalogSettings.ProductSortingEnumDisabled)
- .Select((idOption) =>
- {
- return new KeyValuePair<int, int>(idOption, _catalogSettings.ProductSortingEnumDisplayOrder.TryGetValue(idOption, out var order) ? order : idOption);
- })
+ .Select(idOption => new KeyValuePair<int, int>(idOption, _catalogSettings.ProductSortingEnumDisplayOrder.TryGetValue(idOption, out var order) ? order : idOption))
.OrderBy(x => x.Value);
- if (request.Command.OrderBy == null)
- request.Command.OrderBy = allDisabled ? 0 : activeOptions.First().Key;
+ request.Command.OrderBy ??= allDisabled ? 0 : activeOptions.First().Key;
- if (request.PagingFilteringModel.AllowProductSorting)
+ if (!request.PagingFilteringModel.AllowProductSorting) return;
+ foreach (var option in activeOptions)
{
- foreach (var option in activeOptions)
- {
- var currentPageUrl = _httpContextAccessor.HttpContext.Request.GetDisplayUrl();
- var sortUrl = CommonExtensions.ModifyQueryString(currentPageUrl, "orderby", (option.Key).ToString());
-
- var sortValue = ((ProductSortingEnum)option.Key).GetTranslationEnum(_translationService, request.Language.Id);
- request.PagingFilteringModel.AvailableSortOptions.Add(new SelectListItem {
- Text = sortValue,
- Value = sortUrl,
- Selected = option.Key == request.Command.OrderBy
- });
- }
+ var currentPageUrl = _httpContextAccessor.HttpContext?.Request.GetDisplayUrl();
+ var sortUrl = CommonExtensions.ModifyQueryString(currentPageUrl, "orderby", option.Key.ToString());
+
+ var sortValue = ((ProductSortingEnum)option.Key).GetTranslationEnum(_translationService, request.Language.Id);
+ request.PagingFilteringModel.AvailableSortOptions.Add(new SelectListItem {
+ Text = sortValue,
+ Value = sortUrl,
+ Selected = option.Key == request.Command.OrderBy
+ });
}
}
private void PrepareViewModes(GetViewSortSizeOptions request)
@@ -79,22 +73,21 @@ namespace Grand.Web.Features.Handlers.Catalog
? request.Command.ViewMode
: _catalogSettings.DefaultViewMode;
request.PagingFilteringModel.ViewMode = viewMode;
- if (request.PagingFilteringModel.AllowProductViewModeChanging)
- {
- var currentPageUrl = _httpContextAccessor.HttpContext.Request.GetDisplayUrl();
- //grid
- request.PagingFilteringModel.AvailableViewModes.Add(new SelectListItem {
- Text = _translationService.GetResource("Catalog.ViewMode.Grid"),
- Value = CommonExtensions.ModifyQueryString(currentPageUrl, "viewmode", "grid"),
- Selected = viewMode == "grid"
- });
- //list
- request.PagingFilteringModel.AvailableViewModes.Add(new SelectListItem {
- Text = _translationService.GetResource("Catalog.ViewMode.List"),
- Value = CommonExtensions.ModifyQueryString(currentPageUrl, "viewmode", "list"),
- Selected = viewMode == "list"
- });
- }
+ if (!request.PagingFilteringModel.AllowProductViewModeChanging) return;
+
+ var currentPageUrl = _httpContextAccessor.HttpContext?.Request.GetDisplayUrl();
+ //grid
+ request.PagingFilteringModel.AvailableViewModes.Add(new SelectListItem {
+ Text = _translationService.GetResource("Catalog.ViewMode.Grid"),
+ Value = CommonExtensions.ModifyQueryString(currentPageUrl, "viewmode", "grid"),
+ Selected = viewMode == "grid"
+ });
+ //list
+ request.PagingFilteringModel.AvailableViewModes.Add(new SelectListItem {
+ Text = _translationService.GetResource("Catalog.ViewMode.List"),
+ Value = CommonExtensions.ModifyQueryString(currentPageUrl, "viewmode", "list"),
+ Selected = viewMode == "list"
+ });
}
private void PreparePageSizeOptions(GetViewSortSizeOptions request)
{
@@ -112,8 +105,7 @@ namespace Grand.Web.Features.Handlers.Catalog
// get the first page size entry to use as the default (category page load) or if customer enters invalid value via query string
if (request.Command.PageSize <= 0 || !pageSizes.Contains(request.Command.PageSize.ToString()))
{
- int temp;
- if (int.TryParse(pageSizes.FirstOrDefault(), out temp))
+ if (int.TryParse(pageSizes.FirstOrDefault(), out var temp))
{
if (temp > 0)
{
@@ -122,12 +114,11 @@ namespace Grand.Web.Features.Handlers.Catalog
}
}
- var currentPageUrl = _httpContextAccessor.HttpContext.Request.GetDisplayUrl();
+ var currentPageUrl = _httpContextAccessor.HttpContext?.Request.GetDisplayUrl();
var pageUrl = CommonExtensions.ModifyQueryString(currentPageUrl, "pagenumber", null);
foreach (var pageSize in pageSizes)
{
- int temp;
- if (!int.TryParse(pageSize, out temp))
+ if (!int.TryParse(pageSize, out var temp))
{
continue;
}
@@ -150,7 +141,7 @@ namespace Grand.Web.Features.Handlers.Catalog
if (request.Command.PageSize <= 0)
{
- request.Command.PageSize = int.Parse(request.PagingFilteringModel.PageSizeOptions.FirstOrDefault().Text);
+ request.Command.PageSize = int.Parse(request.PagingFilteringModel.PageSizeOptions.FirstOrDefault()!.Text);
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetBillingAddressHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetBillingAddressHandler.cs
index 77adee71d..9d7204454 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetBillingAddressHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetBillingAddressHandler.cs
@@ -32,7 +32,7 @@ namespace Grand.Web.Features.Handlers.Checkout
var model = new CheckoutBillingAddressModel();
//existing addresses
var addresses = new List<Address>();
- foreach (var item in request.Customer.Addresses.Where(x => x.AddressType == AddressType.Any || x.AddressType == AddressType.Billing))
+ foreach (var item in request.Customer.Addresses.Where(x => x.AddressType is AddressType.Any or AddressType.Billing))
{
if (string.IsNullOrEmpty(item.CountryId))
{
@@ -43,19 +43,18 @@ namespace Grand.Web.Features.Handlers.Checkout
if (country == null || (country.AllowsBilling && _aclService.Authorize(country, request.Store.Id)))
{
addresses.Add(item);
- continue;
}
}
foreach (var address in addresses)
{
- var addressModel = await _mediator.Send(new GetAddressModel() {
+ var addressModel = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Model = null,
Address = address,
- ExcludeProperties = false,
- });
+ ExcludeProperties = false
+ }, cancellationToken);
model.ExistingAddresses.Add(addressModel);
}
@@ -63,7 +62,7 @@ namespace Grand.Web.Features.Handlers.Checkout
model.BillingNewAddress.CountryId = request.SelectedCountryId;
var countries = await _countryService.GetAllCountriesForBilling(request.Language.Id, request.Store.Id);
- model.BillingNewAddress = await _mediator.Send(new GetAddressModel() {
+ model.BillingNewAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Model = model.BillingNewAddress,
@@ -73,7 +72,7 @@ namespace Grand.Web.Features.Handlers.Checkout
LoadCountries = () => countries,
Customer = request.Customer,
OverrideAttributes = request.OverrideAttributes
- });
+ }, cancellationToken);
model.BillingNewAddress.HideAddressType = true;
model.BillingNewAddress.AddressTypeId = _addressSettings.AddressTypeEnabled ? (int)AddressType.Billing : (int)AddressType.Any;
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetConfirmOrderHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetConfirmOrderHandler.cs
index c4c29a238..70b2b8dff 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetConfirmOrderHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetConfirmOrderHandler.cs
@@ -48,7 +48,7 @@ namespace Grand.Web.Features.Handlers.Checkout
TermsOfServiceOnOrderConfirmPage = _orderSettings.TermsOfServiceOnOrderConfirmPage
};
//min order amount validation
- var minOrderTotalAmountOk = await _mediator.Send(new ValidateShoppingCartTotalAmountCommand() { Customer = request.Customer, Cart = request.Cart }, cancellationToken);
+ var minOrderTotalAmountOk = await _mediator.Send(new ValidateShoppingCartTotalAmountCommand { Customer = request.Customer, Cart = request.Cart }, cancellationToken);
if (!minOrderTotalAmountOk)
{
model.MinOrderTotalWarning = string.Format(_translationService.GetResource("Checkout.MinMaxOrderTotalAmount"));
@@ -64,10 +64,10 @@ namespace Grand.Web.Features.Handlers.Checkout
//billing info
var billingAddress = request.Customer.BillingAddress;
if (billingAddress != null)
- model.OrderReviewData.BillingAddress = await _mediator.Send(new GetAddressModel() {
+ model.OrderReviewData.BillingAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Address = billingAddress,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
//shipping info
if (request.Cart.RequiresShipping())
@@ -82,15 +82,15 @@ namespace Grand.Web.Features.Handlers.Checkout
{
var shippingAddress = request.Customer.ShippingAddress;
if (shippingAddress != null)
- model.OrderReviewData.ShippingAddress = await _mediator.Send(new GetAddressModel() {
+ model.OrderReviewData.ShippingAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Address = shippingAddress,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
}
else
{
- var pickup = await _mediator.Send(new GetPickupPointById() { Id = pickupPoint });
+ var pickup = await _mediator.Send(new GetPickupPointById { Id = pickupPoint });
if (pickup != null)
{
var country = await _countryService.GetCountryById(pickup.Address.CountryId);
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetIsPaymentWorkflowRequiredHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetIsPaymentWorkflowRequiredHandler.cs
index 38e1e6d90..d1d75df2b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetIsPaymentWorkflowRequiredHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetIsPaymentWorkflowRequiredHandler.cs
@@ -17,10 +17,10 @@ namespace Grand.Web.Features.Handlers.Checkout
}
public async Task<bool> Handle(GetIsPaymentWorkflowRequired request, CancellationToken cancellationToken)
{
- bool result = true;
+ var result = true;
//check whether order total equals zero
- double? shoppingCartTotalBase = (await _orderTotalCalculationService.GetShoppingCartTotal(request.Cart, useLoyaltyPoints: request.UseLoyaltyPoints)).shoppingCartTotal;
- if (shoppingCartTotalBase.HasValue && shoppingCartTotalBase.Value == 0 && !_paymentSettings.ShowPaymentIfCartIsZero)
+ var shoppingCartTotalBase = (await _orderTotalCalculationService.GetShoppingCartTotal(request.Cart, useLoyaltyPoints: request.UseLoyaltyPoints)).shoppingCartTotal;
+ if (shoppingCartTotalBase is 0 && !_paymentSettings.ShowPaymentIfCartIsZero)
result = false;
return result;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
index d9b94c59f..be54e7034 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentInfoHandler.cs
@@ -21,7 +21,7 @@ namespace Grand.Web.Features.Handlers.Checkout
{
var url = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, routeName: await request.PaymentMethod.GetControllerRouteName(), values: null);
var model = new CheckoutPaymentInfoModel {
- PaymentUrl = url,
+ PaymentUrl = url
};
return await Task.FromResult(model);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentMethodHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentMethodHandler.cs
index 8fc2cfd43..f1ea56805 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentMethodHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetPaymentMethodHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Enums.Checkout;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Enums.Checkout;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Payments;
using Grand.Business.Core.Interfaces.Common.Directory;
@@ -52,8 +52,8 @@ namespace Grand.Web.Features.Handlers.Checkout
//loyalty points
if (_loyaltyPointsSettings.Enabled)
{
- int loyaltyPointsBalance = await _loyaltyPointsService.GetLoyaltyPointsBalance(request.Customer.Id, request.Store.Id);
- double loyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(loyaltyPointsBalance), request.Currency);
+ var loyaltyPointsBalance = await _loyaltyPointsService.GetLoyaltyPointsBalance(request.Customer.Id, request.Store.Id);
+ var loyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(loyaltyPointsBalance), request.Currency);
if (loyaltyPointsAmount > 0 &&
_orderTotalCalculationService.CheckMinimumLoyaltyPointsToUseRequirement(loyaltyPointsBalance))
{
@@ -61,14 +61,14 @@ namespace Grand.Web.Features.Handlers.Checkout
model.LoyaltyPointsAmount = _priceFormatter.FormatPrice(loyaltyPointsAmount, false);
model.LoyaltyPointsBalance = loyaltyPointsBalance;
var shoppingCartTotalBase = (await _orderTotalCalculationService.GetShoppingCartTotal(request.Cart, useLoyaltyPoints: true)).shoppingCartTotal;
- model.LoyaltyPointsEnoughToPayForOrder = (shoppingCartTotalBase.HasValue && shoppingCartTotalBase.Value == 0);
+ model.LoyaltyPointsEnoughToPayForOrder = shoppingCartTotalBase is 0;
}
}
//filter by country
var paymentMethods = (await _paymentService
.LoadActivePaymentMethods(request.Customer, request.Store.Id, request.FilterByCountryId))
- .Where(pm => pm.PaymentMethodType == PaymentMethodType.Standard || pm.PaymentMethodType == PaymentMethodType.Redirection).ToList();
+ .Where(pm => pm.PaymentMethodType is PaymentMethodType.Standard or PaymentMethodType.Redirection).ToList();
var availablepaymentMethods = new List<IPaymentProvider>();
foreach (var pm in paymentMethods)
{
@@ -86,8 +86,8 @@ namespace Grand.Web.Features.Handlers.Checkout
LogoUrl = pm.LogoURL
};
//payment method additional fee
- double paymentMethodAdditionalFee = await _paymentService.GetAdditionalHandlingFee(request.Cart, pm.SystemName);
- double rate = (await _taxService.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, request.Customer)).paymentPrice;
+ var paymentMethodAdditionalFee = await _paymentService.GetAdditionalHandlingFee(request.Cart, pm.SystemName);
+ var rate = (await _taxService.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, request.Customer)).paymentPrice;
if (rate > 0)
pmModel.Fee = _priceFormatter.FormatPaymentMethodAdditionalFee(rate);
@@ -104,7 +104,7 @@ namespace Grand.Web.Features.Handlers.Checkout
paymentMethodToSelect.Selected = true;
}
//if no option has been selected, do it for the first one
- if (model.PaymentMethods.FirstOrDefault(so => so.Selected) == null)
+ if (model.PaymentMethods.FirstOrDefault(so => so.Selected) != null) return model;
{
var paymentMethodToSelect = model.PaymentMethods.FirstOrDefault();
if (paymentMethodToSelect != null)
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingAddressHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingAddressHandler.cs
index ce92b716b..8fe987a14 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingAddressHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingAddressHandler.cs
@@ -55,10 +55,11 @@ namespace Grand.Web.Features.Handlers.Checkout
public async Task<CheckoutShippingAddressModel> Handle(GetShippingAddress request, CancellationToken cancellationToken)
{
- var model = new CheckoutShippingAddressModel();
- model.BillToTheSameAddress = true;
- //allow pickup in store?
- model.AllowPickUpInStore = _shippingSettings.AllowPickUpInStore;
+ var model = new CheckoutShippingAddressModel {
+ BillToTheSameAddress = true,
+ //allow pickup in store?
+ AllowPickUpInStore = _shippingSettings.AllowPickUpInStore
+ };
if (model.AllowPickUpInStore)
{
await PreparePickupPoints(model, request);
@@ -69,7 +70,7 @@ namespace Grand.Web.Features.Handlers.Checkout
//new address
model.ShippingNewAddress.CountryId = request.SelectedCountryId;
var countries = await _countryService.GetAllCountriesForShipping(request.Language.Id, request.Store.Id);
- model.ShippingNewAddress = await _mediator.Send(new GetAddressModel() {
+ model.ShippingNewAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Model = model.ShippingNewAddress,
@@ -78,8 +79,8 @@ namespace Grand.Web.Features.Handlers.Checkout
LoadCountries = () => countries,
PrePopulateWithCustomerFields = request.PrePopulateNewAddressWithCustomerFields,
Customer = request.Customer,
- OverrideAttributes = request.OverrideAttributes,
- });
+ OverrideAttributes = request.OverrideAttributes
+ }, cancellationToken);
model.ShippingNewAddress.HideAddressType = true;
model.ShippingNewAddress.AddressTypeId = _addressSettings.AddressTypeEnabled ? (int)AddressType.Shipping : (int)AddressType.Any;
@@ -94,11 +95,11 @@ namespace Grand.Web.Features.Handlers.Checkout
{
foreach (var pickupPoint in pickupPoints)
{
- var pickupPointModel = new CheckoutPickupPointModel() {
+ var pickupPointModel = new CheckoutPickupPointModel {
Id = pickupPoint.Id,
Name = pickupPoint.Name,
Description = pickupPoint.Description,
- Address = pickupPoint.Address,
+ Address = pickupPoint.Address
};
if (pickupPoint.PickupFee > 0)
{
@@ -126,7 +127,7 @@ namespace Grand.Web.Features.Handlers.Checkout
{
//existing addresses
var addresses = new List<Address>();
- foreach (var item in request.Customer.Addresses.Where(x => x.AddressType == AddressType.Any || x.AddressType == AddressType.Shipping))
+ foreach (var item in request.Customer.Addresses.Where(x => x.AddressType is AddressType.Any or AddressType.Shipping))
{
if (string.IsNullOrEmpty(item.CountryId))
{
@@ -137,17 +138,16 @@ namespace Grand.Web.Features.Handlers.Checkout
if (country == null || (country.AllowsShipping && _aclService.Authorize(country, request.Store.Id)))
{
addresses.Add(item);
- continue;
}
}
foreach (var address in addresses)
{
- var addressModel = await _mediator.Send(new GetAddressModel() {
+ var addressModel = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Model = null,
Address = address,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
model.ExistingAddresses.Add(addressModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingMethodHandler.cs b/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingMethodHandler.cs
index c94b02c3d..6dacc4f8b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingMethodHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Checkout/GetShippingMethodHandler.cs
@@ -57,14 +57,14 @@ namespace Grand.Web.Features.Handlers.Checkout
Name = shippingOption.Name,
Description = shippingOption.Description,
ShippingRateProviderSystemName = shippingOption.ShippingRateProviderSystemName,
- ShippingOption = shippingOption,
+ ShippingOption = shippingOption
};
//adjust rate
var shippingTotal = (await _orderTotalCalculationService.AdjustShippingRate(
shippingOption.Rate, request.Cart)).shippingRate;
- double rateBase = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
+ var rateBase = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
soModel.Fee = _priceFormatter.FormatShippingPrice(rateBase);
model.ShippingMethods.Add(soModel);
@@ -76,9 +76,9 @@ namespace Grand.Web.Features.Handlers.Checkout
{
var shippingOptionToSelect = model.ShippingMethods.ToList()
.Find(so =>
- !String.IsNullOrEmpty(so.Name) &&
+ !string.IsNullOrEmpty(so.Name) &&
so.Name.Equals(selectedShippingOption.Name, StringComparison.OrdinalIgnoreCase) &&
- !String.IsNullOrEmpty(so.ShippingRateProviderSystemName) &&
+ !string.IsNullOrEmpty(so.ShippingRateProviderSystemName) &&
so.ShippingRateProviderSystemName.Equals(selectedShippingOption.ShippingRateProviderSystemName, StringComparison.OrdinalIgnoreCase));
if (shippingOptionToSelect != null)
{
@@ -86,7 +86,7 @@ namespace Grand.Web.Features.Handlers.Checkout
}
}
//if no option has been selected, do it for the first one
- if (model.ShippingMethods.FirstOrDefault(so => so.Selected) == null)
+ if (model.ShippingMethods.FirstOrDefault(so => so.Selected) != null) return model;
{
var shippingOptionToSelect = model.ShippingMethods.FirstOrDefault();
if (shippingOptionToSelect != null)
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
index c07c5a4c0..6a9f083b7 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetAddressModelHandler.cs
@@ -78,15 +78,15 @@ namespace Grand.Web.Features.Handlers.Common
model.VatNumber = address.VatNumber;
model.CountryId = address.CountryId;
Country country = null;
- if (!String.IsNullOrEmpty(address.CountryId))
+ if (!string.IsNullOrEmpty(address.CountryId))
country = await _countryService.GetCountryById(address.CountryId);
- model.CountryName = country != null ? country.GetTranslation(x => x.Name, language.Id) : null;
+ model.CountryName = country?.GetTranslation(x => x.Name, language?.Id);
model.StateProvinceId = address.StateProvinceId;
StateProvince state = null;
- if (!String.IsNullOrEmpty(address.StateProvinceId) && country != null)
+ if (!string.IsNullOrEmpty(address.StateProvinceId) && country != null)
state = country.StateProvinces.FirstOrDefault(x => x.Id == address.StateProvinceId);
- model.StateProvinceName = state != null ? state.GetTranslation(x => x.Name, language.Id) : null;
+ model.StateProvinceName = state?.GetTranslation(x => x.Name, language?.Id);
model.City = address.City;
model.Address1 = address.Address1;
@@ -126,8 +126,8 @@ namespace Grand.Web.Features.Handlers.Common
{
model.AvailableCountries.Add(new SelectListItem {
Text = c.GetTranslation(x => x.Name, language.Id),
- Value = c.Id.ToString(),
- Selected = !string.IsNullOrEmpty(model.CountryId) ? c.Id == model.CountryId : (c.Id == store.DefaultCountryId)
+ Value = c.Id,
+ Selected = !string.IsNullOrEmpty(model.CountryId) ? c.Id == model.CountryId : c.Id == store.DefaultCountryId
});
}
@@ -142,8 +142,8 @@ namespace Grand.Web.Features.Handlers.Common
{
model.AvailableStates.Add(new SelectListItem {
Text = s.GetTranslation(x => x.Name, language.Id),
- Value = s.Id.ToString(),
- Selected = (s.Id == model.StateProvinceId)
+ Value = s.Id,
+ Selected = s.Id == model.StateProvinceId
});
}
}
@@ -188,7 +188,7 @@ namespace Grand.Web.Features.Handlers.Common
Id = attribute.Id,
Name = attribute.GetTranslation(x => x.Name, language.Id),
IsRequired = attribute.IsRequired,
- AttributeControlType = attribute.AttributeControlType,
+ AttributeControlType = attribute.AttributeControlType
};
if (attribute.ShouldHaveValues())
@@ -207,7 +207,7 @@ namespace Grand.Web.Features.Handlers.Common
}
//set already selected attributes
- var selectedAddressAttributes = overrideAttributes ?? (address?.Attributes);
+ var selectedAddressAttributes = overrideAttributes ?? address?.Attributes;
switch (attribute.AttributeControlType)
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs
index ea60ec4f3..7f274f265 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetParseCustomAddressAttributesHandler.cs
@@ -48,7 +48,7 @@ namespace Grand.Web.Features.Handlers.Common
{
foreach (var item in cblAttributes.Split(','))
{
- if (!String.IsNullOrEmpty(item))
+ if (!string.IsNullOrEmpty(item))
customAttributes = _addressAttributeParser.AddAddressAttribute(customAttributes,
attribute, item).ToList();
}
@@ -66,7 +66,7 @@ namespace Grand.Web.Features.Handlers.Common
.ToList())
{
customAttributes = _addressAttributeParser.AddAddressAttribute(customAttributes,
- attribute, selectedAttributeId.ToString()).ToList();
+ attribute, selectedAttributeId).ToList();
}
}
break;
@@ -76,7 +76,7 @@ namespace Grand.Web.Features.Handlers.Common
var ctrlAttributes = request.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- var enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customAttributes = _addressAttributeParser.AddAddressAttribute(customAttributes,
attribute, enteredText).ToList();
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetRobotsTextFileHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetRobotsTextFileHandler.cs
index 9a8fc2d01..680b2c830 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetRobotsTextFileHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetRobotsTextFileHandler.cs
@@ -18,10 +18,7 @@ namespace Grand.Web.Features.Handlers.Common
public async Task<string> Handle(GetRobotsTextFile request, CancellationToken cancellationToken)
{
var robotsTxt = await _robotsTxtService.GetRobotsTxt(request.StoreId);
- if (robotsTxt != null)
- return robotsTxt.Text;
-
- return "";
+ return robotsTxt != null ? robotsTxt.Text : "";
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs
index c68b9c73d..264e1bab1 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetSitemapHandler.cs
@@ -1,23 +1,23 @@
-using Grand.Business.Core.Interfaces.Catalog.Categories;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
+using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
-using Grand.Infrastructure.Caching;
using Grand.Domain.Blogs;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Knowledgebase;
using Grand.Domain.News;
+using Grand.Infrastructure.Caching;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Common;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Blogs;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Common;
using Grand.Web.Models.Knowledgebase;
using Grand.Web.Models.Pages;
using MediatR;
-using Grand.Business.Core.Interfaces.Catalog.Brands;
namespace Grand.Web.Features.Handlers.Common
{
@@ -64,7 +64,7 @@ namespace Grand.Web.Features.Handlers.Common
public async Task<SitemapModel> Handle(GetSitemap request, CancellationToken cancellationToken)
{
- string cacheKey = string.Format(CacheKeyConst.SITEMAP_PAGE_MODEL_KEY,
+ var cacheKey = string.Format(CacheKeyConst.SITEMAP_PAGE_MODEL_KEY,
request.Language.Id,
string.Join(",", request.Customer.GetCustomerGroupIds()),
request.Store.Id);
@@ -102,7 +102,7 @@ namespace Grand.Web.Features.Handlers.Common
Name = product.GetTranslation(x => x.Name, request.Language.Id),
ShortDescription = product.GetTranslation(x => x.ShortDescription, request.Language.Id),
FullDescription = product.GetTranslation(x => x.FullDescription, request.Language.Id),
- SeName = product.GetSeName(request.Language.Id),
+ SeName = product.GetSeName(request.Language.Id)
}).ToList();
}
@@ -117,7 +117,7 @@ namespace Grand.Web.Features.Handlers.Common
SystemName = page.GetTranslation(x => x.SystemName, request.Language.Id),
IncludeInSitemap = page.IncludeInSitemap,
IsPasswordProtected = page.IsPasswordProtected,
- Title = page.GetTranslation(x => x.Title, request.Language.Id),
+ Title = page.GetTranslation(x => x.Title, request.Language.Id)
}).ToList();
//blog posts
@@ -127,10 +127,10 @@ namespace Grand.Web.Features.Handlers.Common
{
Id = blogpost.Id,
SeName = blogpost.GetSeName(request.Language.Id),
- Title = blogpost.GetTranslation(x => x.Title, request.Language.Id),
+ Title = blogpost.GetTranslation(x => x.Title, request.Language.Id)
}).ToList();
- //knowledgebase
+ //knowledge base
var knowledgebasearticles = (await _knowledgebaseService.GetPublicKnowledgebaseArticles()).ToList();
model.KnowledgebaseArticles = knowledgebasearticles.Select(knowledgebasearticle => new KnowledgebaseItemModel
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetStatesProvinceHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetStatesProvinceHandler.cs
index 2f25f58ac..4284e4679 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetStatesProvinceHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetStatesProvinceHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Infrastructure;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Web.Models.Common;
+using Grand.Infrastructure;
using Grand.Web.Features.Models.Common;
+using Grand.Web.Models.Common;
using MediatR;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Common
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Common/GetVendorAddressHandler.cs b/src/Web/Grand.Web/Features/Handlers/Common/GetVendorAddressHandler.cs
index 1cd3b359d..5b72ce892 100644
--- a/src/Web/Grand.Web/Features/Handlers/Common/GetVendorAddressHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Common/GetVendorAddressHandler.cs
@@ -38,15 +38,15 @@ namespace Grand.Web.Features.Handlers.Common
model.Company = request.Address.Company;
model.CountryId = request.Address.CountryId;
Country country = null;
- if (!String.IsNullOrEmpty(request.Address.CountryId))
+ if (!string.IsNullOrEmpty(request.Address.CountryId))
country = await _countryService.GetCountryById(request.Address.CountryId);
- model.CountryName = country != null ? country.GetTranslation(x => x.Name, request.Language.Id) : null;
+ model.CountryName = country?.GetTranslation(x => x.Name, request.Language.Id);
model.StateProvinceId = request.Address.StateProvinceId;
StateProvince state = null;
- if (!String.IsNullOrEmpty(request.Address.StateProvinceId) && country != null)
+ if (!string.IsNullOrEmpty(request.Address.StateProvinceId) && country != null)
state = country.StateProvinces.FirstOrDefault(x => x.Id == request.Address.StateProvinceId);
- model.StateProvinceName = state != null ? state.GetTranslation(x => x.Name, request.Language.Id) : null;
+ model.StateProvinceName = state?.GetTranslation(x => x.Name, request.Language.Id);
model.City = request.Address.City;
model.Address1 = request.Address.Address1;
@@ -83,7 +83,7 @@ namespace Grand.Web.Features.Handlers.Common
{
model.AvailableCountries.Add(new SelectListItem {
Text = c.GetTranslation(x => x.Name, request.Language.Id),
- Value = c.Id.ToString(),
+ Value = c.Id,
Selected = c.Id == model.CountryId
});
}
@@ -91,15 +91,15 @@ namespace Grand.Web.Features.Handlers.Common
if (_vendorSettings.StateProvinceEnabled)
{
var states = await _countryService
- .GetStateProvincesByCountryId(!String.IsNullOrEmpty(model.CountryId) ? model.CountryId : "", request.Language.Id);
+ .GetStateProvincesByCountryId(!string.IsNullOrEmpty(model.CountryId) ? model.CountryId : "", request.Language.Id);
model.AvailableStates.Add(new SelectListItem { Text = _translationService.GetResource("Address.SelectState"), Value = "" });
foreach (var s in states)
{
model.AvailableStates.Add(new SelectListItem {
Text = s.GetTranslation(x => x.Name, request.Language.Id),
- Value = s.Id.ToString(),
- Selected = (s.Id == model.StateProvinceId)
+ Value = s.Id,
+ Selected = s.Id == model.StateProvinceId
});
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Courses/GetCheckOrderHandler.cs b/src/Web/Grand.Web/Features/Handlers/Courses/GetCheckOrderHandler.cs
index 426ba607f..4ff81a935 100644
--- a/src/Web/Grand.Web/Features/Handlers/Courses/GetCheckOrderHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Courses/GetCheckOrderHandler.cs
@@ -1,4 +1,5 @@
using Grand.Business.Core.Interfaces.Checkout.Orders;
+using Grand.Domain.Payments;
using Grand.Web.Features.Models.Courses;
using MediatR;
@@ -18,11 +19,8 @@ namespace Grand.Web.Features.Handlers.Courses
if (string.IsNullOrEmpty(request.Course.ProductId))
return true;
- var orders = await _orderService.SearchOrders(customerId: request.Customer.Id, productId: request.Course.ProductId, ps: Domain.Payments.PaymentStatus.Paid);
- if (orders.TotalCount > 0)
- return true;
-
- return false;
+ var orders = await _orderService.SearchOrders(customerId: request.Customer.Id, productId: request.Course.ProductId, ps: PaymentStatus.Paid);
+ return orders.TotalCount > 0;
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Courses/GetCourseHandler.cs b/src/Web/Grand.Web/Features/Handlers/Courses/GetCourseHandler.cs
index 0dc4c3375..aba46c85c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Courses/GetCourseHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Courses/GetCourseHandler.cs
@@ -1,10 +1,11 @@
-using Grand.Domain.Media;
-using Grand.Business.Core.Interfaces.Marketing.Courses;
+using Grand.Business.Core.Interfaces.Marketing.Courses;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Domain.Media;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Courses;
using Grand.Web.Models.Course;
using MediatR;
+
namespace Grand.Web.Features.Handlers.Courses
{
public class GetCourseHandler : IRequestHandler<GetCourse, CourseModel>
@@ -42,7 +43,7 @@ namespace Grand.Web.Features.Handlers.Courses
var subjects = await _courseSubjectService.GetByCourseId(request.Course.Id);
foreach (var item in subjects)
{
- model.Subjects.Add(new CourseModel.Subject() {
+ model.Subjects.Add(new CourseModel.Subject {
Id = item.Id,
Name = item.Name,
DisplayOrder = item.DisplayOrder
@@ -54,7 +55,7 @@ namespace Grand.Web.Features.Handlers.Courses
var pictureUrl = await _pictureService.GetPictureUrl(item.PictureId, _mediaSettings.LessonThumbPictureSize);
var approved = await _courseActionService.CustomerLessonCompleted(request.Customer.Id, item.Id);
- model.Lessons.Add(new CourseModel.Lesson() {
+ model.Lessons.Add(new CourseModel.Lesson {
Id = item.Id,
SubjectId = item.SubjectId,
Name = item.Name,
@@ -64,7 +65,7 @@ namespace Grand.Web.Features.Handlers.Courses
Approved = approved
});
}
- model.Approved = !model.Lessons.Any(x => !x.Approved);
+ model.Approved = model.Lessons.All(x => x.Approved);
return model;
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetAddressListHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetAddressListHandler.cs
index 050694ac6..a2cff08a0 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetAddressListHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetAddressListHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Domain.Common;
-using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Security;
+using Grand.Domain.Common;
using Grand.Web.Features.Models.Common;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using MediatR;
-using Grand.Business.Core.Interfaces.Common.Security;
namespace Grand.Web.Features.Handlers.Customers
{
@@ -34,24 +34,23 @@ namespace Grand.Web.Features.Handlers.Customers
continue;
}
var country = await _countryService.GetCountryById(item.CountryId);
- if (country != null || _aclService.Authorize(country, request.Store.Id))
+ if (country == null || _aclService.Authorize(country, request.Store.Id))
{
addresses.Add(item);
- continue;
}
}
foreach (var address in addresses)
{
var countries = await _countryService.GetAllCountries(request.Language.Id, request.Store.Id);
- var addressModel = await _mediator.Send(new GetAddressModel() {
+ var addressModel = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Model = null,
Address = address,
ExcludeProperties = false,
LoadCountries = () => countries
- });
+ }, cancellationToken);
model.Addresses.Add(addressModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetAuctionsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetAuctionsHandler.cs
index 3c3928101..98ecc8c4c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetAuctionsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetAuctionsHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
@@ -38,22 +38,22 @@ namespace Grand.Web.Features.Handlers.Customers
foreach (var item in customerBids)
{
var product = await _productService.GetProductById(item.Key);
- if (product != null)
- {
- var bid = new ProductBidTuple();
- bid.Ended = product.AuctionEnded;
- bid.OrderId = item.Where(x => x.Win && x.CustomerId == request.Customer.Id).FirstOrDefault()?.OrderId;
- var amount = product.HighestBid;
- bid.CurrentBidAmount = _priceFormatter.FormatPrice(amount, primaryCurrency);
- bid.CurrentBidAmountValue = amount;
- bid.HighestBidder = product.HighestBidder == request.Customer.Id;
- bid.EndBidDate = product.AvailableEndDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc) : DateTime.MaxValue;
- bid.ProductName = product.GetTranslation(x => x.Name, request.Language.Id);
- bid.ProductSeName = product.GetSeName(request.Language.Id);
- bid.BidAmountValue = item.Max(x => x.Amount);
- bid.BidAmount = _priceFormatter.FormatPrice(bid.BidAmountValue, primaryCurrency);
- model.ProductBidList.Add(bid);
- }
+ if (product == null) continue;
+
+ var bid = new ProductBidTuple {
+ Ended = product.AuctionEnded,
+ OrderId = item.FirstOrDefault(x => x.Win && x.CustomerId == request.Customer.Id)?.OrderId
+ };
+ var amount = product.HighestBid;
+ bid.CurrentBidAmount = _priceFormatter.FormatPrice(amount, primaryCurrency);
+ bid.CurrentBidAmountValue = amount;
+ bid.HighestBidder = product.HighestBidder == request.Customer.Id;
+ bid.EndBidDate = product.AvailableEndDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc) : DateTime.MaxValue;
+ bid.ProductName = product.GetTranslation(x => x.Name, request.Language.Id);
+ bid.ProductSeName = product.GetSeName(request.Language.Id);
+ bid.BidAmountValue = item.Max(x => x.Amount);
+ bid.BidAmount = _priceFormatter.FormatPrice(bid.BidAmountValue, primaryCurrency);
+ model.ProductBidList.Add(bid);
}
model.CustomerId = request.Customer.Id;
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetCoursesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetCoursesHandler.cs
index 40cd74f0f..d9aa0b144 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetCoursesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetCoursesHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Domain.Courses;
+using Grand.Business.Core.Interfaces.Marketing.Courses;
+using Grand.Domain.Courses;
using Grand.Domain.Customers;
-using Grand.Business.Core.Interfaces.Marketing.Courses;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using MediatR;
@@ -27,19 +27,20 @@ namespace Grand.Web.Features.Handlers.Customers
public async Task<CoursesModel> Handle(GetCourses request, CancellationToken cancellationToken)
{
- var model = new CoursesModel();
- model.CustomerId = request.Customer.Id;
+ var model = new CoursesModel {
+ CustomerId = request.Customer.Id
+ };
var courses = await _courseService.GetByCustomer(request.Customer, request.Store.Id);
foreach (var item in courses)
{
var level = await _courseLevelService.GetById(item.LevelId);
- model.CourseList.Add(new CoursesModel.Course() {
+ model.CourseList.Add(new CoursesModel.Course {
Id = item.Id,
Name = item.Name,
SeName = item.SeName,
ShortDescription = item.ShortDescription,
Level = level?.Name,
- Approved = await IsApprovedCourse(item, request.Customer),
+ Approved = await IsApprovedCourse(item, request.Customer)
});
}
return model;
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs
index 2ab8eb91d..e1808d290 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomAttributesHandler.cs
@@ -31,7 +31,7 @@ namespace Grand.Web.Features.Handlers.Customers
Name = attribute.GetTranslation(x => x.Name, request.Language.Id),
IsRequired = attribute.IsRequired,
IsReadOnly = attribute.IsReadOnly,
- AttributeControlType = attribute.AttributeControlTypeId,
+ AttributeControlType = attribute.AttributeControlTypeId
};
if (attribute.ShouldHaveValues())
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetDocumentsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetDocumentsHandler.cs
index 9b6ead528..f8d0853c1 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetDocumentsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetDocumentsHandler.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Documents;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using MediatR;
+using Document = Grand.Web.Models.Customer.Document;
namespace Grand.Web.Features.Handlers.Customers
{
@@ -41,7 +42,7 @@ namespace Grand.Web.Features.Handlers.Customers
model.PagingContext.LoadPagedList(documents);
foreach (var item in documents.Where(x => x.Published).OrderBy(x => x.DisplayOrder))
{
- var doc = new Grand.Web.Models.Customer.Document
+ var doc = new Document
{
Id = item.Id,
Amount = item.TotalAmount,
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetDownloadableProductsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetDownloadableProductsHandler.cs
index cc76d8456..d5dc46989 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetDownloadableProductsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetDownloadableProductsHandler.cs
@@ -41,33 +41,32 @@ namespace Grand.Web.Features.Handlers.Customers
else
query.OwnerId = request.Customer.Id;
- var orders = await _mediator.Send(query);
+ var orders = await _mediator.Send(query, cancellationToken);
foreach (var order in orders)
{
foreach (var orderitem in order.OrderItems)
{
var product = await _productService.GetProductByIdIncludeArch(orderitem.ProductId);
- if (product != null && product.IsDownload)
- {
- var itemModel = new CustomerDownloadableProductsModel.DownloadableProductsModel {
- OrderItemGuid = orderitem.OrderItemGuid,
- OrderId = order.Id,
- OrderNumber = order.OrderNumber,
- CreatedOn = _dateTimeService.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
- ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
- ProductSeName = product.GetSeName(request.Language.Id),
- ProductAttributes = orderitem.AttributeDescription,
- ProductId = orderitem.ProductId
- };
- model.Items.Add(itemModel);
+ if (product is not { IsDownload: true }) continue;
+
+ var itemModel = new CustomerDownloadableProductsModel.DownloadableProductsModel {
+ OrderItemGuid = orderitem.OrderItemGuid,
+ OrderId = order.Id,
+ OrderNumber = order.OrderNumber,
+ CreatedOn = _dateTimeService.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
+ ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
+ ProductSeName = product.GetSeName(request.Language.Id),
+ ProductAttributes = orderitem.AttributeDescription,
+ ProductId = orderitem.ProductId
+ };
+ model.Items.Add(itemModel);
- if (order.IsDownloadAllowed(orderitem, product))
- itemModel.DownloadId = product.DownloadId;
+ if (order.IsDownloadAllowed(orderitem, product))
+ itemModel.DownloadId = product.DownloadId;
- if (order.IsLicenseDownloadAllowed(orderitem, product))
- itemModel.LicenseId = !string.IsNullOrEmpty(orderitem.LicenseDownloadId) ? orderitem.LicenseDownloadId : "";
- }
+ if (order.IsLicenseDownloadAllowed(orderitem, product))
+ itemModel.LicenseId = !string.IsNullOrEmpty(orderitem.LicenseDownloadId) ? orderitem.LicenseDownloadId : "";
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
index 1c9c7d83d..064054509 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetInfoHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Authentication;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Authentication;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Marketing.Newsletters;
@@ -71,11 +71,11 @@ namespace Grand.Web.Features.Handlers.Customers
await PrepareExternalAuth(model, request);
//custom customer attributes
- var customAttributes = await _mediator.Send(new GetCustomAttributes() {
+ var customAttributes = await _mediator.Send(new GetCustomAttributes {
Customer = request.Customer,
Language = request.Language,
OverrideAttributes = request.OverrideCustomCustomerAttributes
- });
+ }, cancellationToken);
foreach (var attribute in customAttributes)
model.CustomerAttributes.Add(attribute);
@@ -116,14 +116,14 @@ namespace Grand.Web.Features.Handlers.Customers
//if (newsletter == null)
// newsletter = await _newsLetterSubscriptionService.GetNewsLetterSubscriptionByCustomerId(request.Customer.Id);
- model.Newsletter = newsletter != null && newsletter.Active;
+ model.Newsletter = newsletter is { Active: true };
var categories = (await _newsletterCategoryService.GetAllNewsletterCategory()).ToList();
- categories.ForEach(x => model.NewsletterCategories.Add(new NewsletterSimpleCategory() {
+ categories.ForEach(x => model.NewsletterCategories.Add(new NewsletterSimpleCategory {
Id = x.Id,
Description = x.GetTranslation(y => y.Description, request.Language.Id),
Name = x.GetTranslation(y => y.Name, request.Language.Id),
- Selected = newsletter == null ? false : newsletter.Categories.Contains(x.Id),
+ Selected = newsletter != null && newsletter.Categories.Contains(x.Id)
}));
}
@@ -137,7 +137,7 @@ namespace Grand.Web.Features.Handlers.Customers
{
model.AvailableCountries.Add(new SelectListItem {
Text = c.GetTranslation(x => x.Name, request.Language.Id),
- Value = c.Id.ToString(),
+ Value = c.Id,
Selected = c.Id == model.CountryId
});
}
@@ -150,7 +150,7 @@ namespace Grand.Web.Features.Handlers.Customers
foreach (var s in states)
{
- model.AvailableStates.Add(new SelectListItem { Text = s.GetTranslation(x => x.Name, request.Language.Id), Value = s.Id.ToString(), Selected = (s.Id == model.StateProvinceId) });
+ model.AvailableStates.Add(new SelectListItem { Text = s.GetTranslation(x => x.Name, request.Language.Id), Value = s.Id, Selected = s.Id == model.StateProvinceId });
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs
index 5ac029cdd..89f99f4e4 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs
@@ -29,18 +29,19 @@ namespace Grand.Web.Features.Handlers.Customers
public async Task<CustomerNavigationModel> Handle(GetNavigation request, CancellationToken cancellationToken)
{
- var model = new CustomerNavigationModel();
- model.HideLoyaltyPoints = !_loyaltyPointsSettings.Enabled;
- model.HideDeleteAccount = !_customerSettings.AllowUsersToDeleteAccount;
- model.HideMerchandiseReturns = !_orderSettings.MerchandiseReturnsEnabled;
- model.HideDownloadableProducts = _customerSettings.HideDownloadableProductsTab;
- model.HideOutOfStockSubscriptions = _customerSettings.HideOutOfStockSubscriptionsTab;
- model.HideAuctions = _customerSettings.HideAuctionsTab;
- model.HideNotes = _customerSettings.HideNotesTab;
- model.HideDocuments = _customerSettings.HideDocumentsTab;
- model.HideReviews = _customerSettings.HideReviewsTab;
- model.HideCourses = _customerSettings.HideCoursesTab;
- model.HideSubAccounts = _customerSettings.HideSubAccountsTab || !string.IsNullOrEmpty(request.Customer.OwnerId);
+ var model = new CustomerNavigationModel {
+ HideLoyaltyPoints = !_loyaltyPointsSettings.Enabled,
+ HideDeleteAccount = !_customerSettings.AllowUsersToDeleteAccount,
+ HideMerchandiseReturns = !_orderSettings.MerchandiseReturnsEnabled,
+ HideDownloadableProducts = _customerSettings.HideDownloadableProductsTab,
+ HideOutOfStockSubscriptions = _customerSettings.HideOutOfStockSubscriptionsTab,
+ HideAuctions = _customerSettings.HideAuctionsTab,
+ HideNotes = _customerSettings.HideNotesTab,
+ HideDocuments = _customerSettings.HideDocumentsTab,
+ HideReviews = _customerSettings.HideReviewsTab,
+ HideCourses = _customerSettings.HideCoursesTab,
+ HideSubAccounts = _customerSettings.HideSubAccountsTab || !string.IsNullOrEmpty(request.Customer.OwnerId)
+ };
if (_vendorSettings.AllowVendorsToEditInfo && request.Vendor != null)
{
model.ShowVendorInfo = true;
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetNotesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetNotesHandler.cs
index 7e80b2448..eb8cb9e89 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetNotesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetNotesHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Customers;
-using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Customers;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using MediatR;
@@ -20,17 +20,19 @@ namespace Grand.Web.Features.Handlers.Customers
public async Task<CustomerNotesModel> Handle(GetNotes request, CancellationToken cancellationToken)
{
- var model = new CustomerNotesModel();
- model.CustomerId = request.Customer.Id;
+ var model = new CustomerNotesModel {
+ CustomerId = request.Customer.Id
+ };
var notes = await _customerNoteService.GetCustomerNotes(request.Customer.Id, true);
foreach (var item in notes)
{
- var mm = new CustomerNote();
- mm.NoteId = item.Id;
- mm.CreatedOn = _dateTimeService.ConvertToUserTime(item.CreatedOnUtc, DateTimeKind.Utc);
- mm.Note = item.Note;
- mm.Title = item.Title;
- mm.DownloadId = item.DownloadId;
+ var mm = new CustomerNote {
+ NoteId = item.Id,
+ CreatedOn = _dateTimeService.ConvertToUserTime(item.CreatedOnUtc, DateTimeKind.Utc),
+ Note = item.Note,
+ Title = item.Title,
+ DownloadId = item.DownloadId
+ };
model.CustomerNoteList.Add(mm);
}
return model;
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs
index 330ebffa7..f3a6e31a9 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetParseCustomAttributesHandler.cs
@@ -1,6 +1,6 @@
-using Grand.Domain.Catalog;
+using Grand.Business.Core.Interfaces.Customers;
+using Grand.Domain.Catalog;
using Grand.Domain.Common;
-using Grand.Business.Core.Interfaces.Customers;
using Grand.Web.Features.Models.Customers;
using MediatR;
@@ -51,7 +51,7 @@ namespace Grand.Web.Features.Handlers.Customers
{
foreach (var item in cblAttributes.Split(','))
{
- if (!String.IsNullOrEmpty(item))
+ if (!string.IsNullOrEmpty(item))
customAttributes = _customerAttributeParser.AddCustomerAttribute(customAttributes,
attribute, item).ToList();
}
@@ -79,7 +79,7 @@ namespace Grand.Web.Features.Handlers.Customers
var ctrlAttributes = request.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- var enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customAttributes = _customerAttributeParser.AddCustomerAttribute(customAttributes,
attribute, enteredText).ToList();
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetPasswordRecoveryConfirmHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetPasswordRecoveryConfirmHandler.cs
index ed12cdb6b..193b85008 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetPasswordRecoveryConfirmHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetPasswordRecoveryConfirmHandler.cs
@@ -24,18 +24,17 @@ namespace Grand.Web.Features.Handlers.Customers
var model = new PasswordRecoveryConfirmModel();
//validate token
- if (!(request.Customer.IsPasswordRecoveryTokenValid(request.Token)))
+ if (!request.Customer.IsPasswordRecoveryTokenValid(request.Token))
{
model.DisablePasswordChanging = true;
model.Result = _translationService.GetResource("Account.PasswordRecovery.WrongToken");
}
//validate token expiration date
- if (request.Customer.IsPasswordRecoveryLinkExpired(_customerSettings))
- {
- model.DisablePasswordChanging = true;
- model.Result = _translationService.GetResource("Account.PasswordRecovery.LinkExpired");
- }
+ if (!request.Customer.IsPasswordRecoveryLinkExpired(_customerSettings)) return await Task.FromResult(model);
+
+ model.DisablePasswordChanging = true;
+ model.Result = _translationService.GetResource("Account.PasswordRecovery.LinkExpired");
return await Task.FromResult(model);
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetRegisterHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetRegisterHandler.cs
index 36fde111c..98fd3517b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetRegisterHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetRegisterHandler.cs
@@ -2,9 +2,9 @@
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Marketing.Newsletters;
-using Grand.Web.Common.Security.Captcha;
using Grand.Domain.Customers;
using Grand.Domain.Tax;
+using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.Customers;
using Grand.Web.Models.Customer;
using Grand.Web.Models.Newsletter;
@@ -91,7 +91,7 @@ namespace Grand.Web.Features.Handlers.Customers
{
model.AvailableCountries.Add(new SelectListItem {
Text = c.GetTranslation(x => x.Name, request.Language.Id),
- Value = c.Id.ToString(),
+ Value = c.Id,
Selected = c.Id == model.CountryId
});
}
@@ -104,17 +104,17 @@ namespace Grand.Web.Features.Handlers.Customers
foreach (var s in states)
{
- model.AvailableStates.Add(new SelectListItem { Text = s.GetTranslation(x => x.Name, request.Language.Id), Value = s.Id.ToString(), Selected = (s.Id == model.StateProvinceId) });
+ model.AvailableStates.Add(new SelectListItem { Text = s.GetTranslation(x => x.Name, request.Language.Id), Value = s.Id, Selected = s.Id == model.StateProvinceId });
}
}
}
//custom customer attributes
- var customAttributes = await _mediator.Send(new GetCustomAttributes() {
+ var customAttributes = await _mediator.Send(new GetCustomAttributes {
Customer = request.Customer,
Language = request.Language,
OverrideAttributes = request.OverrideCustomCustomerAttributes
- });
+ }, cancellationToken);
foreach (var item in customAttributes.Where(x=>!x.IsReadOnly))
{
model.CustomerAttributes.Add(item);
@@ -124,7 +124,7 @@ namespace Grand.Web.Features.Handlers.Customers
var newsletterCategories = await _newsletterCategoryService.GetNewsletterCategoriesByStore(request.Store.Id);
foreach (var item in newsletterCategories)
{
- model.NewsletterCategories.Add(new NewsletterSimpleCategory() {
+ model.NewsletterCategories.Add(new NewsletterSimpleCategory {
Id = item.Id,
Name = item.GetTranslation(x => x.Name, request.Language.Id),
Description = item.GetTranslation(x => x.Description, request.Language.Id),
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetReviewsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetReviewsHandler.cs
index f93634d5f..cd3a82909 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetReviewsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetReviewsHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Features.Models.Customers;
@@ -29,28 +29,28 @@ namespace Grand.Web.Features.Handlers.Customers
public async Task<CustomerProductReviewsModel> Handle(GetReviews request, CancellationToken cancellationToken)
{
- var reviewsModel = new CustomerProductReviewsModel();
-
- reviewsModel.CustomerId = request.Customer.Id;
- reviewsModel.CustomerInfo = request.Customer != null ? !string.IsNullOrEmpty(request.Customer.Email) ? request.Customer.Email : _translationService.GetResource("Admin.Customers.Guest") : "";
+ var reviewsModel = new CustomerProductReviewsModel {
+ CustomerId = request.Customer.Id,
+ CustomerInfo = request.Customer != null ? !string.IsNullOrEmpty(request.Customer.Email) ? request.Customer.Email : _translationService.GetResource("Admin.Customers.Guest") : ""
+ };
var productReviews = await _productReviewService.GetAllProductReviews(request.Customer.Id);
foreach (var productReview in productReviews)
{
var product = await _productService.GetProductById(productReview.ProductId);
- var reviewModel = new CustomerProductReviewModel();
-
- reviewModel.Id = productReview.Id;
- reviewModel.ProductId = productReview.ProductId;
- reviewModel.ProductName = product.Name;
- reviewModel.ProductSeName = product.GetSeName(request.Language.Id);
- reviewModel.Rating = productReview.Rating;
- reviewModel.CreatedOn = _dateTimeService.ConvertToUserTime(productReview.CreatedOnUtc, DateTimeKind.Utc);
- reviewModel.Signature = productReview.Signature;
- reviewModel.ReviewText = productReview.ReviewText;
- reviewModel.ReplyText = productReview.ReplyText;
- reviewModel.IsApproved = productReview.IsApproved;
+ var reviewModel = new CustomerProductReviewModel {
+ Id = productReview.Id,
+ ProductId = productReview.ProductId,
+ ProductName = product.Name,
+ ProductSeName = product.GetSeName(request.Language.Id),
+ Rating = productReview.Rating,
+ CreatedOn = _dateTimeService.ConvertToUserTime(productReview.CreatedOnUtc, DateTimeKind.Utc),
+ Signature = productReview.Signature,
+ ReviewText = productReview.ReviewText,
+ ReplyText = productReview.ReplyText,
+ IsApproved = productReview.IsApproved
+ };
reviewsModel.Reviews.Add(reviewModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountHandler.cs
index 1274bcabd..6ca612b1a 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountHandler.cs
@@ -25,8 +25,7 @@ namespace Grand.Web.Features.Handlers.Customers
var subaccount = await _customerService.GetCustomerById(customerId: request.CustomerId);
if (subaccount != null && subaccount.OwnerId == request.CurrentCustomer.Id)
{
- model = new SubAccountModel()
- {
+ model = new SubAccountModel {
Id = subaccount.Id,
Email = subaccount.Email,
Active = subaccount.Active,
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountsHandler.cs
index 92002cfe6..0c52adff4 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetSubAccountsHandler.cs
@@ -22,8 +22,7 @@ namespace Grand.Web.Features.Handlers.Customers
var subaccouns = await _customerService.GetAllCustomers(ownerId: request.Customer.Id);
foreach (var item in subaccouns)
{
- model.Add(new SubAccountSimpleModel()
- {
+ model.Add(new SubAccountSimpleModel {
Id = item.Id,
Email = item.Email,
Active = item.Active,
diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetUserAgreementHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetUserAgreementHandler.cs
index d6889fa57..adc5bffa6 100644
--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetUserAgreementHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetUserAgreementHandler.cs
@@ -25,12 +25,13 @@ namespace Grand.Web.Features.Handlers.Customers
return null;
var product = await _productService.GetProductById(orderItem.ProductId);
- if (product == null || !product.HasUserAgreement)
+ if (product is not { HasUserAgreement: true })
return null;
- var model = new UserAgreementModel();
- model.UserAgreementText = product.UserAgreementText;
- model.OrderItemGuid = request.OrderItemId;
+ var model = new UserAgreementModel {
+ UserAgreementText = product.UserAgreementText,
+ OrderItemGuid = request.OrderItemId
+ };
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/News/GetHomePageNewsItemsHandler.cs b/src/Web/Grand.Web/Features/Handlers/News/GetHomePageNewsItemsHandler.cs
index 75cf528c8..0d3be4633 100644
--- a/src/Web/Grand.Web/Features/Handlers/News/GetHomePageNewsItemsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/News/GetHomePageNewsItemsHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
@@ -7,8 +7,8 @@ using Grand.Domain.Media;
using Grand.Domain.News;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
-using Grand.Web.Features.Models.News;
using Grand.Web.Events.Cache;
+using Grand.Web.Features.Models.News;
using Grand.Web.Models.Media;
using Grand.Web.Models.News;
using MediatR;
@@ -61,26 +61,26 @@ namespace Grand.Web.Features.Handlers.News
private async Task<HomePageNewsItemsModel.NewsItemModel> PrepareNewsItemModel(NewsItem newsItem)
{
- var model = new HomePageNewsItemsModel.NewsItemModel();
- model.Id = newsItem.Id;
- model.SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id);
- model.Title = newsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id);
- model.Short = newsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id);
- model.Full = newsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id);
- model.CreatedOn = _dateTimeService.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc);
+ var model = new HomePageNewsItemsModel.NewsItemModel {
+ Id = newsItem.Id,
+ SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id),
+ Title = newsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id),
+ Short = newsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id),
+ Full = newsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id),
+ CreatedOn = _dateTimeService.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc)
+ };
//prepare picture model
- if (!string.IsNullOrEmpty(newsItem.PictureId))
+ if (string.IsNullOrEmpty(newsItem.PictureId)) return model;
+
+ var pictureSize = _mediaSettings.NewsListThumbPictureSize;
+ model.PictureModel = new PictureModel
{
- int pictureSize = _mediaSettings.NewsListThumbPictureSize;
- model.PictureModel = new PictureModel
- {
- Id = newsItem.PictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId),
- ImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId, pictureSize),
- Title = string.Format(_translationService.GetResource("Media.News.ImageLinkTitleFormat"), newsItem.Title),
- AlternateText = string.Format(_translationService.GetResource("Media.News.ImageAlternateTextFormat"), newsItem.Title)
- };
- }
+ Id = newsItem.PictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId, pictureSize),
+ Title = string.Format(_translationService.GetResource("Media.News.ImageLinkTitleFormat"), newsItem.Title),
+ AlternateText = string.Format(_translationService.GetResource("Media.News.ImageAlternateTextFormat"), newsItem.Title)
+ };
return model;
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemHandler.cs b/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemHandler.cs
index fe15bd72d..80a936d1f 100644
--- a/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemHandler.cs
@@ -3,11 +3,11 @@ using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Web.Common.Security.Captcha;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Domain.News;
using Grand.Infrastructure;
+using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.News;
using Grand.Web.Models.Media;
using Grand.Web.Models.News;
@@ -44,19 +44,22 @@ namespace Grand.Web.Features.Handlers.News
public async Task<NewsItemModel> Handle(GetNewsItem request, CancellationToken cancellationToken)
{
- var model = new NewsItemModel();
- model.Id = request.NewsItem.Id;
- model.MetaTitle = request.NewsItem.GetTranslation(x => x.MetaTitle, _workContext.WorkingLanguage.Id);
- model.MetaDescription = request.NewsItem.GetTranslation(x => x.MetaDescription, _workContext.WorkingLanguage.Id);
- model.MetaKeywords = request.NewsItem.GetTranslation(x => x.MetaKeywords, _workContext.WorkingLanguage.Id);
- model.SeName = request.NewsItem.GetSeName(_workContext.WorkingLanguage.Id);
- model.Title = request.NewsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id);
- model.Short = request.NewsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id);
- model.Full = request.NewsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id);
- model.AllowComments = request.NewsItem.AllowComments;
- model.CreatedOn = _dateTimeService.ConvertToUserTime(request.NewsItem.StartDateUtc ?? request.NewsItem.CreatedOnUtc, DateTimeKind.Utc);
- model.NumberOfComments = request.NewsItem.CommentCount;
- model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage;
+ var model = new NewsItemModel {
+ Id = request.NewsItem.Id,
+ MetaTitle = request.NewsItem.GetTranslation(x => x.MetaTitle, _workContext.WorkingLanguage.Id),
+ MetaDescription = request.NewsItem.GetTranslation(x => x.MetaDescription, _workContext.WorkingLanguage.Id),
+ MetaKeywords = request.NewsItem.GetTranslation(x => x.MetaKeywords, _workContext.WorkingLanguage.Id),
+ SeName = request.NewsItem.GetSeName(_workContext.WorkingLanguage.Id),
+ Title = request.NewsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id),
+ Short = request.NewsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id),
+ Full = request.NewsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id),
+ AllowComments = request.NewsItem.AllowComments,
+ CreatedOn = _dateTimeService.ConvertToUserTime(request.NewsItem.StartDateUtc ?? request.NewsItem.CreatedOnUtc, DateTimeKind.Utc),
+ NumberOfComments = request.NewsItem.CommentCount,
+ AddNewComment = {
+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage
+ }
+ };
//prepare comments
await PrepareComments(request.NewsItem, model);
@@ -80,7 +83,7 @@ namespace Grand.Web.Features.Handlers.News
CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat),
CommentTitle = nc.CommentTitle,
CommentText = nc.CommentText,
- CreatedOn = _dateTimeService.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc),
+ CreatedOn = _dateTimeService.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc)
};
model.Comments.Add(commentModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemListHandler.cs b/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemListHandler.cs
index ab1eb3fa6..e4d500f71 100644
--- a/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemListHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/News/GetNewsItemListHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Cms;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Cms;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
@@ -39,8 +39,9 @@ namespace Grand.Web.Features.Handlers.News
public async Task<NewsItemListModel> Handle(GetNewsItemList request, CancellationToken cancellationToken)
{
- var model = new NewsItemListModel();
- model.WorkingLanguageId = _workContext.WorkingLanguage.Id;
+ var model = new NewsItemListModel {
+ WorkingLanguageId = _workContext.WorkingLanguage.Id
+ };
if (request.Command.PageSize <= 0) request.Command.PageSize = _newsSettings.NewsArchivePageSize;
if (request.Command.PageNumber <= 0) request.Command.PageNumber = 1;
@@ -59,26 +60,26 @@ namespace Grand.Web.Features.Handlers.News
private async Task<NewsItemListModel.NewsItemModel> PrepareNewsItemModel(NewsItem newsItem)
{
- var model = new NewsItemListModel.NewsItemModel();
- model.Id = newsItem.Id;
- model.SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id);
- model.Title = newsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id);
- model.Short = newsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id);
- model.Full = newsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id);
- model.CreatedOn = _dateTimeService.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc);
+ var model = new NewsItemListModel.NewsItemModel {
+ Id = newsItem.Id,
+ SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id),
+ Title = newsItem.GetTranslation(x => x.Title, _workContext.WorkingLanguage.Id),
+ Short = newsItem.GetTranslation(x => x.Short, _workContext.WorkingLanguage.Id),
+ Full = newsItem.GetTranslation(x => x.Full, _workContext.WorkingLanguage.Id),
+ CreatedOn = _dateTimeService.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc)
+ };
//prepare picture model
- if (!string.IsNullOrEmpty(newsItem.PictureId))
+ if (string.IsNullOrEmpty(newsItem.PictureId)) return model;
+
+ var pictureSize = _mediaSettings.NewsListThumbPictureSize;
+ model.PictureModel = new PictureModel
{
- var pictureSize = _mediaSettings.NewsListThumbPictureSize;
- model.PictureModel = new PictureModel
- {
- Id = newsItem.PictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId),
- ImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId, pictureSize),
- Title = string.Format(_translationService.GetResource("Media.News.ImageLinkTitleFormat"), newsItem.Title),
- AlternateText = string.Format(_translationService.GetResource("Media.News.ImageAlternateTextFormat"), newsItem.Title)
- };
- }
+ Id = newsItem.PictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(newsItem.PictureId, pictureSize),
+ Title = string.Format(_translationService.GetResource("Media.News.ImageLinkTitleFormat"), newsItem.Title),
+ AlternateText = string.Format(_translationService.GetResource("Media.News.ImageAlternateTextFormat"), newsItem.Title)
+ };
return model;
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerLoyaltyPointsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerLoyaltyPointsHandler.cs
index c44e73165..39b808432 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerLoyaltyPointsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerLoyaltyPointsHandler.cs
@@ -6,7 +6,7 @@ using Grand.Web.Features.Models.Orders;
using Grand.Web.Models.Orders;
using MediatR;
-namespace Grand.Web.Features.Handlers.Newsletter
+namespace Grand.Web.Features.Handlers.Orders
{
public class GetCustomerLoyaltyPointsHandler : IRequestHandler<GetCustomerLoyaltyPoints, CustomerLoyaltyPointsModel>
{
@@ -43,15 +43,15 @@ namespace Grand.Web.Features.Handlers.Newsletter
});
}
//current amount/balance
- int loyaltyPointsBalance = await _loyaltyPointsService.GetLoyaltyPointsBalance(request.Customer.Id, request.Store.Id);
- double loyaltyPointsAmountBase = await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(loyaltyPointsBalance);
- double loyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(loyaltyPointsAmountBase, request.Currency);
+ var loyaltyPointsBalance = await _loyaltyPointsService.GetLoyaltyPointsBalance(request.Customer.Id, request.Store.Id);
+ var loyaltyPointsAmountBase = await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(loyaltyPointsBalance);
+ var loyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(loyaltyPointsAmountBase, request.Currency);
model.LoyaltyPointsBalance = loyaltyPointsBalance;
model.LoyaltyPointsAmount = _priceFormatter.FormatPrice(loyaltyPointsAmount, false);
//minimum amount/balance
- int minimumLoyaltyPointsBalance = _loyaltyPointsSettings.MinimumLoyaltyPointsToUse;
- double minimumLoyaltyPointsAmountBase = await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(minimumLoyaltyPointsBalance);
- double minimumLoyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(minimumLoyaltyPointsAmountBase, request.Currency);
+ var minimumLoyaltyPointsBalance = _loyaltyPointsSettings.MinimumLoyaltyPointsToUse;
+ var minimumLoyaltyPointsAmountBase = await _orderTotalCalculationService.ConvertLoyaltyPointsToAmount(minimumLoyaltyPointsBalance);
+ var minimumLoyaltyPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(minimumLoyaltyPointsAmountBase, request.Currency);
model.MinimumLoyaltyPointsBalance = minimumLoyaltyPointsBalance;
model.MinimumLoyaltyPointsAmount = _priceFormatter.FormatPrice(minimumLoyaltyPointsAmount, false);
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerOrderListHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerOrderListHandler.cs
index a79c3e09b..439138690 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerOrderListHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetCustomerOrderListHandler.cs
@@ -1,9 +1,9 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Queries.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Domain.Orders;
using Grand.Web.Features.Models.Orders;
using Grand.Web.Models.Orders;
@@ -87,9 +87,9 @@ namespace Grand.Web.Features.Handlers.Orders
OrderStatus = status?.Name,
PaymentStatus = order.PaymentStatusId.GetTranslationEnum(_translationService, request.Language.Id),
ShippingStatus = order.ShippingStatusId.GetTranslationEnum(_translationService, request.Language.Id),
- IsMerchandiseReturnAllowed = await _mediator.Send(new IsMerchandiseReturnAllowedQuery() { Order = order })
+ IsMerchandiseReturnAllowed = await _mediator.Send(new IsMerchandiseReturnAllowedQuery { Order = order }),
+ OrderTotal = await _priceFormatter.FormatPrice(order.OrderTotal, order.CustomerCurrencyCode, false, request.Language)
};
- orderModel.OrderTotal = await _priceFormatter.FormatPrice(order.OrderTotal, order.CustomerCurrencyCode, false, request.Language);
model.Orders.Add(orderModel);
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnDetailsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnDetailsHandler.cs
index df08ee398..65754451b 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnDetailsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnDetailsHandler.cs
@@ -1,11 +1,11 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
-using Grand.Infrastructure;
using Grand.Domain.Orders;
using Grand.Domain.Tax;
+using Grand.Infrastructure;
using Grand.Web.Features.Models.Common;
using Grand.Web.Features.Models.Orders;
using Grand.Web.Models.Orders;
@@ -43,39 +43,33 @@ namespace Grand.Web.Features.Handlers.Orders
public async Task<MerchandiseReturnDetailsModel> Handle(GetMerchandiseReturnDetails request, CancellationToken cancellationToken)
{
- var model = new MerchandiseReturnDetailsModel();
- model.Comments = request.MerchandiseReturn.CustomerComments;
- model.ReturnNumber = request.MerchandiseReturn.ReturnNumber;
- model.ExternalId = request.MerchandiseReturn.ExternalId;
- model.MerchandiseReturnStatus = request.MerchandiseReturn.MerchandiseReturnStatus;
- model.CreatedOnUtc = request.MerchandiseReturn.CreatedOnUtc;
- model.ShowPickupAddress = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress;
- model.ShowPickupDate = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate;
- model.PickupDate = request.MerchandiseReturn.PickupDate;
- model.UserFields = request.MerchandiseReturn.UserFields;
- model.PickupAddress = await _mediator.Send(new GetAddressModel()
- {
- Language = request.Language,
- Address = request.MerchandiseReturn.PickupAddress,
- ExcludeProperties = false,
- });
+ var model = new MerchandiseReturnDetailsModel {
+ Comments = request.MerchandiseReturn.CustomerComments,
+ ReturnNumber = request.MerchandiseReturn.ReturnNumber,
+ ExternalId = request.MerchandiseReturn.ExternalId,
+ MerchandiseReturnStatus = request.MerchandiseReturn.MerchandiseReturnStatus,
+ CreatedOnUtc = request.MerchandiseReturn.CreatedOnUtc,
+ ShowPickupAddress = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress,
+ ShowPickupDate = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate,
+ PickupDate = request.MerchandiseReturn.PickupDate,
+ UserFields = request.MerchandiseReturn.UserFields,
+ PickupAddress = await _mediator.Send(new GetAddressModel {
+ Language = request.Language,
+ Address = request.MerchandiseReturn.PickupAddress,
+ ExcludeProperties = false
+ }, cancellationToken)
+ };
foreach (var item in request.MerchandiseReturn.MerchandiseReturnItems)
{
- var orderItem = request.Order.OrderItems.Where(x => x.Id == item.OrderItemId).FirstOrDefault();
+ var orderItem = request.Order.OrderItems.FirstOrDefault(x => x.Id == item.OrderItemId);
var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
- string unitPrice = string.Empty;
- if (request.Order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax)
- {
+ var unitPrice = _priceFormatter.FormatPrice(request.Order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax ?
//including tax
- unitPrice = _priceFormatter.FormatPrice(orderItem.UnitPriceInclTax);
- }
- else
- {
+ orderItem.UnitPriceInclTax :
//excluding tax
- unitPrice = _priceFormatter.FormatPrice(orderItem.UnitPriceExclTax);
- }
+ orderItem.UnitPriceExclTax);
model.MerchandiseReturnItems.Add(new MerchandiseReturnDetailsModel.MerchandiseReturnItemModel
{
@@ -106,7 +100,7 @@ namespace Grand.Web.Features.Handlers.Orders
{
Id = merchandiseReturnNote.Id,
MerchandiseReturnId = merchandiseReturnNote.MerchandiseReturnId,
- HasDownload = !String.IsNullOrEmpty(merchandiseReturnNote.DownloadId),
+ HasDownload = !string.IsNullOrEmpty(merchandiseReturnNote.DownloadId),
Note = merchandiseReturnNote.Note,
CreatedOn = _dateTimeService.ConvertToUserTime(merchandiseReturnNote.CreatedOnUtc, DateTimeKind.Utc)
});
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnHandler.cs
index b17a3f109..065d33ff6 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnHandler.cs
@@ -1,9 +1,8 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Shipping;
-using Grand.Business.Core.Queries.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
@@ -42,7 +41,7 @@ namespace Grand.Web.Features.Handlers.Orders
IVendorService vendorService,
IMediator mediator,
OrderSettings orderSettings
- )
+ )
{
_workContext = workContext;
_merchandiseReturnService = merchandiseReturnService;
@@ -56,21 +55,21 @@ namespace Grand.Web.Features.Handlers.Orders
_orderSettings = orderSettings;
}
- public async Task<MerchandiseReturnModel> Handle(GetMerchandiseReturn request, CancellationToken cancellationToken)
+ public async Task<MerchandiseReturnModel> Handle(GetMerchandiseReturn request,
+ CancellationToken cancellationToken)
{
- var model = new MerchandiseReturnModel();
- model.OrderId = request.Order.Id;
- model.OrderNumber = request.Order.OrderNumber;
- model.OrderCode = request.Order.Code;
- model.ShowPickupAddress = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress;
- model.ShowPickupDate = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate;
- model.PickupDateRequired = _orderSettings.MerchandiseReturns_PickupDateRequired;
-
- //return reasons
- model.AvailableReturnReasons = await PrepareAvailableReturnReasons();
-
- //return actions
- model.AvailableReturnActions = await PrepareAvailableReturnActions();
+ var model = new MerchandiseReturnModel {
+ OrderId = request.Order.Id,
+ OrderNumber = request.Order.OrderNumber,
+ OrderCode = request.Order.Code,
+ ShowPickupAddress = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupAddress,
+ ShowPickupDate = _orderSettings.MerchandiseReturns_AllowToSpecifyPickupDate,
+ PickupDateRequired = _orderSettings.MerchandiseReturns_PickupDateRequired,
+ //return reasons
+ AvailableReturnReasons = await PrepareAvailableReturnReasons(),
+ //return actions
+ AvailableReturnActions = await PrepareAvailableReturnActions()
+ };
//products
await PrepareItems(request, model);
@@ -87,8 +86,7 @@ namespace Grand.Web.Features.Handlers.Orders
{
var reasons = new List<MerchandiseReturnModel.MerchandiseReturnReasonModel>();
foreach (var rrr in await _merchandiseReturnService.GetAllMerchandiseReturnReasons())
- reasons.Add(new MerchandiseReturnModel.MerchandiseReturnReasonModel()
- {
+ reasons.Add(new MerchandiseReturnModel.MerchandiseReturnReasonModel {
Id = rrr.Id,
Name = rrr.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id)
});
@@ -99,8 +97,7 @@ namespace Grand.Web.Features.Handlers.Orders
{
var actions = new List<MerchandiseReturnModel.MerchandiseReturnActionModel>();
foreach (var rra in await _merchandiseReturnService.GetAllMerchandiseReturnActions())
- actions.Add(new MerchandiseReturnModel.MerchandiseReturnActionModel()
- {
+ actions.Add(new MerchandiseReturnModel.MerchandiseReturnActionModel {
Id = rra.Id,
Name = rra.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id)
});
@@ -113,54 +110,45 @@ namespace Grand.Web.Features.Handlers.Orders
foreach (var orderItem in request.Order.OrderItems)
{
- var qtyDelivery = shipments.Where(x => x.DeliveryDateUtc.HasValue).SelectMany(x => x.ShipmentItems).Where(x => x.OrderItemId == orderItem.Id).Sum(x => x.Quantity);
-
- var query = new GetMerchandiseReturnQuery()
- {
- StoreId = request.Store.Id,
- };
+ var qtyDelivery = shipments.Where(x => x.DeliveryDateUtc.HasValue).SelectMany(x => x.ShipmentItems)
+ .Where(x => x.OrderItemId == orderItem.Id).Sum(x => x.Quantity);
- var merchandiseReturns = await _merchandiseReturnService.SearchMerchandiseReturns(orderItemId: orderItem.Id);
- int qtyReturn = 0;
+ var merchandiseReturns =
+ await _merchandiseReturnService.SearchMerchandiseReturns(orderItemId: orderItem.Id);
+ var qtyReturn = merchandiseReturns.Sum(rr => rr.MerchandiseReturnItems.Sum(rrItem => rrItem.Quantity));
- foreach (var rr in merchandiseReturns)
+ var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
+ if (product.NotReturnable) continue;
+
+
+ var orderItemModel = new MerchandiseReturnModel.OrderItemModel {
+ Id = orderItem.Id,
+ ProductId = orderItem.ProductId,
+ ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id),
+ AttributeInfo = orderItem.AttributeDescription,
+ VendorId = orderItem.VendorId,
+ VendorName = string.IsNullOrEmpty(orderItem.VendorId)
+ ? ""
+ : (await _vendorService.GetVendorById(orderItem.VendorId))?.Name,
+ Quantity = qtyDelivery - qtyReturn
+ };
+ if (orderItemModel.Quantity > 0)
+ model.Items.Add(orderItemModel);
+ //unit price
+ if (request.Order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax)
{
- foreach (var rrItem in rr.MerchandiseReturnItems)
- {
- qtyReturn += rrItem.Quantity;
- }
+ //including tax
+ orderItemModel.UnitPrice = await _priceFormatter.FormatPrice(orderItem.UnitPriceInclTax,
+ request.Order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
}
-
- var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
- if (!product.NotReturnable)
+ else
{
- var orderItemModel = new MerchandiseReturnModel.OrderItemModel
- {
- Id = orderItem.Id,
- ProductId = orderItem.ProductId,
- ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id),
- AttributeInfo = orderItem.AttributeDescription,
- VendorId = orderItem.VendorId,
- VendorName = string.IsNullOrEmpty(orderItem.VendorId) ? "" : (await _vendorService.GetVendorById(orderItem.VendorId))?.Name,
- Quantity = qtyDelivery - qtyReturn,
- };
- if (orderItemModel.Quantity > 0)
- model.Items.Add(orderItemModel);
- //unit price
- if (request.Order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax)
- {
- //including tax
- orderItemModel.UnitPrice = await _priceFormatter.FormatPrice(orderItem.UnitPriceInclTax, request.Order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
- }
- else
- {
- //excluding tax
- orderItemModel.UnitPrice = await _priceFormatter.FormatPrice(orderItem.UnitPriceExclTax, request.Order.CustomerCurrencyCode, _workContext.WorkingLanguage, false);
- }
+ //excluding tax
+ orderItemModel.UnitPrice = await _priceFormatter.FormatPrice(orderItem.UnitPriceExclTax,
+ request.Order.CustomerCurrencyCode, _workContext.WorkingLanguage, false);
}
}
-
}
private async Task PreparePickupAddress(GetMerchandiseReturn request, MerchandiseReturnModel model)
@@ -174,38 +162,35 @@ namespace Grand.Web.Features.Handlers.Orders
addresses.Add(item);
continue;
}
+
var country = await _countryService.GetCountryById(item.CountryId);
- if (country == null || (country.AllowsShipping && _aclService.Authorize(country, request.Store.Id)))
- {
- addresses.Add(item);
- continue;
- }
+ if (country != null &&
+ (!country.AllowsShipping || !_aclService.Authorize(country, request.Store.Id))) continue;
+ addresses.Add(item);
}
foreach (var address in addresses)
{
- var addressModel = await _mediator.Send(new GetAddressModel()
- {
+ var addressModel = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Address = address,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
model.ExistingAddresses.Add(addressModel);
}
//new address
var countries = await _countryService.GetAllCountriesForShipping(request.Language.Id, request.Store.Id);
- model.MerchandiseReturnNewAddress = await _mediator.Send(new GetAddressModel()
- {
+ model.MerchandiseReturnNewAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Store = request.Store,
Address = null,
ExcludeProperties = false,
LoadCountries = () => countries,
PrePopulateWithCustomerFields = true,
- Customer = _workContext.CurrentCustomer,
+ Customer = _workContext.CurrentCustomer
});
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnsHandler.cs
index 07bd62270..5695e20c0 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetMerchandiseReturnsHandler.cs
@@ -1,9 +1,9 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Checkout.Orders;
-using Grand.Business.Core.Queries.Checkout.Orders;
-using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Domain.Tax;
using Grand.Web.Features.Models.Orders;
using Grand.Web.Models.Orders;
@@ -40,9 +40,8 @@ namespace Grand.Web.Features.Handlers.Orders
{
var model = new CustomerMerchandiseReturnsModel();
- var query = new GetMerchandiseReturnQuery()
- {
- StoreId = request.Store.Id,
+ var query = new GetMerchandiseReturnQuery {
+ StoreId = request.Store.Id
};
if (await _groupService.IsOwner(request.Customer))
@@ -50,7 +49,7 @@ namespace Grand.Web.Features.Handlers.Orders
else
query.CustomerId = request.Customer.Id;
- var merchandiseReturns = await _mediator.Send(query);
+ var merchandiseReturns = await _mediator.Send(query, cancellationToken);
foreach (var merchandiseReturn in merchandiseReturns)
{
@@ -58,7 +57,7 @@ namespace Grand.Web.Features.Handlers.Orders
double total = 0;
foreach (var rrItem in merchandiseReturn.MerchandiseReturnItems)
{
- var orderItem = order.OrderItems.Where(x => x.Id == rrItem.OrderItemId).First();
+ var orderItem = order.OrderItems.First(x => x.Id == rrItem.OrderItemId);
if (order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax)
{
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetOrderDetailsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetOrderDetailsHandler.cs
index 05bd22e68..78cccf069 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetOrderDetailsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetOrderDetailsHandler.cs
@@ -12,6 +12,7 @@ using Grand.Business.Core.Queries.Checkout.Orders;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Orders;
+using Grand.Domain.Payments;
using Grand.Domain.Shipping;
using Grand.Domain.Tax;
using Grand.Web.Extensions;
@@ -80,28 +81,28 @@ namespace Grand.Web.Features.Handlers.Orders
public async Task<OrderDetailsModel> Handle(GetOrderDetails request, CancellationToken cancellationToken)
{
- var model = new OrderDetailsModel();
-
- model.Id = request.Order.Id;
- model.OrderNumber = request.Order.OrderNumber;
- model.OrderCode = request.Order.Code;
- model.CreatedOn = _dateTimeService.ConvertToUserTime(request.Order.CreatedOnUtc, DateTimeKind.Utc);
- model.OrderStatus = (await _orderStatusService.GetByStatusId(request.Order.OrderStatusId))?.Name;
- model.IsReOrderAllowed = _orderSettings.IsReOrderAllowed;
- model.IsMerchandiseReturnAllowed = await _mediator.Send(new IsMerchandiseReturnAllowedQuery() { Order = request.Order });
- model.PdfInvoiceDisabled = _pdfSettings.DisablePdfInvoicesForPendingOrders && request.Order.OrderStatusId == (int)OrderStatusSystem.Pending;
- model.ShowAddOrderNote = _orderSettings.AllowCustomerToAddOrderNote;
+ var model = new OrderDetailsModel {
+ Id = request.Order.Id,
+ OrderNumber = request.Order.OrderNumber,
+ OrderCode = request.Order.Code,
+ CreatedOn = _dateTimeService.ConvertToUserTime(request.Order.CreatedOnUtc, DateTimeKind.Utc),
+ OrderStatus = (await _orderStatusService.GetByStatusId(request.Order.OrderStatusId))?.Name,
+ IsReOrderAllowed = _orderSettings.IsReOrderAllowed,
+ IsMerchandiseReturnAllowed = await _mediator.Send(new IsMerchandiseReturnAllowedQuery { Order = request.Order }, cancellationToken),
+ PdfInvoiceDisabled = _pdfSettings.DisablePdfInvoicesForPendingOrders && request.Order.OrderStatusId == (int)OrderStatusSystem.Pending,
+ ShowAddOrderNote = _orderSettings.AllowCustomerToAddOrderNote
+ };
//shipping info
await PrepareShippingInfo(request, model);
//billing info
- model.BillingAddress = await _mediator.Send(new GetAddressModel() {
+ model.BillingAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Model = null,
Address = request.Order.BillingAddress,
- ExcludeProperties = false,
- });
+ ExcludeProperties = false
+ }, cancellationToken);
//VAT number
model.VatNumber = request.Order.VatNumber;
@@ -133,8 +134,8 @@ namespace Grand.Web.Features.Handlers.Orders
//allow cancel order
if (_orderSettings.UserCanCancelUnpaidOrder)
{
- if (request.Order.OrderStatusId == (int)OrderStatusSystem.Pending && request.Order.PaymentStatusId == Domain.Payments.PaymentStatus.Pending
- && (request.Order.ShippingStatusId == ShippingStatus.ShippingNotRequired || request.Order.ShippingStatusId == ShippingStatus.Pending))
+ if (request.Order.OrderStatusId == (int)OrderStatusSystem.Pending && request.Order.PaymentStatusId == PaymentStatus.Pending
+ && request.Order.ShippingStatusId is ShippingStatus.ShippingNotRequired or ShippingStatus.Pending)
model.UserCanCancelUnpaidOrder = true;
}
@@ -153,25 +154,22 @@ namespace Grand.Web.Features.Handlers.Orders
model.PickUpInStore = request.Order.PickUpInStore;
if (!request.Order.PickUpInStore)
{
- model.ShippingAddress = await _mediator.Send(new GetAddressModel() {
+ model.ShippingAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Model = null,
Address = request.Order.ShippingAddress,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
}
else
{
- if (request.Order.PickupPoint != null)
+ if (request.Order.PickupPoint?.Address != null)
{
- if (request.Order.PickupPoint.Address != null)
- {
- model.PickupAddress = await _mediator.Send(new GetAddressModel() {
- Language = request.Language,
- Address = request.Order.PickupPoint.Address,
- ExcludeProperties = false,
- });
- }
+ model.PickupAddress = await _mediator.Send(new GetAddressModel {
+ Language = request.Language,
+ Address = request.Order.PickupPoint.Address,
+ ExcludeProperties = false
+ });
}
}
model.ShippingMethod = request.Order.ShippingMethod;
@@ -183,7 +181,7 @@ namespace Grand.Web.Features.Handlers.Orders
var shipmentModel = new OrderDetailsModel.ShipmentBriefModel {
Id = shipment.Id,
ShipmentNumber = shipment.ShipmentNumber,
- TrackingNumber = shipment.TrackingNumber,
+ TrackingNumber = shipment.TrackingNumber
};
if (shipment.ShippedDateUtc.HasValue)
shipmentModel.ShippedDate = _dateTimeService.ConvertToUserTime(shipment.ShippedDateUtc.Value, DateTimeKind.Utc);
@@ -201,7 +199,7 @@ namespace Grand.Web.Features.Handlers.Orders
model.PaymentMethod = paymentMethod != null ? paymentMethod.FriendlyName : request.Order.PaymentMethodSystemName;
model.PaymentMethodStatus = request.Order.PaymentStatusId.GetTranslationEnum(_translationService, request.Language.Id);
var paymentTransaction = await _paymentTransactionService.GetOrderByGuid(request.Order.OrderGuid);
- model.CanRePostProcessPayment = paymentTransaction != null ? await _paymentService.CanRePostRedirectPayment(paymentTransaction) : false;
+ model.CanRePostProcessPayment = paymentTransaction != null && await _paymentService.CanRePostRedirectPayment(paymentTransaction);
}
private async Task PrepareOrderTotal(GetOrderDetails request, OrderDetailsModel model)
@@ -255,8 +253,8 @@ namespace Grand.Web.Features.Handlers.Orders
private async Task PrepareTax(GetOrderDetails request, OrderDetailsModel model)
{
- bool displayTax = true;
- bool displayTaxRates = true;
+ var displayTax = true;
+ var displayTaxRates = true;
if (_taxSettings.HideTaxInOrderSummary && request.Order.CustomerTaxDisplayTypeId == TaxDisplayType.IncludingTax)
{
displayTax = false;
@@ -280,7 +278,7 @@ namespace Grand.Web.Features.Handlers.Orders
{
model.TaxRates.Add(new OrderDetailsModel.TaxRate {
Rate = _priceFormatter.FormatTaxRate(tr.Percent),
- Value = await _priceFormatter.FormatPrice(tr.Amount, request.Order.CustomerCurrencyCode, false, request.Language),
+ Value = await _priceFormatter.FormatPrice(tr.Amount, request.Order.CustomerCurrencyCode, false, request.Language)
});
}
}
@@ -304,7 +302,7 @@ namespace Grand.Web.Features.Handlers.Orders
var giftVoucher = await _giftVoucherService.GetGiftVoucherById(gcuh.GiftVoucherId);
model.GiftVouchers.Add(new OrderDetailsModel.GiftVoucher {
CouponCode = giftVoucher.Code,
- Amount = await _priceFormatter.FormatPrice(-gcuh.UsedValue, request.Order.CustomerCurrencyCode, false, request.Language),
+ Amount = await _priceFormatter.FormatPrice(-gcuh.UsedValue, request.Order.CustomerCurrencyCode, false, request.Language)
});
}
@@ -352,7 +350,7 @@ namespace Grand.Web.Features.Handlers.Orders
ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
ProductSeName = product.SeName,
Quantity = orderItem.Quantity,
- AttributeInfo = orderItem.AttributeDescription,
+ AttributeInfo = orderItem.AttributeDescription
};
//prepare picture
orderItemModel.Picture = await PrepareOrderItemPicture(product, orderItem.Attributes, orderItemModel.ProductName);
@@ -407,7 +405,7 @@ namespace Grand.Web.Features.Handlers.Orders
Id = sciPicture?.Id,
ImageUrl = await _pictureService.GetPictureUrl(sciPicture, 80),
Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), productName),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), productName),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), productName)
};
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Orders/GetShipmentDetailsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Orders/GetShipmentDetailsHandler.cs
index 2fa391670..002b2a56e 100644
--- a/src/Web/Grand.Web/Features/Handlers/Orders/GetShipmentDetailsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Orders/GetShipmentDetailsHandler.cs
@@ -48,10 +48,11 @@ namespace Grand.Web.Features.Handlers.Orders
if (request.Shipment == null)
throw new ArgumentNullException(nameof(request.Shipment));
- var model = new ShipmentDetailsModel();
+ var model = new ShipmentDetailsModel {
+ Id = request.Shipment.Id,
+ ShipmentNumber = request.Shipment.ShipmentNumber
+ };
- model.Id = request.Shipment.Id;
- model.ShipmentNumber = request.Shipment.ShipmentNumber;
if (request.Shipment.ShippedDateUtc.HasValue)
model.ShippedDate = _dateTimeService.ConvertToUserTime(request.Shipment.ShippedDateUtc.Value, DateTimeKind.Utc);
if (request.Shipment.DeliveryDateUtc.HasValue)
@@ -76,10 +77,12 @@ namespace Grand.Web.Features.Handlers.Orders
{
foreach (var shipmentEvent in shipmentEvents)
{
- var shipmentStatusEventModel = new ShipmentDetailsModel.ShipmentStatusEventModel();
- shipmentStatusEventModel.Date = shipmentEvent.Date;
- shipmentStatusEventModel.EventName = shipmentEvent.EventName;
- shipmentStatusEventModel.Location = shipmentEvent.Location;
+ var shipmentStatusEventModel = new ShipmentDetailsModel.ShipmentStatusEventModel
+ {
+ Date = shipmentEvent.Date,
+ EventName = shipmentEvent.EventName,
+ Location = shipmentEvent.Location
+ };
model.ShipmentStatusEvents.Add(shipmentStatusEventModel);
}
}
@@ -92,7 +95,7 @@ namespace Grand.Web.Features.Handlers.Orders
model.ShowSku = _catalogSettings.ShowSkuOnProductDetailsPage;
foreach (var shipmentItem in request.Shipment.ShipmentItems)
{
- var orderItem = request.Order.OrderItems.Where(x => x.Id == shipmentItem.OrderItemId).FirstOrDefault();
+ var orderItem = request.Order.OrderItems.FirstOrDefault(x => x.Id == shipmentItem.OrderItemId);
if (orderItem == null)
continue;
var product = await _productService.GetProductByIdIncludeArch(orderItem.ProductId);
@@ -104,7 +107,7 @@ namespace Grand.Web.Features.Handlers.Orders
ProductSeName = product.GetSeName(request.Language.Id),
AttributeInfo = orderItem.AttributeDescription,
QuantityOrdered = orderItem.Quantity,
- QuantityShipped = shipmentItem.Quantity,
+ QuantityShipped = shipmentItem.Quantity
};
model.Items.Add(shipmentItemModel);
@@ -148,24 +151,21 @@ namespace Grand.Web.Features.Handlers.Orders
model.PickUpInStore = order.PickUpInStore;
if (!order.PickUpInStore)
{
- model.ShippingAddress = await _mediator.Send(new GetAddressModel() {
+ model.ShippingAddress = await _mediator.Send(new GetAddressModel {
Language = request.Language,
Address = order.ShippingAddress,
- ExcludeProperties = false,
+ ExcludeProperties = false
});
}
else
{
- if (order.PickupPoint != null)
+ if (order.PickupPoint is { Address: { } })
{
- if (order.PickupPoint.Address != null)
- {
- model.PickupAddress = await _mediator.Send(new GetAddressModel() {
- Language = request.Language,
- Address = order.PickupPoint.Address,
- ExcludeProperties = false,
- });
- }
+ model.PickupAddress = await _mediator.Send(new GetAddressModel {
+ Language = request.Language,
+ Address = order.PickupPoint.Address,
+ ExcludeProperties = false
+ });
}
}
return model;
diff --git a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs
index f1b0867e5..34ded2e9c 100644
--- a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs
@@ -35,18 +35,14 @@ namespace Grand.Web.Features.Handlers.Pages
await _pageService.GetPageBySystemName(request.SystemName, _workContext.CurrentStore.Id) :
await _pageService.GetPageById(request.PageId);
- if (page == null || !page.Published)
+ if (page is not { Published: true })
return null;
if ((page.StartDateUtc.HasValue && page.StartDateUtc > DateTime.UtcNow) || (page.EndDateUtc.HasValue && page.EndDateUtc < DateTime.UtcNow))
return null;
//ACL (access control list)
- if (!_aclService.Authorize(page, _workContext.CurrentCustomer))
- return null;
-
- return page.ToModel(_workContext.WorkingLanguage, _dateTimeService, request.Password);
-
+ return !_aclService.Authorize(page, _workContext.CurrentCustomer) ? null : page.ToModel(_workContext.WorkingLanguage, _dateTimeService, request.Password);
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageLayoutViewPathHandler.cs b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageLayoutViewPathHandler.cs
index 2f148675b..e644a5376 100644
--- a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageLayoutViewPathHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageLayoutViewPathHandler.cs
@@ -16,9 +16,7 @@ namespace Grand.Web.Features.Handlers.Pages
public async Task<string> Handle(GetPageLayoutViewPath request, CancellationToken cancellationToken)
{
- var layout = await _pageLayoutService.GetPageLayoutById(request.LayoutId);
- if (layout == null)
- layout = (await _pageLayoutService.GetAllPageLayouts()).FirstOrDefault();
+ var layout = await _pageLayoutService.GetPageLayoutById(request.LayoutId) ?? (await _pageLayoutService.GetAllPageLayouts()).FirstOrDefault();
if (layout == null)
throw new Exception("No default layout could be loaded");
return layout.ViewPath;
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
index f2f908e92..1c3cb8d27 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
@@ -1,11 +1,10 @@
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Utilities.Catalog;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Media;
@@ -19,7 +18,8 @@ using MediatR;
namespace Grand.Web.Features.Handlers.Products
{
- public class GetProductDetailsAttributeChangeHandler : IRequestHandler<GetProductDetailsAttributeChange, ProductDetailsAttributeChangeModel>
+ public class GetProductDetailsAttributeChangeHandler : IRequestHandler<GetProductDetailsAttributeChange,
+ ProductDetailsAttributeChangeModel>
{
private readonly IMediator _mediator;
private readonly IStockQuantityService _stockQuantityService;
@@ -59,16 +59,19 @@ namespace Grand.Web.Features.Handlers.Products
_mediaSettings = mediaSettings;
}
- public async Task<ProductDetailsAttributeChangeModel> Handle(GetProductDetailsAttributeChange request, CancellationToken cancellationToken)
+ public async Task<ProductDetailsAttributeChangeModel> Handle(GetProductDetailsAttributeChange request,
+ CancellationToken cancellationToken)
{
var model = new ProductDetailsAttributeChangeModel();
- var customAttributes = await _mediator.Send(new GetParseProductAttributes() { Product = request.Product, Model = request.Model }, cancellationToken);
+ var customAttributes =
+ await _mediator.Send(new GetParseProductAttributes { Product = request.Product, Model = request.Model },
+ cancellationToken);
- var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- request.Model.WarehouseId :
- request.Product.UseMultipleWarehouses ? request.Store.DefaultWarehouseId :
- (string.IsNullOrEmpty(request.Store.DefaultWarehouseId) ? request.Product.WarehouseId : request.Store.DefaultWarehouseId);
+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ? request.Model.WarehouseId :
+ request.Product.UseMultipleWarehouses ? request.Store.DefaultWarehouseId :
+ string.IsNullOrEmpty(request.Store.DefaultWarehouseId) ? request.Product.WarehouseId :
+ request.Store.DefaultWarehouseId;
//rental attributes
DateTime? rentalStartDate = null;
@@ -82,38 +85,38 @@ namespace Grand.Web.Features.Handlers.Products
model.Mpn = request.Product.FormatMpn(customAttributes);
model.Gtin = request.Product.FormatGtin(customAttributes);
- if (await _permissionService.Authorize(StandardPermission.DisplayPrices) && !request.Product.EnteredPrice && request.Product.ProductTypeId != ProductType.Auction)
+ if (await _permissionService.Authorize(StandardPermission.DisplayPrices) && !request.Product.EnteredPrice &&
+ request.Product.ProductTypeId != ProductType.Auction)
{
//we do not calculate price of "customer enters price" option is enabled
var unitprice = await _pricingService.GetUnitPrice(request.Product,
request.Customer,
request.Currency,
ShoppingCartType.ShoppingCart,
- 1, customAttributes, (double?)default,
+ 1, customAttributes, default,
rentalStartDate, rentalEndDate,
true);
- double discountAmount = unitprice.discountAmount;
- List<ApplyDiscount> scDiscounts = unitprice.appliedDiscounts;
- double finalPrice = unitprice.unitprice;
+ var finalPrice = unitprice.unitprice;
var productprice = await _taxService.GetProductPrice(request.Product, finalPrice);
- double finalPriceWithDiscount = productprice.productprice;
- double taxRate = productprice.taxRate;
+ var finalPriceWithDiscount = productprice.productprice;
model.Price = _priceFormatter.FormatPrice(finalPriceWithDiscount);
}
+
//stock
- model.StockAvailability = _stockQuantityService.FormatStockMessage(request.Product, warehouseId, customAttributes);
+ model.StockAvailability =
+ _stockQuantityService.FormatStockMessage(request.Product, warehouseId, customAttributes);
//out of stock subscription
- if ((request.Product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes
- || request.Product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock) &&
+ if (request.Product.ManageInventoryMethodId is ManageInventoryMethod.ManageStockByAttributes or ManageInventoryMethod.ManageStock &&
request.Product.BackorderModeId == BackorderMode.NoBackorders &&
request.Product.AllowOutOfStockSubscriptions)
{
var combination = request.Product.FindProductAttributeCombination(customAttributes);
if (combination != null)
- if (_stockQuantityService.GetTotalStockQuantityForCombination(request.Product, combination, warehouseId: warehouseId) <= 0)
+ if (_stockQuantityService.GetTotalStockQuantityForCombination(request.Product, combination,
+ warehouseId: warehouseId) <= 0)
model.DisplayOutOfStockSubscription = true;
if (request.Product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock)
@@ -123,63 +126,59 @@ namespace Grand.Web.Features.Handlers.Products
}
var subscription = await _outOfStockSubscriptionService
- .FindSubscription(request.Customer.Id,
- request.Product.Id, customAttributes, request.Store.Id, warehouseId);
-
- if (subscription != null)
- model.ButtonTextOutOfStockSubscription = _translationService.GetResource("OutOfStockSubscriptions.DeleteNotifyWhenAvailable");
- else
- model.ButtonTextOutOfStockSubscription = _translationService.GetResource("OutOfStockSubscriptions.NotifyMeWhenAvailable");
+ .FindSubscription(request.Customer.Id,
+ request.Product.Id, customAttributes, request.Store.Id, warehouseId);
+ model.ButtonTextOutOfStockSubscription = _translationService.GetResource(subscription != null
+ ? "OutOfStockSubscriptions.DeleteNotifyWhenAvailable"
+ : "OutOfStockSubscriptions.NotifyMeWhenAvailable");
}
+
if (request.Product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)
{
model.NotAvailableAttributeMappingids = PrepareNotAvailableAttributeMapping(request, customAttributes);
}
//conditional attributes
- if (request.Product.ProductAttributeMappings.Where(x=>x.ConditionAttribute.Any()).Any())
+ if (request.Product.ProductAttributeMappings.Any(x => x.ConditionAttribute.Any()))
{
var attributes = request.Product.ProductAttributeMappings;
foreach (var attribute in attributes)
{
var conditionMet = request.Product.IsConditionMet(attribute, customAttributes);
- if (conditionMet.HasValue)
- {
- if (conditionMet.Value)
- model.EnabledAttributeMappingIds.Add(attribute.Id);
- else
- model.DisabledAttributeMappingids.Add(attribute.Id);
- }
+ if (!conditionMet.HasValue) continue;
+ if (conditionMet.Value)
+ model.EnabledAttributeMappingIds.Add(attribute.Id);
+ else
+ model.DisabledAttributeMappingids.Add(attribute.Id);
}
}
+
//picture. used when we want to override a default product picture when some attribute is selected
- if (request.LoadPicture)
+ if (!request.LoadPicture) return model;
+
+ //first, try to get product attribute combination picture
+ var pictureId = request.Product.FindProductAttributeCombination(customAttributes)?.PictureId;
+ if (string.IsNullOrEmpty(pictureId))
{
+ pictureId = request.Product.ParseProductAttributeValues(customAttributes)
+ .FirstOrDefault(attributeValue => !string.IsNullOrEmpty(attributeValue.PictureId))?.PictureId ?? "";
+ }
- //first, try to get product attribute combination picture
- var pictureId = request.Product.FindProductAttributeCombination(customAttributes)?.PictureId;
- if (string.IsNullOrEmpty(pictureId))
- {
- pictureId = request.Product.ParseProductAttributeValues(customAttributes)
- .FirstOrDefault(attributeValue => !string.IsNullOrEmpty(attributeValue.PictureId))?.PictureId ?? "";
- }
+ if (string.IsNullOrEmpty(pictureId)) return model;
- if (!string.IsNullOrEmpty(pictureId))
- {
- var pictureModel = new PictureModel {
- Id = pictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(pictureId),
- ImageUrl = await _pictureService.GetPictureUrl(pictureId, _mediaSettings.ProductDetailsPictureSize)
- };
- model.PictureFullSizeUrl = pictureModel.FullSizeImageUrl;
- model.PictureDefaultSizeUrl = pictureModel.ImageUrl;
- }
- }
+ var pictureModel = new PictureModel {
+ Id = pictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(pictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(pictureId, _mediaSettings.ProductDetailsPictureSize)
+ };
+ model.PictureFullSizeUrl = pictureModel.FullSizeImageUrl;
+ model.PictureDefaultSizeUrl = pictureModel.ImageUrl;
return model;
}
- private List<string> PrepareNotAvailableAttributeMapping(GetProductDetailsAttributeChange request, IList<CustomAttribute> customAttributes)
+ private List<string> PrepareNotAvailableAttributeMapping(GetProductDetailsAttributeChange request,
+ IList<CustomAttribute> customAttributes)
{
var model = new List<string>();
@@ -188,38 +187,40 @@ namespace Grand.Web.Features.Handlers.Products
{
//find all combinations with attributes
var combinations = request.Product.ProductAttributeCombinations
- .Where(x => x.Attributes.Any(z => z.Key == customAttribute.Key && z.Value == customAttribute.Value)).ToList();
+ .Where(x => x.Attributes.Any(z => z.Key == customAttribute.Key && z.Value == customAttribute.Value))
+ .ToList();
//limit to without existing combination
combinations = combinations.Where(x => x.Id != combination?.Id).ToList();
//where the stock is unavailable
- var combinationsStockUnavailable = combinations.Where(x => x.StockQuantity - x.ReservedQuantity <= 0).ToList();
-
+ var combinationsStockUnavailable =
+ combinations.Where(x => x.StockQuantity - x.ReservedQuantity <= 0).ToList();
+
//where the stock is available
var combinationsStockAvailable = combinations
.Where(x => x.StockQuantity - x.ReservedQuantity > 0).ToList();
if (combinationsStockUnavailable.Count > 0)
{
- var x = combinationsStockUnavailable.SelectMany(x => x.Attributes).Where(x => x.Value != customAttribute.Value);
- var notAvailable = x.Select(x => x.Value).Distinct().ToList();
- notAvailable.ForEach((x) =>
+ var x = combinationsStockUnavailable.SelectMany(x => x.Attributes)
+ .Where(x => x.Value != customAttribute.Value);
+ var notAvailable = x.Select(z => z.Value).Distinct().ToList();
+ notAvailable.ForEach(z =>
{
- if (!model.Contains(x))
- model.Add(x);
+ if (!model.Contains(z))
+ model.Add(z);
});
}
- if (combinationsStockAvailable.Count > 0)
- {
- var x = combinationsStockAvailable.SelectMany(x => x.Attributes).Where(x => x.Value != customAttribute.Value);
- var available = x.Select(x => x.Value).Distinct().ToList();
- available.ForEach((x) =>
+
+ if (combinationsStockAvailable.Count <= 0) continue;
+
+ combinationsStockAvailable.SelectMany(x => x.Attributes)
+ .Where(x => x.Value != customAttribute.Value).Select(x => x.Value).Distinct().ToList().ForEach(z =>
{
- if (model.Contains(x))
- model.Remove(x);
+ if (model.Contains(z))
+ model.Remove(z);
});
- }
-
+
// another way to list available combinations
/*
var combinations = request.Product.ProductAttributeCombinations.ToList();
@@ -256,9 +257,10 @@ namespace Grand.Web.Features.Handlers.Products
}
*/
}
+
if (customAttributes.Any())
{
- customAttributes.ToList().ForEach((x) =>
+ customAttributes.ToList().ForEach(x =>
{
if (model.Contains(x.Value))
model.Remove(x.Value);
@@ -280,6 +282,5 @@ namespace Grand.Web.Features.Handlers.Products
return model;
}
-
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
index 23cc854aa..a5b87102a 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs
@@ -1,6 +1,8 @@
using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Categories;
using Grand.Business.Core.Interfaces.Catalog.Collections;
+using Grand.Business.Core.Interfaces.Catalog.Directory;
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
@@ -8,11 +10,9 @@ using Grand.Business.Core.Interfaces.Checkout.Shipping;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure;
-using Grand.Infrastructure.Caching;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
@@ -21,19 +21,20 @@ using Grand.Domain.Orders;
using Grand.Domain.Seo;
using Grand.Domain.Stores;
using Grand.Domain.Vendors;
+using Grand.Infrastructure;
+using Grand.Infrastructure.Caching;
using Grand.Web.Common.Security.Captcha;
+using Grand.Web.Events.Cache;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
-using Grand.Web.Events.Cache;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Globalization;
-using Grand.Business.Core.Interfaces.Catalog.Brands;
-using Grand.Business.Core.Interfaces.Catalog.Directory;
+using ProductExtensions = Grand.Domain.Catalog.ProductExtensions;
namespace Grand.Web.Features.Handlers.Products
{
@@ -138,12 +139,15 @@ namespace Grand.Web.Features.Handlers.Products
_shoppingCartSettings = shoppingCartSettings;
}
- public async Task<ProductDetailsModel> Handle(GetProductDetailsPage request, CancellationToken cancellationToken)
+ public async Task<ProductDetailsModel> Handle(GetProductDetailsPage request,
+ CancellationToken cancellationToken)
{
- return await PrepareProductDetailsModel(request.Store, request.Product, request.UpdateCartItem, request.IsAssociatedProduct);
+ return await PrepareProductDetailsModel(request.Store, request.Product, request.UpdateCartItem,
+ request.IsAssociatedProduct);
}
- private async Task<ProductDetailsModel> PrepareProductDetailsModel(Store store, Product product, ShoppingCartItem updateCartItem, bool isAssociatedProduct)
+ private async Task<ProductDetailsModel> PrepareProductDetailsModel(Store store, Product product,
+ ShoppingCartItem updateCartItem, bool isAssociatedProduct)
{
if (product == null)
throw new ArgumentNullException(nameof(product));
@@ -174,9 +178,10 @@ namespace Grand.Web.Features.Handlers.Products
var shareCode = _catalogSettings.PageShareCode;
if (store.SslEnabled)
{
- //need to change the addthis link to be https linked when the page is, so that the page doesnt ask about mixed mode when viewed in https...
+ //need to change the add this link to be https linked when the page is, so that the page doesnt ask about mixed mode when viewed in https...
shareCode = shareCode.Replace("http://", "https://");
}
+
model.PageShareCode = shareCode;
}
@@ -184,11 +189,11 @@ namespace Grand.Web.Features.Handlers.Products
#region Out of stock subscriptions
- if ((product.ManageInventoryMethodId == ManageInventoryMethod.ManageStock
- || product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes) &&
+ if (product.ManageInventoryMethodId is ManageInventoryMethod.ManageStock or ManageInventoryMethod.ManageStockByAttributes &&
product.BackorderModeId == BackorderMode.NoBackorders &&
product.AllowOutOfStockSubscriptions &&
- _stockQuantityService.GetTotalStockQuantity(product, warehouseId: _workContext.CurrentStore.DefaultWarehouseId) <= 0)
+ _stockQuantityService.GetTotalStockQuantity(product,
+ warehouseId: _workContext.CurrentStore.DefaultWarehouseId) <= 0)
{
//out of stock
model.DisplayOutOfStockSubscription = true;
@@ -220,11 +225,12 @@ namespace Grand.Web.Features.Handlers.Products
model.DefaultPictureZoomEnabled = _mediaSettings.DefaultPictureZoomEnabled;
//default picture
- var defaultPictureSize = isAssociatedProduct ?
- _mediaSettings.AssociatedProductPictureSize :
- _mediaSettings.ProductDetailsPictureSize;
+ var defaultPictureSize = isAssociatedProduct
+ ? _mediaSettings.AssociatedProductPictureSize
+ : _mediaSettings.ProductDetailsPictureSize;
//prepare picture models
- var cachedPictures = await PrepareProductPictureModel(product, defaultPictureSize, isAssociatedProduct, model.Name);
+ var cachedPictures =
+ await PrepareProductPictureModel(product, defaultPictureSize, isAssociatedProduct, model.Name);
model.DefaultPictureModel = cachedPictures.defaultPictureModel;
model.PictureModels = cachedPictures.pictureModels;
@@ -252,11 +258,11 @@ namespace Grand.Web.Features.Handlers.Products
model.ProductAttributes = await PrepareProductAttributeModel(product, defaultPictureSize, updateCartItem);
- #endregion
+ #endregion
#region Product specifications
- model.ProductSpecifications = await _mediator.Send(new GetProductSpecification() {
+ model.ProductSpecifications = await _mediator.Send(new GetProductSpecification {
Language = _workContext.WorkingLanguage,
Product = product
});
@@ -265,7 +271,7 @@ namespace Grand.Web.Features.Handlers.Products
#region Product review overview
- model.ProductReviewOverview = await _mediator.Send(new GetProductReviewOverview() {
+ model.ProductReviewOverview = await _mediator.Send(new GetProductReviewOverview {
Product = product,
Language = _workContext.WorkingLanguage,
Store = _workContext.CurrentStore
@@ -284,7 +290,7 @@ namespace Grand.Web.Features.Handlers.Products
#region Collections
- string collectionsCacheKey = string.Format(CacheKeyConst.PRODUCT_COLLECTIONS_MODEL_KEY,
+ var collectionsCacheKey = string.Format(CacheKeyConst.PRODUCT_COLLECTIONS_MODEL_KEY,
product.Id,
_workContext.WorkingLanguage.Id,
string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()),
@@ -294,9 +300,12 @@ namespace Grand.Web.Features.Handlers.Products
var listCollection = new List<CollectionModel>();
foreach (var item in product.ProductCollections.OrderBy(x => x.DisplayOrder))
{
- var collect = (await _collectionService.GetCollectionById(item.CollectionId)).ToModel(_workContext.WorkingLanguage);
+ var collect =
+ (await _collectionService.GetCollectionById(item.CollectionId)).ToModel(_workContext
+ .WorkingLanguage);
listCollection.Add(collect);
}
+
return listCollection;
});
@@ -309,9 +318,11 @@ namespace Grand.Web.Features.Handlers.Products
//ensure no circular references
if (!isAssociatedProduct)
{
- var associatedProducts = await _productService.GetAssociatedProducts(product.Id, _workContext.CurrentStore.Id);
+ var associatedProducts =
+ await _productService.GetAssociatedProducts(product.Id, _workContext.CurrentStore.Id);
foreach (var associatedProduct in associatedProducts)
- model.AssociatedProducts.Add(await PrepareProductDetailsModel(store, associatedProduct, null, true));
+ model.AssociatedProducts.Add(
+ await PrepareProductDetailsModel(store, associatedProduct, null, true));
}
}
@@ -329,6 +340,7 @@ namespace Grand.Web.Features.Handlers.Products
{
model.ProductBundleModels = await PrepareProductBundleModel(product, updateCartItem);
}
+
#endregion
#region Auctions
@@ -337,7 +349,9 @@ namespace Grand.Web.Features.Handlers.Products
model.HighestBidValue = product.HighestBid;
model.AddToCart.IsAuction = product.ProductTypeId == ProductType.Auction;
model.EndTime = product.AvailableEndDateTimeUtc;
- model.EndTimeLocalTime = product.AvailableEndDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?();
+ model.EndTimeLocalTime = product.AvailableEndDateTimeUtc.HasValue
+ ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc)
+ : new DateTime?();
model.AuctionEnded = product.AuctionEnded;
@@ -347,11 +361,14 @@ namespace Grand.Web.Features.Handlers.Products
}
- private async Task<ProductDetailsModel> PrepareStandardProperties(Product product, ShoppingCartItem updateCartItem)
+ private async Task<ProductDetailsModel> PrepareStandardProperties(Product product,
+ ShoppingCartItem updateCartItem)
{
#region Standard properties
- var warehouseId = updateCartItem != null ? updateCartItem.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId;
+ var warehouseId = updateCartItem != null
+ ? updateCartItem.WarehouseId
+ : _workContext.CurrentStore.DefaultWarehouseId;
var model = new ProductDetailsModel {
Id = product.Id,
@@ -377,7 +394,8 @@ namespace Grand.Web.Features.Handlers.Products
DisplayDiscontinuedMessage =
(!product.Published && _catalogSettings.DisplayDiscontinuedMessageForUnpublishedProducts) ||
(product.ProductTypeId == ProductType.Auction && product.AuctionEnded) ||
- (product.AvailableEndDateTimeUtc.HasValue && product.AvailableEndDateTimeUtc.Value < DateTime.UtcNow),
+ (product.AvailableEndDateTimeUtc.HasValue &&
+ product.AvailableEndDateTimeUtc.Value < DateTime.UtcNow),
CompareProductsEnabled = _catalogSettings.CompareProductsEnabled,
AllowToSelectWarehouse = _shoppingCartSettings.AllowToSelectWarehouse,
IsShipEnabled = product.IsShipEnabled,
@@ -385,23 +403,25 @@ namespace Grand.Web.Features.Handlers.Products
NotReturnable = product.NotReturnable,
EmailAFriendEnabled = _catalogSettings.EmailAFriendEnabled,
AskQuestionOnProduct = _catalogSettings.AskQuestionOnProduct,
- RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnEmailProductToFriendPage
- || _captchaSettings.ShowOnProductReviewPage
- || _captchaSettings.ShowOnAskQuestionPage)
+ RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnEmailProductToFriendPage
+ || _captchaSettings.ShowOnProductReviewPage
+ || _captchaSettings.ShowOnAskQuestionPage)
};
//automatically generate product description?
- if (_seoSettings.GenerateProductMetaDescription && String.IsNullOrEmpty(model.MetaDescription))
+ if (_seoSettings.GenerateProductMetaDescription && string.IsNullOrEmpty(model.MetaDescription))
{
//based on short description
model.MetaDescription = model.ShortDescription;
}
+
//warehouse
if (model.AllowToSelectWarehouse)
{
foreach (var warehouse in await _warehouseService.GetAllWarehouses())
{
- var productwarehouse = product.ProductWarehouseInventory.FirstOrDefault(x => x.WarehouseId == warehouse.Id);
+ var productwarehouse =
+ product.ProductWarehouseInventory.FirstOrDefault(x => x.WarehouseId == warehouse.Id);
model.ProductWarehouses.Add(new ProductDetailsModel.ProductWarehouseModel {
Use = productwarehouse != null,
StockQuantity = productwarehouse?.StockQuantity ?? 0,
@@ -413,6 +433,7 @@ namespace Grand.Web.Features.Handlers.Products
});
}
}
+
//shipping info
if (product.IsShipEnabled)
{
@@ -423,21 +444,26 @@ namespace Grand.Web.Features.Handlers.Products
var deliveryDate = await _deliveryDateService.GetDeliveryDateById(product.DeliveryDateId);
if (deliveryDate != null)
{
- model.DeliveryDate = deliveryDate.GetTranslation(dd => dd.Name, _workContext.WorkingLanguage.Id);
+ model.DeliveryDate =
+ deliveryDate.GetTranslation(dd => dd.Name, _workContext.WorkingLanguage.Id);
model.DeliveryColorSquaresRgb = deliveryDate.ColorSquaresRgb;
}
}
}
+
//additional shipping charge
if (model.AdditionalShippingCharge > 0)
- model.AdditionalShippingChargeStr = _priceFormatter.FormatPrice((await _taxService.GetShippingPrice(model.AdditionalShippingCharge, _workContext.CurrentCustomer)).shippingPrice);
+ model.AdditionalShippingChargeStr = _priceFormatter.FormatPrice(
+ (await _taxService.GetShippingPrice(model.AdditionalShippingCharge, _workContext.CurrentCustomer))
+ .shippingPrice);
//ask question us on the product
if (model.AskQuestionOnProduct)
model.ProductAskQuestion = await PrepareProductAskQuestionSimpleModel(product);
//store name
- model.CurrentStoreName = _workContext.CurrentStore.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);
+ model.CurrentStoreName =
+ _workContext.CurrentStore.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);
return model;
@@ -458,36 +484,36 @@ namespace Grand.Web.Features.Handlers.Products
};
return await Task.FromResult(model);
}
+
private async Task<BrandBriefInfoModel> PrepareBrandBriefInfoModel(Product product)
{
- if (!string.IsNullOrEmpty(product.BrandId))
+ if (string.IsNullOrEmpty(product.BrandId)) return null;
+ var brand = await _brandService.GetBrandById(product.BrandId);
+ if (brand is { Published: true })
{
- var brand = await _brandService.GetBrandById(product.BrandId);
- if (brand != null && brand.Published)
- {
- return new BrandBriefInfoModel {
- Id = brand.Id,
- Name = brand.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- SeName = brand.GetSeName(_workContext.WorkingLanguage.Id),
- };
- }
+ return new BrandBriefInfoModel {
+ Id = brand.Id,
+ Name = brand.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ SeName = brand.GetSeName(_workContext.WorkingLanguage.Id)
+ };
}
+
return null;
}
+
private async Task<VendorBriefInfoModel> PrepareVendorBriefInfoModel(Product product)
{
- if (!string.IsNullOrEmpty(product.VendorId))
+ if (string.IsNullOrEmpty(product.VendorId)) return null;
+ var vendor = await _vendorService.GetVendorById(product.VendorId);
+ if (vendor is { Deleted: false, Active: true })
{
- var vendor = await _vendorService.GetVendorById(product.VendorId);
- if (vendor != null && !vendor.Deleted && vendor.Active)
- {
- return new VendorBriefInfoModel {
- Id = vendor.Id,
- Name = vendor.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- SeName = vendor.GetSeName(_workContext.WorkingLanguage.Id),
- };
- }
+ return new VendorBriefInfoModel {
+ Id = vendor.Id,
+ Name = vendor.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ SeName = vendor.GetSeName(_workContext.WorkingLanguage.Id)
+ };
}
+
return null;
}
@@ -501,36 +527,37 @@ namespace Grand.Web.Features.Handlers.Products
return await _cacheBase.GetAsync(breadcrumbCacheKey, async () =>
{
var breadcrumbModel = new ProductDetailsModel.ProductBreadcrumbModel {
-
Enabled = _catalogSettings.CategoryBreadcrumbEnabled,
ProductId = product.Id,
ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id)
};
var productCategories = product.ProductCategories;
- if (productCategories.Any())
+ if (!productCategories.Any()) return breadcrumbModel;
+
+ var category =
+ await _categoryService.GetCategoryById(productCategories.MinBy(x => x.DisplayOrder).CategoryId);
+ if (category == null) return breadcrumbModel;
+
+ foreach (var catBr in await _categoryService.GetCategoryBreadCrumb(category))
{
- var category = await _categoryService.GetCategoryById(productCategories.OrderBy(x => x.DisplayOrder).FirstOrDefault().CategoryId);
- if (category != null)
- {
- foreach (var catBr in await _categoryService.GetCategoryBreadCrumb(category))
- {
- breadcrumbModel.CategoryBreadcrumb.Add(new CategorySimpleModel {
- Id = catBr.Id,
- Name = catBr.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- SeName = catBr.GetSeName(_workContext.WorkingLanguage.Id),
- IncludeInMenu = catBr.IncludeInMenu
- });
- }
- }
+ breadcrumbModel.CategoryBreadcrumb.Add(new CategorySimpleModel {
+ Id = catBr.Id,
+ Name = catBr.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ SeName = catBr.GetSeName(_workContext.WorkingLanguage.Id),
+ IncludeInMenu = catBr.IncludeInMenu
+ });
}
+
+
return breadcrumbModel;
});
}
private async Task<IList<ProductTagModel>> PrepareProductTagModel(Product product)
{
- var productTagsCacheKey = string.Format(CacheKeyConst.PRODUCTTAG_BY_PRODUCT_MODEL_KEY, product.Id, _workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
+ var productTagsCacheKey = string.Format(CacheKeyConst.PRODUCTTAG_BY_PRODUCT_MODEL_KEY, product.Id,
+ _workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
return await _cacheBase.GetAsync(productTagsCacheKey, async () =>
{
var tags = new List<ProductTagModel>();
@@ -539,78 +566,98 @@ namespace Grand.Web.Features.Handlers.Products
var tag = await _productTagService.GetProductTagByName(item);
if (tag != null)
{
- tags.Add(new ProductTagModel() {
+ tags.Add(new ProductTagModel {
Id = tag.Id,
Name = tag.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id),
SeName = tag.SeName,
- ProductCount = await _productTagService.GetProductCount(tag.Id, _workContext.CurrentStore.Id)
+ ProductCount =
+ await _productTagService.GetProductCount(tag.Id, _workContext.CurrentStore.Id)
});
}
}
+
return tags;
});
}
- private async Task<(PictureModel defaultPictureModel, List<PictureModel> pictureModels)> PrepareProductPictureModel(Product product, int defaultPictureSize, bool isAssociatedProduct, string name)
+ private async Task<(PictureModel defaultPictureModel, List<PictureModel> pictureModels)>
+ PrepareProductPictureModel(Product product, int defaultPictureSize, bool isAssociatedProduct, string name)
{
- var defaultPicture = product.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault();
- if (defaultPicture == null)
- defaultPicture = new ProductPicture();
+ var defaultPicture = product.ProductPictures.MinBy(x => x.DisplayOrder) ?? new ProductPicture();
var picture = await _pictureService.GetPictureById(defaultPicture.PictureId);
var defaultPictureModel = new PictureModel {
Id = defaultPicture.PictureId,
- ImageUrl = await _pictureService.GetPictureUrl(defaultPicture.PictureId, defaultPictureSize, !isAssociatedProduct),
- FullSizeImageUrl = await _pictureService.GetPictureUrl(defaultPicture.PictureId, 0, !isAssociatedProduct),
+ ImageUrl = await _pictureService.GetPictureUrl(defaultPicture.PictureId, defaultPictureSize,
+ !isAssociatedProduct),
+ FullSizeImageUrl =
+ await _pictureService.GetPictureUrl(defaultPicture.PictureId, 0, !isAssociatedProduct),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title =
+ picture != null &&
+ !string.IsNullOrEmpty(
+ picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"),
+ name),
+ //"alt" attribute
+ AlternateText =
+ picture != null &&
+ !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(
+ _translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), name)
};
- //"title" attribute
- defaultPictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), name);
- //"alt" attribute
- defaultPictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), name);
//all pictures
var pictureModels = new List<PictureModel>();
foreach (var productPicture in product.ProductPictures.OrderBy(x => x.DisplayOrder))
{
picture = await _pictureService.GetPictureById(productPicture.PictureId);
- if (picture != null)
- {
- var pictureModel = new PictureModel {
- Id = productPicture.PictureId,
- ThumbImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId, _mediaSettings.ProductThumbPictureSizeOnProductDetailsPage),
- ImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId, _mediaSettings.ProductDetailsPictureSize),
- FullSizeImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId),
- Style = picture?.Style,
- ExtraField = picture?.ExtraField
- };
+ if (picture == null) continue;
+
+ var pictureModel = new PictureModel {
+ Id = productPicture.PictureId,
+ ThumbImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId,
+ _mediaSettings.ProductThumbPictureSizeOnProductDetailsPage),
+ ImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId,
+ _mediaSettings.ProductDetailsPictureSize),
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId),
+ Style = picture.Style,
+ ExtraField = picture.ExtraField,
//"title" attribute
- pictureModel.Title = !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)) ?
- picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), name);
+ Title =
+ !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute,
+ _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(
+ _translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"),
+ name),
//"alt" attribute
- pictureModel.AlternateText = !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)) ?
- picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), name);
+ AlternateText =
+ !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute,
+ _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(
+ _translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"),
+ name)
+ };
- pictureModels.Add(pictureModel);
- }
+ pictureModels.Add(pictureModel);
}
- return (defaultPictureModel, pictureModels);
+ return (defaultPictureModel, pictureModels);
}
private async Task<ProductDetailsModel.ProductPriceModel> PrepareProductPriceModel(Product product)
{
var displayPrices = await _permissionService.Authorize(StandardPermission.DisplayPrices);
- var model = new ProductDetailsModel.ProductPriceModel();
- model.ProductId = product.Id;
+ var model = new ProductDetailsModel.ProductPriceModel {
+ ProductId = product.Id
+ };
if (displayPrices)
{
model.HidePrices = false;
@@ -627,12 +674,18 @@ namespace Grand.Web.Features.Handlers.Products
else
{
var oldproductprice = await _taxService.GetProductPrice(product, product.OldPrice);
- double oldPriceBase = oldproductprice.productprice;
- double finalPriceWithoutDiscount = (await (_taxService.GetProductPrice(product, (await _pricingService.GetFinalPrice(product, _workContext.CurrentCustomer, _workContext.WorkingCurrency, includeDiscounts: false)).finalPrice))).productprice;
-
- var appliedPrice = (await _pricingService.GetFinalPrice(product, _workContext.CurrentCustomer, _workContext.WorkingCurrency, includeDiscounts: true));
- double finalPriceWithDiscount = (await _taxService.GetProductPrice(product, appliedPrice.finalPrice)).productprice;
- double oldPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, _workContext.WorkingCurrency);
+ var oldPriceBase = oldproductprice.productprice;
+ var finalPriceWithoutDiscount = (await _taxService.GetProductPrice(product,
+ (await _pricingService.GetFinalPrice(product, _workContext.CurrentCustomer,
+ _workContext.WorkingCurrency, includeDiscounts: false)).finalPrice)).productprice;
+
+ var appliedPrice = await _pricingService.GetFinalPrice(product, _workContext.CurrentCustomer,
+ _workContext.WorkingCurrency, includeDiscounts: true);
+ var finalPriceWithDiscount =
+ (await _taxService.GetProductPrice(product, appliedPrice.finalPrice)).productprice;
+ var oldPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase,
+ _workContext.WorkingCurrency);
if (finalPriceWithoutDiscount != oldPrice && oldPrice > 0)
model.OldPrice = _priceFormatter.FormatPrice(oldPrice);
@@ -645,7 +698,9 @@ namespace Grand.Web.Features.Handlers.Products
if (product.CatalogPrice > 0)
{
- var catalogPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice, _workContext.WorkingCurrency);
+ var catalogPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice,
+ _workContext.WorkingCurrency);
model.CatalogPrice = _priceFormatter.FormatPrice(catalogPrice);
}
@@ -655,7 +710,10 @@ namespace Grand.Web.Features.Handlers.Products
model.PriceValue = finalPriceWithDiscount;
if (product.BasepriceEnabled)
- model.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice() { Currency = _workContext.WorkingCurrency, Product = product, ProductPrice = finalPriceWithDiscount });
+ model.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice {
+ Currency = _workContext.WorkingCurrency, Product = product,
+ ProductPrice = finalPriceWithDiscount
+ });
//currency code
model.CurrencyCode = _workContext.WorkingCurrency.CurrencyCode;
@@ -667,18 +725,21 @@ namespace Grand.Web.Features.Handlers.Products
var priceStr = _priceFormatter.FormatPrice(finalPriceWithDiscount);
model.ReservationPrice = _priceFormatter.FormatReservationProductPeriod(product, priceStr);
}
+
+ if (product.ProductTypeId != ProductType.Auction) return model;
//auction
- if (product.ProductTypeId == ProductType.Auction)
- {
- model.IsAuction = true;
- double highestBid = await _currencyService.ConvertFromPrimaryStoreCurrency(product.HighestBid, _workContext.WorkingCurrency);
- model.HighestBid = _priceFormatter.FormatPrice(highestBid);
- model.HighestBidValue = highestBid;
- model.DisableBuyButton = product.DisableBuyButton;
- double startPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.StartPrice, _workContext.WorkingCurrency);
- model.StartPrice = _priceFormatter.FormatPrice(startPrice);
- model.StartPriceValue = startPrice;
- }
+ model.IsAuction = true;
+ var highestBid =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.HighestBid,
+ _workContext.WorkingCurrency);
+ model.HighestBid = _priceFormatter.FormatPrice(highestBid);
+ model.HighestBidValue = highestBid;
+ model.DisableBuyButton = product.DisableBuyButton;
+ var startPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.StartPrice,
+ _workContext.WorkingCurrency);
+ model.StartPrice = _priceFormatter.FormatPrice(startPrice);
+ model.StartPriceValue = startPrice;
}
}
}
@@ -689,13 +750,16 @@ namespace Grand.Web.Features.Handlers.Products
model.CatalogPrice = null;
model.Price = null;
}
+
return model;
}
- private async Task<ProductDetailsModel.AddToCartModel> PrepareAddToCartModel(Product product, ShoppingCartItem updatecartitem = null)
+ private async Task<ProductDetailsModel.AddToCartModel> PrepareAddToCartModel(Product product,
+ ShoppingCartItem updatecartitem = null)
{
- var model = new ProductDetailsModel.AddToCartModel();
- model.ProductId = product.Id;
+ var model = new ProductDetailsModel.AddToCartModel {
+ ProductId = product.Id
+ };
if (updatecartitem != null)
{
model.UpdatedShoppingCartItemId = updatecartitem.Id;
@@ -703,8 +767,10 @@ namespace Grand.Web.Features.Handlers.Products
}
//quantity
- model.EnteredQuantity = updatecartitem != null ? updatecartitem.Quantity : product.OrderMinimumQuantity;
- model.MeasureUnit = !string.IsNullOrEmpty(product.UnitId) ? (await _measureService.GetMeasureUnitById(product.UnitId)).Name : string.Empty;
+ model.EnteredQuantity = updatecartitem?.Quantity ?? product.OrderMinimumQuantity;
+ model.MeasureUnit = !string.IsNullOrEmpty(product.UnitId)
+ ? (await _measureService.GetMeasureUnitById(product.UnitId)).Name
+ : string.Empty;
//allowed quantities
var allowedQuantities = product.ParseAllowedQuantities();
@@ -716,73 +782,88 @@ namespace Grand.Web.Features.Handlers.Products
Selected = updatecartitem != null && updatecartitem.Quantity == qty
});
}
+
//minimum quantity notification
if (product.OrderMinimumQuantity > 1)
{
- model.MinimumQuantityNotification = string.Format(_translationService.GetResource("Products.MinimumQuantityNotification"), product.OrderMinimumQuantity);
+ model.MinimumQuantityNotification = string.Format(
+ _translationService.GetResource("Products.MinimumQuantityNotification"),
+ product.OrderMinimumQuantity);
}
+
//'add to cart', 'add to wishlist' buttons
- model.DisableBuyButton = product.DisableBuyButton || !await _permissionService.Authorize(StandardPermission.EnableShoppingCart);
- model.DisableWishlistButton = product.DisableWishlistButton || !await _permissionService.Authorize(StandardPermission.EnableWishlist);
+ model.DisableBuyButton = product.DisableBuyButton ||
+ !await _permissionService.Authorize(StandardPermission.EnableShoppingCart);
+ model.DisableWishlistButton = product.DisableWishlistButton ||
+ !await _permissionService.Authorize(StandardPermission.EnableWishlist);
if (!await _permissionService.Authorize(StandardPermission.DisplayPrices))
{
model.DisableBuyButton = true;
model.DisableWishlistButton = true;
}
+
//pre-order
if (product.AvailableForPreOrder)
{
model.AvailableForPreOrder = !product.PreOrderDateTimeUtc.HasValue ||
- product.PreOrderDateTimeUtc.Value >= DateTime.UtcNow;
+ product.PreOrderDateTimeUtc.Value >= DateTime.UtcNow;
model.PreOrderDateTimeUtc = product.PreOrderDateTimeUtc;
}
//customer entered price
model.EnteredPrice = product.EnteredPrice;
- if (model.EnteredPrice)
- {
- double minimumCustomerEnteredPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.MinEnteredPrice, _workContext.WorkingCurrency);
- double maximumCustomerEnteredPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.MaxEnteredPrice, _workContext.WorkingCurrency);
+ if (!model.EnteredPrice) return model;
+ var minimumCustomerEnteredPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.MinEnteredPrice,
+ _workContext.WorkingCurrency);
+ var maximumCustomerEnteredPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.MaxEnteredPrice,
+ _workContext.WorkingCurrency);
+
+ model.CustomerEnteredPrice = updatecartitem is { EnteredPrice: { } }
+ ? updatecartitem.EnteredPrice.Value
+ : minimumCustomerEnteredPrice;
+ model.CustomerEnteredPriceRange = string.Format(
+ _translationService.GetResource("Products.EnterProductPrice.Range"),
+ _priceFormatter.FormatPrice(minimumCustomerEnteredPrice, false),
+ _priceFormatter.FormatPrice(maximumCustomerEnteredPrice, false));
- model.CustomerEnteredPrice = updatecartitem != null && updatecartitem.EnteredPrice.HasValue ? updatecartitem.EnteredPrice.Value : minimumCustomerEnteredPrice;
- model.CustomerEnteredPriceRange = string.Format(_translationService.GetResource("Products.EnterProductPrice.Range"),
- _priceFormatter.FormatPrice(minimumCustomerEnteredPrice, false),
- _priceFormatter.FormatPrice(maximumCustomerEnteredPrice, false));
- }
return model;
}
- private ProductDetailsModel.GiftVoucherModel PrepareGiftVoucherModel(Product product, ShoppingCartItem updatecartitem = null)
+ private ProductDetailsModel.GiftVoucherModel PrepareGiftVoucherModel(Product product,
+ ShoppingCartItem updatecartitem = null)
{
- var model = new ProductDetailsModel.GiftVoucherModel();
- model.IsGiftVoucher = product.IsGiftVoucher;
- if (model.IsGiftVoucher)
- {
- model.GiftVoucherType = product.GiftVoucherTypeId;
+ var model = new ProductDetailsModel.GiftVoucherModel {
+ IsGiftVoucher = product.IsGiftVoucher
+ };
+ if (!model.IsGiftVoucher) return model;
- if (updatecartitem == null)
- {
- model.SenderName = _workContext.CurrentCustomer.GetFullName();
- model.SenderEmail = _workContext.CurrentCustomer.Email;
- }
- else
- {
- string giftVoucherRecipientName, giftVoucherRecipientEmail, giftVoucherSenderName, giftVoucherSenderEmail, giftVoucherMessage;
- GiftVoucherExtensions.GetGiftVoucherAttribute(updatecartitem.Attributes,
- out giftVoucherRecipientName, out giftVoucherRecipientEmail,
- out giftVoucherSenderName, out giftVoucherSenderEmail, out giftVoucherMessage);
-
- model.RecipientName = giftVoucherRecipientName;
- model.RecipientEmail = giftVoucherRecipientEmail;
- model.SenderName = giftVoucherSenderName;
- model.SenderEmail = giftVoucherSenderEmail;
- model.Message = giftVoucherMessage;
- }
+ model.GiftVoucherType = product.GiftVoucherTypeId;
+
+ if (updatecartitem == null)
+ {
+ model.SenderName = _workContext.CurrentCustomer.GetFullName();
+ model.SenderEmail = _workContext.CurrentCustomer.Email;
}
+ else
+ {
+ GiftVoucherExtensions.GetGiftVoucherAttribute(updatecartitem.Attributes,
+ out var giftVoucherRecipientName, out var giftVoucherRecipientEmail,
+ out var giftVoucherSenderName, out var giftVoucherSenderEmail, out var giftVoucherMessage);
+
+ model.RecipientName = giftVoucherRecipientName;
+ model.RecipientEmail = giftVoucherRecipientEmail;
+ model.SenderName = giftVoucherSenderName;
+ model.SenderEmail = giftVoucherSenderEmail;
+ model.Message = giftVoucherMessage;
+ }
+
return model;
}
- private async Task<IList<ProductDetailsModel.ProductAttributeModel>> PrepareProductAttributeModel(Product product, int defaultPictureSize, ShoppingCartItem updatecartitem = null)
+ private async Task<IList<ProductDetailsModel.ProductAttributeModel>> PrepareProductAttributeModel(
+ Product product, int defaultPictureSize, ShoppingCartItem updatecartitem = null)
{
var model = new List<ProductDetailsModel.ProductAttributeModel>();
@@ -792,7 +873,8 @@ namespace Grand.Web.Features.Handlers.Products
foreach (var attribute in productAttributeMapping.OrderBy(x => x.DisplayOrder))
{
- var productAttribute = await _productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
+ var productAttribute =
+ await _productAttributeService.GetProductAttributeById(attribute.ProductAttributeId);
if (productAttribute == null)
continue;
@@ -815,7 +897,9 @@ namespace Grand.Web.Features.Handlers.Products
.ToList();
}
- var urlselectedValues = !string.IsNullOrEmpty(productAttribute.SeName) ? _httpContextAccessor.HttpContext.Request.Query[productAttribute.SeName].ToList() : new List<string>();
+ var urlselectedValues = !string.IsNullOrEmpty(productAttribute.SeName)
+ ? _httpContextAccessor.HttpContext.Request.Query[productAttribute.SeName].ToList()
+ : new List<string>();
if (attribute.ShouldHaveValues())
{
@@ -833,15 +917,18 @@ namespace Grand.Web.Features.Handlers.Products
&& product.ProductAttributeCombinations.Any()
&& product.ProductAttributeMappings.Count == 1)
{
- var customattributes = Domain.Catalog.ProductExtensions.AddProductAttribute(null, attribute, attributeValue.Id);
- stockAvailability = _stockQuantityService.FormatStockMessage(product, string.Empty, customattributes);
+ var customattributes =
+ ProductExtensions.AddProductAttribute(null, attribute, attributeValue.Id);
+ stockAvailability =
+ _stockQuantityService.FormatStockMessage(product, string.Empty, customattributes);
}
+
var valueModel = new ProductDetailsModel.ProductAttributeValueModel {
Id = attributeValue.Id,
Name = attributeValue.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
ColorSquaresRgb = attributeValue.ColorSquaresRgb, //used with "Color squares" attribute type
IsPreSelected = preselected,
- StockAvailability = stockAvailability,
+ StockAvailability = stockAvailability
};
attributeModel.Values.Add(valueModel);
@@ -849,13 +936,16 @@ namespace Grand.Web.Features.Handlers.Products
var displayPrices = await _permissionService.Authorize(StandardPermission.DisplayPrices);
if (displayPrices)
{
- double attributeValuePriceAdjustment = await _pricingService.GetProductAttributeValuePriceAdjustment(attributeValue);
- var productprice = await _taxService.GetProductPrice(product, attributeValuePriceAdjustment);
- double taxRate = productprice.taxRate;
+ var attributeValuePriceAdjustment =
+ await _pricingService.GetProductAttributeValuePriceAdjustment(attributeValue);
+ var productprice =
+ await _taxService.GetProductPrice(product, attributeValuePriceAdjustment);
if (productprice.productprice > 0)
- valueModel.PriceAdjustment = "+" + _priceFormatter.FormatPrice(productprice.productprice, false);
+ valueModel.PriceAdjustment =
+ "+" + _priceFormatter.FormatPrice(productprice.productprice, false);
else if (productprice.productprice < 0)
- valueModel.PriceAdjustment = "-" + _priceFormatter.FormatPrice(-productprice.productprice, false);
+ valueModel.PriceAdjustment =
+ "-" + _priceFormatter.FormatPrice(-productprice.productprice, false);
valueModel.PriceAdjustmentValue = productprice.productprice;
}
@@ -868,27 +958,30 @@ namespace Grand.Web.Features.Handlers.Products
{
pm = new PictureModel {
Id = attributeValue.ImageSquaresPictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(attributeValue.ImageSquaresPictureId),
- ImageUrl = await _pictureService.GetPictureUrl(attributeValue.ImageSquaresPictureId, _mediaSettings.ImageSquarePictureSize)
+ FullSizeImageUrl =
+ await _pictureService.GetPictureUrl(attributeValue.ImageSquaresPictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(attributeValue.ImageSquaresPictureId,
+ _mediaSettings.ImageSquarePictureSize)
};
}
+
valueModel.ImageSquaresPictureModel = pm;
}
+ if (string.IsNullOrEmpty(attributeValue.PictureId)) continue;
+
//picture of a product attribute value
- if (!string.IsNullOrEmpty(attributeValue.PictureId))
+ var pAttributeModel = new PictureModel();
+ if (attributeValue.PictureId != null)
{
- var pm = new PictureModel();
- if (attributeValue.PictureId != null)
- {
- pm = new PictureModel {
- Id = attributeValue.PictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(attributeValue.PictureId),
- ImageUrl = await _pictureService.GetPictureUrl(attributeValue.PictureId, defaultPictureSize)
- };
- }
- valueModel.PictureModel = pm;
+ pAttributeModel = new PictureModel {
+ Id = attributeValue.PictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(attributeValue.PictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(attributeValue.PictureId,
+ defaultPictureSize)
+ };
}
+ valueModel.PictureModel = pAttributeModel;
}
}
@@ -902,79 +995,77 @@ namespace Grand.Web.Features.Handlers.Products
case AttributeControlType.Checkboxes:
case AttributeControlType.ColorSquares:
case AttributeControlType.ImageSquares:
+ {
+ if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
{
- if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
- {
- //clear default selection
- foreach (var item in attributeModel.Values)
- item.IsPreSelected = false;
-
- //select new values
- var selectedValues = product.ParseProductAttributeValues(updatecartitem.Attributes);
- foreach (var attributeValue in selectedValues)
- foreach (var item in attributeModel.Values)
- if (attributeValue.Id == item.Id)
- item.IsPreSelected = true;
-
- }
+ //clear default selection
+ foreach (var item in attributeModel.Values)
+ item.IsPreSelected = false;
+
+ //select new values
+ var selectedValues = product.ParseProductAttributeValues(updatecartitem.Attributes);
+ foreach (var attributeValue in selectedValues)
+ foreach (var item in attributeModel.Values)
+ if (attributeValue.Id == item.Id)
+ item.IsPreSelected = true;
}
+ }
break;
case AttributeControlType.ReadonlyCheckboxes:
- {
- //do nothing
- //values are already pre-set
- }
+ {
+ //do nothing
+ //values are already pre-set
+ }
break;
case AttributeControlType.TextBox:
case AttributeControlType.MultilineTextbox:
+ {
+ if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
{
- if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
- {
- var enteredText = Domain.Catalog.ProductExtensions.ParseValues(updatecartitem.Attributes, attribute.Id);
- if (enteredText.Any())
- attributeModel.DefaultValue = enteredText[0];
- }
+ var enteredText =
+ ProductExtensions.ParseValues(updatecartitem.Attributes, attribute.Id);
+ if (enteredText.Any())
+ attributeModel.DefaultValue = enteredText[0];
}
+ }
break;
case AttributeControlType.Datepicker:
+ {
+ //keep in mind my that the code below works only in the current culture
+ var selectedDateStr =
+ ProductExtensions.ParseValues(updatecartitem.Attributes, attribute.Id);
+ if (selectedDateStr.Any())
{
- //keep in mind my that the code below works only in the current culture
- var selectedDateStr = Domain.Catalog.ProductExtensions.ParseValues(updatecartitem.Attributes, attribute.Id);
- if (selectedDateStr.Any())
+ if (DateTime.TryParseExact(selectedDateStr[0], "D", CultureInfo.CurrentCulture,
+ DateTimeStyles.None, out var selectedDate))
{
- DateTime selectedDate;
- if (DateTime.TryParseExact(selectedDateStr[0], "D", CultureInfo.CurrentCulture,
- DateTimeStyles.None, out selectedDate))
- {
- //successfully parsed
- attributeModel.SelectedDay = selectedDate.Day;
- attributeModel.SelectedMonth = selectedDate.Month;
- attributeModel.SelectedYear = selectedDate.Year;
- }
+ //successfully parsed
+ attributeModel.SelectedDay = selectedDate.Day;
+ attributeModel.SelectedMonth = selectedDate.Month;
+ attributeModel.SelectedYear = selectedDate.Year;
}
-
}
+ }
break;
case AttributeControlType.FileUpload:
+ {
+ if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
{
- if (updatecartitem.Attributes != null && updatecartitem.Attributes.Any())
- {
- var downloadGuidStr = Domain.Catalog.ProductExtensions.ParseValues(updatecartitem.Attributes, attribute.Id).FirstOrDefault();
- Guid downloadGuid;
- Guid.TryParse(downloadGuidStr, out downloadGuid);
- var download = await _downloadService.GetDownloadByGuid(downloadGuid);
- if (download != null)
- attributeModel.DefaultValue = download.DownloadGuid.ToString();
- }
+ var downloadGuidStr = ProductExtensions
+ .ParseValues(updatecartitem.Attributes, attribute.Id).FirstOrDefault();
+ Guid.TryParse(downloadGuidStr, out var downloadGuid);
+ var download = await _downloadService.GetDownloadByGuid(downloadGuid);
+ if (download != null)
+ attributeModel.DefaultValue = download.DownloadGuid.ToString();
}
- break;
- default:
+ }
break;
}
}
model.Add(attributeModel);
}
+
return model;
}
@@ -982,24 +1073,26 @@ namespace Grand.Web.Features.Handlers.Products
{
var model = new List<ProductDetailsModel.TierPriceModel>();
foreach (var tierPrice in product.TierPrices.OrderBy(x => x.Quantity)
- .FilterByStore(_workContext.CurrentStore.Id)
- .FilterByCurrency(_workContext.WorkingCurrency.CurrencyCode)
- .FilterForCustomer(_workContext.CurrentCustomer)
- .FilterByDate()
- .RemoveDuplicatedQuantities())
+ .FilterByStore(_workContext.CurrentStore.Id)
+ .FilterByCurrency(_workContext.WorkingCurrency.CurrencyCode)
+ .FilterForCustomer(_workContext.CurrentCustomer)
+ .FilterByDate()
+ .RemoveDuplicatedQuantities())
{
var tier = new ProductDetailsModel.TierPriceModel();
var priceBase = await _taxService.GetProductPrice(product, (await _pricingService.GetFinalPrice(product,
- _workContext.CurrentCustomer, _workContext.WorkingCurrency,
- 0, _catalogSettings.DisplayTierPricesWithDiscounts, tierPrice.Quantity)).finalPrice);
+ _workContext.CurrentCustomer, _workContext.WorkingCurrency,
+ 0, _catalogSettings.DisplayTierPricesWithDiscounts, tierPrice.Quantity)).finalPrice);
tier.Quantity = tierPrice.Quantity;
tier.Price = _priceFormatter.FormatPrice(priceBase.productprice, false);
model.Add(tier);
}
+
return model;
}
- private async Task PrepareProductReservation(ProductDetailsModel model, Product product, ShoppingCartItem updateCartItem)
+ private async Task PrepareProductReservation(ProductDetailsModel model, Product product,
+ ShoppingCartItem updateCartItem)
{
if (product.ProductTypeId == ProductType.Reservation)
{
@@ -1010,8 +1103,10 @@ namespace Grand.Web.Features.Handlers.Products
if (updateCartItem == null)
{
- var reservations = await _productReservationService.GetProductReservationsByProductId(product.Id, true, null);
- var inCart = _workContext.CurrentCustomer.ShoppingCartItems.Where(x => !string.IsNullOrEmpty(x.ReservationId)).ToList();
+ var reservations =
+ await _productReservationService.GetProductReservationsByProductId(product.Id, true, null);
+ var inCart = _workContext.CurrentCustomer.ShoppingCartItems
+ .Where(x => !string.IsNullOrEmpty(x.ReservationId)).ToList();
foreach (var cartItem in inCart)
{
var matching = reservations.Where(x => x.Id == cartItem.ReservationId);
@@ -1023,16 +1118,10 @@ namespace Grand.Web.Features.Handlers.Products
if (reservations.Any())
{
- var first = reservations.Where(x => x.Date >= DateTime.UtcNow).OrderBy(x => x.Date).FirstOrDefault();
- if (first != null)
- {
- model.StartDate = first.Date;
- }
- else
- {
- model.StartDate = DateTime.UtcNow;
- }
+ var first = reservations.Where(x => x.Date >= DateTime.UtcNow).MinBy(x => x.Date);
+ model.StartDate = first?.Date ?? DateTime.UtcNow;
}
+
var list = reservations.GroupBy(x => x.Parameter).ToList().Select(x => x.Key);
foreach (var item in list)
{
@@ -1056,7 +1145,8 @@ namespace Grand.Web.Features.Handlers.Products
}
}
- private async Task<IList<ProductDetailsModel.ProductBundleModel>> PrepareProductBundleModel(Product product, ShoppingCartItem updateCartItem)
+ private async Task<IList<ProductDetailsModel.ProductBundleModel>> PrepareProductBundleModel(Product product,
+ ShoppingCartItem updateCartItem)
{
var model = new List<ProductDetailsModel.ProductBundleModel>();
var displayPrices = await _permissionService.Authorize(StandardPermission.DisplayPrices);
@@ -1064,58 +1154,61 @@ namespace Grand.Web.Features.Handlers.Products
foreach (var bundle in product.BundleProducts.OrderBy(x => x.DisplayOrder))
{
var p1 = await _productService.GetProductById(bundle.ProductId);
- if (p1 != null && p1.Published && p1.IsAvailable())
+ if (p1 is not { Published: true } || !p1.IsAvailable()) continue;
+
+ var bundleProduct = new ProductDetailsModel.ProductBundleModel {
+ ProductId = p1.Id,
+ Name = p1.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ ShortDescription = p1.GetTranslation(x => x.ShortDescription, _workContext.WorkingLanguage.Id),
+ SeName = p1.GetSeName(_workContext.WorkingLanguage.Id),
+ Sku = p1.Sku,
+ Mpn = p1.Mpn,
+ Gtin = p1.Gtin,
+ Quantity = bundle.Quantity,
+ UserFields = p1.UserFields
+ };
+ if (displayPrices)
{
- var bundleProduct = new ProductDetailsModel.ProductBundleModel() {
- ProductId = p1.Id,
- Name = p1.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
- ShortDescription = p1.GetTranslation(x => x.ShortDescription, _workContext.WorkingLanguage.Id),
- SeName = p1.GetSeName(_workContext.WorkingLanguage.Id),
- Sku = p1.Sku,
- Mpn = p1.Mpn,
- Gtin = p1.Gtin,
- Quantity = bundle.Quantity,
- UserFields = p1.UserFields
- };
- if (displayPrices)
- {
- var productprice = await _taxService.GetProductPrice(p1, (await _pricingService.GetFinalPrice(p1, _workContext.CurrentCustomer, _workContext.WorkingCurrency, includeDiscounts: true)).finalPrice);
- double taxRateBundle = productprice.taxRate;
- double finalPriceWithDiscountBase = productprice.productprice;
- bundleProduct.Price = _priceFormatter.FormatPrice(productprice.productprice);
- bundleProduct.PriceValue = productprice.productprice;
- }
+ var productprice = await _taxService.GetProductPrice(p1,
+ (await _pricingService.GetFinalPrice(p1, _workContext.CurrentCustomer,
+ _workContext.WorkingCurrency, includeDiscounts: true)).finalPrice);
+ bundleProduct.Price = _priceFormatter.FormatPrice(productprice.productprice);
+ bundleProduct.PriceValue = productprice.productprice;
+ }
- var productPicture = p1.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault();
- if (productPicture == null)
- productPicture = new ProductPicture();
+ var productPicture = p1.ProductPictures.MinBy(x => x.DisplayOrder) ?? new ProductPicture();
- var picture = await _pictureService.GetPictureById(productPicture.PictureId);
+ var picture = await _pictureService.GetPictureById(productPicture.PictureId);
- var pictureModel = new PictureModel {
- Id = productPicture.PictureId,
- ImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId, _mediaSettings.ProductBundlePictureSize),
- FullSizeImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId),
- Style = picture?.Style,
- ExtraField = picture?.ExtraField
- };
+ var pictureModel = new PictureModel {
+ Id = productPicture.PictureId,
+ ImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId,
+ _mediaSettings.ProductBundlePictureSize),
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(productPicture.PictureId),
+ Style = picture?.Style,
+ ExtraField = picture?.ExtraField,
//"title" attribute
- pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.TitleAttribute)) ?
- picture.TitleAttribute :
- string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), p1.Name);
+ Title = picture != null && !string.IsNullOrEmpty(picture.TitleAttribute)
+ ? picture.TitleAttribute
+ : string.Format(
+ _translationService.GetResource("Media.Product.ImageLinkTitleFormat.Details"), p1.Name),
//"alt" attribute
- pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.AltAttribute)) ?
- picture.AltAttribute :
- string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"), p1.Name);
+ AlternateText = picture != null && !string.IsNullOrEmpty(picture.AltAttribute)
+ ? picture.AltAttribute
+ : string.Format(
+ _translationService.GetResource("Media.Product.ImageAlternateTextFormat.Details"),
+ p1.Name)
+ };
- bundleProduct.DefaultPictureModel = pictureModel;
+ bundleProduct.DefaultPictureModel = pictureModel;
- bundleProduct.ProductAttributes = await PrepareProductAttributeModel(p1, _mediaSettings.ProductBundlePictureSize, updateCartItem);
+ bundleProduct.ProductAttributes = await PrepareProductAttributeModel(p1,
+ _mediaSettings.ProductBundlePictureSize, updateCartItem);
- model.Add(bundleProduct);
- }
+ model.Add(bundleProduct);
}
+
return model;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductLayoutViewPathHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductLayoutViewPathHandler.cs
index f494d0f8d..e7363c150 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductLayoutViewPathHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductLayoutViewPathHandler.cs
@@ -16,11 +16,9 @@ namespace Grand.Web.Features.Handlers.Products
public async Task<string> Handle(GetProductLayoutViewPath request, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(request.ProductLayoutId))
- throw new ArgumentNullException("ProductLayoutId");
+ throw new ArgumentNullException(nameof(request.ProductLayoutId));
- var layout = await _productLayoutService.GetProductLayoutById(request.ProductLayoutId);
- if (layout == null)
- layout = (await _productLayoutService.GetAllProductLayouts()).FirstOrDefault();
+ var layout = await _productLayoutService.GetProductLayoutById(request.ProductLayoutId) ?? (await _productLayoutService.GetAllProductLayouts()).FirstOrDefault();
if (layout == null)
throw new Exception("No default layout could be loaded");
return layout.ViewPath;
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
index 874b7b507..d8e9efa26 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductOverviewHandler.cs
@@ -1,25 +1,25 @@
using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Brands;
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Storage;
-using Grand.Infrastructure;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Media;
using Grand.Domain.Tax;
+using Grand.Infrastructure;
using Grand.Web.Features.Models.Catalog;
using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
using Grand.Web.Models.Media;
using MediatR;
-using System.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Grand.Business.Core.Interfaces.Catalog.Brands;
+using System.Diagnostics;
namespace Grand.Web.Features.Handlers.Products
{
@@ -78,45 +78,62 @@ namespace Grand.Web.Features.Handlers.Products
_catalogSettings = catalogSettings;
}
- public async Task<IEnumerable<ProductOverviewModel>> Handle(GetProductOverview request, CancellationToken cancellationToken)
+ public async Task<IEnumerable<ProductOverviewModel>> Handle(GetProductOverview request,
+ CancellationToken cancellationToken)
{
if (request.Products == null)
throw new ArgumentNullException(nameof(request.Products));
- var displayPrices = await _permissionService.Authorize(StandardPermission.DisplayPrices, _workContext.CurrentCustomer);
- var enableShoppingCart = await _permissionService.Authorize(StandardPermission.EnableShoppingCart, _workContext.CurrentCustomer);
- var enableWishlist = await _permissionService.Authorize(StandardPermission.EnableWishlist, _workContext.CurrentCustomer);
- int pictureSize = request.ProductThumbPictureSize.HasValue ? request.ProductThumbPictureSize.Value : _mediaSettings.ProductThumbPictureSize;
- bool priceIncludesTax = _workContext.TaxDisplayType == TaxDisplayType.IncludingTax;
+ var displayPrices =
+ await _permissionService.Authorize(StandardPermission.DisplayPrices, _workContext.CurrentCustomer);
+ var enableShoppingCart =
+ await _permissionService.Authorize(StandardPermission.EnableShoppingCart, _workContext.CurrentCustomer);
+ var enableWishlist =
+ await _permissionService.Authorize(StandardPermission.EnableWishlist, _workContext.CurrentCustomer);
+ var pictureSize = request.ProductThumbPictureSize ?? _mediaSettings.ProductThumbPictureSize;
+ var priceIncludesTax = _workContext.TaxDisplayType == TaxDisplayType.IncludingTax;
- var res = new Dictionary<string, string>
- {
- { "Products.CallForPrice", _translationService.GetResource("Products.CallForPrice", _workContext.WorkingLanguage.Id) },
- { "Products.PriceRangeFrom", _translationService.GetResource("Products.PriceRangeFrom", _workContext.WorkingLanguage.Id)},
- { "Media.Product.ImageLinkTitleFormat", _translationService.GetResource("Media.Product.ImageLinkTitleFormat", _workContext.WorkingLanguage.Id) },
- { "Media.Product.ImageAlternateTextFormat", _translationService.GetResource("Media.Product.ImageAlternateTextFormat", _workContext.WorkingLanguage.Id) }
+ var res = new Dictionary<string, string> {
+ {
+ "Products.CallForPrice",
+ _translationService.GetResource("Products.CallForPrice", _workContext.WorkingLanguage.Id)
+ }, {
+ "Products.PriceRangeFrom",
+ _translationService.GetResource("Products.PriceRangeFrom", _workContext.WorkingLanguage.Id)
+ }, {
+ "Media.Product.ImageLinkTitleFormat",
+ _translationService.GetResource("Media.Product.ImageLinkTitleFormat",
+ _workContext.WorkingLanguage.Id)
+ }, {
+ "Media.Product.ImageAlternateTextFormat",
+ _translationService.GetResource("Media.Product.ImageAlternateTextFormat",
+ _workContext.WorkingLanguage.Id)
+ }
};
var tasks = new List<Task<ProductOverviewModel>>();
foreach (var product in request.Products)
{
- tasks.Add(GetProductOverviewModel(product, request, displayPrices, enableShoppingCart, enableWishlist, pictureSize, priceIncludesTax, res));
+ tasks.Add(GetProductOverviewModel(product, request, displayPrices, enableShoppingCart, enableWishlist,
+ pictureSize, priceIncludesTax, res));
}
- var result = await Task.WhenAll<ProductOverviewModel>(tasks);
+
+ var result = await Task.WhenAll(tasks);
return result;
}
private async Task<ProductOverviewModel> GetProductOverviewModel(Product product, GetProductOverview request,
- bool displayPrices, bool enableShoppingCart, bool enableWishlist, int pictureSize, bool priceIncludesTax, Dictionary<string, string> res)
+ bool displayPrices, bool enableShoppingCart, bool enableWishlist, int pictureSize, bool priceIncludesTax,
+ Dictionary<string, string> res)
{
var model = await PrepareProductOverviewModel(product);
//price
if (request.PreparePriceModel)
{
model.ProductPrice = await PreparePriceModel(product, res, request.ForceRedirectionAfterAddingToCart,
- enableShoppingCart, displayPrices, enableWishlist, priceIncludesTax);
+ enableShoppingCart, displayPrices, enableWishlist, priceIncludesTax);
}
//picture
@@ -130,14 +147,16 @@ namespace Grand.Web.Features.Handlers.Products
//specs
if (request.PrepareSpecificationAttributes && product.ProductSpecificationAttributes.Any())
{
- model.SpecificationAttributeModels = await _mediator.Send(new GetProductSpecification() { Language = _workContext.WorkingLanguage, Product = product });
+ model.SpecificationAttributeModels = await _mediator.Send(new GetProductSpecification
+ { Language = _workContext.WorkingLanguage, Product = product });
}
//attributes
model.ProductAttributeModels = await PrepareAttributesModel(product);
//reviews
- model.ReviewOverviewModel = await _mediator.Send(new GetProductReviewOverview() { Product = product, Language = _workContext.WorkingLanguage, Store = _workContext.CurrentStore });
+ model.ReviewOverviewModel = await _mediator.Send(new GetProductReviewOverview
+ { Product = product, Language = _workContext.WorkingLanguage, Store = _workContext.CurrentStore });
return model;
}
@@ -151,265 +170,312 @@ namespace Grand.Web.Features.Handlers.Products
ShortDescription = product.GetTranslation(x => x.ShortDescription, _workContext.WorkingLanguage.Id),
FullDescription = product.GetTranslation(x => x.FullDescription, _workContext.WorkingLanguage.Id),
SeName = sename,
- Url = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
+ Url = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product",
+ new { SeName = sename }),
ProductType = product.ProductTypeId,
Sku = product.Sku,
Gtin = product.Gtin,
Flag = product.Flag,
Mpn = product.Mpn,
- BrandName = string.IsNullOrEmpty(product.BrandId) ? "" : (await _brandService.GetBrandById(product.BrandId))?.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ BrandName = string.IsNullOrEmpty(product.BrandId)
+ ? ""
+ : (await _brandService.GetBrandById(product.BrandId))?.GetTranslation(x => x.Name,
+ _workContext.WorkingLanguage.Id),
IsFreeShipping = product.IsFreeShipping,
LowStock = product.LowStock,
ShowSku = _catalogSettings.ShowSkuOnCatalogPages,
TaxDisplayType = _workContext.TaxDisplayType,
EndTime = product.AvailableEndDateTimeUtc,
- EndTimeLocalTime = product.AvailableEndDateTimeUtc.HasValue ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc) : new DateTime?(),
+ EndTimeLocalTime = product.AvailableEndDateTimeUtc.HasValue
+ ? _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc)
+ : new DateTime?(),
ShowQty = _catalogSettings.DisplayQuantityOnCatalogPages,
UserFields = product.UserFields,
MarkAsNew = product.MarkAsNew &&
- (!product.MarkAsNewStartDateTimeUtc.HasValue || product.MarkAsNewStartDateTimeUtc.Value < DateTime.UtcNow) &&
- (!product.MarkAsNewEndDateTimeUtc.HasValue || product.MarkAsNewEndDateTimeUtc.Value > DateTime.UtcNow)
+ (!product.MarkAsNewStartDateTimeUtc.HasValue ||
+ product.MarkAsNewStartDateTimeUtc.Value < DateTime.UtcNow) &&
+ (!product.MarkAsNewEndDateTimeUtc.HasValue ||
+ product.MarkAsNewEndDateTimeUtc.Value > DateTime.UtcNow)
};
return model;
}
- private async Task<ProductOverviewModel.ProductPriceModel> PreparePriceModel(Product product, Dictionary<string, string> res,
+ private async Task<ProductOverviewModel.ProductPriceModel> PreparePriceModel(Product product,
+ IReadOnlyDictionary<string, string> res,
bool forceRedirectionAfterAddingToCart, bool enableShoppingCart, bool displayPrices, bool enableWishlist,
bool priceIncludesTax)
{
#region Prepare product price
- var priceModel = new ProductOverviewModel.ProductPriceModel
- {
+ var priceModel = new ProductOverviewModel.ProductPriceModel {
ForceRedirectionAfterAddingToCart = forceRedirectionAfterAddingToCart
};
switch (product.ProductTypeId)
{
case ProductType.GroupedProduct:
- {
- #region Grouped product
+ {
+ #region Grouped product
- var associatedProducts = await _productService.GetAssociatedProducts(product.Id, _workContext.CurrentStore.Id);
+ var associatedProducts =
+ await _productService.GetAssociatedProducts(product.Id, _workContext.CurrentStore.Id);
- //add to cart button (ignore "DisableBuyButton" property for grouped products)
- priceModel.DisableBuyButton = !enableShoppingCart || !displayPrices;
+ //add to cart button (ignore "DisableBuyButton" property for grouped products)
+ priceModel.DisableBuyButton = !enableShoppingCart || !displayPrices;
- //add to wishlist button (ignore "DisableWishlistButton" property for grouped products)
- priceModel.DisableWishlistButton = !enableWishlist || !displayPrices;
+ //add to wishlist button (ignore "DisableWishlistButton" property for grouped products)
+ priceModel.DisableWishlistButton = !enableWishlist || !displayPrices;
- //compare products
- priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
+ //compare products
+ priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
- //catalog price, not used in views, but it's for front developer
- if (product.CatalogPrice > 0)
+ //catalog price, not used in views, but it's for front developer
+ if (product.CatalogPrice > 0)
+ {
+ var catalogPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice,
+ _workContext.WorkingCurrency);
+ priceModel.CatalogPrice = _priceFormatter.FormatPrice(catalogPrice,
+ _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
+ }
+
+ switch (associatedProducts.Count)
+ {
+ case 0:
{
- double catalogPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice, _workContext.WorkingCurrency);
- priceModel.CatalogPrice = _priceFormatter.FormatPrice(catalogPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
}
-
- switch (associatedProducts.Count)
+ break;
+ default:
{
- case 0:
+ //we have at least one associated product
+ //compare products
+ priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
+ if (displayPrices)
+ {
+ //find a minimum possible price
+ double? minPossiblePrice = null;
+ Product minPriceProduct = null;
+ foreach (var associatedProduct in associatedProducts)
{
-
+ //calculate for the maximum quantity (in case if we have tier prices)
+ var tmpPrice = (await _pricingService.GetFinalPrice(associatedProduct,
+ _workContext.CurrentCustomer, _workContext.WorkingCurrency, 0, true,
+ int.MaxValue)).finalPrice;
+ if (minPossiblePrice.HasValue && !(tmpPrice < minPossiblePrice.Value)) continue;
+ minPriceProduct = associatedProduct;
+ minPossiblePrice = tmpPrice;
}
- break;
- default:
+
+ if (minPriceProduct is { EnteredPrice: false })
{
- //we have at least one associated product
- //compare products
- priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
- if (displayPrices)
+ if (minPriceProduct.CallForPrice)
{
- //find a minimum possible price
- double? minPossiblePrice = null;
- Product minPriceProduct = null;
- foreach (var associatedProduct in associatedProducts)
- {
- //calculate for the maximum quantity (in case if we have tier prices)
- var tmpPrice = (await _pricingService.GetFinalPrice(associatedProduct,
- _workContext.CurrentCustomer, _workContext.WorkingCurrency, 0, true, int.MaxValue)).finalPrice;
- if (!minPossiblePrice.HasValue || tmpPrice < minPossiblePrice.Value)
- {
- minPriceProduct = associatedProduct;
- minPossiblePrice = tmpPrice;
- }
- }
- if (minPriceProduct != null && !minPriceProduct.EnteredPrice)
- {
- if (minPriceProduct.CallForPrice)
- {
- priceModel.OldPrice = null;
- priceModel.Price = res["Products.CallForPrice"];
- }
- else if (minPossiblePrice.HasValue)
- {
- //calculate prices
- double finalPrice = (await _taxService.GetProductPrice(minPriceProduct, minPossiblePrice.Value, priceIncludesTax, _workContext.CurrentCustomer)).productprice;
-
- priceModel.OldPrice = null;
- priceModel.Price = string.Format(res["Products.PriceRangeFrom"], _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax));
- priceModel.PriceValue = finalPrice;
-
- //PAngV baseprice (used in Germany)
- if (product.BasepriceEnabled)
- priceModel.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice() { Currency = _workContext.WorkingCurrency, Product = product, ProductPrice = finalPrice });
- }
- else
- {
- //Actually it's not possible (we presume that minimalPrice always has a value)
- //We never should get here
- Debug.WriteLine("Cannot calculate minPrice for product #{0}", product.Id);
- }
- }
+ priceModel.OldPrice = null;
+ priceModel.Price = res["Products.CallForPrice"];
}
- else
+ else if (minPossiblePrice.HasValue)
{
- //hide prices
+ //calculate prices
+ var finalPrice = (await _taxService.GetProductPrice(minPriceProduct,
+ minPossiblePrice.Value, priceIncludesTax, _workContext.CurrentCustomer))
+ .productprice;
+
priceModel.OldPrice = null;
- priceModel.Price = null;
+ priceModel.Price = string.Format(res["Products.PriceRangeFrom"],
+ _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency,
+ _workContext.WorkingLanguage, priceIncludesTax));
+ priceModel.PriceValue = finalPrice;
+
+ //PAngV base price (used in Germany)
+ if (product.BasepriceEnabled)
+ priceModel.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice {
+ Currency = _workContext.WorkingCurrency, Product = product,
+ ProductPrice = finalPrice
+ });
+ }
+ else
+ {
+ //Actually it's not possible (we presume that minimalPrice always has a value)
+ //We never should get here
+ Debug.WriteLine("Cannot calculate minPrice for product #{0}", product.Id);
}
}
- break;
+ }
+ else
+ {
+ //hide prices
+ priceModel.OldPrice = null;
+ priceModel.Price = null;
+ }
}
-
- #endregion
+ break;
}
+
+ #endregion
+ }
break;
case ProductType.SimpleProduct:
case ProductType.Reservation:
default:
- {
- #region Simple product
+ {
+ #region Simple product
- //add to cart button
- priceModel.DisableBuyButton = product.DisableBuyButton || !enableShoppingCart || !displayPrices;
+ //add to cart button
+ priceModel.DisableBuyButton = product.DisableBuyButton || !enableShoppingCart || !displayPrices;
- //add to wishlist button
- priceModel.DisableWishlistButton = product.DisableWishlistButton || !enableWishlist || !displayPrices;
- //compare products
- priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
+ //add to wishlist button
+ priceModel.DisableWishlistButton =
+ product.DisableWishlistButton || !enableWishlist || !displayPrices;
+ //compare products
+ priceModel.DisableAddToCompareListButton = !_catalogSettings.CompareProductsEnabled;
- //pre-order
- if (product.AvailableForPreOrder)
- {
- priceModel.AvailableForPreOrder = !product.PreOrderDateTimeUtc.HasValue ||
- product.PreOrderDateTimeUtc.Value >= DateTime.UtcNow;
- priceModel.PreOrderDateTimeUtc = product.PreOrderDateTimeUtc;
- }
+ //pre-order
+ if (product.AvailableForPreOrder)
+ {
+ priceModel.AvailableForPreOrder = !product.PreOrderDateTimeUtc.HasValue ||
+ product.PreOrderDateTimeUtc.Value >= DateTime.UtcNow;
+ priceModel.PreOrderDateTimeUtc = product.PreOrderDateTimeUtc;
+ }
- //catalog price, not used in views, but it's for front developer
- if (product.CatalogPrice > 0)
- {
- double catalogPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice, _workContext.WorkingCurrency);
- priceModel.CatalogPrice = _priceFormatter.FormatPrice(catalogPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- }
+ //catalog price, not used in views, but it's for front developer
+ if (product.CatalogPrice > 0)
+ {
+ var catalogPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.CatalogPrice,
+ _workContext.WorkingCurrency);
+ priceModel.CatalogPrice = _priceFormatter.FormatPrice(catalogPrice,
+ _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
+ }
- //start price for product auction
- if (product.StartPrice > 0)
- {
- double startPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(product.StartPrice, _workContext.WorkingCurrency);
- priceModel.StartPrice = _priceFormatter.FormatPrice(startPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- priceModel.StartPriceValue = startPrice;
- }
+ //start price for product auction
+ if (product.StartPrice > 0)
+ {
+ var startPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.StartPrice,
+ _workContext.WorkingCurrency);
+ priceModel.StartPrice = _priceFormatter.FormatPrice(startPrice, _workContext.WorkingCurrency,
+ _workContext.WorkingLanguage, priceIncludesTax);
+ priceModel.StartPriceValue = startPrice;
+ }
- //highest bid for product auction
- if (product.HighestBid > 0)
- {
- double highestBid = await _currencyService.ConvertFromPrimaryStoreCurrency(product.HighestBid, _workContext.WorkingCurrency);
- priceModel.HighestBid = _priceFormatter.FormatPrice(highestBid, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- priceModel.HighestBidValue = highestBid;
- }
+ //highest bid for product auction
+ if (product.HighestBid > 0)
+ {
+ var highestBid =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(product.HighestBid,
+ _workContext.WorkingCurrency);
+ priceModel.HighestBid = _priceFormatter.FormatPrice(highestBid, _workContext.WorkingCurrency,
+ _workContext.WorkingLanguage, priceIncludesTax);
+ priceModel.HighestBidValue = highestBid;
+ }
- //prices
- if (displayPrices)
+ //prices
+ if (displayPrices)
+ {
+ if (!product.EnteredPrice)
{
- if (!product.EnteredPrice)
+ if (product.CallForPrice)
{
- if (product.CallForPrice)
- {
- //call for price
- priceModel.OldPrice = null;
- priceModel.Price = res["Products.CallForPrice"];
- }
- else
- {
- //prices
+ //call for price
+ priceModel.OldPrice = null;
+ priceModel.Price = res["Products.CallForPrice"];
+ }
+ else
+ {
+ //prices
- //calculate for the maximum quantity (in case if we have tier prices)
- var infoprice = (await _pricingService.GetFinalPrice(product,
- _workContext.CurrentCustomer, _workContext.WorkingCurrency, 0, true, int.MaxValue));
+ //calculate for the maximum quantity (in case if we have tier prices)
+ var infoprice = await _pricingService.GetFinalPrice(product,
+ _workContext.CurrentCustomer, _workContext.WorkingCurrency, 0, true, int.MaxValue);
- priceModel.AppliedDiscounts = infoprice.appliedDiscounts;
- priceModel.PreferredTierPrice = infoprice.preferredTierPrice;
+ priceModel.AppliedDiscounts = infoprice.appliedDiscounts;
+ priceModel.PreferredTierPrice = infoprice.preferredTierPrice;
- double minPossiblePrice = infoprice.finalPrice;
+ var minPossiblePrice = infoprice.finalPrice;
- double oldPriceBase = (await _taxService.GetProductPrice(product, product.OldPrice, priceIncludesTax, _workContext.CurrentCustomer)).productprice;
- double finalPrice = (await _taxService.GetProductPrice(product, minPossiblePrice, priceIncludesTax, _workContext.CurrentCustomer)).productprice;
+ var oldPriceBase = (await _taxService.GetProductPrice(product, product.OldPrice,
+ priceIncludesTax, _workContext.CurrentCustomer)).productprice;
+ var finalPrice = (await _taxService.GetProductPrice(product, minPossiblePrice,
+ priceIncludesTax, _workContext.CurrentCustomer)).productprice;
- double oldPrice = await _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, _workContext.WorkingCurrency);
+ var oldPrice =
+ await _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase,
+ _workContext.WorkingCurrency);
- //do we have tier prices configured?
- var tierPrices = new List<TierPrice>();
- if (product.TierPrices.Any())
- {
- tierPrices.AddRange(product.TierPrices.OrderBy(tp => tp.Quantity)
- .FilterByStore(_workContext.CurrentStore.Id)
- .FilterByCurrency(_workContext.WorkingCurrency.CurrencyCode)
- .FilterForCustomer(_workContext.CurrentCustomer)
- .FilterByDate()
- .RemoveDuplicatedQuantities());
- }
- //When there is just one tier (with qty 1),
- //there are no actual savings in the list.
- bool displayFromMessage = tierPrices.Any() && !(tierPrices.Count == 1 && tierPrices[0].Quantity <= 1);
- if (displayFromMessage)
+ //do we have tier prices configured?
+ var tierPrices = new List<TierPrice>();
+ if (product.TierPrices.Any())
+ {
+ tierPrices.AddRange(product.TierPrices.OrderBy(tp => tp.Quantity)
+ .FilterByStore(_workContext.CurrentStore.Id)
+ .FilterByCurrency(_workContext.WorkingCurrency.CurrencyCode)
+ .FilterForCustomer(_workContext.CurrentCustomer)
+ .FilterByDate()
+ .RemoveDuplicatedQuantities());
+ }
+
+ //When there is just one tier (with qty 1),
+ //there are no actual savings in the list.
+ var displayFromMessage = tierPrices.Any() &&
+ !(tierPrices.Count == 1 && tierPrices[0].Quantity <= 1);
+ if (displayFromMessage)
+ {
+ priceModel.OldPrice = null;
+ priceModel.Price = string.Format(res["Products.PriceRangeFrom"],
+ _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency,
+ _workContext.WorkingLanguage, priceIncludesTax));
+ priceModel.PriceValue = finalPrice;
+ }
+ else
+ {
+ if (finalPrice != oldPriceBase && oldPriceBase != 0)
{
- priceModel.OldPrice = null;
- priceModel.Price = string.Format(res["Products.PriceRangeFrom"], _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax));
+ priceModel.OldPrice = _priceFormatter.FormatPrice(oldPrice,
+ _workContext.WorkingCurrency, _workContext.WorkingLanguage,
+ priceIncludesTax);
+ priceModel.OldPriceValue = oldPrice;
+ priceModel.Price = _priceFormatter.FormatPrice(finalPrice,
+ _workContext.WorkingCurrency, _workContext.WorkingLanguage,
+ priceIncludesTax);
priceModel.PriceValue = finalPrice;
}
else
{
- if (finalPrice != oldPriceBase && oldPriceBase != 0)
- {
- priceModel.OldPrice = _priceFormatter.FormatPrice(oldPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- priceModel.OldPriceValue = oldPrice;
- priceModel.Price = _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- priceModel.PriceValue = finalPrice;
- }
- else
- {
- priceModel.OldPrice = null;
- priceModel.Price = _priceFormatter.FormatPrice(finalPrice, _workContext.WorkingCurrency, _workContext.WorkingLanguage, priceIncludesTax);
- priceModel.PriceValue = finalPrice;
- }
- }
- if (product.ProductTypeId == ProductType.Reservation)
- {
- //rental product
- priceModel.OldPrice = _priceFormatter.FormatReservationProductPeriod(product, priceModel.OldPrice);
- priceModel.Price = _priceFormatter.FormatReservationProductPeriod(product, priceModel.Price);
+ priceModel.OldPrice = null;
+ priceModel.Price = _priceFormatter.FormatPrice(finalPrice,
+ _workContext.WorkingCurrency, _workContext.WorkingLanguage,
+ priceIncludesTax);
+ priceModel.PriceValue = finalPrice;
}
+ }
- //PAngV baseprice (used in Germany)
- if (product.BasepriceEnabled)
- priceModel.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice() { Currency = _workContext.WorkingCurrency, Product = product, ProductPrice = finalPrice });
-
+ if (product.ProductTypeId == ProductType.Reservation)
+ {
+ //rental product
+ priceModel.OldPrice =
+ _priceFormatter.FormatReservationProductPeriod(product, priceModel.OldPrice);
+ priceModel.Price =
+ _priceFormatter.FormatReservationProductPeriod(product, priceModel.Price);
}
+
+ //PAngV base price (used in Germany)
+ if (product.BasepriceEnabled)
+ priceModel.BasePricePAngV = await _mediator.Send(new GetFormatBasePrice {
+ Currency = _workContext.WorkingCurrency, Product = product,
+ ProductPrice = finalPrice
+ });
}
}
- else
- {
- //hide prices
- priceModel.OldPrice = null;
- priceModel.Price = null;
- }
-
- #endregion
}
+ else
+ {
+ //hide prices
+ priceModel.OldPrice = null;
+ priceModel.Price = null;
+ }
+
+ #endregion
+ }
break;
}
@@ -418,111 +484,118 @@ namespace Grand.Web.Features.Handlers.Products
#endregion
}
- private async Task<IList<PictureModel>> PreparePictureModel(Product product, string name, Dictionary<string, string> res, int pictureSize)
+ private async Task<IList<PictureModel>> PreparePictureModel(Product product, string name,
+ IReadOnlyDictionary<string, string> res, int pictureSize)
{
#region Prepare product picture
+
var result = new List<PictureModel>();
+
async Task<PictureModel> PreparePictureModel(ProductPicture productpicture)
{
- var picture =
- productpicture != null ?
- await _pictureService.GetPictureById(productpicture.PictureId) : null;
+ var picture =
+ productpicture != null ? await _pictureService.GetPictureById(productpicture.PictureId) : null;
- if (productpicture == null)
- productpicture = new ProductPicture();
+ productpicture ??= new ProductPicture();
- var pictureModel = new PictureModel
- {
+ var pictureModel = new PictureModel {
Id = productpicture.PictureId,
ImageUrl = await _pictureService.GetPictureUrl(productpicture.PictureId, pictureSize),
FullSizeImageUrl = await _pictureService.GetPictureUrl(productpicture.PictureId),
Style = picture?.Style,
- ExtraField = picture?.ExtraField
+ ExtraField = picture?.ExtraField,
+ //"title" attribute
+ Title =
+ picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute,
+ _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(res["Media.Product.ImageLinkTitleFormat"], name),
+ //"alt" attribute
+ AlternateText =
+ picture != null &&
+ !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute,
+ _workContext.WorkingLanguage.Id))
+ ? picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id)
+ : string.Format(res["Media.Product.ImageAlternateTextFormat"], name)
};
- //"title" attribute
- pictureModel.Title = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.TitleAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(res["Media.Product.ImageLinkTitleFormat"], name);
- //"alt" attribute
- pictureModel.AlternateText = (picture != null && !string.IsNullOrEmpty(picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id))) ?
- picture.GetTranslation(x => x.AltAttribute, _workContext.WorkingLanguage.Id) :
- string.Format(res["Media.Product.ImageAlternateTextFormat"], name);
return pictureModel;
- };
+ }
//prepare picture model
- result.Add(await PreparePictureModel(product.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault()));
+ result.Add(await PreparePictureModel(product.ProductPictures.MinBy(x => x.DisplayOrder)));
//prepare second picture model
- if (_catalogSettings.SecondPictureOnCatalogPages)
- {
- var secondPicture = product.ProductPictures.OrderBy(x => x.DisplayOrder).Skip(1).Take(1).FirstOrDefault();
- if (secondPicture != null)
- result.Add(await PreparePictureModel(secondPicture));
- }
+ if (!_catalogSettings.SecondPictureOnCatalogPages) return result;
+ var secondPicture = product.ProductPictures.OrderBy(x => x.DisplayOrder).Skip(1).Take(1)
+ .FirstOrDefault();
+ if (secondPicture != null)
+ result.Add(await PreparePictureModel(secondPicture));
+
return result;
- #endregion
+ #endregion
}
private async Task<IList<ProductOverviewModel.ProductAttributeModel>> PrepareAttributesModel(Product product)
{
var result = new List<ProductOverviewModel.ProductAttributeModel>();
- if (product.ProductAttributeMappings.Any(x => x.ShowOnCatalogPage))
+ if (!product.ProductAttributeMappings.Any(x => x.ShowOnCatalogPage)) return result;
+
+
+ foreach (var attribute in product.ProductAttributeMappings.Where(x => x.ShowOnCatalogPage)
+ .OrderBy(x => x.DisplayOrder))
{
- foreach (var attribute in product.ProductAttributeMappings.Where(x => x.ShowOnCatalogPage).OrderBy(x => x.DisplayOrder))
+ var pa = await _mediator.Send(new GetProductAttribute { Id = attribute.ProductAttributeId });
+ if (pa == null) continue;
+
+ var productAttributeModel = new ProductOverviewModel.ProductAttributeModel {
+ Name = pa.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),
+ SeName = pa.SeName,
+ TextPrompt = attribute.TextPrompt,
+ IsRequired = attribute.IsRequired,
+ AttributeControlType = attribute.AttributeControlTypeId,
+ UserFields = pa.UserFields
+ };
+ foreach (var item in attribute.ProductAttributeValues)
{
- var pa = await _mediator.Send(new GetProductAttribute() { Id = attribute.ProductAttributeId });
- if (pa != null)
+ var value = new ProductOverviewModel.ProductAttributeValueModel {
+ Name = item.Name,
+ ColorSquaresRgb = item.ColorSquaresRgb
+ };
+ //"image square" picture (with with "image squares" attribute type only)
+ if (!string.IsNullOrEmpty(item.ImageSquaresPictureId))
{
- var productAttributeModel = new ProductOverviewModel.ProductAttributeModel();
- productAttributeModel.Name = pa.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);
- productAttributeModel.SeName = pa.SeName;
- productAttributeModel.TextPrompt = attribute.TextPrompt;
- productAttributeModel.IsRequired = attribute.IsRequired;
- productAttributeModel.AttributeControlType = attribute.AttributeControlTypeId;
- productAttributeModel.UserFields = pa.UserFields;
- foreach (var item in attribute.ProductAttributeValues)
- {
- var value = new ProductOverviewModel.ProductAttributeValueModel();
- value.Name = item.Name;
- value.ColorSquaresRgb = item.ColorSquaresRgb;
- //"image square" picture (with with "image squares" attribute type only)
- if (!string.IsNullOrEmpty(item.ImageSquaresPictureId))
- {
- var pm = new PictureModel();
- pm = new PictureModel
- {
- Id = item.ImageSquaresPictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(item.ImageSquaresPictureId),
- ImageUrl = await _pictureService.GetPictureUrl(item.ImageSquaresPictureId, _mediaSettings.ImageSquarePictureSize)
- };
- value.ImageSquaresPictureModel = pm;
- }
+ var pm = new PictureModel();
+ pm = new PictureModel {
+ Id = item.ImageSquaresPictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(item.ImageSquaresPictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(item.ImageSquaresPictureId,
+ _mediaSettings.ImageSquarePictureSize)
+ };
+ value.ImageSquaresPictureModel = pm;
+ }
- //picture of a product attribute value
- if (!string.IsNullOrEmpty(item.PictureId))
- {
- var pm = new PictureModel();
- pm = new PictureModel
- {
- Id = item.PictureId,
- FullSizeImageUrl = await _pictureService.GetPictureUrl(item.PictureId),
- ImageUrl = await _pictureService.GetPictureUrl(item.PictureId, 50)
- };
- value.PictureModel = pm;
- }
- productAttributeModel.Values.Add(value);
- }
- result.Add(productAttributeModel);
+ //picture of a product attribute value
+ if (!string.IsNullOrEmpty(item.PictureId))
+ {
+ var pm = new PictureModel();
+ pm = new PictureModel {
+ Id = item.PictureId,
+ FullSizeImageUrl = await _pictureService.GetPictureUrl(item.PictureId),
+ ImageUrl = await _pictureService.GetPictureUrl(item.PictureId, 50)
+ };
+ value.PictureModel = pm;
}
+
+ productAttributeModel.Values.Add(value);
}
+
+ result.Add(productAttributeModel);
}
+
return result;
}
-
}
-
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewOverviewHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewOverviewHandler.cs
index 7c577c3f7..7655cbd26 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewOverviewHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewOverviewHandler.cs
@@ -6,14 +6,9 @@ namespace Grand.Web.Features.Handlers.Products
{
public class GetProductReviewOverviewHandler : IRequestHandler<GetProductReviewOverview, ProductReviewOverviewModel>
{
- public GetProductReviewOverviewHandler()
- {
- }
-
public async Task<ProductReviewOverviewModel> Handle(GetProductReviewOverview request, CancellationToken cancellationToken)
{
- var productReview = new ProductReviewOverviewModel()
- {
+ var productReview = new ProductReviewOverviewModel {
RatingSum = request.Product.ApprovedRatingSum,
TotalReviews = request.Product.ApprovedTotalReviews,
ProductId = request.Product.Id,
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
index 431462eb3..857289426 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductReviewsHandler.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Domain.Catalog;
@@ -69,9 +69,9 @@ namespace Grand.Web.Features.Handlers.Products
ProductId = request.Product.Id,
ProductReviewId = pr.Id,
HelpfulYesTotal = pr.HelpfulYesTotal,
- HelpfulNoTotal = pr.HelpfulNoTotal,
+ HelpfulNoTotal = pr.HelpfulNoTotal
},
- WrittenOnStr = _dateTimeService.ConvertToUserTime(pr.CreatedOnUtc, DateTimeKind.Utc).ToString("g"),
+ WrittenOnStr = _dateTimeService.ConvertToUserTime(pr.CreatedOnUtc, DateTimeKind.Utc).ToString("g")
});
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductSpecificationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductSpecificationHandler.cs
index f800ec96b..f9bb9315f 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductSpecificationHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductSpecificationHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Domain.Catalog;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
+using Grand.Domain.Catalog;
using Grand.Web.Features.Models.Products;
using Grand.Web.Models.Catalog;
using MediatR;
using System.Net;
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
namespace Grand.Web.Features.Handlers.Products
{
@@ -37,9 +37,9 @@ namespace Grand.Web.Features.Handlers.Products
{
m.SpecificationAttributeId = item.SpecificationAttributeId;
m.SpecificationAttributeName = specificationAttribute.GetTranslation(x => x.Name, request.Language.Id);
- m.ColorSquaresRgb = specificationAttribute.SpecificationAttributeOptions.Where(x => x.Id == item.SpecificationAttributeOptionId).FirstOrDefault() != null ? specificationAttribute.SpecificationAttributeOptions.Where(x => x.Id == item.SpecificationAttributeOptionId).FirstOrDefault().ColorSquaresRgb : "";
+ m.ColorSquaresRgb = specificationAttribute.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == item.SpecificationAttributeOptionId) != null ? specificationAttribute.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == item.SpecificationAttributeOptionId)!.ColorSquaresRgb : "";
m.UserFields = specificationAttribute.UserFields;
- m.ValueRaw = WebUtility.HtmlEncode(specificationAttribute.SpecificationAttributeOptions.Where(x => x.Id == item.SpecificationAttributeOptionId).FirstOrDefault().GetTranslation(x => x.Name, request.Language.Id));
+ m.ValueRaw = WebUtility.HtmlEncode(specificationAttribute.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == item.SpecificationAttributeOptionId).GetTranslation(x => x.Name, request.Language.Id));
}
break;
case SpecificationAttributeType.CustomText:
@@ -51,8 +51,6 @@ namespace Grand.Web.Features.Handlers.Products
case SpecificationAttributeType.Hyperlink:
m.ValueRaw = string.Format("<a href='{0}' target='_blank'>{0}</a>", item.CustomValue);
break;
- default:
- break;
}
spa.Add(m);
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetAddToCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetAddToCartHandler.cs
index a614cdc7b..73a8fde45 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetAddToCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetAddToCartHandler.cs
@@ -2,7 +2,6 @@
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Utilities.Catalog;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Storage;
@@ -10,11 +9,11 @@ using Grand.Domain.Catalog;
using Grand.Domain.Media;
using Grand.Domain.Orders;
using Grand.Domain.Tax;
+using Grand.Web.Extensions;
using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Grand.Web.Extensions;
namespace Grand.Web.Features.Handlers.ShoppingCart
{
@@ -111,7 +110,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
else
{
var productprices = await _taxService.GetProductPrice(request.Product, (await _pricingService.GetUnitPrice(request.ShoppingCartItem, request.Product)).unitprice);
- double taxRate = productprices.taxRate;
model.Price = !request.CustomerEnteredPrice.HasValue ? _priceFormatter.FormatPrice(productprices.productprice) : _priceFormatter.FormatPrice(request.CustomerEnteredPrice.Value);
model.DecimalPrice = request.CustomerEnteredPrice ?? productprices.productprice;
model.TotalPrice = _priceFormatter.FormatPrice(productprices.productprice * request.ShoppingCartItem.Quantity);
@@ -150,8 +148,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
{
var subTotalIncludingTax = request.TaxDisplayType == TaxDisplayType.IncludingTax && !_taxSettings.ForceTaxExclusionFromOrderSubtotal;
var shoppingCartSubTotal = await _orderTotalCalculationService.GetShoppingCartSubTotal(cart, subTotalIncludingTax);
- List<ApplyDiscount> orderSubTotalAppliedDiscounts = shoppingCartSubTotal.appliedDiscounts;
- double subTotalWithDiscountBase = shoppingCartSubTotal.subTotalWithDiscount;
model.SubTotal = _priceFormatter.FormatPrice(shoppingCartSubTotal.subTotalWithoutDiscount, request.Currency, request.Language, subTotalIncludingTax);
model.DecimalSubTotal = shoppingCartSubTotal.subTotalWithoutDiscount;
if (shoppingCartSubTotal.discountAmount > 0)
@@ -177,9 +173,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
return new PictureModel
{
Id = sciPicture?.Id,
- ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.AddToCartThumbPictureSize, true),
+ ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.AddToCartThumbPictureSize),
Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), request.Product.Name),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), request.Product.Name),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), request.Product.Name)
};
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingHandler.cs
index d3d03851a..4d36438be 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingHandler.cs
@@ -30,36 +30,36 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
public async Task<EstimateShippingModel> Handle(GetEstimateShipping request, CancellationToken cancellationToken)
{
- var model = new EstimateShippingModel();
- model.Enabled = request.Cart.Any() && request.Cart.RequiresShipping() && _shippingSettings.EstimateShippingEnabled;
- if (model.Enabled)
- {
- //countries
- var defaultEstimateCountryId = (request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null) ? request.Customer.ShippingAddress.CountryId : model.CountryId;
- if (string.IsNullOrEmpty(defaultEstimateCountryId))
- defaultEstimateCountryId = request.Store.DefaultCountryId;
+ var model = new EstimateShippingModel {
+ Enabled = request.Cart.Any() && request.Cart.RequiresShipping() && _shippingSettings.EstimateShippingEnabled
+ };
+ if (!model.Enabled) return model;
+
+ //countries
+ var defaultEstimateCountryId = request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null ? request.Customer.ShippingAddress.CountryId : model.CountryId;
+ if (string.IsNullOrEmpty(defaultEstimateCountryId))
+ defaultEstimateCountryId = request.Store.DefaultCountryId;
- model.AvailableCountries.Add(new SelectListItem { Text = _translationService.GetResource("Address.SelectCountry"), Value = "" });
- foreach (var c in await _countryService.GetAllCountriesForShipping(request.Language.Id, request.Store.Id))
- model.AvailableCountries.Add(new SelectListItem {
- Text = c.GetTranslation(x => x.Name, request.Language.Id),
- Value = c.Id.ToString(),
- Selected = c.Id == defaultEstimateCountryId
+ model.AvailableCountries.Add(new SelectListItem { Text = _translationService.GetResource("Address.SelectCountry"), Value = "" });
+ foreach (var c in await _countryService.GetAllCountriesForShipping(request.Language.Id, request.Store.Id))
+ model.AvailableCountries.Add(new SelectListItem {
+ Text = c.GetTranslation(x => x.Name, request.Language.Id),
+ Value = c.Id,
+ Selected = c.Id == defaultEstimateCountryId
+ });
+ //states
+ var defaultEstimateStateId = request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null ? request.Customer.ShippingAddress.StateProvinceId : model.StateProvinceId;
+ var states = !string.IsNullOrEmpty(defaultEstimateCountryId) ? await _countryService.GetStateProvincesByCountryId(defaultEstimateCountryId, request.Language.Id) : new List<StateProvince>();
+ if (states.Any())
+ foreach (var s in states)
+ model.AvailableStates.Add(new SelectListItem {
+ Text = s.GetTranslation(x => x.Name, request.Language.Id),
+ Value = s.Id,
+ Selected = s.Id == defaultEstimateStateId
});
- //states
- string defaultEstimateStateId = (request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null) ? request.Customer.ShippingAddress.StateProvinceId : model.StateProvinceId;
- var states = !String.IsNullOrEmpty(defaultEstimateCountryId) ? await _countryService.GetStateProvincesByCountryId(defaultEstimateCountryId, request.Language.Id) : new List<StateProvince>();
- if (states.Any())
- foreach (var s in states)
- model.AvailableStates.Add(new SelectListItem {
- Text = s.GetTranslation(x => x.Name, request.Language.Id),
- Value = s.Id.ToString(),
- Selected = s.Id == defaultEstimateStateId
- });
- if (request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null)
- model.ZipPostalCode = request.Customer.ShippingAddress.ZipPostalCode;
- }
+ if (request.SetEstimateShippingDefaultAddress && request.Customer.ShippingAddress != null)
+ model.ZipPostalCode = request.Customer.ShippingAddress.ZipPostalCode;
return model;
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingResultHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingResultHandler.cs
index 4022841f1..0d20079c2 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingResultHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetEstimateShippingResultHandler.cs
@@ -3,7 +3,6 @@ using Grand.Business.Core.Interfaces.Catalog.Tax;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Shipping;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Business.Core.Utilities.Catalog;
using Grand.Business.Core.Utilities.Checkout;
using Grand.Domain.Common;
using Grand.Domain.Orders;
@@ -47,65 +46,61 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
{
var model = new EstimateShippingResultModel();
- if (request.Cart.RequiresShipping())
+ if (!request.Cart.RequiresShipping()) return model;
+
+ var address = new Address {
+ CountryId = request.CountryId,
+ StateProvinceId = request.StateProvinceId,
+ ZipPostalCode = request.ZipPostalCode
+ };
+ GetShippingOptionResponse getShippingOptionResponse = await _shippingService
+ .GetShippingOptions(request.Customer, request.Cart, address, "", request.Store);
+ if (!getShippingOptionResponse.Success)
{
- var address = new Address {
- CountryId = request.CountryId,
- StateProvinceId = request.StateProvinceId,
- ZipPostalCode = request.ZipPostalCode,
- };
- GetShippingOptionResponse getShippingOptionResponse = await _shippingService
- .GetShippingOptions(request.Customer, request.Cart, address, "", request.Store);
- if (!getShippingOptionResponse.Success)
- {
- foreach (var error in getShippingOptionResponse.Errors)
- model.Warnings.Add(error);
- }
- else
+ foreach (var error in getShippingOptionResponse.Errors)
+ model.Warnings.Add(error);
+ }
+ else
+ {
+ if (getShippingOptionResponse.ShippingOptions.Any())
{
- if (getShippingOptionResponse.ShippingOptions.Any())
+ foreach (var shippingOption in getShippingOptionResponse.ShippingOptions)
{
- foreach (var shippingOption in getShippingOptionResponse.ShippingOptions)
- {
- var soModel = new EstimateShippingResultModel.ShippingOptionModel {
- Name = shippingOption.Name,
- Description = shippingOption.Description,
-
- };
+ var soModel = new EstimateShippingResultModel.ShippingOptionModel {
+ Name = shippingOption.Name,
+ Description = shippingOption.Description
- //calculate discounted and taxed rate
- var total = await _orderTotalCalculationService.AdjustShippingRate(shippingOption.Rate, request.Cart);
- List<ApplyDiscount> appliedDiscounts = total.appliedDiscounts;
- double shippingTotal = total.shippingRate;
+ };
- double rate = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
- soModel.Price = _priceFormatter.FormatShippingPrice(rate);
- model.ShippingOptions.Add(soModel);
- }
+ //calculate discounted and taxed rate
+ var total = await _orderTotalCalculationService.AdjustShippingRate(shippingOption.Rate, request.Cart);
+ var shippingTotal = total.shippingRate;
- //pickup in store?
- if (_shippingSettings.AllowPickUpInStore)
- {
- var pickupPoints = await _pickupPointService.GetAllPickupPoints();
- if (pickupPoints.Count > 0)
- {
- var soModel = new EstimateShippingResultModel.ShippingOptionModel {
- Name = _translationService.GetResource("Checkout.PickUpInStore"),
- Description = _translationService.GetResource("Checkout.PickUpInStore.Description"),
- };
-
- double shippingTotal = pickupPoints.Max(x => x.PickupFee);
- double rate = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
- soModel.Price = _priceFormatter.FormatShippingPrice(rate);
- model.ShippingOptions.Add(soModel);
- }
- }
+ var rate = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
+ soModel.Price = _priceFormatter.FormatShippingPrice(rate);
+ model.ShippingOptions.Add(soModel);
}
- else
+
+ //pickup in store?
+ if (!_shippingSettings.AllowPickUpInStore) return model;
{
- model.Warnings.Add(_translationService.GetResource("Checkout.ShippingIsNotAllowed"));
+ var pickupPoints = await _pickupPointService.GetAllPickupPoints();
+ if (pickupPoints.Count <= 0) return model;
+ var soModel = new EstimateShippingResultModel.ShippingOptionModel {
+ Name = _translationService.GetResource("Checkout.PickUpInStore"),
+ Description = _translationService.GetResource("Checkout.PickUpInStore.Description")
+ };
+
+ var shippingTotal = pickupPoints.Max(x => x.PickupFee);
+ var rate = (await _taxService.GetShippingPrice(shippingTotal, request.Customer)).shippingPrice;
+ soModel.Price = _priceFormatter.FormatShippingPrice(rate);
+ model.ShippingOptions.Add(soModel);
}
}
+ else
+ {
+ model.Warnings.Add(_translationService.GetResource("Checkout.ShippingIsNotAllowed"));
+ }
}
return model;
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
index 0b04f8a36..a6111f1ba 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniShoppingCartHandler.cs
@@ -1,9 +1,8 @@
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Commands.Checkout.Orders;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Utilities.Catalog;
-using Grand.Business.Core.Commands.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.CheckoutAttributes;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Directory;
@@ -14,13 +13,13 @@ using Grand.Domain.Common;
using Grand.Domain.Media;
using Grand.Domain.Orders;
using Grand.Domain.Tax;
+using Grand.Web.Extensions;
using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Grand.Web.Extensions;
namespace Grand.Web.Features.Handlers.ShoppingCart
{
@@ -85,116 +84,131 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
_mediaSettings = mediaSettings;
}
- public async Task<MiniShoppingCartModel> Handle(GetMiniShoppingCart request, CancellationToken cancellationToken)
+ public async Task<MiniShoppingCartModel> Handle(GetMiniShoppingCart request,
+ CancellationToken cancellationToken)
{
- var model = new MiniShoppingCartModel
- {
+ var model = new MiniShoppingCartModel {
ShowProductImages = _shoppingCartSettings.ShowImagesInsidebarCart,
DisplayShoppingCartButton = true,
CurrentCustomerIsGuest = await _groupService.IsGuest(request.Customer),
- AnonymousCheckoutAllowed = _orderSettings.AnonymousCheckoutAllowed,
+ AnonymousCheckoutAllowed = _orderSettings.AnonymousCheckoutAllowed
};
- if (request.Customer.ShoppingCartItems.Any())
+ if (!request.Customer.ShoppingCartItems.Any()) return model;
+
+ var shoppingCartTypes = new List<ShoppingCartType> {
+ ShoppingCartType.ShoppingCart,
+ ShoppingCartType.Auctions
+ };
+ if (_shoppingCartSettings.AllowOnHoldCart)
+ shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
+
+ var cart = await _shoppingCartService.GetShoppingCart(request.Store.Id, shoppingCartTypes.ToArray());
+ model.TotalProducts = cart.Sum(x => x.Quantity);
+ if (!cart.Any()) return model;
+
+ //subtotal
+ var subTotalIncludingTax = request.TaxDisplayType == TaxDisplayType.IncludingTax &&
+ !_taxSettings.ForceTaxExclusionFromOrderSubtotal;
+ var shoppingCartSubTotal =
+ await _orderTotalCalculationService.GetShoppingCartSubTotal(cart, subTotalIncludingTax);
+
+ model.SubTotal = _priceFormatter.FormatPrice(shoppingCartSubTotal.subTotalWithoutDiscount,
+ request.Currency, request.Language, subTotalIncludingTax);
+
+ var requiresShipping = cart.RequiresShipping();
+ var checkoutAttributesExist =
+ (await _checkoutAttributeService.GetAllCheckoutAttributes(request.Store.Id, !requiresShipping))
+ .Any();
+
+ var minOrderSubtotalAmountOk = await _mediator.Send(new ValidateMinShoppingCartSubtotalAmountCommand {
+ Customer = request.Customer,
+ Cart = cart.Where
+ (x => x.ShoppingCartTypeId is ShoppingCartType.ShoppingCart or ShoppingCartType.Auctions).ToList()
+ }, cancellationToken);
+
+ model.DisplayCheckoutButton = !_orderSettings.TermsOfServiceOnShoppingCartPage &&
+ minOrderSubtotalAmountOk &&
+ !checkoutAttributesExist;
+
+ foreach (var sci in cart
+ .OrderByDescending(x => x.Id)
+ .Take(_shoppingCartSettings.MiniCartProductNumber)
+ .ToList())
{
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
- shoppingCartTypes.Add(ShoppingCartType.Auctions);
- if (_shoppingCartSettings.AllowOnHoldCart)
- shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
-
- var cart = await _shoppingCartService.GetShoppingCart(request.Store.Id, shoppingCartTypes.ToArray());
- model.TotalProducts = cart.Sum(x => x.Quantity);
- if (cart.Any())
+ var product = await _productService.GetProductById(sci.ProductId);
+ if (product == null)
+ continue;
+
+ var sename = product.GetSeName(request.Language.Id);
+ var cartItemModel = new MiniShoppingCartModel.ShoppingCartItemModel {
+ Id = sci.Id,
+ ProductId = product.Id,
+ ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
+ ProductSeName = sename,
+ ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product",
+ new { SeName = sename }),
+ Quantity = sci.Quantity,
+ AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes)
+ };
+ if (product.ProductTypeId == ProductType.Reservation)
{
- //subtotal
- var subTotalIncludingTax = request.TaxDisplayType == TaxDisplayType.IncludingTax && !_taxSettings.ForceTaxExclusionFromOrderSubtotal;
- var shoppingCartSubTotal = await _orderTotalCalculationService.GetShoppingCartSubTotal(cart, subTotalIncludingTax);
- double orderSubTotalDiscountAmountBase = shoppingCartSubTotal.discountAmount;
- List<ApplyDiscount> orderSubTotalAppliedDiscounts = shoppingCartSubTotal.appliedDiscounts;
-
- model.SubTotal = _priceFormatter.FormatPrice(shoppingCartSubTotal.subTotalWithoutDiscount, request.Currency, request.Language, subTotalIncludingTax);
-
- var requiresShipping = cart.RequiresShipping();
- var checkoutAttributesExist = (await _checkoutAttributeService.GetAllCheckoutAttributes(request.Store.Id, !requiresShipping)).Any();
+ var reservation = "";
+ if (sci.RentalEndDateUtc == default(DateTime) || sci.RentalEndDateUtc == null)
+ {
+ reservation =
+ string.Format(_translationService.GetResource("ShoppingCart.Reservation.StartDate"),
+ sci.RentalStartDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat));
+ }
+ else
+ {
+ reservation = string.Format(
+ _translationService.GetResource("ShoppingCart.Reservation.Date"),
+ sci.RentalStartDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat),
+ sci.RentalEndDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat));
+ }
- var minOrderSubtotalAmountOk = await _mediator.Send(new ValidateMinShoppingCartSubtotalAmountCommand()
+ if (!string.IsNullOrEmpty(sci.Parameter))
{
- Customer = request.Customer,
- Cart = cart.Where
- (x => x.ShoppingCartTypeId == ShoppingCartType.ShoppingCart || x.ShoppingCartTypeId == ShoppingCartType.Auctions).ToList()
- });
-
- model.DisplayCheckoutButton = !_orderSettings.TermsOfServiceOnShoppingCartPage &&
- minOrderSubtotalAmountOk &&
- !checkoutAttributesExist;
-
- foreach (var sci in cart
- .OrderByDescending(x => x.Id)
- .Take(_shoppingCartSettings.MiniCartProductNumber)
- .ToList())
+ reservation += "<br>" +
+ string.Format(
+ _translationService.GetResource("ShoppingCart.Reservation.Option"),
+ sci.Parameter);
+ }
+
+ if (!string.IsNullOrEmpty(sci.Duration))
{
- var product = await _productService.GetProductById(sci.ProductId);
- if (product == null)
- continue;
-
- var sename = product.GetSeName(request.Language.Id);
- var cartItemModel = new MiniShoppingCartModel.ShoppingCartItemModel
- {
- Id = sci.Id,
- ProductId = product.Id,
- ProductName = product.GetTranslation(x => x.Name, request.Language.Id),
- ProductSeName = sename,
- ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
- Quantity = sci.Quantity,
- AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes)
- };
- if (product.ProductTypeId == ProductType.Reservation)
- {
- var reservation = "";
- if (sci.RentalEndDateUtc == default(DateTime) || sci.RentalEndDateUtc == null)
- {
- reservation = string.Format(_translationService.GetResource("ShoppingCart.Reservation.StartDate"), sci.RentalStartDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat));
- }
- else
- {
- reservation = string.Format(_translationService.GetResource("ShoppingCart.Reservation.Date"), sci.RentalStartDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat), sci.RentalEndDateUtc?.ToString(_shoppingCartSettings.ReservationDateFormat));
- }
-
- if (!string.IsNullOrEmpty(sci.Parameter))
- {
- reservation += "<br>" + string.Format(_translationService.GetResource("ShoppingCart.Reservation.Option"), sci.Parameter);
- }
- if (!string.IsNullOrEmpty(sci.Duration))
- {
- reservation += "<br>" + string.Format(_translationService.GetResource("ShoppingCart.Reservation.Duration"), sci.Duration);
- }
- if (string.IsNullOrEmpty(cartItemModel.AttributeInfo))
- cartItemModel.AttributeInfo = reservation;
- else
- cartItemModel.AttributeInfo += "<br>" + reservation;
- }
- //unit prices
- if (product.CallForPrice)
- {
- cartItemModel.UnitPrice = _translationService.GetResource("Products.CallForPrice");
- }
- else
- {
- var productprices = await _taxService.GetProductPrice(product, (await _pricingService.GetUnitPrice(sci, product)).unitprice);
- double taxRate = productprices.taxRate;
- cartItemModel.UnitPrice = _priceFormatter.FormatPrice(productprices.productprice);
- }
-
- //picture
- if (_shoppingCartSettings.ShowImagesInsidebarCart)
- {
- cartItemModel.Picture = await PrepareCartItemPicture(product, sci.Attributes);
- }
-
- model.Items.Add(cartItemModel);
+ reservation += "<br>" +
+ string.Format(
+ _translationService.GetResource("ShoppingCart.Reservation.Duration"),
+ sci.Duration);
}
+
+ if (string.IsNullOrEmpty(cartItemModel.AttributeInfo))
+ cartItemModel.AttributeInfo = reservation;
+ else
+ cartItemModel.AttributeInfo += "<br>" + reservation;
+ }
+
+ //unit prices
+ if (product.CallForPrice)
+ {
+ cartItemModel.UnitPrice = _translationService.GetResource("Products.CallForPrice");
+ }
+ else
+ {
+ var productprices = await _taxService.GetProductPrice(product,
+ (await _pricingService.GetUnitPrice(sci, product)).unitprice);
+ cartItemModel.UnitPrice = _priceFormatter.FormatPrice(productprices.productprice);
}
+
+ //picture
+ if (_shoppingCartSettings.ShowImagesInsidebarCart)
+ {
+ cartItemModel.Picture = await PrepareCartItemPicture(product, sci.Attributes);
+ }
+
+ model.Items.Add(cartItemModel);
}
return model;
@@ -203,13 +217,14 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
private async Task<PictureModel> PrepareCartItemPicture(Product product, IList<CustomAttribute> attributes)
{
var sciPicture = await product.GetProductPicture(attributes, _productService, _pictureService);
- return new PictureModel
- {
+ return new PictureModel {
Id = sciPicture?.Id,
- ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.MiniCartThumbPictureSize, true),
- Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), product.Name),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name),
+ ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.MiniCartThumbPictureSize),
+ Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"),
+ product.Name),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"),
+ product.Name)
};
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
index 86629d218..14e96ce57 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetMiniWishlistHandler.cs
@@ -86,7 +86,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductSeName = sename,
ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
Quantity = sci.Quantity,
- AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes),
+ AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes)
};
//unit prices
@@ -124,9 +124,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
var sciPicture = await product.GetProductPicture(attributes, _productService, _pictureService);
return new PictureModel {
Id = sciPicture?.Id,
- ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.MiniCartThumbPictureSize, true),
+ ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.MiniCartThumbPictureSize),
Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), product.Name),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name)
};
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetOrderTotalsHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetOrderTotalsHandler.cs
index a17f7cebb..5bf8ddb37 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetOrderTotalsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetOrderTotalsHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Business.Core.Interfaces.Catalog.Prices;
+using Grand.Business.Core.Commands.Checkout.Orders;
+using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Commands.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Payments;
-using Grand.Business.Core.Utilities.Checkout;
using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Utilities.Checkout;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Orders;
@@ -50,26 +50,26 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
public async Task<OrderTotalsModel> Handle(GetOrderTotals request, CancellationToken cancellationToken)
{
- var model = new OrderTotalsModel();
- model.IsEditable = request.IsEditable;
+ var model = new OrderTotalsModel {
+ IsEditable = request.IsEditable
+ };
- if (request.Cart.Any())
- {
- //subtotal
- await PrepareSubtotal(model, request);
+ if (!request.Cart.Any()) return model;
+
+ //subtotal
+ await PrepareSubtotal(model, request);
- //shipping info
- await PrepareShippingInfo(model, request);
+ //shipping info
+ await PrepareShippingInfo(model, request);
- //payment method fee
- await PreparePayment(model, request);
+ //payment method fee
+ await PreparePayment(model, request);
- //tax
- await PrepareTax(model, request);
+ //tax
+ await PrepareTax(model, request);
- //total
- await PrepareTotal(model, request);
- }
+ //total
+ await PrepareTotal(model, request);
return model;
}
@@ -148,7 +148,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
{
model.TaxRates.Add(new OrderTotalsModel.TaxRate {
Rate = _priceFormatter.FormatTaxRate(tr.Key),
- Value = _priceFormatter.FormatPrice(tr.Value, false),
+ Value = _priceFormatter.FormatPrice(tr.Value, false)
});
}
}
@@ -204,7 +204,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
: 0;
var earnLoyaltyPoints = shoppingCartTotalBase.Value - shippingBaseInclTax.Value;
if (earnLoyaltyPoints > 0)
- model.WillEarnLoyaltyPoints = await _mediator.Send(new CalculateLoyaltyPointsCommand() { Customer = request.Customer, Amount = await _currencyService.ConvertToPrimaryStoreCurrency(earnLoyaltyPoints, request.Currency) });
+ model.WillEarnLoyaltyPoints = await _mediator.Send(new CalculateLoyaltyPointsCommand { Customer = request.Customer, Amount = await _currencyService.ConvertToPrimaryStoreCurrency(earnLoyaltyPoints, request.Currency) });
}
}
@@ -213,8 +213,8 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
var gcModel = new OrderTotalsModel.GiftVoucher {
Id = appliedGiftVoucher.GiftVoucher.Id,
CouponCode = appliedGiftVoucher.GiftVoucher.Code,
+ Amount = _priceFormatter.FormatPrice(-appliedGiftVoucher.AmountCanBeUsed, false)
};
- gcModel.Amount = _priceFormatter.FormatPrice(-appliedGiftVoucher.AmountCanBeUsed, false);
var remainingAmountBase = appliedGiftVoucher.GiftVoucher.GetGiftVoucherRemainingAmount() - appliedGiftVoucher.AmountCanBeUsed;
gcModel.Remaining = _priceFormatter.FormatPrice(remainingAmountBase, false);
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
index ace8fa006..c3dee651a 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
@@ -1,10 +1,10 @@
-using Grand.Domain.Catalog;
-using Grand.Business.Core.Interfaces.Catalog.Products;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Domain.Catalog;
using Grand.Domain.Common;
+using Grand.Domain.Orders;
using Grand.Web.Features.Models.ShoppingCart;
using MediatR;
-using Grand.Domain.Orders;
namespace Grand.Web.Features.Handlers.ShoppingCart
{
@@ -90,7 +90,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
var ctrlAttributes = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- var enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customAttributes = ProductExtensions.AddProductAttribute(customAttributes,
attribute, enteredText).ToList();
}
@@ -108,8 +108,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
}
}
break;
- default:
- break;
}
}
//validate conditional attributes (if specified)
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
index efdf0a400..da5edca63 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs
@@ -1,24 +1,26 @@
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Commands.Checkout.Orders;
+using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Catalog.Discounts;
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Utilities.Catalog;
-using Grand.Business.Core.Commands.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.CheckoutAttributes;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Checkout.Shipping;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Utilities.Catalog;
+using Grand.Business.Core.Utilities.Checkout;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Domain.Orders;
+using Grand.Web.Extensions;
using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
@@ -26,8 +28,6 @@ using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
-using Grand.Business.Core.Utilities.Checkout;
-using Grand.Web.Extensions;
namespace Grand.Web.Features.Handlers.ShoppingCart
{
@@ -148,19 +148,19 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
model.ShowCheckoutAsGuestButton = model.IsGuest && _orderSettings.AnonymousCheckoutAllowed;
var checkoutAttributes = request.Customer.GetUserFieldFromEntity<List<CustomAttribute>>(SystemCustomerFieldNames.CheckoutAttributes, request.Store.Id);
model.CheckoutAttributeInfo = await _checkoutAttributeFormatter.FormatAttributes(checkoutAttributes, request.Customer);
- if (!request.Cart.Where(x => x.ShoppingCartTypeId == ShoppingCartType.ShoppingCart || x.ShoppingCartTypeId == ShoppingCartType.Auctions).ToList().Any())
+ if (!request.Cart.Where(x => x.ShoppingCartTypeId is ShoppingCartType.ShoppingCart or ShoppingCartType.Auctions).ToList().Any())
{
model.MinOrderSubtotalWarning = _translationService.GetResource("Checkout.MinOrderOneProduct");
}
else
{
- var minOrderSubtotalAmountOk = await _mediator.Send(new ValidateMinShoppingCartSubtotalAmountCommand() {
+ var minOrderSubtotalAmountOk = await _mediator.Send(new ValidateMinShoppingCartSubtotalAmountCommand {
Customer = request.Customer,
- Cart = request.Cart.Where(x => x.ShoppingCartTypeId == ShoppingCartType.ShoppingCart || x.ShoppingCartTypeId == ShoppingCartType.Auctions).ToList()
+ Cart = request.Cart.Where(x => x.ShoppingCartTypeId is ShoppingCartType.ShoppingCart or ShoppingCartType.Auctions).ToList()
});
if (!minOrderSubtotalAmountOk)
{
- double minOrderSubtotalAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(_orderSettings.MinOrderSubtotalAmount, request.Currency);
+ var minOrderSubtotalAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(_orderSettings.MinOrderSubtotalAmount, request.Currency);
model.MinOrderSubtotalWarning = string.Format(_translationService.GetResource("Checkout.MinOrderSubtotalAmount"), _priceFormatter.FormatPrice(minOrderSubtotalAmount, false));
}
}
@@ -172,11 +172,10 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
foreach (var couponCode in discountCouponCodes)
{
var discount = await _discountService.GetDiscountByCouponCode(couponCode);
- if (discount != null &&
- discount.RequiresCouponCode &&
+ if (discount is { RequiresCouponCode: true } &&
(await _discountService.ValidateDiscount(discount, request.Customer, request.Currency)).IsValid)
{
- model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel() {
+ model.DiscountBox.AppliedDiscountsWithCodes.Add(new ShoppingCartModel.DiscountBoxModel.DiscountInfoModel {
Id = discount.Id,
CouponCode = couponCode
});
@@ -208,7 +207,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
AttributeControlType = attribute.AttributeControlTypeId,
DefaultValue = attribute.DefaultValue
};
- if (!String.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))
+ if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))
{
attributeModel.AllowedFileExtensions = attribute.ValidationFileAllowedExtensions
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
@@ -225,20 +224,18 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
Id = attributeValue.Id,
Name = attributeValue.GetTranslation(x => x.Name, request.Language.Id),
ColorSquaresRgb = attributeValue.ColorSquaresRgb,
- IsPreSelected = attributeValue.IsPreSelected,
+ IsPreSelected = attributeValue.IsPreSelected
};
attributeModel.Values.Add(attributeValueModel);
//display price if allowed
- if (await _permissionService.Authorize(StandardPermission.DisplayPrices))
- {
- double priceAdjustmentBase = (await _taxService.GetCheckoutAttributePrice(attribute, attributeValue)).checkoutPrice;
- double priceAdjustment = await _currencyService.ConvertFromPrimaryStoreCurrency(priceAdjustmentBase, request.Currency);
- if (priceAdjustmentBase > 0)
- attributeValueModel.PriceAdjustment = "+" + _priceFormatter.FormatPrice(priceAdjustment);
- else if (priceAdjustmentBase < 0)
- attributeValueModel.PriceAdjustment = "-" + _priceFormatter.FormatPrice(-priceAdjustment);
- }
+ if (!await _permissionService.Authorize(StandardPermission.DisplayPrices)) continue;
+ var priceAdjustmentBase = (await _taxService.GetCheckoutAttributePrice(attribute, attributeValue)).checkoutPrice;
+ var priceAdjustment = await _currencyService.ConvertFromPrimaryStoreCurrency(priceAdjustmentBase, request.Currency);
+ if (priceAdjustmentBase > 0)
+ attributeValueModel.PriceAdjustment = "+" + _priceFormatter.FormatPrice(priceAdjustment);
+ else if (priceAdjustmentBase < 0)
+ attributeValueModel.PriceAdjustment = "-" + _priceFormatter.FormatPrice(-priceAdjustment);
}
}
//set already selected attributes
@@ -290,16 +287,13 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
if (selectedCheckoutAttributes != null && selectedCheckoutAttributes.Any())
{
var downloadGuidStr = selectedCheckoutAttributes.Where(x => x.Key == attribute.Id).Select(x => x.Value).FirstOrDefault();
- Guid downloadGuid;
- Guid.TryParse(downloadGuidStr, out downloadGuid);
+ Guid.TryParse(downloadGuidStr, out var downloadGuid);
var download = await _downloadService.GetDownloadByGuid(downloadGuid);
if (download != null)
attributeModel.DefaultValue = download.DownloadGuid.ToString();
}
}
break;
- default:
- break;
}
model.CheckoutAttributes.Add(attributeModel);
@@ -328,10 +322,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes),
+ AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually
};
- cartItemModel.AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually;
-
if (product.RequireOtherProducts)
cartItemModel.DisableRemoval = product.RequireOtherProducts && product.ParseRequiredProductIds().Intersect(request.Cart.Select(x => x.ProductId)).Any();
@@ -396,7 +389,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
if (sci.ShoppingCartTypeId == ShoppingCartType.Auctions)
{
cartItemModel.DisableRemoval = true;
- cartItemModel.AuctionInfo = _translationService.GetResource("ShoppingCart.auctionwonon") + " " + _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc).ToString();
+ cartItemModel.AuctionInfo = _translationService.GetResource("ShoppingCart.auctionwonon") + " " + _dateTimeService.ConvertToUserTime(product.AvailableEndDateTimeUtc.Value, DateTimeKind.Utc);
}
//unit prices
@@ -408,11 +401,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
}
else
{
- var unitprices = await _pricingService.GetUnitPrice(sci, product, true);
- double discountAmount = unitprices.discountAmount;
+ var unitprices = await _pricingService.GetUnitPrice(sci, product);
List<ApplyDiscount> appliedDiscounts = unitprices.appliedDiscounts;
var productprices = await _taxService.GetProductPrice(product, unitprices.unitprice);
- double taxRate = productprices.taxRate;
cartItemModel.UnitPriceWithoutDiscountValue =
(await _taxService.GetProductPrice(product, (await _pricingService.GetUnitPrice(sci, product, false)).unitprice)).productprice;
@@ -423,15 +414,14 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
if (appliedDiscounts != null && appliedDiscounts.Any())
{
var discount = await _discountService.GetDiscountById(appliedDiscounts.FirstOrDefault().DiscountId);
- if (discount != null && discount.MaximumDiscountedQuantity.HasValue)
+ if (discount is { MaximumDiscountedQuantity: { } })
cartItemModel.DiscountedQty = discount.MaximumDiscountedQuantity.Value;
appliedDiscounts.ForEach(x => cartItemModel.Discounts.Add(x.DiscountId));
}
//sub total
- var subtotal = await _pricingService.GetSubTotal(sci, product, true);
- double shoppingCartItemDiscountBase = subtotal.discountAmount;
- List<ApplyDiscount> scDiscounts = subtotal.appliedDiscounts;
+ var subtotal = await _pricingService.GetSubTotal(sci, product);
+ var shoppingCartItemDiscountBase = subtotal.discountAmount;
var shoppingCartItemSubTotalWithDiscount = (await _taxService.GetProductPrice(product, subtotal.subTotal)).productprice;
cartItemModel.SubTotal = _priceFormatter.FormatPrice(shoppingCartItemSubTotalWithDiscount);
cartItemModel.SubTotalValue = shoppingCartItemSubTotalWithDiscount;
@@ -469,9 +459,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
var sciPicture = await product.GetProductPicture(attributes, _productService, _pictureService);
return new PictureModel {
Id = sciPicture?.Id,
- ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.CartThumbPictureSize, true),
+ ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.CartThumbPictureSize),
Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), product.Name),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name)
};
}
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
index b95300423..1dbf81b01 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetWishlistHandler.cs
@@ -2,17 +2,18 @@
using Grand.Business.Core.Interfaces.Catalog.Prices;
using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Business.Core.Interfaces.Catalog.Tax;
-using Grand.Business.Core.Utilities.Catalog;
using Grand.Business.Core.Interfaces.Checkout.Orders;
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Business.Core.Interfaces.Common.Security;
-using Grand.Business.Core.Utilities.Common.Security;
using Grand.Business.Core.Interfaces.Storage;
+using Grand.Business.Core.Utilities.Checkout;
+using Grand.Business.Core.Utilities.Common.Security;
using Grand.Domain.Catalog;
using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Media;
using Grand.Domain.Orders;
+using Grand.Web.Extensions;
using Grand.Web.Features.Models.ShoppingCart;
using Grand.Web.Models.Media;
using Grand.Web.Models.ShoppingCart;
@@ -20,8 +21,6 @@ using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Routing;
-using Grand.Business.Core.Utilities.Checkout;
-using Grand.Web.Extensions;
namespace Grand.Web.Features.Handlers.ShoppingCart
{
@@ -80,7 +79,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
{
EmailWishlistEnabled = _shoppingCartSettings.EmailWishlistEnabled,
IsEditable = request.IsEditable,
- DisplayAddToCart = await _permissionService.Authorize(StandardPermission.EnableShoppingCart),
+ DisplayAddToCart = await _permissionService.Authorize(StandardPermission.EnableShoppingCart)
};
if (!request.Cart.Any())
@@ -119,10 +118,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
ProductUrl = _linkGenerator.GetUriByRouteValues(_httpContextAccessor.HttpContext, "Product", new { SeName = sename }),
Quantity = sci.Quantity,
AttributeInfo = await _productAttributeFormatter.FormatAttributes(product, sci.Attributes),
+ AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually
};
- cartItemModel.AllowItemEditing = _shoppingCartSettings.AllowCartItemEditing && product.VisibleIndividually;
-
//allowed quantities
var allowedQuantities = product.ParseAllowedQuantities();
foreach (var qty in allowedQuantities)
@@ -150,7 +148,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
else
{
var productprice = await _taxService.GetProductPrice(product, (await _pricingService.GetUnitPrice(sci, product)).unitprice);
- double taxRate = productprice.taxRate;
cartItemModel.UnitPrice = _priceFormatter.FormatPrice(productprice.productprice);
}
//subtotal, discount
@@ -161,11 +158,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
else
{
//sub total
- var subtotal = await _pricingService.GetSubTotal(sci, product, true);
- double shoppingCartItemDiscountBase = subtotal.discountAmount;
- List<ApplyDiscount> scDiscounts = subtotal.appliedDiscounts;
+ var subtotal = await _pricingService.GetSubTotal(sci, product);
+ var shoppingCartItemDiscountBase = subtotal.discountAmount;
var productprices = await _taxService.GetProductPrice(product, subtotal.subTotal);
- double taxRate = productprices.taxRate;
cartItemModel.SubTotal = _priceFormatter.FormatPrice(productprices.productprice);
//display an applied discount amount
@@ -205,9 +200,9 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
return new PictureModel
{
Id = sciPicture?.Id,
- ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.CartThumbPictureSize, true),
+ ImageUrl = await _pictureService.GetPictureUrl(sciPicture, _mediaSettings.CartThumbPictureSize),
Title = string.Format(_translationService.GetResource("Media.Product.ImageLinkTitleFormat"), product.Name),
- AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name),
+ AlternateText = string.Format(_translationService.GetResource("Media.Product.ImageAlternateTextFormat"), product.Name)
};
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Vendors/GetVendorReviewsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Vendors/GetVendorReviewsHandler.cs
index 3d78d9a6d..7ea688b0e 100644
--- a/src/Web/Grand.Web/Features/Handlers/Vendors/GetVendorReviewsHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Vendors/GetVendorReviewsHandler.cs
@@ -1,9 +1,9 @@
using Grand.Business.Core.Extensions;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Customers;
-using Grand.Infrastructure;
using Grand.Domain.Customers;
using Grand.Domain.Vendors;
+using Grand.Infrastructure;
using Grand.Web.Common.Security.Captcha;
using Grand.Web.Features.Models.Vendors;
using Grand.Web.Models.Vendors;
@@ -71,9 +71,9 @@ namespace Grand.Web.Features.Handlers.Vendors
VendorId = request.Vendor.Id,
VendorReviewId = pr.Id,
HelpfulYesTotal = pr.HelpfulYesTotal,
- HelpfulNoTotal = pr.HelpfulNoTotal,
+ HelpfulNoTotal = pr.HelpfulNoTotal
},
- WrittenOnStr = _dateTimeService.ConvertToUserTime(pr.CreatedOnUtc, DateTimeKind.Utc).ToString("g"),
+ WrittenOnStr = _dateTimeService.ConvertToUserTime(pr.CreatedOnUtc, DateTimeKind.Utc).ToString("g")
});
}
diff --git a/src/Web/Grand.Web/Features/Models/Catalog/GetFormatBasePrice.cs b/src/Web/Grand.Web/Features/Models/Catalog/GetFormatBasePrice.cs
index dec85895a..1c3e0160e 100644
--- a/src/Web/Grand.Web/Features/Models/Catalog/GetFormatBasePrice.cs
+++ b/src/Web/Grand.Web/Features/Models/Catalog/GetFormatBasePrice.cs
@@ -1,6 +1,7 @@
using Grand.Domain.Catalog;
using Grand.Domain.Directory;
using MediatR;
+
namespace Grand.Web.Features.Models.Catalog
{
public class GetFormatBasePrice : IRequest<string>
diff --git a/src/Web/Grand.Web/Features/Models/Checkout/GetBillingAddress.cs b/src/Web/Grand.Web/Features/Models/Checkout/GetBillingAddress.cs
index 7ee6e01c1..1feb341a9 100644
--- a/src/Web/Grand.Web/Features/Models/Checkout/GetBillingAddress.cs
+++ b/src/Web/Grand.Web/Features/Models/Checkout/GetBillingAddress.cs
@@ -13,8 +13,8 @@ namespace Grand.Web.Features.Models.Checkout
{
public IList<ShoppingCartItem> Cart { get; set; }
- public string SelectedCountryId { get; set; } = null;
- public bool PrePopulateNewAddressWithCustomerFields { get; set; } = false;
+ public string SelectedCountryId { get; set; }
+ public bool PrePopulateNewAddressWithCustomerFields { get; set; }
public IList<CustomAttribute> OverrideAttributes { get; set; }
public Customer Customer { get; set; }
public Store Store { get; set; }
diff --git a/src/Web/Grand.Web/Features/Models/Checkout/GetIsPaymentWorkflowRequired.cs b/src/Web/Grand.Web/Features/Models/Checkout/GetIsPaymentWorkflowRequired.cs
index fc57f16db..1049e149d 100644
--- a/src/Web/Grand.Web/Features/Models/Checkout/GetIsPaymentWorkflowRequired.cs
+++ b/src/Web/Grand.Web/Features/Models/Checkout/GetIsPaymentWorkflowRequired.cs
@@ -6,6 +6,6 @@ namespace Grand.Web.Features.Models.Checkout
public class GetIsPaymentWorkflowRequired : IRequest<bool>
{
public IList<ShoppingCartItem> Cart { get; set; }
- public bool? UseLoyaltyPoints { get; set; } = null;
+ public bool? UseLoyaltyPoints { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Checkout/GetShippingAddress.cs b/src/Web/Grand.Web/Features/Models/Checkout/GetShippingAddress.cs
index 35a71b570..f7b3f04cc 100644
--- a/src/Web/Grand.Web/Features/Models/Checkout/GetShippingAddress.cs
+++ b/src/Web/Grand.Web/Features/Models/Checkout/GetShippingAddress.cs
@@ -10,8 +10,8 @@ namespace Grand.Web.Features.Models.Checkout
{
public class GetShippingAddress : IRequest<CheckoutShippingAddressModel>
{
- public string SelectedCountryId { get; set; } = null;
- public bool PrePopulateNewAddressWithCustomerFields { get; set; } = false;
+ public string SelectedCountryId { get; set; }
+ public bool PrePopulateNewAddressWithCustomerFields { get; set; }
public IList<CustomAttribute> OverrideAttributes { get; set; }
public Customer Customer { get; set; }
public Store Store { get; set; }
diff --git a/src/Web/Grand.Web/Features/Models/Common/GetAddressModel.cs b/src/Web/Grand.Web/Features/Models/Common/GetAddressModel.cs
index ec54d5e82..bbee5038b 100644
--- a/src/Web/Grand.Web/Features/Models/Common/GetAddressModel.cs
+++ b/src/Web/Grand.Web/Features/Models/Common/GetAddressModel.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Localization;
using Grand.Domain.Stores;
using Grand.Web.Models.Common;
using MediatR;
+
namespace Grand.Web.Features.Models.Common
{
public class GetAddressModel : IRequest<AddressModel>
@@ -12,9 +13,9 @@ namespace Grand.Web.Features.Models.Common
public AddressModel Model { get; set; }
public Address Address { get; set; }
public bool ExcludeProperties { get; set; }
- public Func<IList<Country>> LoadCountries { get; set; } = null;
- public bool PrePopulateWithCustomerFields { get; set; } = false;
- public Customer Customer { get; set; } = null;
+ public Func<IList<Country>> LoadCountries { get; set; }
+ public bool PrePopulateWithCustomerFields { get; set; }
+ public Customer Customer { get; set; }
public Language Language { get; set; }
public Store Store { get; set; }
public IList<CustomAttribute> OverrideAttributes { get; set; }
diff --git a/src/Web/Grand.Web/Features/Models/Common/GetVendorAddress.cs b/src/Web/Grand.Web/Features/Models/Common/GetVendorAddress.cs
index 967916d27..3ac9f4808 100644
--- a/src/Web/Grand.Web/Features/Models/Common/GetVendorAddress.cs
+++ b/src/Web/Grand.Web/Features/Models/Common/GetVendorAddress.cs
@@ -12,9 +12,9 @@ namespace Grand.Web.Features.Models.Common
public VendorAddressModel Model { get; set; }
public Address Address { get; set; }
public bool ExcludeProperties { get; set; }
- public Func<IList<Country>> LoadCountries { get; set; } = null;
- public bool PrePopulateWithCustomerFields { get; set; } = false;
- public Customer Customer { get; set; } = null;
+ public Func<IList<Country>> LoadCountries { get; set; }
+ public bool PrePopulateWithCustomerFields { get; set; }
+ public Customer Customer { get; set; }
public Language Language { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Customers/GetNavigation.cs b/src/Web/Grand.Web/Features/Models/Customers/GetNavigation.cs
index 3edfb1e3e..f433843ea 100644
--- a/src/Web/Grand.Web/Features/Models/Customers/GetNavigation.cs
+++ b/src/Web/Grand.Web/Features/Models/Customers/GetNavigation.cs
@@ -9,7 +9,7 @@ namespace Grand.Web.Features.Models.Customers
{
public class GetNavigation : IRequest<CustomerNavigationModel>
{
- public int SelectedTabId { get; set; } = 0;
+ public int SelectedTabId { get; set; }
public Customer Customer { get; set; }
public Language Language { get; set; }
public Store Store { get; set; }
diff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsPage.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsPage.cs
index 8ad2d79b1..a2f4b6156 100644
--- a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsPage.cs
+++ b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsPage.cs
@@ -10,7 +10,7 @@ namespace Grand.Web.Features.Models.Products
{
public Store Store { get; set; }
public Product Product { get; set; }
- public ShoppingCartItem UpdateCartItem { get; set; } = null;
- public bool IsAssociatedProduct { get; set; } = false;
+ public ShoppingCartItem UpdateCartItem { get; set; }
+ public bool IsAssociatedProduct { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductOverview.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductOverview.cs
index 0b2eba625..ff8e9cf33 100644
--- a/src/Web/Grand.Web/Features/Models/Products/GetProductOverview.cs
+++ b/src/Web/Grand.Web/Features/Models/Products/GetProductOverview.cs
@@ -9,8 +9,8 @@ namespace Grand.Web.Features.Models.Products
public IEnumerable<Product> Products { get; set; }
public bool PreparePriceModel { get; set; } = true;
public bool PreparePictureModel { get; set; } = true;
- public int? ProductThumbPictureSize { get; set; } = null;
- public bool PrepareSpecificationAttributes { get; set; } = false;
- public bool ForceRedirectionAfterAddingToCart { get; set; } = false;
+ public int? ProductThumbPictureSize { get; set; }
+ public bool PrepareSpecificationAttributes { get; set; }
+ public bool ForceRedirectionAfterAddingToCart { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductReviews.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductReviews.cs
index ffaac96cc..9a77f76a6 100644
--- a/src/Web/Grand.Web/Features/Models/Products/GetProductReviews.cs
+++ b/src/Web/Grand.Web/Features/Models/Products/GetProductReviews.cs
@@ -13,6 +13,6 @@ namespace Grand.Web.Features.Models.Products
public Language Language { get; set; }
public Store Store { get; set; }
public Customer Customer { get; set; }
- public int Size { get; set; } = 0;
+ public int Size { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/ShoppingCart/GetShoppingCart.cs b/src/Web/Grand.Web/Features/Models/ShoppingCart/GetShoppingCart.cs
index 6deea9d16..ec8b13ec2 100644
--- a/src/Web/Grand.Web/Features/Models/ShoppingCart/GetShoppingCart.cs
+++ b/src/Web/Grand.Web/Features/Models/ShoppingCart/GetShoppingCart.cs
@@ -18,6 +18,6 @@ namespace Grand.Web.Features.Models.ShoppingCart
public TaxDisplayType TaxDisplayType { get; set; }
public IList<ShoppingCartItem> Cart { get; set; }
public bool IsEditable { get; set; } = true;
- public bool ValidateCheckoutAttributes { get; set; } = false;
+ public bool ValidateCheckoutAttributes { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs b/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
index 2c799fabe..7e30ed1dd 100644
--- a/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/AddBlogCommentModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Blogs
{
- public partial class AddBlogCommentModel : BaseEntityModel
+ public class AddBlogCommentModel : BaseEntityModel
{
[GrandResourceDisplayName("Blog.Comments.CommentText")]
public string CommentText { get; set; }
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogCommentModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogCommentModel.cs
index f6830cd2d..ac6e31970 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogCommentModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogCommentModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogCommentModel : BaseEntityModel
+ public class BlogCommentModel : BaseEntityModel
{
public string CustomerId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPagingFilteringModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPagingFilteringModel.cs
index 44fe8ed30..7edaf4001 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPagingFilteringModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPagingFilteringModel.cs
@@ -2,42 +2,34 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPagingFilteringModel : BasePageableModel
+ public class BlogPagingFilteringModel : BasePageableModel
{
#region Methods
public virtual DateTime? GetParsedMonth()
{
DateTime? result = null;
- if (!String.IsNullOrEmpty(Month))
+ if (string.IsNullOrEmpty(Month)) return null;
+ var tempDate = Month.Split(new [] { '-' });
+ if (tempDate.Length != 2) return null;
+ int.TryParse(tempDate[0], out var year);
+ int.TryParse(tempDate[1], out var month);
+ try
{
- string[] tempDate = Month.Split(new [] { '-' });
- if (tempDate.Length == 2)
- {
- int.TryParse(tempDate[0], out var year);
- int.TryParse(tempDate[1], out var month);
- try
- {
- result = new DateTime(year, month, 1);
- }
- catch { }
- }
+ result = new DateTime(year, month, 1);
}
+ catch { }
return result;
}
public virtual DateTime? GetFromMonth()
{
var filterByMonth = GetParsedMonth();
- if (filterByMonth.HasValue)
- return filterByMonth.Value;
- return null;
+ return filterByMonth;
}
public virtual DateTime? GetToMonth()
{
var filterByMonth = GetParsedMonth();
- if (filterByMonth.HasValue)
- return filterByMonth.Value.AddMonths(1).AddSeconds(-1);
- return null;
+ return filterByMonth?.AddMonths(1).AddSeconds(-1);
}
#endregion
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostCategoryModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostCategoryModel.cs
index 00fe5ffc9..2555a1e79 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostCategoryModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostCategoryModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostCategoryModel : BaseModel
+ public class BlogPostCategoryModel : BaseModel
{
public string Id { get; set; }
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
index 01e0b520b..363da9ec9 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostListModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostListModel : BaseModel
+ public class BlogPostListModel : BaseModel
{
public BlogPostListModel()
{
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
index 0f7975273..3a5311dcf 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostModel : BaseEntityModel
+ public class BlogPostModel : BaseEntityModel
{
public BlogPostModel()
{
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
index 4a9bfaf37..74fda05c5 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostTagListModel : BaseModel
+ public class BlogPostTagListModel : BaseModel
{
public BlogPostTagListModel()
{
@@ -14,33 +14,32 @@ namespace Grand.Web.Models.Blogs
var itemWeights = new List<double>();
foreach (var tag in Tags)
itemWeights.Add(tag.BlogPostCount);
- double mean;
- double stdDev = StdDev(itemWeights, out mean);
+ var stdDev = StdDev(itemWeights, out var mean);
return GetFontSize(blogPostTag.BlogPostCount, mean, stdDev);
}
protected int GetFontSize(double weight, double mean, double stdDev)
{
- double factor = (weight - mean);
+ var factor = weight - mean;
if (factor != 0 && stdDev != 0) factor /= stdDev;
- return (factor > 2) ? 150 :
- (factor > 1) ? 120 :
- (factor > 0.5) ? 100 :
- (factor > -0.5) ? 90 :
- (factor > -1) ? 85 :
- (factor > -2) ? 80 :
+ return factor > 2 ? 150 :
+ factor > 1 ? 120 :
+ factor > 0.5 ? 100 :
+ factor > -0.5 ? 90 :
+ factor > -1 ? 85 :
+ factor > -2 ? 80 :
75;
}
protected double Mean(IEnumerable<double> values)
{
double sum = 0;
- int count = 0;
+ var count = 0;
- foreach (double d in values)
+ foreach (var d in values)
{
sum += d;
count++;
@@ -53,11 +52,11 @@ namespace Grand.Web.Models.Blogs
{
mean = Mean(values);
double sumOfDiffSquares = 0;
- int count = 0;
+ var count = 0;
- foreach (double d in values)
+ foreach (var d in values)
{
- double diff = (d - mean);
+ var diff = d - mean;
sumOfDiffSquares += diff * diff;
count++;
}
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostTagModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostTagModel.cs
index c93abbf0c..7a1d7fe6a 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostTagModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostTagModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostTagModel : BaseModel
+ public class BlogPostTagModel : BaseModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
index 32f4d9bac..445e9c02e 100644
--- a/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostYearMonthModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Blogs
{
- public partial class BlogPostYearModel : BaseModel
+ public class BlogPostYearModel : BaseModel
{
public BlogPostYearModel()
{
@@ -11,7 +11,7 @@ namespace Grand.Web.Models.Blogs
public int Year { get; set; }
public IList<BlogPostMonthModel> Months { get; set; }
}
- public partial class BlogPostMonthModel : BaseModel
+ public class BlogPostMonthModel : BaseModel
{
public int Month { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/BrandModel.cs b/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
index 996b767b0..a8531cd4f 100644
--- a/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/BrandModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Catalog
{
- public partial class BrandModel : BaseEntityModel
+ public class BrandModel : BaseEntityModel
{
public BrandModel()
{
@@ -25,7 +25,7 @@ namespace Grand.Web.Models.Catalog
public IList<ProductOverviewModel> Products { get; set; }
}
- public partial class BrandBriefInfoModel : BaseEntityModel
+ public class BrandBriefInfoModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
index 7d64da94d..9c9ec39b7 100644
--- a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs
@@ -1,5 +1,5 @@
-using Grand.Business.Core.Interfaces.Catalog.Products;
-using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Extensions;
+using Grand.Business.Core.Interfaces.Catalog.Products;
using Grand.Domain.Catalog;
using Grand.Infrastructure.Extensions;
using Grand.Infrastructure.Models;
@@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.Catalog
{
- public partial class CatalogPagingFilteringModel : BasePageableModel
+ public class CatalogPagingFilteringModel : BasePageableModel
{
#region Constructors
@@ -57,7 +57,7 @@ namespace Grand.Web.Models.Catalog
#region Nested classes
- public partial class SpecificationFilterModel : BaseModel
+ public class SpecificationFilterModel : BaseModel
{
#region Ctor
@@ -76,7 +76,7 @@ namespace Grand.Web.Models.Catalog
//comma separated list of parameters to exclude
const string excludedQueryStringParams = "pagenumber";
var excludedQueryStringParamsSplitted = excludedQueryStringParams.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- foreach (string exclude in excludedQueryStringParamsSplitted)
+ foreach (var exclude in excludedQueryStringParamsSplitted)
url = CommonExtensions.ModifyQueryString(url, exclude, null);
return url;
}
@@ -86,7 +86,7 @@ namespace Grand.Web.Models.Catalog
if (optionIds == null)
return "";
- string result = string.Join(",", optionIds);
+ var result = string.Join(",", optionIds);
return result;
}
@@ -102,20 +102,16 @@ namespace Grand.Web.Models.Catalog
foreach (var item in query)
{
var spec = await specificationAttributeService.GetSpecificationAttributeBySeName(item.Key);
- if (spec != null)
+ if (spec == null) continue;
+ foreach (var value in item.Value)
{
- foreach (var value in item.Value)
+ foreach (var option in value.Split(","))
{
- foreach (var option in value.Split(","))
- {
- var opt = spec.SpecificationAttributeOptions.FirstOrDefault(x => x.SeName == option.ToLowerInvariant());
- if (opt != null)
- {
- if (!result.Contains(opt.Id))
- result.Add(opt.Id);
- }
-
- }
+ var opt = spec.SpecificationAttributeOptions.FirstOrDefault(x => x.SeName == option.ToLowerInvariant());
+ if (opt == null) continue;
+ if (!result.Contains(opt.Id))
+ result.Add(opt.Id);
+
}
}
}
@@ -124,7 +120,7 @@ namespace Grand.Web.Models.Catalog
}
public virtual async Task PrepareSpecsFilters(IList<string> alreadyFilteredSpecOptionIds,
- IList<string> filterableSpecificationAttributeOptionIds,
+ IEnumerable<string> filterableSpecificationAttributeOptionIds,
ISpecificationAttributeService specificationAttributeService,
string url, string langId)
{
@@ -143,9 +139,9 @@ namespace Grand.Web.Models.Catalog
SpecificationAttributeDisplayOrder = sa.DisplayOrder,
SpecificationAttributeOptionId = sao,
SpecificationAttributeOptionName = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao).GetTranslation(x => x.Name, langId),
- SpecificationAttributeOptionSeName = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao).SeName,
- SpecificationAttributeOptionDisplayOrder = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao).DisplayOrder,
- SpecificationAttributeOptionColorRgb = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao).ColorSquaresRgb,
+ SpecificationAttributeOptionSeName = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao)!.SeName,
+ SpecificationAttributeOptionDisplayOrder = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao)!.DisplayOrder,
+ SpecificationAttributeOptionColorRgb = sa.SpecificationAttributeOptions.FirstOrDefault(x => x.Id == sao)!.ColorSquaresRgb
});
}
}
@@ -191,11 +187,11 @@ namespace Grand.Web.Models.Catalog
NotFilteredItems = allFilters.Except(alreadyFilteredOptions).Select(x =>
{
//filter URL
- var alreadyFiltered = alreadyFilteredOptions.Where(y => y.SpecificationAttributeId == x.SpecificationAttributeId).Select(x => x.SpecificationAttributeOptionSeName)
+ var alreadyFiltered = alreadyFilteredOptions.Where(y => y.SpecificationAttributeId == x.SpecificationAttributeId).Select(s => s.SpecificationAttributeOptionSeName)
.Concat(new List<string> { x.SpecificationAttributeOptionSeName });
var filterUrl = CommonExtensions.ModifyQueryString(url, x.SpecificationAttributeSeName, GenerateFilteredSpecQueryParam(alreadyFiltered.ToList()));
- return new SpecificationFilterItem() {
+ return new SpecificationFilterItem {
SpecificationAttributeName = x.SpecificationAttributeName,
SpecificationAttributeSeName = x.SpecificationAttributeSeName,
SpecificationAttributeOptionName = x.SpecificationAttributeOptionName,
@@ -217,7 +213,7 @@ namespace Grand.Web.Models.Catalog
#endregion
}
- public partial class SpecificationFilterItem : BaseModel
+ public class SpecificationFilterItem : BaseModel
{
public string SpecificationAttributeName { get; set; }
public string SpecificationAttributeSeName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs b/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
index e464af7ee..f3a2573af 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategoryModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Catalog
{
- public partial class CategoryModel : BaseEntityModel
+ public class CategoryModel : BaseEntityModel
{
public CategoryModel()
{
@@ -33,7 +33,7 @@ namespace Grand.Web.Models.Catalog
public IList<ProductOverviewModel> FeaturedProducts { get; set; }
public IList<ProductOverviewModel> Products { get; set; }
#region Nested Classes
- public partial class SubCategoryModel : BaseEntityModel
+ public class SubCategoryModel : BaseEntityModel
{
public SubCategoryModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
index a957dda42..72c8e040f 100644
--- a/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CategoryNavigationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class CategoryNavigationModel : BaseModel
+ public class CategoryNavigationModel : BaseModel
{
public CategoryNavigationModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs b/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
index 66bbd4e4b..830309571 100644
--- a/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CollectionModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Catalog
{
- public partial class CollectionModel : BaseEntityModel
+ public class CollectionModel : BaseEntityModel
{
public CollectionModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
index 52cd008f7..97249475f 100644
--- a/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CollectionNavigationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class CollectionNavigationModel : BaseModel
+ public class CollectionNavigationModel : BaseModel
{
public CollectionNavigationModel()
{
@@ -14,7 +14,7 @@ namespace Grand.Web.Models.Catalog
public int TotalCollections { get; set; }
}
- public partial class CollectionBriefInfoModel : BaseEntityModel
+ public class CollectionBriefInfoModel : BaseEntityModel
{
public string Name { get; set; }
public string SeName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs b/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
index 26ee179c7..5c2629d4f 100644
--- a/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CompareProductsModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class CompareProductsModel : BaseEntityModel
+ public class CompareProductsModel : BaseEntityModel
{
public CompareProductsModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs b/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
index 59e14bd5f..0a80f26a3 100644
--- a/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/CustomerOutOfStockSubscriptionsModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Catalog
{
- public partial class CustomerOutOfStockSubscriptionsModel
+ public class CustomerOutOfStockSubscriptionsModel
{
public CustomerOutOfStockSubscriptionsModel()
{
@@ -16,7 +16,7 @@ namespace Grand.Web.Models.Catalog
#region Nested classes
- public partial class OutOfStockSubscriptionModel : BaseEntityModel
+ public class OutOfStockSubscriptionModel : BaseEntityModel
{
public string ProductId { get; set; }
public string ProductName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/MenuModel.cs b/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
index b2f66c39e..73a3504a4 100644
--- a/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/MenuModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class MenuModel : BaseModel
+ public class MenuModel : BaseModel
{
public MenuModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/OutOfStockSubscribeModel.cs b/src/Web/Grand.Web/Models/Catalog/OutOfStockSubscribeModel.cs
index 393a2f43b..4b005a9d0 100644
--- a/src/Web/Grand.Web/Models/Catalog/OutOfStockSubscribeModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/OutOfStockSubscribeModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class OutOfStockSubscribeModel : BaseModel
+ public class OutOfStockSubscribeModel : BaseModel
{
public string ProductId { get; set; }
public string ProductName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
index 14b680430..adf111ca1 100644
--- a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class PopularProductTagsModel : BaseModel
+ public class PopularProductTagsModel : BaseModel
{
public PopularProductTagsModel()
{
@@ -13,25 +13,25 @@ namespace Grand.Web.Models.Catalog
protected virtual int GetFontSize(double weight, double mean, double stdDev)
{
- double factor = (weight - mean);
+ var factor = weight - mean;
if (factor != 0 && stdDev != 0) factor /= stdDev;
- return (factor > 2) ? 150 :
- (factor > 1) ? 120 :
- (factor > 0.5) ? 100 :
- (factor > -0.5) ? 90 :
- (factor > -1) ? 85 :
- (factor > -2) ? 80 :
+ return factor > 2 ? 150 :
+ factor > 1 ? 120 :
+ factor > 0.5 ? 100 :
+ factor > -0.5 ? 90 :
+ factor > -1 ? 85 :
+ factor > -2 ? 80 :
75;
}
protected virtual double Mean(IEnumerable<double> values)
{
double sum = 0;
- int count = 0;
+ var count = 0;
- foreach (double d in values)
+ foreach (var d in values)
{
sum += d;
count++;
@@ -44,11 +44,11 @@ namespace Grand.Web.Models.Catalog
{
mean = Mean(values);
double sumOfDiffSquares = 0;
- int count = 0;
+ var count = 0;
- foreach (double d in values)
+ foreach (var d in values)
{
- double diff = (d - mean);
+ var diff = d - mean;
sumOfDiffSquares += diff * diff;
count++;
}
@@ -65,8 +65,7 @@ namespace Grand.Web.Models.Catalog
var itemWeights = new List<double>();
foreach (var tag in Tags)
itemWeights.Add(tag.ProductCount);
- double mean;
- double stdDev = StdDev(itemWeights, out mean);
+ var stdDev = StdDev(itemWeights, out var mean);
return GetFontSize(productTag.ProductCount, mean, stdDev);
}
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionModel.cs
index 13263f6fe..68856ab47 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductAskQuestionModel : BaseEntityModel
+ public class ProductAskQuestionModel : BaseEntityModel
{
public string ProductId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
index b57d22e4d..d34c96a41 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductAskQuestionSimpleModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductAskQuestionSimpleModel : BaseEntityModel
+ public class ProductAskQuestionSimpleModel : BaseEntityModel
{
[GrandResourceDisplayName("Products.AskQuestion.Email")]
public string AskQuestionEmail { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
index a23c22870..dfd14ec6b 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsAttributeChangeModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class ProductDetailsAttributeChangeModel : BaseEntityModel
+ public class ProductDetailsAttributeChangeModel : BaseEntityModel
{
public ProductDetailsAttributeChangeModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
index faeacef08..21d593048 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs
@@ -1,14 +1,14 @@
using Grand.Business.Core.Utilities.Catalog;
-using Grand.Infrastructure.ModelBinding;
-using Grand.Infrastructure.Models;
using Grand.Domain.Catalog;
using Grand.Domain.Orders;
+using Grand.Infrastructure.ModelBinding;
+using Grand.Infrastructure.Models;
using Grand.Web.Models.Media;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductDetailsModel : BaseEntityModel
+ public class ProductDetailsModel : BaseEntityModel
{
public ProductDetailsModel()
{
@@ -103,7 +103,7 @@ namespace Grand.Web.Models.Catalog
public bool RenderCaptcha { get; set; }
#region Nested Classes
- public partial class ProductBreadcrumbModel : BaseModel
+ public class ProductBreadcrumbModel : BaseModel
{
public ProductBreadcrumbModel()
{
@@ -117,7 +117,7 @@ namespace Grand.Web.Models.Catalog
public IList<CategorySimpleModel> CategoryBreadcrumb { get; set; }
}
- public partial class AddToCartModel : BaseModel
+ public class AddToCartModel : BaseModel
{
public AddToCartModel()
{
@@ -134,7 +134,7 @@ namespace Grand.Web.Models.Catalog
public bool EnteredPrice { get; set; }
[GrandResourceDisplayName("Products.EnterProductPrice")]
public double CustomerEnteredPrice { get; set; }
- public String CustomerEnteredPriceRange { get; set; }
+ public string CustomerEnteredPriceRange { get; set; }
public bool DisableBuyButton { get; set; }
public bool DisableWishlistButton { get; set; }
//reservation
@@ -150,7 +150,7 @@ namespace Grand.Web.Models.Catalog
public ShoppingCartType? UpdateShoppingCartItemType { get; set; }
}
- public partial class ProductPriceModel : BaseModel
+ public class ProductPriceModel : BaseModel
{
public ProductPriceModel()
{
@@ -187,7 +187,7 @@ namespace Grand.Web.Models.Catalog
public TierPrice PreferredTierPrice { get; set; }
}
- public partial class GiftVoucherModel : BaseModel
+ public class GiftVoucherModel : BaseModel
{
public bool IsGiftVoucher { get; set; }
@@ -205,14 +205,14 @@ namespace Grand.Web.Models.Catalog
public GiftVoucherType GiftVoucherType { get; set; }
}
- public partial class TierPriceModel : BaseModel
+ public class TierPriceModel : BaseModel
{
public string Price { get; set; }
public int Quantity { get; set; }
}
- public partial class ProductAttributeModel : BaseEntityModel
+ public class ProductAttributeModel : BaseEntityModel
{
public ProductAttributeModel()
{
@@ -256,7 +256,7 @@ namespace Grand.Web.Models.Catalog
public IList<ProductAttributeValueModel> Values { get; set; }
}
- public partial class ProductAttributeValueModel : BaseEntityModel
+ public class ProductAttributeValueModel : BaseEntityModel
{
public ProductAttributeValueModel()
{
@@ -275,7 +275,7 @@ namespace Grand.Web.Models.Catalog
public PictureModel PictureModel { get; set; }
}
- public partial class ProductBundleModel : BaseModel
+ public class ProductBundleModel : BaseModel
{
public ProductBundleModel()
{
@@ -296,7 +296,7 @@ namespace Grand.Web.Models.Catalog
public IList<ProductAttributeModel> ProductAttributes { get; set; }
}
- public partial class ProductWarehouseModel : BaseModel
+ public class ProductWarehouseModel : BaseModel
{
public bool Use { get; set; }
public string WarehouseId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
index ff7581a40..a25bef613 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductEmailAFriendModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductEmailAFriendModel : BaseModel
+ public class ProductEmailAFriendModel : BaseModel
{
public string ProductId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
index 68d0da840..9bbf79cda 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductOverviewModel.cs
@@ -6,7 +6,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductOverviewModel : BaseEntityModel
+ public class ProductOverviewModel : BaseEntityModel
{
public ProductOverviewModel()
{
@@ -54,7 +54,7 @@ namespace Grand.Web.Models.Catalog
public ProductReviewOverviewModel ReviewOverviewModel { get; set; }
#region Nested Classes
- public partial class ProductPriceModel : BaseModel
+ public class ProductPriceModel : BaseModel
{
public ProductPriceModel()
{
@@ -83,7 +83,7 @@ namespace Grand.Web.Models.Catalog
}
- public partial class ProductAttributeModel : BaseModel
+ public class ProductAttributeModel : BaseModel
{
public ProductAttributeModel()
{
@@ -97,7 +97,7 @@ namespace Grand.Web.Models.Catalog
public IList<ProductAttributeValueModel> Values { get; set; }
}
- public partial class ProductAttributeValueModel : BaseModel
+ public class ProductAttributeValueModel : BaseModel
{
public ProductAttributeValueModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
index dfd60217f..3ce852714 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductReviewModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Catalog
{
- public partial class ProductReviewOverviewModel : BaseModel
+ public class ProductReviewOverviewModel : BaseModel
{
public string ProductId { get; set; }
@@ -14,7 +14,7 @@ namespace Grand.Web.Models.Catalog
public bool AllowCustomerReviews { get; set; }
}
- public partial class ProductReviewsModel : BaseModel
+ public class ProductReviewsModel : BaseModel
{
public ProductReviewsModel()
{
@@ -32,7 +32,7 @@ namespace Grand.Web.Models.Catalog
public ProductReviewOverviewModel ProductReviewOverviewModel { get; set; }
}
- public partial class ProductReviewModel : BaseEntityModel
+ public class ProductReviewModel : BaseEntityModel
{
public string CustomerId { get; set; }
public string CustomerName { get; set; }
@@ -47,7 +47,7 @@ namespace Grand.Web.Models.Catalog
}
- public partial class ProductReviewHelpfulnessModel : BaseModel
+ public class ProductReviewHelpfulnessModel : BaseModel
{
public string ProductReviewId { get; set; }
public string ProductId { get; set; }
@@ -57,7 +57,7 @@ namespace Grand.Web.Models.Catalog
public int HelpfulNoTotal { get; set; }
}
- public partial class AddProductReviewModel : BaseModel
+ public class AddProductReviewModel : BaseModel
{
[GrandResourceDisplayName("Reviews.Fields.Title")]
public string Title { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductSpecificationModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductSpecificationModel.cs
index 62e328bab..c4f535a04 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductSpecificationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductSpecificationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class ProductSpecificationModel : BaseModel
+ public class ProductSpecificationModel : BaseModel
{
public string SpecificationAttributeId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductTagModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductTagModel.cs
index 0b892b72c..d78705b15 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductTagModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductTagModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class ProductTagModel : BaseEntityModel
+ public class ProductTagModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
index 491d69ab7..a601b1c40 100644
--- a/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/ProductsByTagModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class ProductsByTagModel : BaseEntityModel
+ public class ProductsByTagModel : BaseEntityModel
{
public ProductsByTagModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
index 322ca3f75..b74e039d0 100644
--- a/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/SearchBoxModel.cs
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.Catalog
{
- public partial class SearchBoxModel : BaseModel
+ public class SearchBoxModel : BaseModel
{
public SearchBoxModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/SearchModel.cs b/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
index 544409f6a..93566cee9 100644
--- a/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/SearchModel.cs
@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.Catalog
{
- public partial class SearchModel : BaseModel
+ public class SearchModel : BaseModel
{
public SearchModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
index 6270cf676..f66d717c7 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorModel.cs
@@ -4,7 +4,7 @@ using Grand.Web.Models.Vendors;
namespace Grand.Web.Models.Catalog
{
- public partial class VendorModel : BaseEntityModel
+ public class VendorModel : BaseEntityModel
{
public VendorModel()
{
diff --git a/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs b/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
index 45961db63..eb94103d7 100644
--- a/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Catalog/VendorNavigationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Catalog
{
- public partial class VendorNavigationModel : BaseModel
+ public class VendorNavigationModel : BaseModel
{
public VendorNavigationModel()
{
@@ -14,7 +14,7 @@ namespace Grand.Web.Models.Catalog
public int TotalVendors { get; set; }
}
- public partial class VendorBriefInfoModel : BaseEntityModel
+ public class VendorBriefInfoModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
index 4d85bbf4a..537ff6635 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutBillingAddressModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutBillingAddressModel : BaseModel
+ public class CheckoutBillingAddressModel : BaseModel
{
public CheckoutBillingAddressModel()
{
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutCompletedModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutCompletedModel.cs
index eee653e75..b274ebece 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutCompletedModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutCompletedModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutCompletedModel : BaseModel
+ public class CheckoutCompletedModel : BaseModel
{
public string OrderId { get; set; }
public int OrderNumber { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
index 27c1eb608..5271c4c4e 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutConfirmModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutConfirmModel : BaseModel
+ public class CheckoutConfirmModel : BaseModel
{
public CheckoutConfirmModel()
{
@@ -17,7 +17,7 @@ namespace Grand.Web.Models.Checkout
public IList<string> Warnings { get; set; }
public OrderReviewDataModel OrderReviewData { get; set; }
- public partial class OrderReviewDataModel : BaseModel
+ public class OrderReviewDataModel : BaseModel
{
public OrderReviewDataModel()
{
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutModel.cs
index 6b980f8b8..0395137a8 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutModel : BaseModel
+ public class CheckoutModel : BaseModel
{
public bool ShippingRequired { get; set; }
public CheckoutBillingAddressModel BillingAddress { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentInfoModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentInfoModel.cs
index b775057b3..bdf686228 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentInfoModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentInfoModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutPaymentInfoModel : BaseModel
+ public class CheckoutPaymentInfoModel : BaseModel
{
public string PaymentUrl { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
index ae67a6164..46317b912 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutPaymentMethodModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutPaymentMethodModel : BaseModel
+ public class CheckoutPaymentMethodModel : BaseModel
{
public CheckoutPaymentMethodModel()
{
@@ -19,7 +19,7 @@ namespace Grand.Web.Models.Checkout
public string PaymentMethod{ get; set; }
#region Nested classes
- public partial class PaymentMethodModel : BaseModel
+ public class PaymentMethodModel : BaseModel
{
public string PaymentMethodSystemName { get; set; }
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutPickupPointModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutPickupPointModel.cs
index ef22dd699..9a85f887c 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutPickupPointModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutPickupPointModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutPickupPointModel : BaseModel
+ public class CheckoutPickupPointModel : BaseModel
{
public string Id { get; set; }
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
index 70c5f3837..6ac5d2736 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingAddressModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutShippingAddressModel : BaseModel
+ public class CheckoutShippingAddressModel : BaseModel
{
public CheckoutShippingAddressModel()
{
diff --git a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
index 65ae819f4..dfc33a40e 100644
--- a/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
+++ b/src/Web/Grand.Web/Models/Checkout/CheckoutShippingMethodModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Checkout
{
- public partial class CheckoutShippingMethodModel : BaseModel
+ public class CheckoutShippingMethodModel : BaseModel
{
public CheckoutShippingMethodModel()
{
@@ -19,7 +19,7 @@ namespace Grand.Web.Models.Checkout
#region Nested classes
- public partial class ShippingMethodModel : BaseModel
+ public class ShippingMethodModel : BaseModel
{
public string ShippingRateProviderSystemName { get; set; }
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Cms/WidgetModel.cs b/src/Web/Grand.Web/Models/Cms/WidgetModel.cs
index ac86d6584..12805f543 100644
--- a/src/Web/Grand.Web/Models/Cms/WidgetModel.cs
+++ b/src/Web/Grand.Web/Models/Cms/WidgetModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Cms
{
- public partial class WidgetModel : BaseModel
+ public class WidgetModel : BaseModel
{
public string WidgetZone { get; set; }
public string ViewComponentName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs b/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
index 0c0a02248..1ff01925f 100644
--- a/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
+++ b/src/Web/Grand.Web/Models/Common/AddressAttributeModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Common
{
- public partial class AddressAttributeModel : BaseEntityModel
+ public class AddressAttributeModel : BaseEntityModel
{
public AddressAttributeModel()
{
@@ -24,7 +24,7 @@ namespace Grand.Web.Models.Common
public IList<AddressAttributeValueModel> Values { get; set; }
}
- public partial class AddressAttributeValueModel : BaseEntityModel
+ public class AddressAttributeValueModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/AddressModel.cs b/src/Web/Grand.Web/Models/Common/AddressModel.cs
index 3de2f5330..c7bdc0729 100644
--- a/src/Web/Grand.Web/Models/Common/AddressModel.cs
+++ b/src/Web/Grand.Web/Models/Common/AddressModel.cs
@@ -8,7 +8,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Common
{
- public partial class AddressModel : BaseEntityModel
+ public class AddressModel : BaseEntityModel
{
public AddressModel()
{
diff --git a/src/Web/Grand.Web/Models/Common/ContactUsModel.cs b/src/Web/Grand.Web/Models/Common/ContactUsModel.cs
index d195ab161..bcc94d00c 100644
--- a/src/Web/Grand.Web/Models/Common/ContactUsModel.cs
+++ b/src/Web/Grand.Web/Models/Common/ContactUsModel.cs
@@ -1,14 +1,14 @@
using Grand.Domain.Catalog;
+using Grand.Domain.Common;
using Grand.Infrastructure.ModelBinding;
using Grand.Infrastructure.Models;
-using Grand.Domain.Common;
using Grand.Web.Common.Binders;
using Grand.Web.Common.Models;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Models.Common
{
- public partial class ContactUsModel : BaseModel
+ public class ContactUsModel : BaseModel
{
public ContactUsModel()
{
@@ -42,7 +42,7 @@ namespace Grand.Web.Models.Common
public IList<CustomAttribute> ContactAttribute { get; set; }
public IList<ContactAttributeModel> ContactAttributes { get; set; }
- public partial class ContactAttributeModel : BaseEntityModel
+ public class ContactAttributeModel : BaseEntityModel
{
public ContactAttributeModel()
{
@@ -81,7 +81,7 @@ namespace Grand.Web.Models.Common
public IList<ContactAttributeValueModel> Values { get; set; }
}
- public partial class ContactAttributeValueModel : BaseEntityModel
+ public class ContactAttributeValueModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/ContactVendorModel.cs b/src/Web/Grand.Web/Models/Common/ContactVendorModel.cs
index 083e93105..ba56fdbb5 100644
--- a/src/Web/Grand.Web/Models/Common/ContactVendorModel.cs
+++ b/src/Web/Grand.Web/Models/Common/ContactVendorModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Common
{
- public partial class ContactVendorModel : BaseModel
+ public class ContactVendorModel : BaseModel
{
public string VendorId { get; set; }
public string VendorName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/CurrencyModel.cs b/src/Web/Grand.Web/Models/Common/CurrencyModel.cs
index 48aeb7b25..7a9c6701f 100644
--- a/src/Web/Grand.Web/Models/Common/CurrencyModel.cs
+++ b/src/Web/Grand.Web/Models/Common/CurrencyModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class CurrencyModel : BaseEntityModel
+ public class CurrencyModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/FooterModel.cs b/src/Web/Grand.Web/Models/Common/FooterModel.cs
index 31e07e3f8..50cb63366 100644
--- a/src/Web/Grand.Web/Models/Common/FooterModel.cs
+++ b/src/Web/Grand.Web/Models/Common/FooterModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class FooterModel : BaseModel
+ public class FooterModel : BaseModel
{
public FooterModel()
{
diff --git a/src/Web/Grand.Web/Models/Common/LanguageModel.cs b/src/Web/Grand.Web/Models/Common/LanguageModel.cs
index eaa8cf308..b60209b51 100644
--- a/src/Web/Grand.Web/Models/Common/LanguageModel.cs
+++ b/src/Web/Grand.Web/Models/Common/LanguageModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class LanguageModel : BaseEntityModel
+ public class LanguageModel : BaseEntityModel
{
public string Name { get; set; }
public bool Rtl { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/PagerModel.cs b/src/Web/Grand.Web/Models/Common/PagerModel.cs
index b2c799f79..f273e29ae 100644
--- a/src/Web/Grand.Web/Models/Common/PagerModel.cs
+++ b/src/Web/Grand.Web/Models/Common/PagerModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class PagerModel : BasePageableModel
+ public class PagerModel : BasePageableModel
{
}
diff --git a/src/Web/Grand.Web/Models/Common/ShoppingCartLinksModel.cs b/src/Web/Grand.Web/Models/Common/ShoppingCartLinksModel.cs
index ae93961a7..dd5418848 100644
--- a/src/Web/Grand.Web/Models/Common/ShoppingCartLinksModel.cs
+++ b/src/Web/Grand.Web/Models/Common/ShoppingCartLinksModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class ShoppingCartLinksModel : BaseModel
+ public class ShoppingCartLinksModel : BaseModel
{
public bool MiniShoppingCartEnabled { get; set; }
public bool ShoppingCartEnabled { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/SitemapModel.cs b/src/Web/Grand.Web/Models/Common/SitemapModel.cs
index 40d5695ca..258b6ed3d 100644
--- a/src/Web/Grand.Web/Models/Common/SitemapModel.cs
+++ b/src/Web/Grand.Web/Models/Common/SitemapModel.cs
@@ -1,12 +1,12 @@
using Grand.Infrastructure.Models;
-using Grand.Web.Models.Catalog;
-using Grand.Web.Models.Pages;
using Grand.Web.Models.Blogs;
+using Grand.Web.Models.Catalog;
using Grand.Web.Models.Knowledgebase;
+using Grand.Web.Models.Pages;
namespace Grand.Web.Models.Common
{
- public partial class SitemapModel : BaseModel
+ public class SitemapModel : BaseModel
{
public SitemapModel()
{
diff --git a/src/Web/Grand.Web/Models/Common/StateProvinceModel.cs b/src/Web/Grand.Web/Models/Common/StateProvinceModel.cs
index 55fc88ae6..d021a121e 100644
--- a/src/Web/Grand.Web/Models/Common/StateProvinceModel.cs
+++ b/src/Web/Grand.Web/Models/Common/StateProvinceModel.cs
@@ -1,7 +1,7 @@

namespace Grand.Web.Models.Common
{
- public partial class StateProvinceModel
+ public class StateProvinceModel
{
public string id { get; set; }
public string name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/StoreModel.cs b/src/Web/Grand.Web/Models/Common/StoreModel.cs
index 8f24c0327..0bae39370 100644
--- a/src/Web/Grand.Web/Models/Common/StoreModel.cs
+++ b/src/Web/Grand.Web/Models/Common/StoreModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class StoreModel : BaseEntityModel
+ public class StoreModel : BaseEntityModel
{
public string Name { get; set; }
public string Shortcut { get; set; }
diff --git a/src/Web/Grand.Web/Models/Common/StoreThemeModel.cs b/src/Web/Grand.Web/Models/Common/StoreThemeModel.cs
index ecf2c995c..6c64e71ee 100644
--- a/src/Web/Grand.Web/Models/Common/StoreThemeModel.cs
+++ b/src/Web/Grand.Web/Models/Common/StoreThemeModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Common
{
- public partial class StoreThemeModel : BaseModel
+ public class StoreThemeModel : BaseModel
{
public string Name { get; set; }
public string Title { get; set; }
diff --git a/src/Web/Grand.Web/Models/Course/CourseModel.cs b/src/Web/Grand.Web/Models/Course/CourseModel.cs
index e72e49f8a..6d2d85a44 100644
--- a/src/Web/Grand.Web/Models/Course/CourseModel.cs
+++ b/src/Web/Grand.Web/Models/Course/CourseModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Course
{
- public partial class CourseModel : BaseEntityModel
+ public class CourseModel : BaseEntityModel
{
public CourseModel()
{
@@ -23,13 +23,13 @@ namespace Grand.Web.Models.Course
public IList<Lesson> Lessons { get; set; }
public bool Approved { get; set; }
- public partial class Subject : BaseEntityModel
+ public class Subject : BaseEntityModel
{
public string Name { get; set; }
public int DisplayOrder { get; set; }
}
- public partial class Lesson : BaseEntityModel
+ public class Lesson : BaseEntityModel
{
public string SubjectId { get; set; }
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/AccountActivationModel.cs b/src/Web/Grand.Web/Models/Customer/AccountActivationModel.cs
index 1ad346f91..8280b3334 100644
--- a/src/Web/Grand.Web/Models/Customer/AccountActivationModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/AccountActivationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class AccountActivationModel : BaseModel
+ public class AccountActivationModel : BaseModel
{
public string Result { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Customer/ChangePasswordModel.cs b/src/Web/Grand.Web/Models/Customer/ChangePasswordModel.cs
index f4162d65e..3abb82854 100644
--- a/src/Web/Grand.Web/Models/Customer/ChangePasswordModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/ChangePasswordModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class ChangePasswordModel : BaseModel
+ public class ChangePasswordModel : BaseModel
{
[DataType(DataType.Password)]
[GrandResourceDisplayName("Account.ChangePassword.Fields.OldPassword")]
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
index 7e9cc1ebe..d2ffc0da9 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAddressEditModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Customer
{
- public partial class CustomerAddressEditModel : BaseModel
+ public class CustomerAddressEditModel : BaseModel
{
public CustomerAddressEditModel()
{
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
index d067a03e4..9e70ec7a3 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAddressListModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Customer
{
- public partial class CustomerAddressListModel : BaseModel
+ public class CustomerAddressListModel : BaseModel
{
public CustomerAddressListModel()
{
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
index f559e9b92..46baeedea 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerAttributeModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Customer
{
- public partial class CustomerAttributeModel : BaseEntityModel
+ public class CustomerAttributeModel : BaseEntityModel
{
public CustomerAttributeModel()
{
@@ -26,7 +26,7 @@ namespace Grand.Web.Models.Customer
}
- public partial class CustomerAttributeValueModel : BaseEntityModel
+ public class CustomerAttributeValueModel : BaseEntityModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
index 893ae4aae..f0e3dd899 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerDownloadableProductsModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class CustomerDownloadableProductsModel : BaseModel
+ public class CustomerDownloadableProductsModel : BaseModel
{
public CustomerDownloadableProductsModel()
{
@@ -12,7 +12,7 @@ namespace Grand.Web.Models.Customer
public IList<DownloadableProductsModel> Items { get; set; }
#region Nested classes
- public partial class DownloadableProductsModel : BaseModel
+ public class DownloadableProductsModel : BaseModel
{
public Guid OrderItemGuid { get; set; }
@@ -32,7 +32,7 @@ namespace Grand.Web.Models.Customer
#endregion
}
- public partial class UserAgreementModel : BaseModel
+ public class UserAgreementModel : BaseModel
{
public Guid OrderItemGuid { get; set; }
public string UserAgreementText { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
index 4d937e5a2..5285b2d48 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerInfoModel.cs
@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class CustomerInfoModel : BaseModel
+ public class CustomerInfoModel : BaseModel
{
public CustomerInfoModel()
{
@@ -143,7 +143,7 @@ namespace Grand.Web.Models.Customer
#region Nested classes
- public partial class AssociatedExternalAuthModel : BaseEntityModel
+ public class AssociatedExternalAuthModel : BaseEntityModel
{
public string Email { get; set; }
public string ExternalIdentifier { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs
index 01a9386b7..192d55ac2 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class CustomerNavigationModel : BaseModel
+ public class CustomerNavigationModel : BaseModel
{
public bool HideInfo { get; set; }
public bool HideAddresses { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
index 92a527d68..f4b8df021 100644
--- a/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/CustomerProductReviewModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class CustomerProductReviewModel : BaseEntityModel
+ public class CustomerProductReviewModel : BaseEntityModel
{
public string ProductId { get; set; }
public string ProductName { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/DeleteAccountModel.cs b/src/Web/Grand.Web/Models/Customer/DeleteAccountModel.cs
index 3dc46bfef..787618404 100644
--- a/src/Web/Grand.Web/Models/Customer/DeleteAccountModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/DeleteAccountModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class DeleteAccountModel : BaseModel
+ public class DeleteAccountModel : BaseModel
{
[DataType(DataType.Password)]
[GrandResourceDisplayName("Account.DeleteAccount.Fields.Password")]
diff --git a/src/Web/Grand.Web/Models/Customer/ExternalAuthenticationMethodModel.cs b/src/Web/Grand.Web/Models/Customer/ExternalAuthenticationMethodModel.cs
index c995c0cee..252c52c5b 100644
--- a/src/Web/Grand.Web/Models/Customer/ExternalAuthenticationMethodModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/ExternalAuthenticationMethodModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class ExternalAuthenticationMethodModel : BaseModel
+ public class ExternalAuthenticationMethodModel : BaseModel
{
public string ViewComponentName { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Customer/LoginModel.cs b/src/Web/Grand.Web/Models/Customer/LoginModel.cs
index 7a5abc501..a0df8bc71 100644
--- a/src/Web/Grand.Web/Models/Customer/LoginModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/LoginModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class LoginModel : BaseModel
+ public class LoginModel : BaseModel
{
public bool CheckoutAsGuest { get; set; }
diff --git a/src/Web/Grand.Web/Models/Customer/PasswordRecoveryConfirmModel.cs b/src/Web/Grand.Web/Models/Customer/PasswordRecoveryConfirmModel.cs
index 853ba6ead..f00c37314 100644
--- a/src/Web/Grand.Web/Models/Customer/PasswordRecoveryConfirmModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/PasswordRecoveryConfirmModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class PasswordRecoveryConfirmModel : BaseModel
+ public class PasswordRecoveryConfirmModel : BaseModel
{
[DataType(DataType.Password)]
[GrandResourceDisplayName("Account.PasswordRecovery.NewPassword")]
diff --git a/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs b/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
index 29d20a415..a0e55b09d 100644
--- a/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/PaswordRecoveryModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class PasswordRecoveryModel : BaseModel
+ public class PasswordRecoveryModel : BaseModel
{
[DataType(DataType.EmailAddress)]
[GrandResourceDisplayName("Account.PasswordRecovery.Email")]
diff --git a/src/Web/Grand.Web/Models/Customer/RegisterModel.cs b/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
index f6bdbdab9..c208f6ca0 100644
--- a/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/RegisterModel.cs
@@ -9,7 +9,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Customer
{
- public partial class RegisterModel : BaseModel
+ public class RegisterModel : BaseModel
{
public RegisterModel()
{
diff --git a/src/Web/Grand.Web/Models/Customer/RegisterResultModel.cs b/src/Web/Grand.Web/Models/Customer/RegisterResultModel.cs
index e88e8a5f9..f06bb699a 100644
--- a/src/Web/Grand.Web/Models/Customer/RegisterResultModel.cs
+++ b/src/Web/Grand.Web/Models/Customer/RegisterResultModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Customer
{
- public partial class RegisterResultModel : BaseModel
+ public class RegisterResultModel : BaseModel
{
public string Result { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Install/InstallModel.cs b/src/Web/Grand.Web/Models/Install/InstallModel.cs
index 38b50c49b..f80da5bb6 100644
--- a/src/Web/Grand.Web/Models/Install/InstallModel.cs
+++ b/src/Web/Grand.Web/Models/Install/InstallModel.cs
@@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Install
{
- public partial class InstallModel : BaseModel
+ public class InstallModel : BaseModel
{
public InstallModel()
{
diff --git a/src/Web/Grand.Web/Models/Knowledgebase/AddKnowledgebaseArticleCommentModel.cs b/src/Web/Grand.Web/Models/Knowledgebase/AddKnowledgebaseArticleCommentModel.cs
index 132635edc..dec18f9db 100644
--- a/src/Web/Grand.Web/Models/Knowledgebase/AddKnowledgebaseArticleCommentModel.cs
+++ b/src/Web/Grand.Web/Models/Knowledgebase/AddKnowledgebaseArticleCommentModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Knowledgebase
{
- public partial class AddKnowledgebaseArticleCommentModel : BaseEntityModel
+ public class AddKnowledgebaseArticleCommentModel : BaseEntityModel
{
[GrandResourceDisplayName("Knowledgebase.Article.CommentText")]
public string CommentText { get; set; }
diff --git a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleCommentModel.cs b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleCommentModel.cs
index 0ae9c30df..40d5f8ca3 100644
--- a/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleCommentModel.cs
+++ b/src/Web/Grand.Web/Models/Knowledgebase/KnowledgebaseArticleCommentModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Knowledgebase
{
- public partial class KnowledgebaseArticleCommentModel : BaseEntityModel
+ public class KnowledgebaseArticleCommentModel : BaseEntityModel
{
public string CustomerId { get; set; }
diff --git a/src/Web/Grand.Web/Models/Media/PictureModel.cs b/src/Web/Grand.Web/Models/Media/PictureModel.cs
index adc10d27b..d3550e3f2 100644
--- a/src/Web/Grand.Web/Models/Media/PictureModel.cs
+++ b/src/Web/Grand.Web/Models/Media/PictureModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Media
{
- public partial class PictureModel : BaseEntityModel
+ public class PictureModel : BaseEntityModel
{
public string ImageUrl { get; set; }
public string ThumbImageUrl { get; set; }
diff --git a/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs b/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
index 082af4b2c..e23ab2c8c 100644
--- a/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
+++ b/src/Web/Grand.Web/Models/News/AddNewsCommentModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.News
{
- public partial class AddNewsCommentModel : BaseModel
+ public class AddNewsCommentModel : BaseModel
{
[GrandResourceDisplayName("News.Comments.CommentTitle")]
public string CommentTitle { get; set; }
diff --git a/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs b/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
index 5658da573..62f92bf19 100644
--- a/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
+++ b/src/Web/Grand.Web/Models/News/HomePageNewsItemsModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.News
{
- public partial class HomePageNewsItemsModel : BaseModel
+ public class HomePageNewsItemsModel : BaseModel
{
public HomePageNewsItemsModel()
{
diff --git a/src/Web/Grand.Web/Models/News/NewsCommentModel.cs b/src/Web/Grand.Web/Models/News/NewsCommentModel.cs
index a88d4c591..2868606e2 100644
--- a/src/Web/Grand.Web/Models/News/NewsCommentModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsCommentModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.News
{
- public partial class NewsCommentModel : BaseEntityModel
+ public class NewsCommentModel : BaseEntityModel
{
public string CustomerId { get; set; }
diff --git a/src/Web/Grand.Web/Models/News/NewsItemListModel.cs b/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
index 654dd9981..b5e6da568 100644
--- a/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsItemListModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.News
{
- public partial class NewsItemListModel : BaseModel
+ public class NewsItemListModel : BaseModel
{
public NewsItemListModel()
{
diff --git a/src/Web/Grand.Web/Models/News/NewsItemModel.cs b/src/Web/Grand.Web/Models/News/NewsItemModel.cs
index 4170c0f14..6b99b000a 100644
--- a/src/Web/Grand.Web/Models/News/NewsItemModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsItemModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.News
{
- public partial class NewsItemModel : BaseEntityModel
+ public class NewsItemModel : BaseEntityModel
{
public NewsItemModel()
{
diff --git a/src/Web/Grand.Web/Models/News/NewsPagingFilteringModel.cs b/src/Web/Grand.Web/Models/News/NewsPagingFilteringModel.cs
index a0c9977d8..f15f45b77 100644
--- a/src/Web/Grand.Web/Models/News/NewsPagingFilteringModel.cs
+++ b/src/Web/Grand.Web/Models/News/NewsPagingFilteringModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.News
{
- public partial class NewsPagingFilteringModel : BasePageableModel
+ public class NewsPagingFilteringModel : BasePageableModel
{
}
}
\ 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 6392de885..c74549ca6 100644
--- a/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs
+++ b/src/Web/Grand.Web/Models/Newsletter/NewsletterCategoryModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Newsletter
{
- public partial class NewsletterCategoryModel : BaseModel
+ public class NewsletterCategoryModel : BaseModel
{
public NewsletterCategoryModel()
{
diff --git a/src/Web/Grand.Web/Models/Newsletter/SubscribeNewsletterResultModel.cs b/src/Web/Grand.Web/Models/Newsletter/SubscribeNewsletterResultModel.cs
index 40e4bee31..401993652 100644
--- a/src/Web/Grand.Web/Models/Newsletter/SubscribeNewsletterResultModel.cs
+++ b/src/Web/Grand.Web/Models/Newsletter/SubscribeNewsletterResultModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Newsletter
{
- public partial class SubscribeNewsletterResultModel: BaseModel
+ public class SubscribeNewsletterResultModel: BaseModel
{
public string Result { get; set; }
public string ResultCategory { get; set; }
diff --git a/src/Web/Grand.Web/Models/Newsletter/SubscriptionActivationModel.cs b/src/Web/Grand.Web/Models/Newsletter/SubscriptionActivationModel.cs
index a275a6cab..ec0286eba 100644
--- a/src/Web/Grand.Web/Models/Newsletter/SubscriptionActivationModel.cs
+++ b/src/Web/Grand.Web/Models/Newsletter/SubscriptionActivationModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Newsletter
{
- public partial class SubscriptionActivationModel : BaseModel
+ public class SubscriptionActivationModel : BaseModel
{
public string Result { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
index d4f61e174..9c0debd3e 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerLoyaltyPointsModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Orders
{
- public partial class CustomerLoyaltyPointsModel : BaseModel
+ public class CustomerLoyaltyPointsModel : BaseModel
{
public CustomerLoyaltyPointsModel()
{
@@ -18,7 +18,7 @@ namespace Grand.Web.Models.Orders
#region Nested classes
- public partial class LoyaltyPointsHistoryModel : BaseEntityModel
+ public class LoyaltyPointsHistoryModel : BaseEntityModel
{
[GrandResourceDisplayName("LoyaltyPoints.Fields.Points")]
public int Points { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
index dac82e87f..122bf6bbd 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerMerchandiseReturnsModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Orders
{
- public partial class CustomerMerchandiseReturnsModel : BaseModel
+ public class CustomerMerchandiseReturnsModel : BaseModel
{
public CustomerMerchandiseReturnsModel()
{
@@ -12,7 +12,7 @@ namespace Grand.Web.Models.Orders
public IList<MerchandiseReturnModel> Items { get; set; }
#region Nested classes
- public partial class MerchandiseReturnModel : BaseEntityModel
+ public class MerchandiseReturnModel : BaseEntityModel
{
public int ReturnNumber { get; set; }
public string MerchandiseReturnStatus { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs b/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
index 8de7748d1..577f744aa 100644
--- a/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/CustomerOrderListModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Orders
{
- public partial class CustomerOrderListModel : BaseModel
+ public class CustomerOrderListModel : BaseModel
{
public CustomerOrderListModel()
{
@@ -14,7 +14,7 @@ namespace Grand.Web.Models.Orders
#region Nested classes
- public partial class OrderDetailsModel : BaseEntityModel
+ public class OrderDetailsModel : BaseEntityModel
{
public string OrderTotal { get; set; }
public bool IsMerchandiseReturnAllowed { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
index 1830b3420..1f28100cf 100644
--- a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnDetailsModel.cs
@@ -40,7 +40,7 @@ namespace Grand.Web.Models.Orders
#region Nested Classes
- public partial class MerchandiseReturnNote : BaseEntityModel
+ public class MerchandiseReturnNote : BaseEntityModel
{
public bool HasDownload { get; set; }
public string Note { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
index 639fadcb5..1305e0d44 100644
--- a/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/MerchandiseReturnModel.cs
@@ -4,7 +4,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Orders
{
- public partial class MerchandiseReturnModel : BaseModel
+ public class MerchandiseReturnModel : BaseModel
{
public MerchandiseReturnModel()
{
@@ -47,7 +47,7 @@ namespace Grand.Web.Models.Orders
#region Nested classes
- public partial class OrderItemModel : BaseEntityModel
+ public class OrderItemModel : BaseEntityModel
{
public string ProductId { get; set; }
@@ -71,11 +71,11 @@ namespace Grand.Web.Models.Orders
public string MerchandiseReturnActionId { get; set; }
}
- public partial class MerchandiseReturnReasonModel : BaseEntityModel
+ public class MerchandiseReturnReasonModel : BaseEntityModel
{
public string Name { get; set; }
}
- public partial class MerchandiseReturnActionModel : BaseEntityModel
+ public class MerchandiseReturnActionModel : BaseEntityModel
{
public string Name { get; set; }
}
diff --git a/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
index 82be431b7..49374141d 100644
--- a/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/OrderDetailsModel.cs
@@ -4,7 +4,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.Orders
{
- public partial class OrderDetailsModel : BaseEntityModel
+ public class OrderDetailsModel : BaseEntityModel
{
public OrderDetailsModel()
{
@@ -80,7 +80,7 @@ namespace Grand.Web.Models.Orders
#region Nested Classes
- public partial class OrderItemModel : BaseEntityModel
+ public class OrderItemModel : BaseEntityModel
{
public OrderItemModel()
{
@@ -107,19 +107,19 @@ namespace Grand.Web.Models.Orders
public string LicenseId { get; set; }
}
- public partial class TaxRate : BaseModel
+ public class TaxRate : BaseModel
{
public string Rate { get; set; }
public string Value { get; set; }
}
- public partial class GiftVoucher : BaseModel
+ public class GiftVoucher : BaseModel
{
public string CouponCode { get; set; }
public string Amount { get; set; }
}
- public partial class OrderNote : BaseEntityModel
+ public class OrderNote : BaseEntityModel
{
public bool HasDownload { get; set; }
public string Note { get; set; }
@@ -127,7 +127,7 @@ namespace Grand.Web.Models.Orders
public string OrderId { get; set; }
}
- public partial class ShipmentBriefModel : BaseEntityModel
+ public class ShipmentBriefModel : BaseEntityModel
{
public string TrackingNumber { get; set; }
public int ShipmentNumber { get; set; }
diff --git a/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs b/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
index 93d76e2db..737c7a4ca 100644
--- a/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
+++ b/src/Web/Grand.Web/Models/Orders/ShipmentDetailsModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Common;
namespace Grand.Web.Models.Orders
{
- public partial class ShipmentDetailsModel : BaseEntityModel
+ public class ShipmentDetailsModel : BaseEntityModel
{
public ShipmentDetailsModel()
{
@@ -24,7 +24,7 @@ namespace Grand.Web.Models.Orders
#region Nested Classes
- public partial class ShipmentItemModel : BaseEntityModel
+ public class ShipmentItemModel : BaseEntityModel
{
public string Sku { get; set; }
public string ProductId { get; set; }
@@ -37,21 +37,21 @@ namespace Grand.Web.Models.Orders
public int QuantityShipped { get; set; }
}
- public partial class ShipmentStatusEventModel : BaseModel
+ public class ShipmentStatusEventModel : BaseModel
{
public string EventName { get; set; }
public string Location { get; set; }
public string Country { get; set; }
public DateTime? Date { get; set; }
}
- public partial class ShipmentNote : BaseEntityModel
+ public class ShipmentNote : BaseEntityModel
{
public bool HasDownload { get; set; }
public string Note { get; set; }
public DateTime CreatedOn { get; set; }
public string ShipmentId { get; set; }
}
- public partial class OrderModel : BaseEntityModel
+ public class OrderModel : BaseEntityModel
{
public int OrderNumber { get; set; }
public string OrderCode { get; set; }
diff --git a/src/Web/Grand.Web/Models/Pages/PageModel.cs b/src/Web/Grand.Web/Models/Pages/PageModel.cs
index 42e217209..f8d4e2f10 100644
--- a/src/Web/Grand.Web/Models/Pages/PageModel.cs
+++ b/src/Web/Grand.Web/Models/Pages/PageModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.Pages
{
- public partial class PageModel : BaseEntityModel
+ public class PageModel : BaseEntityModel
{
public string SystemName { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
index ab2f23ee6..399bb67e7 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/AddToCartModel.cs
@@ -4,7 +4,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class AddToCartModel : BaseModel
+ public class AddToCartModel : BaseModel
{
public AddToCartModel()
{
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
index 450bd8207..a6a058a7d 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/EstimateShippingModel.cs
@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class EstimateShippingModel : BaseModel
+ public class EstimateShippingModel : BaseModel
{
public EstimateShippingModel()
{
@@ -25,7 +25,7 @@ namespace Grand.Web.Models.ShoppingCart
public IList<SelectListItem> AvailableStates { get; set; }
}
- public partial class EstimateShippingResultModel : BaseModel
+ public class EstimateShippingResultModel : BaseModel
{
public EstimateShippingResultModel()
{
@@ -39,7 +39,7 @@ namespace Grand.Web.Models.ShoppingCart
#region Nested Classes
- public partial class ShippingOptionModel : BaseModel
+ public class ShippingOptionModel : BaseModel
{
public string Name { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
index a2166a621..d627ea034 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/MiniShoppingCartModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class MiniShoppingCartModel : BaseModel
+ public class MiniShoppingCartModel : BaseModel
{
public MiniShoppingCartModel()
{
@@ -22,7 +22,7 @@ namespace Grand.Web.Models.ShoppingCart
#region Nested Classes
- public partial class ShoppingCartItemModel : BaseEntityModel
+ public class ShoppingCartItemModel : BaseEntityModel
{
public ShoppingCartItemModel()
{
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
index 93e18c0e0..e4ef802ab 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/MiniWishlistModel.cs
@@ -3,7 +3,7 @@ using Grand.Web.Models.Media;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class MiniWishlistModel : BaseModel
+ public class MiniWishlistModel : BaseModel
{
public MiniWishlistModel()
{
@@ -18,7 +18,7 @@ namespace Grand.Web.Models.ShoppingCart
#region Nested Classes
- public partial class WishlistItemModel : BaseEntityModel
+ public class WishlistItemModel : BaseEntityModel
{
public WishlistItemModel()
{
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
index b14b9797f..fb955b9fb 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/OrderTotalsModel.cs
@@ -2,7 +2,7 @@
namespace Grand.Web.Models.ShoppingCart
{
- public partial class OrderTotalsModel : BaseModel
+ public class OrderTotalsModel : BaseModel
{
public OrderTotalsModel()
{
@@ -48,13 +48,13 @@ namespace Grand.Web.Models.ShoppingCart
#region Nested classes
- public partial class TaxRate: BaseModel
+ public class TaxRate: BaseModel
{
public string Rate { get; set; }
public string Value { get; set; }
}
- public partial class GiftVoucher : BaseEntityModel
+ public class GiftVoucher : BaseEntityModel
{
public string CouponCode { get; set; }
public string Amount { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
index 1390aeb91..095e60cf5 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/ShoppingCartModel.cs
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class ShoppingCartModel : BaseModel
+ public class ShoppingCartModel : BaseModel
{
public ShoppingCartModel()
{
@@ -35,7 +35,7 @@ namespace Grand.Web.Models.ShoppingCart
public GiftVoucherBoxModel GiftVoucherBox { get; set; }
#region Nested Classes
- public partial class ShoppingCartItemModel : BaseEntityModel
+ public class ShoppingCartItemModel : BaseEntityModel
{
public ShoppingCartItemModel()
{
@@ -78,7 +78,7 @@ namespace Grand.Web.Models.ShoppingCart
public IList<string> Warnings { get; set; }
}
- public partial class CheckoutAttributeModel : BaseEntityModel
+ public class CheckoutAttributeModel : BaseEntityModel
{
public CheckoutAttributeModel()
{
@@ -104,7 +104,7 @@ namespace Grand.Web.Models.ShoppingCart
public IList<CheckoutAttributeValueModel> Values { get; set; }
}
- public partial class CheckoutAttributeValueModel : BaseEntityModel
+ public class CheckoutAttributeValueModel : BaseEntityModel
{
public string Name { get; set; }
@@ -115,7 +115,7 @@ namespace Grand.Web.Models.ShoppingCart
public bool IsPreSelected { get; set; }
}
- public partial class DiscountBoxModel : BaseModel
+ public class DiscountBoxModel : BaseModel
{
public DiscountBoxModel()
{
@@ -131,7 +131,7 @@ namespace Grand.Web.Models.ShoppingCart
}
}
- public partial class GiftVoucherBoxModel : BaseModel
+ public class GiftVoucherBoxModel : BaseModel
{
public bool Display { get; set; }
public string Message { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
index a07f56f2b..24a1c46f4 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/WishlistEmailAFriendModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class WishlistEmailAFriendModel : BaseModel
+ public class WishlistEmailAFriendModel : BaseModel
{
[GrandResourceDisplayName("Wishlist.EmailAFriend.FriendEmail")]
public string FriendEmail { get; set; }
diff --git a/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs b/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
index dd550775c..591c07834 100644
--- a/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
+++ b/src/Web/Grand.Web/Models/ShoppingCart/WishlistModel.cs
@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
namespace Grand.Web.Models.ShoppingCart
{
- public partial class WishlistModel : BaseModel
+ public class WishlistModel : BaseModel
{
public WishlistModel()
{
@@ -32,7 +32,7 @@ namespace Grand.Web.Models.ShoppingCart
#region Nested Classes
- public partial class ShoppingCartItemModel : BaseEntityModel
+ public class ShoppingCartItemModel : BaseEntityModel
{
public ShoppingCartItemModel()
{
diff --git a/src/Web/Grand.Web/Models/Upgrade/UpgradeModel.cs b/src/Web/Grand.Web/Models/Upgrade/UpgradeModel.cs
deleted file mode 100644
index 5bc04787c..000000000
--- a/src/Web/Grand.Web/Models/Upgrade/UpgradeModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Grand.Web.Models.Upgrade
-{
- public partial class UpgradeModel
- {
- public string DatabaseVersion { get; set; }
- public string ApplicationVersion { get; set; }
- public string ApplicationDBVersion { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
index 9e67f01b5..f8ce6f0be 100644
--- a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Vendors
{
- public partial class ApplyVendorModel : BaseModel
+ public class ApplyVendorModel : BaseModel
{
public ApplyVendorModel()
diff --git a/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
index 8ba3168ec..863fd15e7 100644
--- a/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/VendorAddressModel.cs
@@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations;
namespace Grand.Web.Models.Vendors
{
- public partial class VendorAddressModel : BaseEntityModel
+ public class VendorAddressModel : BaseEntityModel
{
public VendorAddressModel()
{
diff --git a/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs
index 658b6db6b..4e123a67e 100644
--- a/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Vendors
{
- public partial class VendorInfoModel : BaseModel
+ public class VendorInfoModel : BaseModel
{
public VendorInfoModel()
{
diff --git a/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
index 3a2e620c4..3d18d6bb9 100644
--- a/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
+++ b/src/Web/Grand.Web/Models/Vendors/VendorReviewOverviewModel.cs
@@ -3,7 +3,7 @@ using Grand.Infrastructure.Models;
namespace Grand.Web.Models.Vendors
{
- public partial class VendorReviewOverviewModel : BaseModel
+ public class VendorReviewOverviewModel : BaseModel
{
public string VendorId { get; set; }
@@ -14,7 +14,7 @@ namespace Grand.Web.Models.Vendors
public bool AllowCustomerReviews { get; set; }
}
- public partial class VendorReviewsModel : BaseModel
+ public class VendorReviewsModel : BaseModel
{
public VendorReviewsModel()
{
@@ -32,7 +32,7 @@ namespace Grand.Web.Models.Vendors
public VendorReviewOverviewModel VendorReviewOverview { get; set; }
}
- public partial class VendorReviewModel : BaseEntityModel
+ public class VendorReviewModel : BaseEntityModel
{
public string CustomerId { get; set; }
@@ -49,7 +49,7 @@ namespace Grand.Web.Models.Vendors
public string WrittenOnStr { get; set; }
}
- public partial class VendorReviewHelpfulnessModel : BaseModel
+ public class VendorReviewHelpfulnessModel : BaseModel
{
public string VendorReviewId { get; set; }
public string VendorId { get; set; }
@@ -59,7 +59,7 @@ namespace Grand.Web.Models.Vendors
public int HelpfulNoTotal { get; set; }
}
- public partial class AddVendorReviewModel : BaseModel
+ public class AddVendorReviewModel : BaseModel
{
[GrandResourceDisplayName("Reviews.Fields.Title")]
public string Title { get; set; }
diff --git a/src/Web/Grand.Web/Program.cs b/src/Web/Grand.Web/Program.cs
index 872cf4106..3a9386087 100644
--- a/src/Web/Grand.Web/Program.cs
+++ b/src/Web/Grand.Web/Program.cs
@@ -2,14 +2,16 @@
using Grand.Web.Common.Startup;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
+using StartupBase = Grand.Infrastructure.StartupBase;
var builder = WebApplication.CreateBuilder(args);
-builder.Host.UseDefaultServiceProvider((context, options) =>
+builder.Host.UseDefaultServiceProvider((_, options) =>
{
options.ValidateScopes = false;
options.ValidateOnBuild = false;
@@ -40,7 +42,7 @@ builder.Host.ConfigureAppConfiguration((hostingContext, config) =>
Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(builder.Configuration).CreateLogger();
//add services
-Grand.Infrastructure.StartupBase.ConfigureServices(builder.Services, builder.Configuration);
+StartupBase.ConfigureServices(builder.Services, builder.Configuration);
//Allow non ASCII chars in headers
var config = new AppConfig();
@@ -49,7 +51,7 @@ if (config.AllowNonAsciiCharInHeaders)
{
builder.WebHost.ConfigureKestrel(options =>
{
- options.ResponseHeaderEncodingSelector = (_) => Encoding.UTF8;
+ options.ResponseHeaderEncodingSelector = _ => Encoding.UTF8;
});
}
if (config.MaxRequestBodySize.HasValue)
@@ -59,7 +61,7 @@ if (config.MaxRequestBodySize.HasValue)
host.Limits.MaxRequestBodySize = config.MaxRequestBodySize.Value;
});
- builder.Services.Configure<Microsoft.AspNetCore.Http.Features.FormOptions>(opt =>
+ builder.Services.Configure<FormOptions>(opt =>
{
opt.MultipartBodyLengthLimit = config.MaxRequestBodySize.Value;
});
@@ -72,7 +74,7 @@ builder.Services.RegisterTasks();
var app = builder.Build();
//request pipeline
-Grand.Infrastructure.StartupBase.ConfigureRequestPipeline(app, builder.Environment);
+StartupBase.ConfigureRequestPipeline(app, builder.Environment);
//run app
app.Run();
diff --git a/src/Web/Grand.Web/Themes/Default/Views/_ViewImports.cshtml b/src/Web/Grand.Web/Themes/Default/Views/_ViewImports.cshtml
index 55b41408c..f506024d7 100644
--- a/src/Web/Grand.Web/Themes/Default/Views/_ViewImports.cshtml
+++ b/src/Web/Grand.Web/Themes/Default/Views/_ViewImports.cshtml
@@ -38,5 +38,6 @@
@using Grand.Domain.Orders
@using Grand.Domain.Tax
@using Grand.Domain.Seo
+@using Grand.Web.Common.Localization
-@inject Grand.Web.Common.Localization.LocService Loc
+@inject LocService Loc
diff --git a/src/Web/Grand.Web/Validators/Blogs/BlogPostValidator.cs b/src/Web/Grand.Web/Validators/Blogs/BlogPostValidator.cs
index ad17fde7e..fd5c4d8fe 100644
--- a/src/Web/Grand.Web/Validators/Blogs/BlogPostValidator.cs
+++ b/src/Web/Grand.Web/Validators/Blogs/BlogPostValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Blogs;
namespace Grand.Web.Validators.Blogs
diff --git a/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionSimpleValidator.cs b/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionSimpleValidator.cs
index 591e661aa..f7e880e2b 100644
--- a/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionSimpleValidator.cs
+++ b/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionSimpleValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Catalog;
namespace Grand.Web.Validators.Catalog
diff --git a/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionValidator.cs b/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionValidator.cs
index f113f70a8..c83a14ddc 100644
--- a/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionValidator.cs
+++ b/src/Web/Grand.Web/Validators/Catalog/ProductAskQuestionValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Catalog;
namespace Grand.Web.Validators.Catalog
diff --git a/src/Web/Grand.Web/Validators/Catalog/ProductEmailAFriendValidator.cs b/src/Web/Grand.Web/Validators/Catalog/ProductEmailAFriendValidator.cs
index c87f5ab27..240574ff7 100644
--- a/src/Web/Grand.Web/Validators/Catalog/ProductEmailAFriendValidator.cs
+++ b/src/Web/Grand.Web/Validators/Catalog/ProductEmailAFriendValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Catalog;
namespace Grand.Web.Validators.Catalog
diff --git a/src/Web/Grand.Web/Validators/Catalog/ProductReviewsValidator.cs b/src/Web/Grand.Web/Validators/Catalog/ProductReviewsValidator.cs
index b7d41b078..4276344bd 100644
--- a/src/Web/Grand.Web/Validators/Catalog/ProductReviewsValidator.cs
+++ b/src/Web/Grand.Web/Validators/Catalog/ProductReviewsValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Catalog;
namespace Grand.Web.Validators.Catalog
diff --git a/src/Web/Grand.Web/Validators/Common/AddressValidator.cs b/src/Web/Grand.Web/Validators/Common/AddressValidator.cs
index a06b47e41..bca8a01ac 100644
--- a/src/Web/Grand.Web/Validators/Common/AddressValidator.cs
+++ b/src/Web/Grand.Web/Validators/Common/AddressValidator.cs
@@ -1,8 +1,8 @@
using FluentValidation;
-using Grand.Domain.Common;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Common;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Common;
namespace Grand.Web.Validators.Common
@@ -39,21 +39,17 @@ namespace Grand.Web.Validators.Common
}
if (addressSettings.CountryEnabled && addressSettings.StateProvinceEnabled)
{
- RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, context) =>
+ RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, _) =>
{
var countryId = !string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "";
var country = await countryService.GetCountryById(countryId);
- if (country != null && country.StateProvinces.Any())
+ if (country == null || !country.StateProvinces.Any()) return false;
+ //if yes, then ensure that state is selected
+ if (string.IsNullOrEmpty(y))
{
- //if yes, then ensure that state is selected
- if (String.IsNullOrEmpty(y))
- {
- return false;
- }
- if (country.StateProvinces.FirstOrDefault(x => x.Id == y) != null)
- return true;
+ return false;
}
- return false;
+ return country.StateProvinces.FirstOrDefault(s => s.Id == y) != null;
}).WithMessage(translationService.GetResource("Address.Fields.StateProvince.Required"));
}
if (addressSettings.CompanyRequired && addressSettings.CompanyEnabled)
diff --git a/src/Web/Grand.Web/Validators/Common/ContactUsValidator.cs b/src/Web/Grand.Web/Validators/Common/ContactUsValidator.cs
index fe8497d9e..be2e9c54b 100644
--- a/src/Web/Grand.Web/Validators/Common/ContactUsValidator.cs
+++ b/src/Web/Grand.Web/Validators/Common/ContactUsValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Common;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Common;
namespace Grand.Web.Validators.Common
diff --git a/src/Web/Grand.Web/Validators/Common/ContactVendorValidator.cs b/src/Web/Grand.Web/Validators/Common/ContactVendorValidator.cs
index 85a631381..81bc1e22d 100644
--- a/src/Web/Grand.Web/Validators/Common/ContactVendorValidator.cs
+++ b/src/Web/Grand.Web/Validators/Common/ContactVendorValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Common;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Common;
namespace Grand.Web.Validators.Common
diff --git a/src/Web/Grand.Web/Validators/Customer/AddOrderNoteValidator.cs b/src/Web/Grand.Web/Validators/Customer/AddOrderNoteValidator.cs
index 663bd6ca2..209ece160 100644
--- a/src/Web/Grand.Web/Validators/Customer/AddOrderNoteValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/AddOrderNoteValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Orders;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/ChangePasswordValidator.cs b/src/Web/Grand.Web/Validators/Customer/ChangePasswordValidator.cs
index f5e5b2eaf..9939adea1 100644
--- a/src/Web/Grand.Web/Validators/Customer/ChangePasswordValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/ChangePasswordValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Customers;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs b/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs
index 2eb04ff8c..c8b268b38 100644
--- a/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/CheckoutBillingAddressValidator.cs
@@ -1,8 +1,9 @@
-using Grand.Domain.Common;
-using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Common;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Checkout;
+using Grand.Web.Models.Common;
using Grand.Web.Validators.Common;
namespace Grand.Web.Validators.Customer
@@ -11,7 +12,7 @@ namespace Grand.Web.Validators.Customer
{
public CheckoutBillingAddressValidator(
IEnumerable<IValidatorConsumer<CheckoutBillingAddressModel>> validators,
- IEnumerable<IValidatorConsumer<Models.Common.AddressModel>> addressValidators,
+ IEnumerable<IValidatorConsumer<AddressModel>> addressValidators,
ITranslationService translationService,
ICountryService countryService,
AddressSettings addressSettings)
diff --git a/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs b/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs
index f836035df..7cb482398 100644
--- a/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/CheckoutShippingAddressValidator.cs
@@ -1,8 +1,9 @@
-using Grand.Domain.Common;
-using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Common;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Checkout;
+using Grand.Web.Models.Common;
using Grand.Web.Validators.Common;
namespace Grand.Web.Validators.Customer
@@ -11,7 +12,7 @@ namespace Grand.Web.Validators.Customer
{
public CheckoutShippingAddressValidator(
IEnumerable<IValidatorConsumer<CheckoutShippingAddressModel>> validators,
- IEnumerable<IValidatorConsumer<Models.Common.AddressModel>> addressValidators,
+ IEnumerable<IValidatorConsumer<AddressModel>> addressValidators,
ITranslationService translationService,
ICountryService countryService,
AddressSettings addressSettings)
diff --git a/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs b/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs
index 5cb68b2a8..6f933e59e 100644
--- a/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/CustomerAddressEditValidator.cs
@@ -1,7 +1,8 @@
-using Grand.Domain.Common;
-using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Directory;
+using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Common;
+using Grand.Infrastructure.Validators;
+using Grand.Web.Models.Common;
using Grand.Web.Models.Customer;
using Grand.Web.Validators.Common;
@@ -11,7 +12,7 @@ namespace Grand.Web.Validators.Customer
{
public CustomerAddressEditValidator(
IEnumerable<IValidatorConsumer<CustomerAddressEditModel>> validators,
- IEnumerable<IValidatorConsumer<Models.Common.AddressModel>> addressvalidators,
+ IEnumerable<IValidatorConsumer<AddressModel>> addressvalidators,
ITranslationService translationService,
ICountryService countryService,
AddressSettings addressSettings)
diff --git a/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs b/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs
index 4d8b9aafd..3a3a65f71 100644
--- a/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/CustomerInfoValidator.cs
@@ -1,10 +1,10 @@
using FluentValidation;
-using Grand.Domain.Customers;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Web.Models.Customer;
+using Grand.Domain.Customers;
+using Grand.Infrastructure.Validators;
using Grand.SharedKernel.Extensions;
+using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
{
@@ -45,45 +45,34 @@ namespace Grand.Web.Validators.Customer
customerSettings.StateProvinceEnabled &&
customerSettings.StateProvinceRequired)
{
- RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, context) =>
+ RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, _) =>
{
var countryId = !string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "";
var country = await countryService.GetCountryById(countryId);
- if (country != null && country.StateProvinces.Any())
+ if (country == null || !country.StateProvinces.Any()) return false;
+ //if yes, then ensure that state is selected
+ if (string.IsNullOrEmpty(y))
{
- //if yes, then ensure that state is selected
- if (string.IsNullOrEmpty(y))
- {
- return false;
- }
- if (country.StateProvinces.FirstOrDefault(x => x.Id == y) != null)
- return true;
+ return false;
}
- return false;
-
+ return country.StateProvinces.FirstOrDefault(s => s.Id == y) != null;
}).WithMessage(translationService.GetResource("Account.Fields.StateProvince.Required"));
}
if (customerSettings.DateOfBirthEnabled && customerSettings.DateOfBirthRequired)
{
- RuleFor(x => x.DateOfBirthDay).Must((x, context) =>
+ RuleFor(x => x.DateOfBirthDay).Must((x, _) =>
{
var dateOfBirth = x.ParseDateOfBirth();
- if (!dateOfBirth.HasValue)
- return false;
-
- return true;
+ return dateOfBirth.HasValue;
}).WithMessage(translationService.GetResource("Account.Fields.DateOfBirth.Required"));
//minimum age
- RuleFor(x => x.DateOfBirthDay).Must((x, context) =>
+ RuleFor(x => x.DateOfBirthDay).Must((x, _) =>
{
var dateOfBirth = x.ParseDateOfBirth();
- if (dateOfBirth.HasValue && customerSettings.DateOfBirthMinimumAge.HasValue &&
- CommonHelper.GetDifferenceInYears(dateOfBirth.Value, DateTime.Today) <
- customerSettings.DateOfBirthMinimumAge.Value)
- return false;
-
- return true;
+ return !dateOfBirth.HasValue || !customerSettings.DateOfBirthMinimumAge.HasValue ||
+ CommonHelper.GetDifferenceInYears(dateOfBirth.Value, DateTime.Today) >=
+ customerSettings.DateOfBirthMinimumAge.Value;
}).WithMessage(string.Format(translationService.GetResource("Account.Fields.DateOfBirth.MinimumAge"), customerSettings.DateOfBirthMinimumAge));
}
if (customerSettings.CompanyRequired && customerSettings.CompanyEnabled)
diff --git a/src/Web/Grand.Web/Validators/Customer/DeleteAccountValidator.cs b/src/Web/Grand.Web/Validators/Customer/DeleteAccountValidator.cs
index aaff8082f..fa654eee9 100644
--- a/src/Web/Grand.Web/Validators/Customer/DeleteAccountValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/DeleteAccountValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/LoginValidator.cs b/src/Web/Grand.Web/Validators/Customer/LoginValidator.cs
index 05410d1d8..c6a857ce0 100644
--- a/src/Web/Grand.Web/Validators/Customer/LoginValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/LoginValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Customers;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryConfirmValidator.cs b/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryConfirmValidator.cs
index cda505c6f..85cf1b469 100644
--- a/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryConfirmValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryConfirmValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Customers;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryValidator.cs b/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryValidator.cs
index df352cad2..ee52fac89 100644
--- a/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/PasswordRecoveryValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
diff --git a/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs b/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs
index 892715c67..6ec6fff84 100644
--- a/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/RegisterValidator.cs
@@ -1,10 +1,10 @@
using FluentValidation;
-using Grand.Domain.Customers;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
-using Grand.Web.Models.Customer;
+using Grand.Domain.Customers;
+using Grand.Infrastructure.Validators;
using Grand.SharedKernel.Extensions;
+using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
{
@@ -54,46 +54,35 @@ namespace Grand.Web.Validators.Customer
customerSettings.StateProvinceEnabled &&
customerSettings.StateProvinceRequired)
{
- RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, context) =>
+ RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, _) =>
{
//does selected country has states?
var countryId = !string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "";
var country = await countryService.GetCountryById(countryId);
- if (country != null && country.StateProvinces.Any())
+ if (country == null || !country.StateProvinces.Any()) return false;
+ //if yes, then ensure that state is selected
+ if (string.IsNullOrEmpty(y))
{
- //if yes, then ensure that state is selected
- if (string.IsNullOrEmpty(y))
- {
- return false;
- }
- if (country.StateProvinces.FirstOrDefault(x => x.Id == y) != null)
- return true;
+ return false;
}
- return false;
-
+ return country.StateProvinces.FirstOrDefault(s => s.Id == y) != null;
}).WithMessage(translationService.GetResource("Account.Fields.StateProvince.Required"));
}
if (customerSettings.DateOfBirthEnabled && customerSettings.DateOfBirthRequired)
{
- RuleFor(x => x.DateOfBirthDay).Must((x, context) =>
+ RuleFor(x => x.DateOfBirthDay).Must((x, _) =>
{
var dateOfBirth = x.ParseDateOfBirth();
- if (!dateOfBirth.HasValue)
- return false;
-
- return true;
+ return dateOfBirth.HasValue;
}).WithMessage(translationService.GetResource("Account.Fields.DateOfBirth.Required"));
//minimum age
- RuleFor(x => x.DateOfBirthDay).Must((x, context) =>
+ RuleFor(x => x.DateOfBirthDay).Must((x, _) =>
{
var dateOfBirth = x.ParseDateOfBirth();
- if (dateOfBirth.HasValue && customerSettings.DateOfBirthMinimumAge.HasValue &&
- CommonHelper.GetDifferenceInYears(dateOfBirth.Value, DateTime.Today) <
- customerSettings.DateOfBirthMinimumAge.Value)
- return false;
-
- return true;
+ return !dateOfBirth.HasValue || !customerSettings.DateOfBirthMinimumAge.HasValue ||
+ CommonHelper.GetDifferenceInYears(dateOfBirth.Value, DateTime.Today) >=
+ customerSettings.DateOfBirthMinimumAge.Value;
}).WithMessage(string.Format(translationService.GetResource("Account.Fields.DateOfBirth.MinimumAge"), customerSettings.DateOfBirthMinimumAge));
}
if (customerSettings.CompanyRequired && customerSettings.CompanyEnabled)
diff --git a/src/Web/Grand.Web/Validators/Customer/SubAccountValidator.cs b/src/Web/Grand.Web/Validators/Customer/SubAccountValidator.cs
index 1e7f2bc01..edd4173b0 100644
--- a/src/Web/Grand.Web/Validators/Customer/SubAccountValidator.cs
+++ b/src/Web/Grand.Web/Validators/Customer/SubAccountValidator.cs
@@ -1,7 +1,7 @@
using FluentValidation;
+using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Domain.Customers;
using Grand.Infrastructure.Validators;
-using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Web.Models.Customer;
namespace Grand.Web.Validators.Customer
@@ -21,11 +21,11 @@ namespace Grand.Web.Validators.Customer
RuleFor(x => x.LastName).NotEmpty().WithMessage(translationService.GetResource("Account.Fields.LastName.Required"));
RuleFor(x => x.Password).NotEmpty().WithMessage(translationService.GetResource("Account.Fields.Password.Required"))
- .When(subaccount => (string.IsNullOrEmpty(subaccount.Id)) || (!string.IsNullOrEmpty(subaccount.Id) && !string.IsNullOrEmpty(subaccount.Password)));
+ .When(subaccount => string.IsNullOrEmpty(subaccount.Id) || (!string.IsNullOrEmpty(subaccount.Id) && !string.IsNullOrEmpty(subaccount.Password)));
if (!string.IsNullOrEmpty(customerSettings.PasswordRegularExpression))
RuleFor(x => x.Password).Matches(customerSettings.PasswordRegularExpression).WithMessage(string.Format(translationService.GetResource("Account.Fields.Password.Validation")))
- .When(subaccount => (string.IsNullOrEmpty(subaccount.Id)) || (!string.IsNullOrEmpty(subaccount.Id) && !string.IsNullOrEmpty(subaccount.Password)));
+ .When(subaccount => string.IsNullOrEmpty(subaccount.Id) || (!string.IsNullOrEmpty(subaccount.Id) && !string.IsNullOrEmpty(subaccount.Password)));
}
}
diff --git a/src/Web/Grand.Web/Validators/Knowledgebase/KnowledgebaseArticleValidator.cs b/src/Web/Grand.Web/Validators/Knowledgebase/KnowledgebaseArticleValidator.cs
index 13b184bb6..9c3758c34 100644
--- a/src/Web/Grand.Web/Validators/Knowledgebase/KnowledgebaseArticleValidator.cs
+++ b/src/Web/Grand.Web/Validators/Knowledgebase/KnowledgebaseArticleValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Knowledgebase;
namespace Grand.Web.Validators.Knowledgebase
diff --git a/src/Web/Grand.Web/Validators/News/NewsItemValidator.cs b/src/Web/Grand.Web/Validators/News/NewsItemValidator.cs
index a90a0904c..2c27d9ab3 100644
--- a/src/Web/Grand.Web/Validators/News/NewsItemValidator.cs
+++ b/src/Web/Grand.Web/Validators/News/NewsItemValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.News;
namespace Grand.Web.Validators.News
diff --git a/src/Web/Grand.Web/Validators/ShoppingCart/WishlistEmailAFriendValidator.cs b/src/Web/Grand.Web/Validators/ShoppingCart/WishlistEmailAFriendValidator.cs
index d7b58d21f..dea342a19 100644
--- a/src/Web/Grand.Web/Validators/ShoppingCart/WishlistEmailAFriendValidator.cs
+++ b/src/Web/Grand.Web/Validators/ShoppingCart/WishlistEmailAFriendValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.ShoppingCart;
namespace Grand.Web.Validators.ShoppingCart
diff --git a/src/Web/Grand.Web/Validators/Vendors/ApplyVendorValidator.cs b/src/Web/Grand.Web/Validators/Vendors/ApplyVendorValidator.cs
index cf97f3852..392d8ad3c 100644
--- a/src/Web/Grand.Web/Validators/Vendors/ApplyVendorValidator.cs
+++ b/src/Web/Grand.Web/Validators/Vendors/ApplyVendorValidator.cs
@@ -1,10 +1,9 @@
using FluentValidation;
-using Grand.Domain.Vendors;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Vendors;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Vendors;
-using Grand.Web.Validators.Common;
namespace Grand.Web.Validators.Vendors
{
diff --git a/src/Web/Grand.Web/Validators/Vendors/VendorAddressValidator.cs b/src/Web/Grand.Web/Validators/Vendors/VendorAddressValidator.cs
index 68e7c4d69..c4db43199 100644
--- a/src/Web/Grand.Web/Validators/Vendors/VendorAddressValidator.cs
+++ b/src/Web/Grand.Web/Validators/Vendors/VendorAddressValidator.cs
@@ -1,11 +1,11 @@
using FluentValidation;
-using Grand.Domain.Vendors;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Vendors;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Vendors;
-namespace Grand.Web.Validators.Common
+namespace Grand.Web.Validators.Vendors
{
public class VendorAddressValidator : BaseGrandValidator<VendorAddressModel>
{
@@ -27,22 +27,17 @@ namespace Grand.Web.Validators.Common
}
if (addressSettings.CountryEnabled && addressSettings.StateProvinceEnabled)
{
- RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, context) =>
+ RuleFor(x => x.StateProvinceId).MustAsync(async (x, y, _) =>
{
var countryId = !string.IsNullOrEmpty(x.CountryId) ? x.CountryId : "";
var country = await countryService.GetCountryById(countryId);
- if (country != null && country.StateProvinces.Any())
+ if (country == null || !country.StateProvinces.Any()) return false;
+ //if yes, then ensure that state is selected
+ if (string.IsNullOrEmpty(y))
{
- //if yes, then ensure that state is selected
- if (string.IsNullOrEmpty(y))
- {
- return false;
- }
- if (country.StateProvinces.FirstOrDefault(x => x.Id == y) != null)
- return true;
+ return false;
}
- return false;
-
+ return country.StateProvinces.FirstOrDefault(s => s.Id == y) != null;
}).WithMessage(translationService.GetResource("Account.VendorInfo.StateProvince.Required"));
}
if (addressSettings.CompanyRequired && addressSettings.CompanyEnabled)
diff --git a/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs b/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs
index 18d306e0b..55eb300ab 100644
--- a/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs
+++ b/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs
@@ -1,10 +1,9 @@
using FluentValidation;
-using Grand.Domain.Vendors;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Domain.Vendors;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Vendors;
-using Grand.Web.Validators.Common;
namespace Grand.Web.Validators.Vendors
{
diff --git a/src/Web/Grand.Web/Validators/Vendors/VendorReviewsValidator.cs b/src/Web/Grand.Web/Validators/Vendors/VendorReviewsValidator.cs
index 26e198b65..53b4c701d 100644
--- a/src/Web/Grand.Web/Validators/Vendors/VendorReviewsValidator.cs
+++ b/src/Web/Grand.Web/Validators/Vendors/VendorReviewsValidator.cs
@@ -1,6 +1,6 @@
using FluentValidation;
-using Grand.Infrastructure.Validators;
using Grand.Business.Core.Interfaces.Common.Localization;
+using Grand.Infrastructure.Validators;
using Grand.Web.Models.Vendors;
namespace Grand.Web.Validators.Vendors
diff --git a/src/Web/Grand.Web/Views/Account/AccountActivation.cshtml b/src/Web/Grand.Web/Views/Account/AccountActivation.cshtml
index ea99be310..762dfeea0 100644
--- a/src/Web/Grand.Web/Views/Account/AccountActivation.cshtml
+++ b/src/Web/Grand.Web/Views/Account/AccountActivation.cshtml
@@ -1,5 +1,4 @@
@model AccountActivationModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_SingleColumn";
diff --git a/src/Web/Grand.Web/Views/Account/AddressAdd.cshtml b/src/Web/Grand.Web/Views/Account/AddressAdd.cshtml
index 034cd3882..d8227958a 100644
--- a/src/Web/Grand.Web/Views/Account/AddressAdd.cshtml
+++ b/src/Web/Grand.Web/Views/Account/AddressAdd.cshtml
@@ -1,5 +1,4 @@
@model CustomerAddressEditModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -18,8 +17,13 @@
<h1 class="generalTitle h2">@Loc["Account.CustomerAddresses.AddNew"]</h1>
<div asp-validation-summary="All" class="message-error"></div>
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "Address";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "Address"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress" />
}
<vc:widget widget-zone="customer-address-add-form" additional-data="@Model"></vc:widget>
diff --git a/src/Web/Grand.Web/Views/Account/AddressEdit.cshtml b/src/Web/Grand.Web/Views/Account/AddressEdit.cshtml
index 81f31ef20..e7b4948fa 100644
--- a/src/Web/Grand.Web/Views/Account/AddressEdit.cshtml
+++ b/src/Web/Grand.Web/Views/Account/AddressEdit.cshtml
@@ -1,5 +1,4 @@
@model CustomerAddressEditModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -18,8 +17,13 @@
<h1 class="h2 generalTitle">@Loc["Account.CustomerAddresses.Edit"]</h1>
<div asp-validation-summary="All" class="message-error"></div>
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "Address";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "Address"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress" />
}
<vc:widget widget-zone="customer-address-edit-form" additional-data="@Model"></vc:widget>
diff --git a/src/Web/Grand.Web/Views/Account/Addresses.cshtml b/src/Web/Grand.Web/Views/Account/Addresses.cshtml
index 044f81d46..58cac9bb1 100644
--- a/src/Web/Grand.Web/Views/Account/Addresses.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Addresses.cshtml
@@ -1,5 +1,4 @@
@model CustomerAddressListModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -29,7 +28,7 @@
</tr>
</thead>
<tbody>
- @for (int i = 0; i < Model.Addresses.Count; i++)
+ @for (var i = 0; i < Model.Addresses.Count; i++)
{
var address = Model.Addresses[i];
<tr>
@@ -59,11 +58,11 @@
@address.FaxNumber
</li>
}
- @if (address.CompanyEnabled && !String.IsNullOrEmpty(address.Company))
+ @if (address.CompanyEnabled && !string.IsNullOrEmpty(address.Company))
{
<li class="company">@address.Company</li>
}
- @if (address.VatNumberEnabled && !String.IsNullOrEmpty(address.VatNumber))
+ @if (address.VatNumberEnabled && !string.IsNullOrEmpty(address.VatNumber))
{
<li class="vatnumber">@address.VatNumber</li>
}
@@ -73,7 +72,7 @@
@address.Address1
</li>
}
- @if (address.StreetAddress2Enabled && !String.IsNullOrEmpty(address.Address2))
+ @if (address.StreetAddress2Enabled && !string.IsNullOrEmpty(address.Address2))
{
<li class="address2">
@address.Address2
@@ -92,7 +91,7 @@
}
if (address.StateProvinceEnabled)
{
- if (!String.IsNullOrEmpty(cityStateZip))
+ if (!string.IsNullOrEmpty(cityStateZip))
{
cityStateZip += " ";
}
@@ -100,7 +99,7 @@
}
if (address.ZipPostalCodeEnabled)
{
- if (!String.IsNullOrEmpty(cityStateZip))
+ if (!string.IsNullOrEmpty(cityStateZip))
{
cityStateZip += " ";
}
@@ -110,13 +109,13 @@
@cityStateZip
</li>
}
- @if (address.CountryEnabled && !String.IsNullOrEmpty(address.CountryName))
+ @if (address.CountryEnabled && !string.IsNullOrEmpty(address.CountryName))
{
<li class="country">
@address.CountryName
</li>
}
- @if (!String.IsNullOrEmpty(address.FormattedCustomAddressAttributes))
+ @if (!string.IsNullOrEmpty(address.FormattedCustomAddressAttributes))
{
<li class="custom-attributes-view">
@Html.Raw(address.FormattedCustomAddressAttributes)
diff --git a/src/Web/Grand.Web/Views/Account/Auctions.cshtml b/src/Web/Grand.Web/Views/Account/Auctions.cshtml
index 537d3891c..061606222 100644
--- a/src/Web/Grand.Web/Views/Account/Auctions.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Auctions.cshtml
@@ -1,5 +1,4 @@
@model CustomerAuctionsModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -18,7 +17,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">
@@ -79,7 +78,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/Web/Grand.Web/Views/Account/ChangePassword.cshtml b/src/Web/Grand.Web/Views/Account/ChangePassword.cshtml
index 7417f1fc6..0c8dc3033 100644
--- a/src/Web/Grand.Web/Views/Account/ChangePassword.cshtml
+++ b/src/Web/Grand.Web/Views/Account/ChangePassword.cshtml
@@ -1,5 +1,4 @@
@model ChangePasswordModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -15,7 +14,7 @@
<form asp-route="CustomerChangePassword" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">
<section class="page account-page change-password-page pl-lg-3 pt-3 pt-lg-0">
<h1 class="h2 generalTitle">@Loc["Account.ChangePassword"]</h1>
- @if (!String.IsNullOrEmpty(Model.Result))
+ @if (!string.IsNullOrEmpty(Model.Result))
{
<section class="result alert alert-info">
@Model.Result
diff --git a/src/Web/Grand.Web/Views/Account/Courses.cshtml b/src/Web/Grand.Web/Views/Account/Courses.cshtml
index 55d33a030..85d0b239b 100644
--- a/src/Web/Grand.Web/Views/Account/Courses.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Courses.cshtml
@@ -1,5 +1,4 @@
@model CoursesModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -20,7 +19,7 @@
<div class="card mb-3">
<div class="card-header">
<h3 class="h5 mb-0 d-inline-flex">
- <a href="@Url.RouteUrl("Course", new { SeName = item.SeName })">
+ <a href="@Url.RouteUrl("Course", new { item.SeName })">
@item.Name
</a>
</h3>
diff --git a/src/Web/Grand.Web/Views/Account/DeleteAccount.cshtml b/src/Web/Grand.Web/Views/Account/DeleteAccount.cshtml
index 2f18e1bab..db810778f 100644
--- a/src/Web/Grand.Web/Views/Account/DeleteAccount.cshtml
+++ b/src/Web/Grand.Web/Views/Account/DeleteAccount.cshtml
@@ -1,5 +1,4 @@
@model DeleteAccountModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/Account/Documents.cshtml b/src/Web/Grand.Web/Views/Account/Documents.cshtml
index fba59070d..6234e3def 100644
--- a/src/Web/Grand.Web/Views/Account/Documents.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Documents.cshtml
@@ -1,5 +1,4 @@
@model DocumentsModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/Account/DownloadableProducts.cshtml b/src/Web/Grand.Web/Views/Account/DownloadableProducts.cshtml
index df993fc17..f139a5cf9 100644
--- a/src/Web/Grand.Web/Views/Account/DownloadableProducts.cshtml
+++ b/src/Web/Grand.Web/Views/Account/DownloadableProducts.cshtml
@@ -1,5 +1,4 @@
@model CustomerDownloadableProductsModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -27,7 +26,7 @@
</tr>
</thead>
<tbody role="rowgroup">
- @for (int i = 0; i < Model.Items.Count; i++)
+ @for (var i = 0; i < Model.Items.Count; i++)
{
var item = Model.Items[i];
<tr role="row">
@@ -42,7 +41,7 @@
<td>
<div>
<a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
- @if (!String.IsNullOrEmpty(item.ProductAttributes))
+ @if (!string.IsNullOrEmpty(item.ProductAttributes))
{
<div class="attributes">@Html.Raw(item.ProductAttributes)</div>
}
@@ -50,13 +49,13 @@
</td>
<td>
<div>
- @if (!String.IsNullOrEmpty(item.DownloadId)) {
+ @if (!string.IsNullOrEmpty(item.DownloadId)) {
<a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">
@Loc["DownloadableProducts.Fields.Download"]</a>
}else {
@Loc["DownloadableProducts.Fields.Download.NA"]
}
- @if (!String.IsNullOrEmpty(item.LicenseId)) {
+ @if (!string.IsNullOrEmpty(item.LicenseId)) {
<a href="@Url.RouteUrl("GetLicense", new { orderItemId = item.OrderItemGuid })">
@Loc["DownloadableProducts.Fields.DownloadLicense"]
</a>
diff --git a/src/Web/Grand.Web/Views/Account/EnableTwoFactorAuthenticator.cshtml b/src/Web/Grand.Web/Views/Account/EnableTwoFactorAuthenticator.cshtml
index daba06f86..2d98b0171 100644
--- a/src/Web/Grand.Web/Views/Account/EnableTwoFactorAuthenticator.cshtml
+++ b/src/Web/Grand.Web/Views/Account/EnableTwoFactorAuthenticator.cshtml
@@ -1,12 +1,11 @@
@model CustomerInfoModel.TwoFactorAuthenticationModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
//title
pagebuilder.AddTitleParts(Loc["Title.TwoFactorAuth"]);
- var code = "ManualEntryQrCode";
- var imageUrl = "QrCodeImageUrl";
+ const string code = "ManualEntryQrCode";
+ const string imageUrl = "QrCodeImageUrl";
var errors = Model.CustomValues.ContainsKey("Errors") ? Model.CustomValues["Errors"] : null;
}
@@ -24,7 +23,7 @@
<li>@Loc[$"Account.TwoFactorAuth.{Model.TwoFactorAuthenticationType}.FourthLine"]</li>
</ul>
<div class="message-error">@errors</div>
- @if (Model.TwoFactorAuthenticationType == Grand.Domain.Customers.TwoFactorAuthenticationType.AppVerification)
+ @if (Model.TwoFactorAuthenticationType == TwoFactorAuthenticationType.AppVerification)
{
@await Component.InvokeAsync("Widget", new { widgetZone = "Enable.TwoFactorAuthentication.AppVerification" })
<div class="mb-2">
@@ -72,7 +71,7 @@
</div>
</div>
}
- @if (Model.TwoFactorAuthenticationType == Grand.Domain.Customers.TwoFactorAuthenticationType.EmailVerification)
+ @if (Model.TwoFactorAuthenticationType == TwoFactorAuthenticationType.EmailVerification)
{
@await Component.InvokeAsync("Widget", new { widgetZone = "Enable.TwoFactorAuthentication.EmailVerification" })
<div class="mb-2">
@@ -109,7 +108,7 @@
</div>
</div>
}
- @if (Model.TwoFactorAuthenticationType == Grand.Domain.Customers.TwoFactorAuthenticationType.SMSVerification && string.IsNullOrWhiteSpace(errors))
+ @if (Model.TwoFactorAuthenticationType == TwoFactorAuthenticationType.SMSVerification && string.IsNullOrWhiteSpace(errors))
{
@await Component.InvokeAsync("Widget", new { widgetZone = "Enable.TwoFactorAuthentication.SMSVerification" })
<div class="mb-2">
diff --git a/src/Web/Grand.Web/Views/Account/Info.cshtml b/src/Web/Grand.Web/Views/Account/Info.cshtml
index 5d745faaa..c4e453070 100644
--- a/src/Web/Grand.Web/Views/Account/Info.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Info.cshtml
@@ -1,7 +1,6 @@
@model CustomerInfoModel
-@inject Grand.Domain.Customers.CustomerSettings customerSettings
+@inject CustomerSettings customerSettings
@inject IPageHeadBuilder pagebuilder
-@using Grand.Web.Models.Customer;
@{
Layout = "_TwoColumns";
@@ -161,9 +160,9 @@
control-year="@Html.IdFor(x => x.DateOfBirthYear)"
begin-year="@(DateTime.Now.Year - 100)"
end-year="DateTime.Now.Year"
- selected-day="(Model.DateOfBirthDay.HasValue ? Model.DateOfBirthDay.Value : 0)"
- selected-month="(Model.DateOfBirthMonth.HasValue ? Model.DateOfBirthMonth.Value : 0)"
- selected-year="(Model.DateOfBirthYear.HasValue ? Model.DateOfBirthYear.Value : 0)"
+ selected-day="Model.DateOfBirthDay ?? 0"
+ selected-month="Model.DateOfBirthMonth ?? 0"
+ selected-year="Model.DateOfBirthYear ?? 0"
PartialViewName="Partials/DatePickerDropDowns"
class="col-12 input-group px-0" />
@@ -573,11 +572,11 @@
<h3 class="card-header">@Loc["Account.TwoFactorAuth"]</h3>
@if (Model.Is2faEnabled)
{
- @Html.ActionLink(Loc["Account.TwoFactorAuth.Disable"], "DisableTwoFactorAuthenticator", "Account", new object { }, new { @class = "btn btn-info login-button" })
+ @Html.ActionLink(Loc["Account.TwoFactorAuth.Disable"], "DisableTwoFactorAuthenticator", "Account", new object(), new { @class = "btn btn-info login-button" })
}
else
{
- @Html.ActionLink(Loc["Account.TwoFactorAuth.Enable"], "EnableTwoFactorAuthenticator", "Account", new object { }, new { @class = "btn btn-info login-button" })
+ @Html.ActionLink(Loc["Account.TwoFactorAuth.Enable"], "EnableTwoFactorAuthenticator", "Account", new object(), new { @class = "btn btn-info login-button" })
}
</div>
}
@@ -617,9 +616,8 @@
{
<text>customer_attribute_</text> @item.Id <text>: '@itemValue.Id',</text>
break;
- } else {
- <text>customer_attribute_</text> @item.Id <text>: '',</text>
}
+ <text>customer_attribute_</text> @item.Id <text>: '',</text>
}
}
break;
diff --git a/src/Web/Grand.Web/Views/Account/Login.cshtml b/src/Web/Grand.Web/Views/Account/Login.cshtml
index 2b57ea38f..9f524b74f 100644
--- a/src/Web/Grand.Web/Views/Account/Login.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Login.cshtml
@@ -7,7 +7,7 @@
pagebuilder.AddTitleParts(Loc["Title.Login"]);
//register URL with return URL (if specified)
- var registerUrl = Url.RouteUrl("Register", new { returnUrl = this.Context.Request.Query["returnUrl"] });
+ var registerUrl = Url.RouteUrl("Register", new { returnUrl = Context.Request.Query["returnUrl"] });
}
<div class="page login-page">
<h2 class="generalTitle text-center mt-3">@Loc["Account.Login.Welcome"]</h2>
diff --git a/src/Web/Grand.Web/Views/Account/Notes.cshtml b/src/Web/Grand.Web/Views/Account/Notes.cshtml
index e576641b2..7e4039219 100644
--- a/src/Web/Grand.Web/Views/Account/Notes.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Notes.cshtml
@@ -1,5 +1,4 @@
@model CustomerNotesModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/Account/Partials/CreateOrUpdateSubAccount.cshtml b/src/Web/Grand.Web/Views/Account/Partials/CreateOrUpdateSubAccount.cshtml
index bfb044fb8..98fd4e658 100644
--- a/src/Web/Grand.Web/Views/Account/Partials/CreateOrUpdateSubAccount.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Partials/CreateOrUpdateSubAccount.cshtml
@@ -1,9 +1,5 @@
@model SubAccountModel
-@inject Grand.Domain.Customers.CustomerSettings customerSettings
-@{
- var edit_email = !string.IsNullOrEmpty(Model.Id) && !customerSettings.AllowUsersToChangeEmail;
- var validPassword = string.IsNullOrEmpty(Model.Id) ? "'required|min:Password'" : "";
-}
+
<input asp-for="Id" type="hidden" />
<div class="edit-subaccount row">
<div class="form-group col-sm-12 col-md-6">
diff --git a/src/Web/Grand.Web/Views/Account/Partials/CustomerAttributes.cshtml b/src/Web/Grand.Web/Views/Account/Partials/CustomerAttributes.cshtml
index ab17df4bf..127c5bf4d 100644
--- a/src/Web/Grand.Web/Views/Account/Partials/CustomerAttributes.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Partials/CustomerAttributes.cshtml
@@ -1,7 +1,7 @@
-@model IList<Grand.Web.Models.Customer.CustomerAttributeModel>
+@model IList<CustomerAttributeModel>
@foreach (var attribute in Model)
{
- var controlId = string.Format("customer_attribute_{0}", attribute.Id);
+ var controlId = $"customer_attribute_{attribute.Id}";
var controlName = $"attributes[{attribute.Id}]";
var textPrompt = attribute.Name;
diff --git a/src/Web/Grand.Web/Views/Account/Partials/NewsLetterCategories.cshtml b/src/Web/Grand.Web/Views/Account/Partials/NewsLetterCategories.cshtml
index 4a709b6d2..b78d77d1e 100644
--- a/src/Web/Grand.Web/Views/Account/Partials/NewsLetterCategories.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Partials/NewsLetterCategories.cshtml
@@ -1,4 +1,4 @@
-@model IList<Grand.Web.Models.Newsletter.NewsletterSimpleCategory>
+@model IList<NewsletterSimpleCategory>
@if(Model.Any())
{
<div class="row">
diff --git a/src/Web/Grand.Web/Views/Account/PasswordRecovery.cshtml b/src/Web/Grand.Web/Views/Account/PasswordRecovery.cshtml
index aa9ff65e4..2e9bbf528 100644
--- a/src/Web/Grand.Web/Views/Account/PasswordRecovery.cshtml
+++ b/src/Web/Grand.Web/Views/Account/PasswordRecovery.cshtml
@@ -1,5 +1,4 @@
@model PasswordRecoveryModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_SingleColumn";
@@ -9,7 +8,7 @@
}
<div class="page password-recovery-page">
<h1 class="generalTitle h2">@Loc["Account.PasswordRecovery"]</h1>
- @if (!String.IsNullOrEmpty(Model.Result))
+ @if (!string.IsNullOrEmpty(Model.Result))
{
<div class="result alert alert-info mt-3">
@Model.Result
diff --git a/src/Web/Grand.Web/Views/Account/PasswordRecoveryConfirm.cshtml b/src/Web/Grand.Web/Views/Account/PasswordRecoveryConfirm.cshtml
index 559a3890a..918aa042f 100644
--- a/src/Web/Grand.Web/Views/Account/PasswordRecoveryConfirm.cshtml
+++ b/src/Web/Grand.Web/Views/Account/PasswordRecoveryConfirm.cshtml
@@ -6,10 +6,9 @@
//title
pagebuilder.AddTitleParts(Loc["Title.PasswordRecovery"]);
}
-@using Grand.Web.Models.Customer;
<div class="page password-recovery-page">
<h1 class="generalTitle h2">@Loc["Account.PasswordRecovery"]</h1>
- @if (!String.IsNullOrEmpty(Model.Result))
+ @if (!string.IsNullOrEmpty(Model.Result))
{
<div class="alert alert-info mt-3">@Model.Result</div>
}
diff --git a/src/Web/Grand.Web/Views/Account/Register.cshtml b/src/Web/Grand.Web/Views/Account/Register.cshtml
index 7b37686ca..595d7f921 100644
--- a/src/Web/Grand.Web/Views/Account/Register.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Register.cshtml
@@ -146,9 +146,9 @@
control-year="@Html.IdFor(x => x.DateOfBirthYear)"
begin-year="@(DateTime.Now.Year - 100)"
end-year="DateTime.Now.Year"
- selected-day="Model.DateOfBirthDay.HasValue ? Model.DateOfBirthDay.Value : 0"
- selected-month="Model.DateOfBirthMonth.HasValue ? Model.DateOfBirthMonth.Value : 0"
- selected-year="Model.DateOfBirthYear.HasValue ? Model.DateOfBirthYear.Value : 0"
+ selected-day="Model.DateOfBirthDay ?? 0"
+ selected-month="Model.DateOfBirthMonth ?? 0"
+ selected-year="Model.DateOfBirthYear ?? 0"
PartialViewName="Partials/DatePickerDropDowns"
class="col-12 input-group px-0" />
</div>
@@ -544,9 +544,8 @@
{
<text>customer_attribute_</text> @item.Id <text>: '@itemValue.Id',</text>
break;
- } else {
- <text>customer_attribute_</text> @item.Id <text>: '',</text>
- }
+ }
+ <text>customer_attribute_</text> @item.Id <text>: '',</text>
}
}
break;
diff --git a/src/Web/Grand.Web/Views/Account/RegisterResult.cshtml b/src/Web/Grand.Web/Views/Account/RegisterResult.cshtml
index 3d068fa08..d43bf482a 100644
--- a/src/Web/Grand.Web/Views/Account/RegisterResult.cshtml
+++ b/src/Web/Grand.Web/Views/Account/RegisterResult.cshtml
@@ -7,9 +7,9 @@
pagebuilder.AddTitleParts(Loc["Title.Register"]);
//continue URL
- var qs = this.Context.Request.Query["ReturnUrl"];
+ var qs = Context.Request.Query["ReturnUrl"];
var continueUrl = "";
- if (!String.IsNullOrEmpty(qs) && Url.IsLocalUrl(qs))
+ if (!string.IsNullOrEmpty(qs) && Url.IsLocalUrl(qs))
{
continueUrl = qs;
}
diff --git a/src/Web/Grand.Web/Views/Account/Reviews.cshtml b/src/Web/Grand.Web/Views/Account/Reviews.cshtml
index e3bcf16e7..42a70f0f3 100644
--- a/src/Web/Grand.Web/Views/Account/Reviews.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Reviews.cshtml
@@ -1,5 +1,4 @@
@model CustomerProductReviewsModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@inject IWorkContext workContext
@{
@@ -21,7 +20,7 @@
<div class="product-review-list">
@foreach (var review in Model.Reviews)
{
- int ratingStars = review.Rating;
+ var ratingStars = review.Rating;
<div class="card product-review-item mb-3">
<header class="card-header">
<div class="review-info d-inline-flex w-100">
diff --git a/src/Web/Grand.Web/Views/Account/SubAccountAdd.cshtml b/src/Web/Grand.Web/Views/Account/SubAccountAdd.cshtml
index b0e962995..8abdca4bc 100644
--- a/src/Web/Grand.Web/Views/Account/SubAccountAdd.cshtml
+++ b/src/Web/Grand.Web/Views/Account/SubAccountAdd.cshtml
@@ -1,5 +1,4 @@
@model SubAccountModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/Account/SubAccountEdit.cshtml b/src/Web/Grand.Web/Views/Account/SubAccountEdit.cshtml
index a8e3675c9..e76a2fd0d 100644
--- a/src/Web/Grand.Web/Views/Account/SubAccountEdit.cshtml
+++ b/src/Web/Grand.Web/Views/Account/SubAccountEdit.cshtml
@@ -1,5 +1,4 @@
@model SubAccountModel
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/Account/SubAccounts.cshtml b/src/Web/Grand.Web/Views/Account/SubAccounts.cshtml
index eb1fe1cd1..d329b8d6a 100644
--- a/src/Web/Grand.Web/Views/Account/SubAccounts.cshtml
+++ b/src/Web/Grand.Web/Views/Account/SubAccounts.cshtml
@@ -1,5 +1,4 @@
@model IList<SubAccountSimpleModel>
-@using Grand.Web.Models.Customer;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -22,7 +21,7 @@
{
<div class="col-12 px-0">
<div class="row account-list">
- @for (int i = 0; i < Model.Count; i++)
+ @for (var i = 0; i < Model.Count; i++)
{
var account = Model[i];
<div class="col-md-6 col-12 mb-3">
diff --git a/src/Web/Grand.Web/Views/Account/TwoFactorAuthorization.cshtml b/src/Web/Grand.Web/Views/Account/TwoFactorAuthorization.cshtml
index a3663869b..c2dab7f96 100644
--- a/src/Web/Grand.Web/Views/Account/TwoFactorAuthorization.cshtml
+++ b/src/Web/Grand.Web/Views/Account/TwoFactorAuthorization.cshtml
@@ -5,8 +5,6 @@
//title
pagebuilder.AddTitleParts(Loc["Title.Login"]);
- //register URL with return URL (if specified)
- var registerUrl = Url.RouteUrl("Register", new { returnUrl = this.Context.Request.Query["returnUrl"] });
}
<div class="page login-page">
<h1 class="generalTitle h2 text-center">@Loc["Login.TwoFactorAuth.EnterCode"]</h1>
diff --git a/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml b/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
index 0365e8856..798fad99c 100644
--- a/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/BlogPost.cshtml
@@ -1,11 +1,10 @@
@model BlogPostModel
-@using Grand.Web.Models.Blogs;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
//title
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
}
@@ -47,10 +46,10 @@
{
<div class="tags generalMarginSupporter">
<div class="col-form-label w-100">@Loc["Blog.Tags"]:</div>
- @for (int i = 0; i < Model.Tags.Count; i++)
+ @for (var i = 0; i < Model.Tags.Count; i++)
{
var tag = Model.Tags[i];
- <a class="btn btn-sm btn-light mr-2 mb-2" href="@Url.RouteUrl("BlogByTag", new {tag = tag})">@tag</a>
+ <a class="btn btn-sm btn-light mr-2 mb-2" href="@Url.RouteUrl("BlogByTag", new { tag})">@tag</a>
}
</div>
}
@@ -65,7 +64,7 @@
@{
var result = TempData["Grand.blog.addcomment.result"] as string;
}
- @if (!String.IsNullOrEmpty(result))
+ @if (!string.IsNullOrEmpty(result))
{
<div class="result alert alert-info">@result</div>
}
diff --git a/src/Web/Grand.Web/Views/Blog/Components/BlogCategories/Default.cshtml b/src/Web/Grand.Web/Views/Blog/Components/BlogCategories/Default.cshtml
index 8158a8f35..7147f1af0 100644
--- a/src/Web/Grand.Web/Views/Blog/Components/BlogCategories/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/Components/BlogCategories/Default.cshtml
@@ -1,5 +1,4 @@
@model IList<BlogPostCategoryModel>
-@using Grand.Web.Models.Blogs
@if (Model.Any())
{
<section id="block-blog-archive" class="block block-blog-archive">
diff --git a/src/Web/Grand.Web/Views/Blog/Components/BlogMonths/Default.cshtml b/src/Web/Grand.Web/Views/Blog/Components/BlogMonths/Default.cshtml
index 8c1f23956..418ec2849 100644
--- a/src/Web/Grand.Web/Views/Blog/Components/BlogMonths/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/Components/BlogMonths/Default.cshtml
@@ -1,5 +1,4 @@
@model IList<BlogPostYearModel>
-@using Grand.Web.Models.Blogs;
@if (Model.Any())
{
<section id="block-blog-archive" class="block block-blog-archive">
diff --git a/src/Web/Grand.Web/Views/Blog/Components/BlogTags/Default.cshtml b/src/Web/Grand.Web/Views/Blog/Components/BlogTags/Default.cshtml
index e0634a9b1..06609b0f0 100644
--- a/src/Web/Grand.Web/Views/Blog/Components/BlogTags/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/Components/BlogTags/Default.cshtml
@@ -1,5 +1,4 @@
@model BlogPostTagListModel
-@using Grand.Web.Models.Blogs
@if (Model.Tags.Any())
{
<div id="block-popular-blogtags" class="block block-popular-blogtags">
diff --git a/src/Web/Grand.Web/Views/Blog/List.cshtml b/src/Web/Grand.Web/Views/Blog/List.cshtml
index 61f051e9f..8a438594a 100644
--- a/src/Web/Grand.Web/Views/Blog/List.cshtml
+++ b/src/Web/Grand.Web/Views/Blog/List.cshtml
@@ -1,5 +1,4 @@
@model BlogPostListModel
-@using Grand.Web.Models.Blogs;
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -18,11 +17,11 @@
}
<div class="page blog-page">
<h2 class="generalTitle">
- @if (String.IsNullOrEmpty(Model.PagingFilteringContext.Tag))
+ @if (string.IsNullOrEmpty(Model.PagingFilteringContext.Tag))
{
if (Model.PagingFilteringContext.GetParsedMonth().HasValue)
{
- @String.Format(Loc["Blog.FilteredByMonth"], Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"))
+ @string.Format(Loc["Blog.FilteredByMonth"], Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"))
}
else
{
@@ -31,7 +30,7 @@
}
else
{
- @String.Format(Loc["Blog.TaggedWith"], Model.PagingFilteringContext.Tag)
+ @string.Format(Loc["Blog.TaggedWith"], Model.PagingFilteringContext.Tag)
}
@if (!string.IsNullOrEmpty(Model.SearchKeyword))
{
@@ -66,31 +65,31 @@
}
<div class="card-header">
<h3 class="h5 mb-0">
- <a href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
+ <a href="@Url.RouteUrl("BlogPost", new { item.SeName })">
@item.Title
</a>
</h3>
</div>
<div class="card-body">
- @Html.Raw(!String.IsNullOrEmpty(item.BodyOverview) ? item.BodyOverview : item.Body)
+ @Html.Raw(!string.IsNullOrEmpty(item.BodyOverview) ? item.BodyOverview : item.Body)
@if (item.Tags.Any())
{
<div class="tags">
<div class="col-form-label w-100">@Loc["Blog.Tags"]:</div>
- @for (int i = 0; i < item.Tags.Count; i++)
+ @for (var i = 0; i < item.Tags.Count; i++)
{
var tag = item.Tags[i];
- <a class="btn btn-sm btn-light my-1" href="@Url.RouteUrl("BlogByTag", new {tag = tag})">@tag</a>
+ <a class="btn btn-sm btn-light my-1" href="@Url.RouteUrl("BlogByTag", new { tag})">@tag</a>
}
</div>
}
<div class="buttons mt-3">
@if (item.AllowComments)
{
- <a href="@Url.RouteUrl("BlogPost", new {SeName = item.SeName})#comments" class="btn btn-outline-secondary read-comments">@string.Format(Loc["Blog.CommentsLink"], item.NumberOfComments)</a>
+ <a href="@Url.RouteUrl("BlogPost", new { item.SeName})#comments" class="btn btn-outline-secondary read-comments">@string.Format(Loc["Blog.CommentsLink"], item.NumberOfComments)</a>
}
- <a href="@Url.RouteUrl("BlogPost", new {SeName = item.SeName})" class="btn btn-outline-info read-more">@Loc["Blog.MoreInfo"]</a>
+ <a href="@Url.RouteUrl("BlogPost", new { item.SeName})" class="btn btn-outline-info read-more">@Loc["Blog.MoreInfo"]</a>
</div>
</div>
<div class="card-footer">
diff --git a/src/Web/Grand.Web/Views/Catalog/BrandAll.cshtml b/src/Web/Grand.Web/Views/Catalog/BrandAll.cshtml
index ca2973890..c5ea2dbe4 100644
--- a/src/Web/Grand.Web/Views/Catalog/BrandAll.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/BrandAll.cshtml
@@ -1,5 +1,4 @@
@model IList<BrandModel>
-@using Grand.Web.Models.Catalog
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -14,7 +13,7 @@
@foreach (var item in Model)
{
<div class="col-md-4 col-6 mb-2">
- <a class="mb-2" href="@Url.RouteUrl("Brand", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a class="mb-2" href="@Url.RouteUrl("Brand", new { item.SeName })" title="@item.PictureModel.Title">
<div class="card">
<article>
<img class="img-fluid" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText">
diff --git a/src/Web/Grand.Web/Views/Catalog/BrandLayout.GridOrLines.cshtml b/src/Web/Grand.Web/Views/Catalog/BrandLayout.GridOrLines.cshtml
index 4791112d7..84ad01f1b 100644
--- a/src/Web/Grand.Web/Views/Catalog/BrandLayout.GridOrLines.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/BrandLayout.GridOrLines.cshtml
@@ -4,14 +4,14 @@
@{
Layout = "_TwoColumns";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var collectionUrl = Url.RouteUrl("Brand", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var collectionUrl = Url.RouteUrl("Brand", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(collectionUrl);
}
}
@@ -20,7 +20,7 @@
<h1 class="generalTitle h2">@Model.Name</h1>
@await Component.InvokeAsync("Widget", new { widgetZone = "branddetails_top", additionalData = Model.Id })
@*Rendering description section*@
- @if (!String.IsNullOrWhiteSpace(Model.Description))
+ @if (!string.IsNullOrWhiteSpace(Model.Description))
{
<div class="card collection-description">
<div class="card-body">
@@ -67,7 +67,7 @@
</div>
@*Rendering bottom description section*@
- @if (!String.IsNullOrWhiteSpace(Model.BottomDescription))
+ @if (!string.IsNullOrWhiteSpace(Model.BottomDescription))
{
<div class="card brand-description">
<div class="card-body">
diff --git a/src/Web/Grand.Web/Views/Catalog/CategoryLayout.GridOrLines.cshtml b/src/Web/Grand.Web/Views/Catalog/CategoryLayout.GridOrLines.cshtml
index 8c61d569e..2721fe613 100644
--- a/src/Web/Grand.Web/Views/Catalog/CategoryLayout.GridOrLines.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/CategoryLayout.GridOrLines.cshtml
@@ -4,18 +4,18 @@
@{
Layout = "_TwoColumns";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var categoryUrl = Url.RouteUrl("Category", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var categoryUrl = Url.RouteUrl("Category", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(categoryUrl);
}
}
-@* Rednering category breadcrumbs*@
+@* Rendering category breadcrumbs*@
@section Breadcrumb
{
@if (Model.DisplayCategoryBreadcrumb)
@@ -44,7 +44,7 @@
<a>
<strong class="current-item" itemprop="name">@cat.Name</strong>
<span itemprop="item" itemscope itemtype="http://schema.org/Thing"
- id="@Url.RouteUrl("Category", new {SeName = cat.SeName})">
+ id="@Url.RouteUrl("Category", new { cat.SeName})">
</span>
<meta itemprop="position" content="@count" />
</a>
@@ -53,10 +53,10 @@
else
{
<li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">
- <a href="@Url.RouteUrl("Category", new { SeName = cat.SeName })" title="@cat.Name" itemprop="item">
+ <a href="@Url.RouteUrl("Category", new { cat.SeName })" title="@cat.Name" itemprop="item">
<span itemprop="name">@cat.Name</span>
<span itemprop="item" itemscope itemtype="http://schema.org/Thing"
- id="@Url.RouteUrl("Category", new { SeName = cat.SeName })">
+ id="@Url.RouteUrl("Category", new { cat.SeName })">
</span>
<meta itemprop="position" content="@count" />
</a>
@@ -73,7 +73,7 @@
<h1 class="generalTitle h2">@Model.Name</h1>
@await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })
@*Rendering category description*@
- @if (!String.IsNullOrWhiteSpace(Model.Description))
+ @if (!string.IsNullOrWhiteSpace(Model.Description))
{
<div class="card mb-2">
<div class="card-body">
@@ -90,7 +90,7 @@
@foreach (var item in Model.SubCategories)
{
<div class="col-md-4 col-6 mb-2">
- <a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Category", new { item.SeName })" title="@item.PictureModel.Title">
<div class="card mb-2">
<article>
<img class="img-fluid" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText">
@@ -161,7 +161,7 @@
</template>
</div>
@*Rendering bottom description*@
- @if (!String.IsNullOrWhiteSpace(Model.BottomDescription))
+ @if (!string.IsNullOrWhiteSpace(Model.BottomDescription))
{
<div class="card">
<div class="card-body">
@@ -169,7 +169,7 @@
</div>
</div>
}
- @*Rendering rccently viewed products section*@
+ @*Rendering recently viewed products section*@
@await Component.InvokeAsync("RecentlyViewedProductsBlock", new { productThumbPictureSize = 235 })
diff --git a/src/Web/Grand.Web/Views/Catalog/CollectionAll.cshtml b/src/Web/Grand.Web/Views/Catalog/CollectionAll.cshtml
index de01614b9..27264b5b1 100644
--- a/src/Web/Grand.Web/Views/Catalog/CollectionAll.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/CollectionAll.cshtml
@@ -1,5 +1,4 @@
@model IList<CollectionModel>
-@using Grand.Web.Models.Catalog
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -14,7 +13,7 @@
@foreach (var item in Model)
{
<div class="col-md-4 col-6 mb-2">
- <a class="mb-2" href="@Url.RouteUrl("Collection", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a class="mb-2" href="@Url.RouteUrl("Collection", new { item.SeName })" title="@item.PictureModel.Title">
<div class="card">
<article>
<img class="img-fluid" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText">
diff --git a/src/Web/Grand.Web/Views/Catalog/CollectionLayout.GridOrLines.cshtml b/src/Web/Grand.Web/Views/Catalog/CollectionLayout.GridOrLines.cshtml
index eeccf244f..6498e219d 100644
--- a/src/Web/Grand.Web/Views/Catalog/CollectionLayout.GridOrLines.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/CollectionLayout.GridOrLines.cshtml
@@ -3,14 +3,14 @@
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var collectionUrl = Url.RouteUrl("Collection", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var collectionUrl = Url.RouteUrl("Collection", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(collectionUrl);
}
}
@@ -19,7 +19,7 @@
<h1 class="generalTitle h2">@Model.Name</h1>
@await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_top", additionalData = Model.Id })
@*Rendering description section*@
- @if (!String.IsNullOrWhiteSpace(Model.Description))
+ @if (!string.IsNullOrWhiteSpace(Model.Description))
{
<div class="card collection-description">
<div class="card-body">
@@ -82,7 +82,7 @@
</div>
@*Rendering bottom description section*@
- @if (!String.IsNullOrWhiteSpace(Model.BottomDescription))
+ @if (!string.IsNullOrWhiteSpace(Model.BottomDescription))
{
<div class="card collection-description">
<div class="card-body">
diff --git a/src/Web/Grand.Web/Views/Catalog/Components/VendorReviews/Partials/VendorReview.Modal.cshtml b/src/Web/Grand.Web/Views/Catalog/Components/VendorReviews/Partials/VendorReview.Modal.cshtml
index 97418f7c3..3f802b7c5 100644
--- a/src/Web/Grand.Web/Views/Catalog/Components/VendorReviews/Partials/VendorReview.Modal.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Components/VendorReviews/Partials/VendorReview.Modal.cshtml
@@ -1,6 +1,6 @@
@model VendorReviewsModel
@{
- var vendorlink = @Url.RouteUrl("Vendor", new { SeName = Model.VendorSeName } );
+ var vendorlink = Url.RouteUrl("Vendor", new { SeName = Model.VendorSeName } );
}
<b-modal id="ModalVendorReview" ref="ModalVendorReview" :dark-theme="darkMode" size="xl" @@shown="vendorreviews.modalReviewShown()" @@hide="vendorreviews.modalReviewClose()" centered hide-footer hide-header>
<template v-if="vendorreviews.Model !== null">
diff --git a/src/Web/Grand.Web/Views/Catalog/Partials/VendorReviewOverview.cshtml b/src/Web/Grand.Web/Views/Catalog/Partials/VendorReviewOverview.cshtml
index 0f1c22f19..957384df8 100644
--- a/src/Web/Grand.Web/Views/Catalog/Partials/VendorReviewOverview.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Partials/VendorReviewOverview.cshtml
@@ -1,10 +1,10 @@
-@model VendorReviewOverviewModel
-@using System.Globalization
+@using System.Globalization
+@model VendorReviewOverviewModel
@{
- int ratingPercent = 0;
+ var ratingPercent = 0;
if (Model.TotalReviews != 0)
{
- ratingPercent = ((Model.RatingSum * 100) / Model.TotalReviews) / 5;
+ ratingPercent = Model.RatingSum * 100 / Model.TotalReviews / 5;
}
}
@if (Model.AllowCustomerReviews)
@@ -14,7 +14,7 @@
double ratingValue = 0;
if (Model.TotalReviews != 0)
{
- ratingValue = Convert.ToDouble(((Model.RatingSum * (double)100) / Model.TotalReviews) / (double)100);
+ ratingValue = Convert.ToDouble(Model.RatingSum * (double)100 / Model.TotalReviews / 100);
}
}
<div class="rating">
@@ -27,7 +27,7 @@
</b-button>
</div>
@{
- double ratingValuee = ratingPercent / (double)20;
+ var ratingValuee = ratingPercent / (double)20;
}
<span itemprop="reviewCount" style="display: none;">(@ratingValuee.ToString("0.0", new CultureInfo("en-US")))</span>
</template>
diff --git a/src/Web/Grand.Web/Views/Catalog/ProductTagsAll.cshtml b/src/Web/Grand.Web/Views/Catalog/ProductTagsAll.cshtml
index 9c1313bae..22464c669 100644
--- a/src/Web/Grand.Web/Views/Catalog/ProductTagsAll.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/ProductTagsAll.cshtml
@@ -1,5 +1,4 @@
@model PopularProductTagsModel
-@using Grand.Web.Models.Catalog
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -14,7 +13,7 @@
<div class="btn-group-sm">
@foreach (var item in Model.Tags)
{
- <a class="btn btn-light d-flex align-items-center mr-2 mb-2" href="@Url.RouteUrl("ProductsByTagName", new { SeName = item.SeName })" style="font-size:@(Model.GetFontSize(item))%;">
+ <a class="btn btn-light d-flex align-items-center mr-2 mb-2" href="@Url.RouteUrl("ProductsByTagName", new { item.SeName })" style="font-size:@(Model.GetFontSize(item))%;">
@item.Name
</a>
}
diff --git a/src/Web/Grand.Web/Views/Catalog/ProductsByTag.cshtml b/src/Web/Grand.Web/Views/Catalog/ProductsByTag.cshtml
index da9b52f61..caef79074 100644
--- a/src/Web/Grand.Web/Views/Catalog/ProductsByTag.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/ProductsByTag.cshtml
@@ -11,12 +11,12 @@
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var productsByTagUrl = Url.RouteUrl("ProductsByTag", new { productTagId = Model.Id, SeName = Model.TagSeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var productsByTagUrl = Url.RouteUrl("ProductsByTag", new { productTagId = Model.Id, SeName = Model.TagSeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(productsByTagUrl);
}
}
<div class="page product-tag-page">
- <h1 class="generalTitle h2">@String.Format(Loc["Products.Tags.ProductsTaggedWith"], Model.TagName)</h1>
+ <h1 class="generalTitle h2">@string.Format(Loc["Products.Tags.ProductsTaggedWith"], Model.TagName)</h1>
@await Component.InvokeAsync("Widget", new { widgetZone = "productsbytag_top", additionalData = Model.Id })
<div id="catalog-products">
<partial name="Partials/Selectors" />
diff --git a/src/Web/Grand.Web/Views/Catalog/Search.cshtml b/src/Web/Grand.Web/Views/Catalog/Search.cshtml
index 6580a6fcb..ce36b0800 100644
--- a/src/Web/Grand.Web/Views/Catalog/Search.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Search.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Web.Models.Catalog.SearchModel
+@model SearchModel
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -134,7 +134,7 @@
<partial name="Partials/Pagination" />
</template>
</div>
- @if (!String.IsNullOrEmpty(Model.Warning))
+ @if (!string.IsNullOrEmpty(Model.Warning))
{
<div class="warning alert alert-danger my-3">
@Model.Warning
diff --git a/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml b/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
index 6b23259c9..1b5dd40c2 100644
--- a/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/Vendor.cshtml
@@ -3,14 +3,14 @@
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var vendorUrl = Url.RouteUrl("Vendor", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var vendorUrl = Url.RouteUrl("Vendor", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(vendorUrl);
}
}
@@ -41,7 +41,7 @@
<div class="row">
<div class="col-12">
<b-tabs class="mt-3" content-class="mt-3" align="center">
- @if (!String.IsNullOrEmpty(Model.Description))
+ @if (!string.IsNullOrEmpty(Model.Description))
{
<b-tab id="description-tab" title="@Loc["vendor.Description"]" active>
<article class="text-xs-center generalMarginSupporter vendor-description" v-html="catalog.Model.Description"></article>
@@ -51,21 +51,21 @@
{
<b-tab id="address-tab" title="@Loc["Vendor.Address"]">
<ul class="info px-0 mb-0">
- @if (Model.Address.CompanyEnabled && !String.IsNullOrEmpty(Model.Address.Company))
+ @if (Model.Address.CompanyEnabled && !string.IsNullOrEmpty(Model.Address.Company))
{
<li class="company">
<label class="col-form-label">@Loc["Address.Fields.Company"]:</label>
@Model.Address.Company
</li>
}
- @if (Model.Address.StreetAddressEnabled && !String.IsNullOrEmpty(Model.Address.Address1))
+ @if (Model.Address.StreetAddressEnabled && !string.IsNullOrEmpty(Model.Address.Address1))
{
<li class="address1">
<label class="col-form-label w-100">@Loc["Address.Fields.Address1"]:</label>
@Model.Address.Address1
</li>
}
- @if (Model.Address.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.Address.Address2))
+ @if (Model.Address.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.Address.Address2))
{
<li class="address2">
<label class="col-form-label">@Loc["Address.Fields.Address2"]:</label>
@@ -75,7 +75,7 @@
@if (Model.Address.CityEnabled || Model.Address.StateProvinceEnabled || Model.Address.ZipPostalCodeEnabled)
{
var cityStateZip = "";
- if (Model.Address.CityEnabled && !String.IsNullOrEmpty(Model.Address.City))
+ if (Model.Address.CityEnabled && !string.IsNullOrEmpty(Model.Address.City))
{
cityStateZip = Model.Address.City;
if (Model.Address.StateProvinceEnabled || Model.Address.ZipPostalCodeEnabled)
@@ -85,7 +85,7 @@
}
if (Model.Address.StateProvinceEnabled)
{
- if (!String.IsNullOrEmpty(cityStateZip))
+ if (!string.IsNullOrEmpty(cityStateZip))
{
cityStateZip += " ";
}
@@ -93,33 +93,33 @@
}
if (Model.Address.ZipPostalCodeEnabled)
{
- if (!String.IsNullOrEmpty(cityStateZip))
+ if (!string.IsNullOrEmpty(cityStateZip))
{
cityStateZip += " ";
}
cityStateZip += Model.Address.ZipPostalCode;
}
- if (!String.IsNullOrEmpty(cityStateZip))
+ if (!string.IsNullOrEmpty(cityStateZip))
{
<li class="city-state-zip">
@cityStateZip
</li>
}
}
- @if (Model.Address.CountryEnabled && !String.IsNullOrEmpty(Model.Address.CountryName))
+ @if (Model.Address.CountryEnabled && !string.IsNullOrEmpty(Model.Address.CountryName))
{
<li class="country">
@Model.Address.CountryName
</li>
}
- @if (Model.Address.PhoneEnabled && !String.IsNullOrEmpty(Model.Address.PhoneNumber))
+ @if (Model.Address.PhoneEnabled && !string.IsNullOrEmpty(Model.Address.PhoneNumber))
{
<li class="phone">
<label class="col-form-label">@Loc["Address.Fields.PhoneNumber"]:</label>
@Model.Address.PhoneNumber
</li>
}
- @if (Model.Address.FaxEnabled && !String.IsNullOrEmpty(Model.Address.FaxNumber))
+ @if (Model.Address.FaxEnabled && !string.IsNullOrEmpty(Model.Address.FaxNumber))
{
<li class="fax">
<label class="col-form-label">@Loc["Address.Fields.FaxNumber"]:</label>
diff --git a/src/Web/Grand.Web/Views/Catalog/VendorAll.cshtml b/src/Web/Grand.Web/Views/Catalog/VendorAll.cshtml
index 7d401f315..389f31cd5 100644
--- a/src/Web/Grand.Web/Views/Catalog/VendorAll.cshtml
+++ b/src/Web/Grand.Web/Views/Catalog/VendorAll.cshtml
@@ -1,5 +1,4 @@
@model IList<VendorModel>
-@using Grand.Web.Models.Catalog
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -15,7 +14,7 @@
@foreach (var item in Model)
{
<div class="col-md-4 col-6">
- <a class="mb-2" href="@Url.RouteUrl("Vendor", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a class="mb-2" href="@Url.RouteUrl("Vendor", new { item.SeName })" title="@item.PictureModel.Title">
<div class="card">
<article>
<img class="img-fluid" src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText">
diff --git a/src/Web/Grand.Web/Views/Checkout/Partials/BillingAddress.cshtml b/src/Web/Grand.Web/Views/Checkout/Partials/BillingAddress.cshtml
index 30efccbbc..42539452d 100644
--- a/src/Web/Grand.Web/Views/Checkout/Partials/BillingAddress.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Partials/BillingAddress.cshtml
@@ -35,8 +35,13 @@
<div class="enter-address">
<div asp-validation-summary="ModelOnly" class="message-error"></div>
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "BillingNewAddress";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "BillingNewAddress"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.BillingAddress.BillingNewAddress" view-data="dataDictAddress" />
}
</div>
diff --git a/src/Web/Grand.Web/Views/Checkout/Partials/BillingWithoutShipping.cshtml b/src/Web/Grand.Web/Views/Checkout/Partials/BillingWithoutShipping.cshtml
index 1918100ee..321bf7a88 100644
--- a/src/Web/Grand.Web/Views/Checkout/Partials/BillingWithoutShipping.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Partials/BillingWithoutShipping.cshtml
@@ -15,23 +15,23 @@
var addressLine = "";
addressLine += address.FirstName;
addressLine += " " + address.LastName;
- if (address.StreetAddressEnabled && !String.IsNullOrEmpty(address.Address1))
+ if (address.StreetAddressEnabled && !string.IsNullOrEmpty(address.Address1))
{
addressLine += ", " + address.Address1;
}
- if (address.CityEnabled && !String.IsNullOrEmpty(address.City))
+ if (address.CityEnabled && !string.IsNullOrEmpty(address.City))
{
addressLine += ", " + address.City;
}
- if (address.StateProvinceEnabled && !String.IsNullOrEmpty(address.StateProvinceName))
+ if (address.StateProvinceEnabled && !string.IsNullOrEmpty(address.StateProvinceName))
{
addressLine += ", " + address.StateProvinceName;
}
- if (address.ZipPostalCodeEnabled && !String.IsNullOrEmpty(address.ZipPostalCode))
+ if (address.ZipPostalCodeEnabled && !string.IsNullOrEmpty(address.ZipPostalCode))
{
addressLine += " " + address.ZipPostalCode;
}
- if (address.CountryEnabled && !String.IsNullOrWhiteSpace(address.CountryName))
+ if (address.CountryEnabled && !string.IsNullOrWhiteSpace(address.CountryName))
{
addressLine += ", " + address.CountryName;
}
@@ -46,8 +46,13 @@
<div class="new-billing-address" id="billing-new-address-form">
<div class="enter-address">
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "BillingNewAddress";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "BillingNewAddress"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.BillingNewAddress" view-data="dataDictAddress" />
}
<div asp-validation-summary="ModelOnly" class="message-error"></div>
diff --git a/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddress.cshtml b/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddress.cshtml
index 8cfb4bb54..c5f0a2379 100644
--- a/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddress.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddress.cshtml
@@ -30,23 +30,23 @@
var addressLine = "";
addressLine += address.FirstName;
addressLine += " " + address.LastName;
- if (address.StreetAddressEnabled && !String.IsNullOrEmpty(address.Address1))
+ if (address.StreetAddressEnabled && !string.IsNullOrEmpty(address.Address1))
{
addressLine += ", " + address.Address1;
}
- if (address.CityEnabled && !String.IsNullOrEmpty(address.City))
+ if (address.CityEnabled && !string.IsNullOrEmpty(address.City))
{
addressLine += ", " + address.City;
}
- if (address.StateProvinceEnabled && !String.IsNullOrEmpty(address.StateProvinceName))
+ if (address.StateProvinceEnabled && !string.IsNullOrEmpty(address.StateProvinceName))
{
addressLine += ", " + address.StateProvinceName;
}
- if (address.ZipPostalCodeEnabled && !String.IsNullOrEmpty(address.ZipPostalCode))
+ if (address.ZipPostalCodeEnabled && !string.IsNullOrEmpty(address.ZipPostalCode))
{
addressLine += " " + address.ZipPostalCode;
}
- if (address.CountryEnabled && !String.IsNullOrWhiteSpace(address.CountryName))
+ if (address.CountryEnabled && !string.IsNullOrWhiteSpace(address.CountryName))
{
addressLine += ", " + address.CountryName;
}
@@ -61,8 +61,13 @@
<div class="new-shipping-address" id="shipping-new-address-form" ref="newShippingAddress">
<div class="enter-address">
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "ShippingNewAddress";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "ShippingNewAddress"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.ShippingNewAddress" view-data="dataDictAddress" />
}
<div asp-validation-summary="ModelOnly" class="message-error"></div>
diff --git a/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddressPickupInStore.cshtml b/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddressPickupInStore.cshtml
index 7abc13adc..802a9c70e 100644
--- a/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddressPickupInStore.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Partials/ShippingAddressPickupInStore.cshtml
@@ -1,5 +1,4 @@
@model CheckoutShippingAddressModel
-@using System.Text
@if (Model.AllowPickUpInStore && !Model.PickUpInStoreOnly && Model.PickupPoints.Any())
{
@@ -36,7 +35,7 @@
<div class="section single-pickup-point">
<ul>
<li class="single-pickup-point name">@point.Name</li>
- <li class="single-pickup-point address">@(string.Format("{0} {1} {2}", point.Address.City, point.Address.ZipPostalCode, point.Address.Address1))</li>
+ <li class="single-pickup-point address">@($"{point.Address.City} {point.Address.ZipPostalCode} {point.Address.Address1}")</li>
@if (!string.IsNullOrEmpty(point.PickupFee))
{
<li class="single-pickup-point fee">@point.PickupFee</li>
@@ -54,19 +53,19 @@
addressLine.Append(point.Name);
if (!string.IsNullOrEmpty(point.Address.City))
{
- addressLine.AppendFormat(", {0}", point.Address.City);
+ addressLine.Append($", {point.Address.City}");
}
if (!string.IsNullOrEmpty(point.Address.ZipPostalCode))
{
- addressLine.AppendFormat(", {0}", point.Address.ZipPostalCode);
+ addressLine.Append($", {point.Address.ZipPostalCode}");
}
if (!string.IsNullOrEmpty(point.Address.Address1))
{
- addressLine.AppendFormat(", {0}", point.Address.Address1);
+ addressLine.Append($", {point.Address.Address1}");
}
if (!string.IsNullOrEmpty(point.PickupFee))
{
- addressLine.AppendFormat(", {0}", point.PickupFee);
+ addressLine.Append($", {point.PickupFee}");
}
<option value="@point.Id">@(addressLine)</option>
}
diff --git a/src/Web/Grand.Web/Views/Checkout/Partials/Summary.cshtml b/src/Web/Grand.Web/Views/Checkout/Partials/Summary.cshtml
index 6e12d366f..d30301eff 100644
--- a/src/Web/Grand.Web/Views/Checkout/Partials/Summary.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Partials/Summary.cshtml
@@ -1,8 +1,4 @@
-@{
-
- var modelExists = Model != null;
-}
-<div class="order-summary-content mt-3" id="ordersummarypagecart" v-if="vmorder.cart">
+<div class="order-summary-content mt-3" id="ordersummarypagecart" v-if="vmorder.cart">
@await Component.InvokeAsync("Widget", new { widgetZone = "checkout_summary_content_before" })
<div v-if="typeof vmorder.cart.Items !== 'undefined' && vmorder.cart.Items.length > 0">
<template v-if="vmorder.OrderReviewData && vmorder.Confirm">
diff --git a/src/Web/Grand.Web/Views/Checkout/Start.cshtml b/src/Web/Grand.Web/Views/Checkout/Start.cshtml
index ad826147c..7c5529cd4 100644
--- a/src/Web/Grand.Web/Views/Checkout/Start.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Start.cshtml
@@ -20,18 +20,18 @@
}
@{
//step numbers
- int shippingAddressStepNumber = 1;
- int billingAddressStepNumber = 2;
- int shippingMethodStepNumber = 3;
- int paymentMethodStepNumber = 4;
- int paymentInfoStepNumber = 5;
- int confirmOrderStepNumber = 6;
+ var shippingAddressStepNumber = 1;
+ var billingAddressStepNumber = 2;
+ var shippingMethodStepNumber = 3;
+ var paymentMethodStepNumber = 4;
+ var paymentInfoStepNumber = 5;
+ var confirmOrderStepNumber = 6;
if (!Model.ShippingRequired)
{
billingAddressStepNumber = 1;
- paymentMethodStepNumber = paymentMethodStepNumber - 2;
- paymentInfoStepNumber = paymentInfoStepNumber - 2;
- confirmOrderStepNumber = confirmOrderStepNumber - 2;
+ paymentMethodStepNumber -= 2;
+ paymentInfoStepNumber -= 2;
+ confirmOrderStepNumber -= 2;
}
}
@@ -81,6 +81,7 @@
</div>
<input type="submit" ref="shippingSubmit" id="opc-shipping-submit" class="d-none" />
</form>
+ </validation-observer>
<div class="col-12 buttons py-1 px-0 mt-3" id="shipping-buttons-container">
<input type="button" class="btn btn-info new-address-next-step-button" title="@Loc["Common.Continue"]" @if (Model.ShippingAddress.ExistingAddresses.Any()) { <text>@@click="vmorder.saveStep('vShipping', 'shippingSubmit', vm.$refs.shippingSelect.value === '')"</text> } else { <text>@@click="vmorder.saveStep('vShipping', 'shippingSubmit', true)"</text> } value="@Loc["Common.Continue"]" />
<span id="shipping-please-wait" class="please-wait" style="display: none;"> @Loc["Common.LoadingNextStep"]</span>
@@ -149,11 +150,8 @@
</div>
</form>
<div class="col-12 buttons py-1 mt-3 px-0" id="payment-method-buttons-container">
- @if (paymentMethodStepNumber > 1)
- {
- <a class="btn btn-secondary" href="#" id="back-payment_method" @@click="vmorder.backStep(vmorder.previousStep)">@Loc["Common.Back"]</a>
- }
- <input type="button" class="btn btn-info payment-method-next-step-button" @@click="vmorder.saveStep('vPaymentMethod', null, false);vmorder.setDisabled(event)" value="@Loc["Common.Continue"]" />
+ <a class="btn btn-secondary" href="#" id="back-payment_method" @@click="vmorder.backStep(vmorder.previousStep)">@Loc["Common.Back"]</a>
+ <input type="button" class="btn btn-info payment-method-next-step-button" @@click="vmorder.saveStep('vPaymentMethod', null, false);vmorder.setDisabled(event)" value="@Loc["Common.Continue"]"/>
<span class="please-wait" id="payment-method-please-wait" style="display: none;">@Loc["Common.LoadingNextStep"]</span>
</div>
</div>
@@ -169,10 +167,7 @@
</div>
</form>
<div class="col-12 buttons py-1 mt-3 px-0" id="payment-info-buttons-container">
- @if (!Model.HasSinglePaymentMethod || paymentMethodStepNumber > 1)
- {
- <a class="btn btn-secondary" href="#" id="back-payment_info" @@click="vmorder.backStep(vmorder.previousStep)">@Loc["Common.Back"]</a>
- }
+ <a class="btn btn-secondary" href="#" id="back-payment_info" @@click="vmorder.backStep(vmorder.previousStep)">@Loc["Common.Back"]</a>
<input type="button" class="btn btn-info payment-info-next-step-button" @@click="vmorder.saveStep('vPaymentInfo', null, false)" value="@Loc["Common.Continue"]" />
<span class="please-wait" id="payment-info-please-wait" style="display: none;">@Loc["Common.LoadingNextStep"]</span>
</div>
diff --git a/src/Web/Grand.Web/Views/Common/Partials/ContactAttributes.cshtml b/src/Web/Grand.Web/Views/Common/Partials/ContactAttributes.cshtml
index a7ab2372b..cd67442cd 100644
--- a/src/Web/Grand.Web/Views/Common/Partials/ContactAttributes.cshtml
+++ b/src/Web/Grand.Web/Views/Common/Partials/ContactAttributes.cshtml
@@ -1,7 +1,7 @@
-@model IList<Grand.Web.Models.Common.ContactUsModel.ContactAttributeModel>
-@using Grand.Domain.Media;
-@using System.Text;
-@inject Grand.Business.Core.Interfaces.Storage.IDownloadService downloadService
+@using Grand.Business.Core.Interfaces.Storage
+@using Grand.Domain.Media
+@model IList<ContactUsModel.ContactAttributeModel>
+@inject IDownloadService downloadService
@if (Model.Any())
{
@@ -9,7 +9,7 @@
<div class="form-group contact-attributes">
@foreach (var attribute in Model)
{
- var controlId = $"contact_attribute_{attribute.Id}";;
+ var controlId = $"contact_attribute_{attribute.Id}";
var controlName = $"attributes[{attribute.Id}]";
var textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
<div id="@($"contact_attribute_label_{attribute.Id}")" class="col-12 px-0">
@@ -43,7 +43,7 @@
<option selected="@attributeValue.IsPreSelected" value="@(attributeValue.Id)">@attributeName</option>
}
</select>
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}').addEventListener('change',function(){{contactAttributeChange();}});\n", controlId);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}').addEventListener('change',function(){{contactAttributeChange();}});\n");
}
break;
case AttributeControlType.RadioList:
@@ -65,7 +65,7 @@
</fieldset>
</li>
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(){{contactAttributeChange();}});\n", controlId, attributeValue.Id);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(){{contactAttributeChange();}});\n");
}
</ul>
}
@@ -85,7 +85,7 @@
<span class="custom-control-description" for="@(controlId)_@(attributeValue.Id)">@attributeName</span>
</label>
</li>
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(){{contactAttributeChange();}});\n", controlId, attributeValue.Id);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(){{contactAttributeChange();}});\n");
}
</ul>
</fieldset>
@@ -104,9 +104,9 @@
control-year="@($"attributes[{attribute.Id}_year]")"
begin-year="@(DateTime.Now.Year)"
end-year="@(DateTime.Now.Year+1)"
- selected-day="(attribute.SelectedDay.HasValue ? attribute.SelectedDay.Value : 0)"
- selected-month="(attribute.SelectedMonth.HasValue ? attribute.SelectedMonth.Value : 0)"
- selected-year="(attribute.SelectedYear.HasValue ? attribute.SelectedYear.Value : 0)"
+ selected-day="attribute.SelectedDay ?? 0"
+ selected-month="attribute.SelectedMonth ?? 0"
+ selected-year="attribute.SelectedYear ?? 0"
PartialViewName="Partials/DatePickerDropDowns"
class="input-group" />
}
@@ -114,7 +114,7 @@
case AttributeControlType.FileUpload:
{
Download download = null;
- if (!String.IsNullOrEmpty(attribute.DefaultValue))
+ if (!string.IsNullOrEmpty(attribute.DefaultValue))
{
download = await downloadService.GetDownloadByGuid(new Guid(attribute.DefaultValue));
}
@@ -185,7 +185,7 @@
@foreach (var attributeValue in attribute.Values)
{
var attributeName = attributeValue.Name;
- <li class="mr-1 p-0" @(attributeValue.IsPreSelected ? @Html.Raw(" class=\"selected-value border border-primary\"") : null)>
+ <li class="mr-1 p-0" @(attributeValue.IsPreSelected ? Html.Raw(" class=\"selected-value border border-primary\"") : null)>
<label for="@(controlId)_@(attributeValue.Id)" class="mb-0">
<input id="@(controlId)_@(attributeValue.Id)" type="radio" name="@(controlName)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected" />
<span class="color-container" title="@attributeName">
@@ -193,7 +193,7 @@
</span>
</label>
</li>
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(){{contactAttributeChange();}});\n", controlId, attributeValue.Id);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(){{contactAttributeChange();}});\n");
}
</ul>
<script asp-location="Footer">
diff --git a/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml b/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml
index c120a7006..1b9b0b92f 100644
--- a/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml
+++ b/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml
@@ -15,7 +15,7 @@
<div>@item.Description</div>
</div>
<div class="custom-control custom-switch">
- <input @if (!(item.AllowToDisable)) { <text> checked</text> } @if (item.State == true) { <text> checked</text> } type="checkbox"
+ <input @if (!item.AllowToDisable) { <text> checked</text> } @if (item.State) { <text> checked</text> } type="checkbox"
value="@item.SystemName" class="custom-control-input" id="[email protected]" name="[email protected]">
<label class="custom-control-label" for="[email protected]"></label>
</div>
diff --git a/src/Web/Grand.Web/Views/Common/Sitemap.cshtml b/src/Web/Grand.Web/Views/Common/Sitemap.cshtml
index 8c7a8fc65..7c083de5d 100644
--- a/src/Web/Grand.Web/Views/Common/Sitemap.cshtml
+++ b/src/Web/Grand.Web/Views/Common/Sitemap.cshtml
@@ -20,7 +20,7 @@
<div class="list-group">
@foreach (var category in Model.Categories)
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Category", new { SeName = category.SeName })">@category.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Category", new { category.SeName })">@category.Name</a>
}
</div>
</div>
@@ -61,7 +61,7 @@
<div class="list-group">
@foreach (var item in Model.BlogPosts)
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("BlogPost", new {SeName = item.SeName})">@item.Title</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("BlogPost", new { item.SeName})">@item.Title</a>
}
</div>
</div>
@@ -73,7 +73,7 @@
<div class="list-group">
@foreach (var item in Model.KnowledgebaseArticles)
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("KnowledgebaseArticle", new {SeName = item.SeName})">@item.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("KnowledgebaseArticle", new { item.SeName})">@item.Name</a>
}
</div>
</div>
@@ -85,7 +85,7 @@
<div class="list-group">
@foreach (var brand in Model.Brands)
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Brand", new { SeName = brand.SeName })">@brand.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Brand", new { brand.SeName })">@brand.Name</a>
}
</div>
</div>
@@ -97,7 +97,7 @@
<div class="list-group sitemap-products-group">
@foreach (var product in Model.Products)
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Product", new { SeName = product.SeName })">@product.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Product", new { product.SeName })">@product.Name</a>
}
</div>
</div>
diff --git a/src/Web/Grand.Web/Views/Course/Details.cshtml b/src/Web/Grand.Web/Views/Course/Details.cshtml
index f71f5a373..7ac2e5d37 100644
--- a/src/Web/Grand.Web/Views/Course/Details.cshtml
+++ b/src/Web/Grand.Web/Views/Course/Details.cshtml
@@ -3,14 +3,14 @@
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_SingleColumn";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var courseUrl = Url.RouteUrl("Course", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var courseUrl = Url.RouteUrl("Course", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(courseUrl);
}
@@ -24,7 +24,7 @@
<img src="@Model.PictureUrl" class="mr-3" />
<div class="media-body">
<h2 class="d-flex flex-column">@Model.Name<span class="h6">(@Model.Level)</span></h2>
- @if (!String.IsNullOrWhiteSpace(Model.Description))
+ @if (!string.IsNullOrWhiteSpace(Model.Description))
{
<p>
@Html.Raw(Model.Description)
diff --git a/src/Web/Grand.Web/Views/Course/Lesson.cshtml b/src/Web/Grand.Web/Views/Course/Lesson.cshtml
index 70e7c1d3b..ad72f269a 100644
--- a/src/Web/Grand.Web/Views/Course/Lesson.cshtml
+++ b/src/Web/Grand.Web/Views/Course/Lesson.cshtml
@@ -2,7 +2,7 @@
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_SingleColumn";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : $"{Model.CourseName} - {Model.Name}");
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : $"{Model.CourseName} - {Model.Name}");
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
}
@@ -35,7 +35,7 @@
document.getElementById("btnApprove").addEventListener('click', function (event) {
if (confirm('@Loc["Admin.Common.AreYouSure"]')) {
axios({
- url: '@Url.Action("Approved", "Course", new { Id = Model.Id })',
+ url: '@Url.Action("Approved", "Course", new { Model.Id })',
method: 'post',
}).then(function (response) {
if (response) {
@@ -57,7 +57,7 @@
{
<a class="btn btn-secondary" id="btnDownloadFile" href="@Url.Action("DownloadFile", "Course", new { id = Model.Id })">@Loc["Course.DownloadLesson"]</a>
}
- @if (!String.IsNullOrWhiteSpace(Model.ShortDescription))
+ @if (!string.IsNullOrWhiteSpace(Model.ShortDescription))
{
<p>
@Html.Raw(Model.ShortDescription)
diff --git a/src/Web/Grand.Web/Views/Home/Index.cshtml b/src/Web/Grand.Web/Views/Home/Index.cshtml
index 946ef1d2d..63c58b85a 100644
--- a/src/Web/Grand.Web/Views/Home/Index.cshtml
+++ b/src/Web/Grand.Web/Views/Home/Index.cshtml
@@ -1,4 +1,5 @@
-@inject Grand.Business.Core.Interfaces.Storage.IPictureService pictureService
+@using Grand.Business.Core.Interfaces.Storage
+@inject IPictureService pictureService
@inject SeoSettings seoSettings
@{
Layout = "_SingleColumn";
@@ -10,12 +11,12 @@
<meta property="og:type" content="website" />
<meta property="og:title" content="@seoSettings.DefaultTitle" />
<meta property="og:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)" />
- @if (!String.IsNullOrWhiteSpace(seoSettings.StorePictureId))
+ @if (!string.IsNullOrWhiteSpace(seoSettings.StorePictureId))
{
var picture = await pictureService.GetPictureUrl(seoSettings.StorePictureId);
<meta property="og:image" content="@picture" />
}
- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
+ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
}
@if (seoSettings.TwitterMetaTags)
{
@@ -23,13 +24,13 @@
<meta property="twitter:site" content="@seoSettings.DefaultTitle" />
<meta property="twitter:title" content="@seoSettings.DefaultTitle" />
<meta property="twitter:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)" />
- @if (!String.IsNullOrWhiteSpace(seoSettings.StorePictureId))
+ @if (!string.IsNullOrWhiteSpace(seoSettings.StorePictureId))
{
var picture = await pictureService.GetPictureUrl(seoSettings.StorePictureId);
<meta property="twitter:image" content="@picture" />
}
- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
}
}
diff --git a/src/Web/Grand.Web/Views/Install/Index.cshtml b/src/Web/Grand.Web/Views/Install/Index.cshtml
index fc8e6f102..3c24f978d 100644
--- a/src/Web/Grand.Web/Views/Install/Index.cshtml
+++ b/src/Web/Grand.Web/Views/Install/Index.cshtml
@@ -1,6 +1,5 @@
-@model InstallModel
-@using Grand.Web.Models.Install;
-@using Grand.Business.Core.Interfaces.System.Installation;
+@using Grand.Business.Core.Interfaces.System.Installation
+@model Grand.Web.Models.Install.InstallModel
@inject IInstallationLocalizedService LocalizedService
@{
Layout = null;
diff --git a/src/Web/Grand.Web/Views/Knowledgebase/Article.cshtml b/src/Web/Grand.Web/Views/Knowledgebase/Article.cshtml
index 2c98d6a96..e8f2d65ca 100644
--- a/src/Web/Grand.Web/Views/Knowledgebase/Article.cshtml
+++ b/src/Web/Grand.Web/Views/Knowledgebase/Article.cshtml
@@ -3,14 +3,14 @@
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var articleUrl = Url.RouteUrl("KnowledgebaseArticle", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var articleUrl = Url.RouteUrl("KnowledgebaseArticle", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(articleUrl);
}
}
@@ -28,7 +28,7 @@
@foreach (var cat in Model.CategoryBreadcrumb)
{
<li class="breadcrumb-item">
- <a href="@Url.RouteUrl("KnowledgebaseCategory", new { SeName = cat.SeName })" title="@cat.Name">@cat.Name</a>
+ <a href="@Url.RouteUrl("KnowledgebaseCategory", new { cat.SeName })" title="@cat.Name">@cat.Name</a>
</li>
}
</ol>
@@ -36,7 +36,7 @@
}
@section left {
- @await Component.InvokeAsync("KnowledgebaseCategories", new Grand.Web.Models.Knowledgebase.KnowledgebaseHomePageModel { CurrentCategoryId = Model.ParentCategoryId })
+ @await Component.InvokeAsync("KnowledgebaseCategories", new KnowledgebaseHomePageModel { CurrentCategoryId = Model.ParentCategoryId })
}
<div class="page">
@@ -46,7 +46,7 @@
<div class="card">
<div class="card-body">
- @Html.Raw(@Model.Content)
+ @Html.Raw(Model.Content)
</div>
</div>
@@ -56,7 +56,7 @@
<div class="list-group">
@foreach (var article in Model.RelatedArticles)
{
- <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { SeName = article.SeName })">
+ <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { article.SeName })">
@article.Name
</a>
}
@@ -72,7 +72,7 @@
@{
var result = TempData["Grand.knowledgebase.addarticlecomment.result"] as string;
}
- @if (!String.IsNullOrEmpty(result))
+ @if (!string.IsNullOrEmpty(result))
{
<div class="result card bg-info p-3 text-white">@result</div>
}
diff --git a/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseCategories/Default.cshtml b/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseCategories/Default.cshtml
index 98a4b25e7..759f2d2b6 100644
--- a/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseCategories/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseCategories/Default.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Web.Models.Knowledgebase.KnowledgebaseHomePageModel
+@model KnowledgebaseHomePageModel
@if (Model.Categories.Any())
{
diff --git a/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseHomepageArticles/Default.cshtml b/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseHomepageArticles/Default.cshtml
index c1116dde2..7995dee32 100644
--- a/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseHomepageArticles/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Knowledgebase/Components/KnowledgebaseHomepageArticles/Default.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Web.Models.Knowledgebase.KnowledgebaseHomePageModel
+@model KnowledgebaseHomePageModel
@if (Model.Items.Any())
{
@@ -8,7 +8,7 @@
{
if (item.IsArticle)
{
- <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { SeName = item.SeName })">
+ <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { item.SeName })">
@item.Name
</a>
}
diff --git a/src/Web/Grand.Web/Views/Knowledgebase/List.cshtml b/src/Web/Grand.Web/Views/Knowledgebase/List.cshtml
index d3853921b..d3de299bf 100644
--- a/src/Web/Grand.Web/Views/Knowledgebase/List.cshtml
+++ b/src/Web/Grand.Web/Views/Knowledgebase/List.cshtml
@@ -15,14 +15,14 @@
@foreach (var cat in Model.CategoryBreadcrumb)
{
<li class="breadcrumb-item">
- <a href="@Url.RouteUrl("KnowledgebaseCategory", new { SeName = cat.SeName })" title="@cat.Name">@cat.Name</a>
+ <a href="@Url.RouteUrl("KnowledgebaseCategory", new { cat.SeName })" title="@cat.Name">@cat.Name</a>
</li>
}
</ol>
}
@section left {
- @await Component.InvokeAsync("KnowledgebaseCategories", @Model)
+ @await Component.InvokeAsync("KnowledgebaseCategories", Model)
}
<div class="page">
@@ -63,7 +63,7 @@
</form>
@await Component.InvokeAsync("PageBlock", new { systemName = "KnowledgebaseHomePage" })
- @await Component.InvokeAsync("KnowledgebaseHomepageArticles", @Model)
+ @await Component.InvokeAsync("KnowledgebaseHomepageArticles", Model)
}
else
{
@@ -77,12 +77,12 @@
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var categoryUrl = Url.RouteUrl("ArticlesByCategory", new { SeName = Model.CurrentCategorySeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var categoryUrl = Url.RouteUrl("ArticlesByCategory", new { SeName = Model.CurrentCategorySeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(categoryUrl);
}
}
- @Html.Raw(@Model.CurrentCategoryDescription)
+ @Html.Raw(Model.CurrentCategoryDescription)
@if (Model.Items.Any())
{
@@ -91,8 +91,8 @@
{
if (item.IsArticle)
{
- <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { SeName = item.SeName })">
- @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(@item.FormattedBreadcrumbs))
+ <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseArticle", new { item.SeName })">
+ @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(item.FormattedBreadcrumbs))
{
@item.FormattedBreadcrumbs
}
@@ -104,8 +104,8 @@
}
else
{
- <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseCategory", new { SeName = item.SeName })">
- @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(@item.FormattedBreadcrumbs))
+ <a class="list-group-item" href="@Url.RouteUrl("KnowledgebaseCategory", new { item.SeName })">
+ @if (!string.IsNullOrEmpty(Model.SearchKeyword) && !string.IsNullOrEmpty(item.FormattedBreadcrumbs))
{
@item.FormattedBreadcrumbs
}
diff --git a/src/Web/Grand.Web/Views/Knowledgebase/Partials/KnowledgebaseCategoryLine.Navigation.cshtml b/src/Web/Grand.Web/Views/Knowledgebase/Partials/KnowledgebaseCategoryLine.Navigation.cshtml
index 2090a83e5..fb22fab65 100644
--- a/src/Web/Grand.Web/Views/Knowledgebase/Partials/KnowledgebaseCategoryLine.Navigation.cshtml
+++ b/src/Web/Grand.Web/Views/Knowledgebase/Partials/KnowledgebaseCategoryLine.Navigation.cshtml
@@ -1,10 +1,10 @@
-@model Grand.Web.Models.Knowledgebase.KnowledgebaseCategoryModel
+@model KnowledgebaseCategoryModel
<ul class="sublist">
@if (Model.IsCurrent)
{
<li class="active last">
- <a href="@Url.RouteUrl("KnowledgebaseCategory", new { SeName = Model.SeName })"><strong>@Model.Name</strong></a>
+ <a href="@Url.RouteUrl("KnowledgebaseCategory", new { Model.SeName })"><strong>@Model.Name</strong></a>
@foreach (var category in Model.Children)
{
<partial name="Partials/KnowledgebaseCategoryLine.Navigation" model="category" />
@@ -14,7 +14,7 @@
else
{
<li class="inactive">
- <a href="@Url.RouteUrl("KnowledgebaseCategory", new { SeName = Model.SeName })">@Model.Name</a>
+ <a href="@Url.RouteUrl("KnowledgebaseCategory", new { Model.SeName })">@Model.Name</a>
</li>
}
</ul>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/MerchandiseReturn/CustomerMerchandiseReturns.cshtml b/src/Web/Grand.Web/Views/MerchandiseReturn/CustomerMerchandiseReturns.cshtml
index 995e23cc6..d81dba77e 100644
--- a/src/Web/Grand.Web/Views/MerchandiseReturn/CustomerMerchandiseReturns.cshtml
+++ b/src/Web/Grand.Web/Views/MerchandiseReturn/CustomerMerchandiseReturns.cshtml
@@ -1,6 +1,4 @@
@model CustomerMerchandiseReturnsModel
-@using Grand.Web.Models.Customer
-@using Grand.Web.Models.Orders
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
diff --git a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
index 298513029..2ef1ea3c5 100644
--- a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
+++ b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
@@ -8,7 +8,7 @@
}
<div class="page return-request-page">
<h1 class="text-center generalTitle h2">@string.Format(Loc["MerchandiseReturns.Title"], Model.OrderNumber)</h1>
- @if (!String.IsNullOrEmpty(Model.Result))
+ @if (!string.IsNullOrEmpty(Model.Result))
{
<div class="result alert alert-info">
@Html.Raw(Model.Result)
@@ -16,7 +16,7 @@
}
else
{
- @if (!String.IsNullOrEmpty(Model.Error))
+ @if (!string.IsNullOrEmpty(Model.Error))
{
<div class="result alert alert-danger">
@Model.Error
@@ -57,11 +57,11 @@
<td>
<div class="product">
<a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
- @if (!String.IsNullOrEmpty(item.AttributeInfo))
+ @if (!string.IsNullOrEmpty(item.AttributeInfo))
{
<a id="attributes-btn" class="btn btn-sm btn-outline-info" v-b-tooltip.html.right.hover title="@Html.Raw(item.AttributeInfo)">Attributes</a>
}
- @if (!String.IsNullOrEmpty(item.VendorName))
+ @if (!string.IsNullOrEmpty(item.VendorName))
{
<div class="vendor">
@item.VendorName
@@ -79,7 +79,7 @@
v-bind:class="[classes , 'custom-select form-control']" v-model="merchandisereturns.quantity_@(item.Id)"
ref="quantity@(item.Id)"
asp-for="@Model.Items[j].Quantity">
- @for (int i = 0; i <= item.Quantity; i++)
+ @for (var i = 0; i <= item.Quantity; i++)
{
<option value="@(i)">@(i)</option>
}
@@ -138,23 +138,23 @@
var addressLine = "";
addressLine += address.FirstName;
addressLine += " " + address.LastName;
- if (address.StreetAddressEnabled && !String.IsNullOrEmpty(address.Address1))
+ if (address.StreetAddressEnabled && !string.IsNullOrEmpty(address.Address1))
{
addressLine += ", " + address.Address1;
}
- if (address.CityEnabled && !String.IsNullOrEmpty(address.City))
+ if (address.CityEnabled && !string.IsNullOrEmpty(address.City))
{
addressLine += ", " + address.City;
}
- if (address.StateProvinceEnabled && !String.IsNullOrEmpty(address.StateProvinceName))
+ if (address.StateProvinceEnabled && !string.IsNullOrEmpty(address.StateProvinceName))
{
addressLine += ", " + address.StateProvinceName;
}
- if (address.ZipPostalCodeEnabled && !String.IsNullOrEmpty(address.ZipPostalCode))
+ if (address.ZipPostalCodeEnabled && !string.IsNullOrEmpty(address.ZipPostalCode))
{
addressLine += " " + address.ZipPostalCode;
}
- if (address.CountryEnabled && !String.IsNullOrWhiteSpace(address.CountryName))
+ if (address.CountryEnabled && !string.IsNullOrWhiteSpace(address.CountryName))
{
addressLine += ", " + address.CountryName;
}
@@ -169,8 +169,13 @@
<div class="section new-pickup-address" id="pickup-new-address-form" ref="visible">
<div class="enter-address">
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "MerchandiseReturnNewAddress";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "MerchandiseReturnNewAddress"
+ }
+ };
<partial name="Partials/CreateOrUpdateAddress" model="Model.MerchandiseReturnNewAddress" view-data="dataDictAddress" />
}
</div>
diff --git a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturnDetails.cshtml b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturnDetails.cshtml
index 8bd619ec0..b55703971 100644
--- a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturnDetails.cshtml
+++ b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturnDetails.cshtml
@@ -1,5 +1,4 @@
@model MerchandiseReturnDetailsModel
-@using Grand.Web.Models.Orders
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -81,7 +80,7 @@
</div>
</div>
- @if (!String.IsNullOrEmpty(Model.Comments))
+ @if (!string.IsNullOrEmpty(Model.Comments))
{
<div class="comments">
<label class="col-form-label">@Loc["Account.CustomerMerchandiseReturns.Comments"] </label>
@@ -95,7 +94,7 @@
@if (Model.ShowPickupDate)
{
- @if (Model.PickupDate != default(DateTime))
+ @if (Model.PickupDate != default)
{
<div class="d-inline-flex align-items-center w-100 my-3">
<b-icon class="mx-2" icon="calendar2-check" variant="info"></b-icon>
@@ -133,13 +132,13 @@
@Loc["Order.Fax"]: @Model.PickupAddress.FaxNumber
</li>
}
- @if (Model.PickupAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.PickupAddress.Company))
+ @if (Model.PickupAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.PickupAddress.Company))
{
<li class="company">
@Model.PickupAddress.Company
</li>
}
- @if (Model.PickupAddress.VatNumberEnabled && !String.IsNullOrEmpty(Model.PickupAddress.VatNumber))
+ @if (Model.PickupAddress.VatNumberEnabled && !string.IsNullOrEmpty(Model.PickupAddress.VatNumber))
{
<li class="company">
@Model.PickupAddress.VatNumber
@@ -151,7 +150,7 @@
@Model.PickupAddress.Address1
</li>
}
- @if (Model.PickupAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.PickupAddress.Address2))
+ @if (Model.PickupAddress.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.PickupAddress.Address2))
{
<li class="address2">
@Model.PickupAddress.Address2
@@ -178,14 +177,14 @@
}
</li>
}
- @if (Model.PickupAddress.CountryEnabled && !String.IsNullOrEmpty(Model.PickupAddress.CountryName))
+ @if (Model.PickupAddress.CountryEnabled && !string.IsNullOrEmpty(Model.PickupAddress.CountryName))
{
<li class="country">
@Model.PickupAddress.CountryName
</li>
}
- @if (!String.IsNullOrEmpty(Model.PickupAddress.FormattedCustomAddressAttributes))
+ @if (!string.IsNullOrEmpty(Model.PickupAddress.FormattedCustomAddressAttributes))
{
<li class="custom-attributes-view">
@Html.Raw(Model.PickupAddress.FormattedCustomAddressAttributes)
diff --git a/src/Web/Grand.Web/Views/News/List.cshtml b/src/Web/Grand.Web/Views/News/List.cshtml
index 2ef81e0e8..54c3eed04 100644
--- a/src/Web/Grand.Web/Views/News/List.cshtml
+++ b/src/Web/Grand.Web/Views/News/List.cshtml
@@ -20,7 +20,7 @@
}
<div class="card-header">
<h3 class="h5 mb-0">
- <a href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">
+ <a href="@Url.RouteUrl("NewsItem", new { item.SeName })">
@item.Title
</a>
</h3>
@@ -29,7 +29,7 @@
@Html.Raw(item.Short)
</div>
<div class="buttons mb-3 px-3">
- <a class="btn btn-sm btn-outline-info read-more" href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">@Loc["News.MoreInfo"]</a>
+ <a class="btn btn-sm btn-outline-info read-more" href="@Url.RouteUrl("NewsItem", new { item.SeName })">@Loc["News.MoreInfo"]</a>
</div>
<div class="card-footer">
<small class="text-muted">@item.CreatedOn.ToString("D")</small>
diff --git a/src/Web/Grand.Web/Views/News/NewsItem.cshtml b/src/Web/Grand.Web/Views/News/NewsItem.cshtml
index 06aa2a1d7..0cabdb4db 100644
--- a/src/Web/Grand.Web/Views/News/NewsItem.cshtml
+++ b/src/Web/Grand.Web/Views/News/NewsItem.cshtml
@@ -4,7 +4,7 @@
Layout = "_TwoColumns";
//title
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
}
@@ -37,7 +37,7 @@
@{
var result = TempData["Grand.news.addcomment.result"] as string;
}
- @if (!String.IsNullOrEmpty(result))
+ @if (!string.IsNullOrEmpty(result))
{
<div class="result alert alert-info">@result</div>
}
diff --git a/src/Web/Grand.Web/Views/Newsletter/SubscriptionActivation.cshtml b/src/Web/Grand.Web/Views/Newsletter/SubscriptionActivation.cshtml
index 0173e4b57..9b3f171df 100644
--- a/src/Web/Grand.Web/Views/Newsletter/SubscriptionActivation.cshtml
+++ b/src/Web/Grand.Web/Views/Newsletter/SubscriptionActivation.cshtml
@@ -1,5 +1,4 @@
@model SubscriptionActivationModel
-@using Grand.Web.Models.Newsletter;
@{
Layout = "_SingleColumn";
}
diff --git a/src/Web/Grand.Web/Views/Order/CustomerLoyaltyPoints.cshtml b/src/Web/Grand.Web/Views/Order/CustomerLoyaltyPoints.cshtml
index 5189676f3..444373753 100644
--- a/src/Web/Grand.Web/Views/Order/CustomerLoyaltyPoints.cshtml
+++ b/src/Web/Grand.Web/Views/Order/CustomerLoyaltyPoints.cshtml
@@ -34,7 +34,7 @@
</tr>
</thead>
<tbody role="rowgroup">
- @for (int i = 0; i < Model.LoyaltyPoints.Count; i++)
+ @for (var i = 0; i < Model.LoyaltyPoints.Count; i++)
{
var item = Model.LoyaltyPoints[i];
<tr role="row">
diff --git a/src/Web/Grand.Web/Views/Order/Details.cshtml b/src/Web/Grand.Web/Views/Order/Details.cshtml
index df098208f..859f80bd7 100644
--- a/src/Web/Grand.Web/Views/Order/Details.cshtml
+++ b/src/Web/Grand.Web/Views/Order/Details.cshtml
@@ -5,14 +5,7 @@
@{
var supportRtl = workContext.WorkingLanguage.Rtl;
- if (!Model.PrintMode)
- {
- Layout = "_SingleColumn";
- }
- else
- {
- Layout = "_Print";
- }
+ Layout = !Model.PrintMode ? "_SingleColumn" : "_Print";
//title
pagebuilder.AddTitleParts(Loc["Title.OrderDetails"]);
@@ -43,8 +36,10 @@
{
<a @@click="$bvModal.show('ModalAddOrderNote')" class="btn btn-outline-secondary">@Loc["Order.AddOrderNote"]</a>
- var notemodel = new AddOrderNoteModel();
- notemodel.OrderId = Model.Id;
+ var notemodel = new AddOrderNoteModel
+ {
+ OrderId = Model.Id
+ };
<partial name="Partials/AddOrderNote" model="@notemodel"/>
}
@@ -118,13 +113,13 @@
@Loc["Order.Fax"]: @Model.BillingAddress.FaxNumber
</li>
}
- @if (Model.BillingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.BillingAddress.Company))
+ @if (Model.BillingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.BillingAddress.Company))
{
<li class="company">
@Model.BillingAddress.Company
</li>
}
- @if (Model.BillingAddress.VatNumberEnabled && !String.IsNullOrEmpty(Model.BillingAddress.VatNumber))
+ @if (Model.BillingAddress.VatNumberEnabled && !string.IsNullOrEmpty(Model.BillingAddress.VatNumber))
{
<li class="company">
@Model.BillingAddress.VatNumber
@@ -136,7 +131,7 @@
@Model.BillingAddress.Address1
</li>
}
- @if (Model.BillingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.BillingAddress.Address2))
+ @if (Model.BillingAddress.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.BillingAddress.Address2))
{
<li class="address2">
@Model.BillingAddress.Address2
@@ -165,13 +160,13 @@
}
</li>
}
- @if (Model.BillingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.BillingAddress.CountryName))
+ @if (Model.BillingAddress.CountryEnabled && !string.IsNullOrEmpty(Model.BillingAddress.CountryName))
{
<li class="country">
@Model.BillingAddress.CountryName
</li>
}
- @if (!String.IsNullOrEmpty(Model.VatNumber))
+ @if (!string.IsNullOrEmpty(Model.VatNumber))
{
<li class="vat">
<span class="label">
@@ -182,13 +177,13 @@
</span>
</li>
}
- @if (!String.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))
+ @if (!string.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))
{
<li class="custom-attributes-view">
@Html.Raw(Model.BillingAddress.FormattedCustomAddressAttributes)
</li>
}
- @if (!String.IsNullOrEmpty(Model.PaymentMethod))
+ @if (!string.IsNullOrEmpty(Model.PaymentMethod))
{
<li class="title">
<h5 class="generalMarginSupporter generalTitle">@Loc["Order.Payment"]</h5>
@@ -268,7 +263,7 @@
@Loc["Order.Fax"]: @Model.ShippingAddress.FaxNumber
</li>
}
- if (Model.ShippingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.Company))
+ if (Model.ShippingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.ShippingAddress.Company))
{
<li class="company">
@Model.ShippingAddress.Company
@@ -280,7 +275,7 @@
@Model.ShippingAddress.Address1
</li>
}
- if (Model.ShippingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.ShippingAddress.Address2))
+ if (Model.ShippingAddress.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.ShippingAddress.Address2))
{
<li class="address2">
@Model.ShippingAddress.Address2
@@ -309,13 +304,13 @@
}
</li>
}
- if (Model.ShippingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
+ if (Model.ShippingAddress.CountryEnabled && !string.IsNullOrEmpty(Model.ShippingAddress.CountryName))
{
<li class="country">
@Model.ShippingAddress.CountryName
</li>
}
- if (!String.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))
+ if (!string.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))
{
<li class="custom-attributes-view">
@Html.Raw(Model.ShippingAddress.FormattedCustomAddressAttributes)
@@ -439,11 +434,11 @@
{
<div class="rental-info">@Html.Raw(item.RentalInfo)</div>
}
- @if (!String.IsNullOrEmpty(item.DownloadId))
+ @if (!string.IsNullOrEmpty(item.DownloadId))
{
<div class="download"><a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.Download"]</a></div>
}
- @if (!String.IsNullOrEmpty(item.LicenseId))
+ @if (!string.IsNullOrEmpty(item.LicenseId))
{
<div class="download license">
<a href="@Url.RouteUrl("GetLicense", new {orderItemId = item.OrderItemGuid})">@Loc["DownloadableProducts.Fields.DownloadLicense"]</a>
@@ -603,7 +598,7 @@
</table>
</div>
<div class="d-inline-flex w-100 justify-content-between flex-wrap">
- @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
+ @if (!string.IsNullOrEmpty(Model.CheckoutAttributeInfo))
{
<div class="selected-checkout-attributes">
@Html.Raw(Model.CheckoutAttributeInfo)
diff --git a/src/Web/Grand.Web/Views/Order/ShipmentDetails.cshtml b/src/Web/Grand.Web/Views/Order/ShipmentDetails.cshtml
index 269942402..894551bd5 100644
--- a/src/Web/Grand.Web/Views/Order/ShipmentDetails.cshtml
+++ b/src/Web/Grand.Web/Views/Order/ShipmentDetails.cshtml
@@ -46,7 +46,7 @@
@Loc["Order.Shipments.DeliveryDate.NotYet"]
}
</li>
- @if (!String.IsNullOrEmpty(Model.TrackingNumber))
+ @if (!string.IsNullOrEmpty(Model.TrackingNumber))
{
<li class="tracking-number">
@Loc["Order.Shipments.TrackingNumber"]:
@@ -79,7 +79,7 @@
<li class="fax">
<span>@Loc["Order.Shipments.Fax"]:</span> @Model.Order.ShippingAddress.FaxNumber
</li>
- if (!String.IsNullOrEmpty(Model.Order.ShippingAddress.Company))
+ if (!string.IsNullOrEmpty(Model.Order.ShippingAddress.Company))
{
<li class="company">
@Model.Order.ShippingAddress.Company
@@ -88,7 +88,7 @@
<li class="address1">
@Model.Order.ShippingAddress.Address1
</li>
- if (!String.IsNullOrEmpty(Model.Order.ShippingAddress.Address2))
+ if (!string.IsNullOrEmpty(Model.Order.ShippingAddress.Address2))
{
<li class="address2">
@Model.Order.ShippingAddress.Address2
@@ -98,7 +98,7 @@
@Model.Order.ShippingAddress.City, @Model.Order.ShippingAddress.StateProvinceName
@Model.Order.ShippingAddress.ZipPostalCode
</li>
- if (!String.IsNullOrEmpty(Model.Order.ShippingAddress.CountryName))
+ if (!string.IsNullOrEmpty(Model.Order.ShippingAddress.CountryName))
{
<li class="country">
@Model.Order.ShippingAddress.CountryName
@@ -168,13 +168,13 @@
<div class="col-12 col-md name">
<strong class="d-lg-none">@Loc["Order.Shipments.Product(s).Name"]: </strong>
<em><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></em>
- @if (!String.IsNullOrEmpty(item.AttributeInfo))
+ @if (!string.IsNullOrEmpty(item.AttributeInfo))
{
<div class="col attributes">
@Html.Raw(item.AttributeInfo)
</div>
}
- @if (!String.IsNullOrEmpty(item.RentalInfo))
+ @if (!string.IsNullOrEmpty(item.RentalInfo))
{
<div class="col rental-info">
@Html.Raw(item.RentalInfo)
diff --git a/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml b/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
index b5495263b..9ff07bf12 100644
--- a/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
+++ b/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
@@ -1,6 +1,4 @@
@model CustomerOutOfStockSubscriptionsModel
-@using Grand.Web.Models.Catalog
-@using Grand.Web.Models.Customer
@inject IPageHeadBuilder pagebuilder
@{
Layout = "_TwoColumns";
@@ -51,7 +49,7 @@
</tr>
</thead>
<tbody>
- @for (int i = 0; i < Model.Subscriptions.Count; i++)
+ @for (var i = 0; i < Model.Subscriptions.Count; i++)
{
var item = Model.Subscriptions[i];
<tr @(i % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
@@ -63,7 +61,7 @@
</label>
</td>
<td class="product">
- @Html.RouteLink(item.ProductName, "Product", new { SeName = item.SeName })
+ @Html.RouteLink(item.ProductName, "Product", new { item.SeName })
@if (!string.IsNullOrEmpty(item.AttributeDescription))
{
<br />
diff --git a/src/Web/Grand.Web/Views/OutOfStockSubscription/SubscribePopup.cshtml b/src/Web/Grand.Web/Views/OutOfStockSubscription/SubscribePopup.cshtml
index 947c1bc7e..700496e82 100644
--- a/src/Web/Grand.Web/Views/OutOfStockSubscription/SubscribePopup.cshtml
+++ b/src/Web/Grand.Web/Views/OutOfStockSubscription/SubscribePopup.cshtml
@@ -1,5 +1,4 @@
@model OutOfStockSubscribeModel
-@using Grand.Web.Models.Catalog;
@{
Layout = "";
}
@@ -35,7 +34,7 @@
}
else
{
- <input type="submit" id="out-of-stock-notify-me" value="@(Model.AlreadySubscribed ? @Loc["OutOfStockSubscriptions.Unsubscribe"] : @Loc["OutOfStockSubscriptions.NotifyMe"])"
+ <input type="submit" id="out-of-stock-notify-me" value="@(Model.AlreadySubscribed ? Loc["OutOfStockSubscriptions.Unsubscribe"] : Loc["OutOfStockSubscriptions.NotifyMe"])"
class="btn btn-success btn-sm notify-me-button" />
<script>
document.getElementById('out-of-stock-subscription-form').addEventListener('submit', function (event) {
diff --git a/src/Web/Grand.Web/Views/Page/PageDetails.cshtml b/src/Web/Grand.Web/Views/Page/PageDetails.cshtml
index b9e0a48e0..e83151721 100644
--- a/src/Web/Grand.Web/Views/Page/PageDetails.cshtml
+++ b/src/Web/Grand.Web/Views/Page/PageDetails.cshtml
@@ -15,7 +15,7 @@
if (!Model.IsPasswordProtected)
{
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
}
@@ -23,7 +23,7 @@
var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
if (canonicalUrlsEnabled)
{
- var pageUrl = Url.RouteUrl("Page", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var pageUrl = Url.RouteUrl("Page", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(pageUrl);
}
}
diff --git a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml
index aa2255856..18edf84c0 100644
--- a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml
+++ b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml
@@ -1,13 +1,20 @@
-@model (IList<Order>, string)
-@inject Grand.Business.Core.Interfaces.Catalog.Products.IProductService _productService
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICountryService _countryService
-@inject Grand.Business.Core.Interfaces.Common.Stores.IStoreService _storeService
-@inject Grand.Business.Core.Interfaces.Storage.IPictureService _pictureService
+@using Grand.Business.Core.Interfaces.Catalog.Products
+@using Grand.Business.Core.Interfaces.Checkout.GiftVouchers
+@using Grand.Business.Core.Interfaces.Checkout.Payments
+@using Grand.Business.Core.Interfaces.Common.Directory
+@using Grand.Business.Core.Interfaces.Common.Localization
+@using Grand.Business.Core.Interfaces.Common.Stores
+@using Grand.Business.Core.Interfaces.Storage
+@model (IList<Order>, string)
+@inject IProductService _productService
+@inject ICountryService _countryService
+@inject IStoreService _storeService
+@inject IPictureService _pictureService
@inject PdfSettings _pdfSettings
-@inject Grand.Business.Core.Interfaces.Common.Localization.ITranslationService _translationService
-@inject Grand.Business.Core.Interfaces.Checkout.Payments.IPaymentService _paymentService
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICurrencyService _currencyService
-@inject Grand.Business.Core.Interfaces.Checkout.GiftVouchers.IGiftVoucherService _giftVoucherService
+@inject ITranslationService _translationService
+@inject IPaymentService _paymentService
+@inject ICurrencyService _currencyService
+@inject IGiftVoucherService _giftVoucherService
@{
var logoPicture = await _pictureService.GetPictureById(_pdfSettings.LogoPictureId);
var logoExists = logoPicture != null;
@@ -57,7 +64,7 @@
var store = await _storeService.GetStoreById(order.StoreId);
if (!string.IsNullOrEmpty(_pdfSettings.InvoiceHeaderText))
{
- <div> @Html.Raw(@_pdfSettings.InvoiceHeaderText)</div>
+ <div> @Html.Raw(_pdfSettings.InvoiceHeaderText)</div>
}
<h2>@store.CompanyName</h2>
if (logoExists)
@@ -84,10 +91,10 @@
<li>@((await _countryService.GetCountryById(order.BillingAddress.CountryId))?.Name)</li>
@{
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);
- string paymentMethodStr = paymentMethod != null ? paymentMethod.FriendlyName : order.PaymentMethodSystemName;
+ var paymentMethodStr = paymentMethod != null ? paymentMethod.FriendlyName : order.PaymentMethodSystemName;
}
<li>@(string.Format(_translationService.GetResource("PDFInvoice.PaymentMethod", order.CustomerLanguageId), paymentMethodStr))</li>
- @await Component.InvokeAsync("Widget", new { widgetZone = "pdf_payment_method_below", additionalData = @order.Id })
+ @await Component.InvokeAsync("Widget", new { widgetZone = "pdf_payment_method_below", additionalData = order.Id })
</ul>
}
</td>
@@ -180,7 +187,7 @@
if (!string.IsNullOrEmpty(_pdfSettings.InvoiceFooterText))
{
<footer class="footer">
- @Html.Raw(@_pdfSettings.InvoiceFooterText)
+ @Html.Raw(_pdfSettings.InvoiceFooterText)
</footer>
}
if (Model.Item1.Count - 1 > i)
diff --git a/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml b/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml
index fe5a3fa68..f673ce178 100644
--- a/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml
+++ b/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml
@@ -1,19 +1,28 @@
-@using Grand.Domain.Shipping
-@model IList<Shipment>
-@inject Grand.Business.Core.Interfaces.Checkout.Orders.IOrderService _orderService
-@inject Grand.Business.Core.Interfaces.Checkout.Shipping.IShipmentService _shipmentService
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICountryService _cournyService
-@inject Grand.Business.Core.Interfaces.Catalog.Products.IProductService _productService
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICountryService _countryService
-@inject Grand.Business.Core.Interfaces.Common.Configuration.ISettingService _settingService
-@inject Grand.Business.Core.Interfaces.Common.Stores.IStoreService _storeService
-@inject Grand.Infrastructure.IWorkContext _workContext
-@inject Grand.Business.Core.Interfaces.Storage.IPictureService _pictureService
+@using Grand.Business.Core.Interfaces.Checkout.Orders
+@using Grand.Business.Core.Interfaces.Checkout.Payments
+@using Grand.Business.Core.Interfaces.Checkout.Shipping
+@using Grand.Business.Core.Interfaces.Common.Configuration
+@using Grand.Business.Core.Interfaces.Common.Directory
+@using Grand.Business.Core.Interfaces.Common.Localization
+@using Grand.Business.Core.Interfaces.Common.Stores
+@using Grand.Business.Core.Interfaces.Storage
+@using Grand.Business.Core.Interfaces.Catalog.Products
+@using Grand.Business.Core.Interfaces.Checkout.GiftVouchers
+@model IList<Grand.Domain.Shipping.Shipment>
+@inject IOrderService _orderService
+@inject IShipmentService _shipmentService
+@inject ICountryService _cournyService
+@inject IProductService _productService
+@inject ICountryService _countryService
+@inject ISettingService _settingService
+@inject IStoreService _storeService
+@inject IWorkContext _workContext
+@inject IPictureService _pictureService
@inject PdfSettings _pdfSettings
-@inject Grand.Business.Core.Interfaces.Common.Localization.ITranslationService _translationService
-@inject Grand.Business.Core.Interfaces.Checkout.Payments.IPaymentService _paymentService
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICurrencyService _currencyService
-@inject Grand.Business.Core.Interfaces.Checkout.GiftVouchers.IGiftVoucherService _giftVoucherService
+@inject ITranslationService _translationService
+@inject IPaymentService _paymentService
+@inject ICurrencyService _currencyService
+@inject IGiftVoucherService _giftVoucherService
@{
var companyName = _workContext.CurrentStore.CompanyName;
@@ -56,7 +65,7 @@
</style>
</head>
<body>
- @for (int i = 0; i < Model.Count; i++)
+ @for (var i = 0; i < Model.Count; i++)
{
var order = await _orderService.GetOrderById(Model[i].OrderId);
var shipment = Model[i];
diff --git a/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml b/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
index ab8211aa4..cafffe011 100644
--- a/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
+++ b/src/Web/Grand.Web/Views/Product/CompareProducts.cshtml
@@ -6,7 +6,6 @@
//title
pagebuilder.AddTitleParts(Loc["Title.CompareProducts"]);
}
-@using Grand.Web.Models.Catalog;
@{
var specificationAttributes = new List<ProductSpecificationModel>();
foreach (var product in Model.Products)
diff --git a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml
index deceabca4..f8808ae73 100644
--- a/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml
@@ -1,7 +1,7 @@
@model ProductReviewsModel
@{
- var productlink = @Url.RouteUrl("Product", new { SeName = Model.ProductSeName });
+ var productlink = Url.RouteUrl("Product", new { SeName = Model.ProductSeName });
}
<b-modal id="ModalProductReview" ref="ModalProductReview" :dark-theme="darkMode" size="xl" @@shown="productreviews.modalReviewShown()" @@hide="productreviews.modalReviewClose()" centered hide-footer hide-header>
diff --git a/src/Web/Grand.Web/Views/Product/NewProducts.cshtml b/src/Web/Grand.Web/Views/Product/NewProducts.cshtml
index 7e100472f..9b14f6302 100644
--- a/src/Web/Grand.Web/Views/Product/NewProducts.cshtml
+++ b/src/Web/Grand.Web/Views/Product/NewProducts.cshtml
@@ -6,7 +6,6 @@
//title
pagebuilder.AddTitleParts(Loc["Title.NewProducts"]);
}
-@using Grand.Web.Models.Catalog;
<div class="page recently-added-products-page col-12 px-0">
<h1 class="h2 generalTitle">@Loc["Products.NewProducts"]</h1>
@if (Model.Any())
diff --git a/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
index f2c52d25a..cebfec51a 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
@@ -2,7 +2,7 @@
@if (!Model.DisableWishlistButton)
{
var addToWishlistText = "";
- if (!String.IsNullOrEmpty(Model.UpdatedShoppingCartItemId) && Model.UpdateShoppingCartItemType.HasValue && Model.UpdateShoppingCartItemType.Value == ShoppingCartType.Wishlist)
+ if (!string.IsNullOrEmpty(Model.UpdatedShoppingCartItemId) && Model.UpdateShoppingCartItemType is ShoppingCartType.Wishlist)
{
addToWishlistText = Loc["ShoppingCart.AddToWishlist.Update"];
}
diff --git a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
index 3112cd492..c4873ccc9 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
@@ -1,4 +1,5 @@
-@model ProductDetailsModel
+@using System.Globalization
+@model ProductDetailsModel
<div class="row">
<div class="form-group col-12">
@if (Model.EndTime.HasValue)
@@ -23,7 +24,7 @@
{
<div class="d-inline-flex flex-wrap justify-content-center">
<label class="ended-label mb-0">@Loc["ShoppingCart.Auctionends"]:</label>
- <div class="count-date">@Model.EndTimeLocalTime.Value.ToString()</div>
+ <div class="count-date">@Model.EndTimeLocalTime!.Value.ToString()</div>
</div>
}
</div>
@@ -31,7 +32,7 @@
@if (Model.EndTime > DateTime.UtcNow)
{
<div class="btn-group w-100 mt-3">
- <input name="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(System.Globalization.CultureInfo.InvariantCulture))" />
+ <input name="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(CultureInfo.InvariantCulture))" />
<button id="[email protected]" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" data-productid="@Model.Id" onclick="AxiosCart.addbid('@Url.RouteUrl("AddBid", new { productId = Model.Id })', '#product-details-form'); return false;">
<b-icon icon="hammer" class="mx-1"></b-icon><span>@Loc["ShoppingCart.Bid"]</span>
</button>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Availability.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Availability.cshtml
index d285bf39f..227b2f691 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Availability.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Availability.cshtml
@@ -1,6 +1,6 @@
@model ProductDetailsModel
<div class="availability generalMarginSupporter">
- @if (!String.IsNullOrWhiteSpace(Model.StockAvailability))
+ @if (!string.IsNullOrWhiteSpace(Model.StockAvailability))
{
<div class="stock">
<span class="label">@Loc["Products.Availability"]:</span>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Breadcrumbs.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Breadcrumbs.cshtml
index 8286aeef1..8302ad055 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Breadcrumbs.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Breadcrumbs.cshtml
@@ -19,10 +19,10 @@
{
count++;
<li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item">
- <a href="@Url.RouteUrl("Category", new { SeName = category.SeName })" target="_self">
+ <a href="@Url.RouteUrl("Category", new { category.SeName })" target="_self">
<span itemprop="name">@category.Name</span>
<span itemprop="item" itemscope itemtype="http://schema.org/Thing"
- id="@Url.RouteUrl("Category", new { SeName = category.SeName })">
+ id="@Url.RouteUrl("Category", new { category.SeName })">
</span>
<meta itemprop="position" content="@count" />
</a>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Codes.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Codes.cshtml
index 7593dddc1..12f2e8e99 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Codes.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Codes.cshtml
@@ -1,20 +1,20 @@
@model ProductDetailsModel
<div class="additional-details mt-2">
- @if (!String.IsNullOrWhiteSpace(Model.Sku) && Model.ShowSku)
+ @if (!string.IsNullOrWhiteSpace(Model.Sku) && Model.ShowSku)
{
<div class="sku">
<span class="label">@Loc["Products.Sku"]:</span>
<span class="value" itemprop="sku" id="[email protected]">@Model.Sku</span>
</div>
}
- @if (!String.IsNullOrWhiteSpace(Model.Mpn) && Model.ShowMpn)
+ @if (!string.IsNullOrWhiteSpace(Model.Mpn) && Model.ShowMpn)
{
<div class="collection-part-number">
<span class="label">@Loc["Products.Mpn"]:</span>
<span class="value" itemprop="mpn" id="[email protected]">@Model.Mpn</span>
</div>
}
- @if (!String.IsNullOrWhiteSpace(Model.Gtin) && Model.ShowGtin)
+ @if (!string.IsNullOrWhiteSpace(Model.Gtin) && Model.ShowGtin)
{
<div class="gtin">
<span class="label">@Loc["Products.GTIN"]:</span>
@@ -25,7 +25,7 @@
{
<div class="product-brand generalMarginSupporter">
<span class="label">@Loc["Products.Brand"]:</span>
- <span class="value"><a href="@Url.RouteUrl("Brand", new { SeName = Model.BrandModel.SeName })">@Model.BrandModel.Name</a></span>
+ <span class="value"><a href="@Url.RouteUrl("Brand", new { Model.BrandModel.SeName })">@Model.BrandModel.Name</a></span>
</div>
}
@@ -33,7 +33,7 @@
{
<div class="product-vendor generalMarginSupporter">
<span class="label">@Loc["Products.Vendor"]:</span>
- <span class="value"><a href="@Url.RouteUrl("Vendor", new { SeName = Model.VendorModel.SeName })">@Model.VendorModel.Name</a></span>
+ <span class="value"><a href="@Url.RouteUrl("Vendor", new { Model.VendorModel.SeName })">@Model.VendorModel.Name</a></span>
</div>
}
</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Collections.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Collections.cshtml
index 826d48222..c3065133e 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Collections.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Collections.cshtml
@@ -9,10 +9,10 @@
<strong class="label">@Loc["Products.Collections"]:</strong>
}
<span class="value">
- @for (int i = 0; i < Model.Count; i++)
+ @for (var i = 0; i < Model.Count; i++)
{
var item = Model[i];
- <a href="@Url.RouteUrl("Collection", new { SeName = item.SeName })">@item.Name</a>
+ <a href="@Url.RouteUrl("Collection", new { item.SeName })">@item.Name</a>
if (i != Model.Count - 1)
{
<span class="separator">,</span>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
index 7fa042c03..da3b7de44 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Prices.cshtml
@@ -1,4 +1,5 @@
-@model ProductDetailsModel.ProductPriceModel
+@using System.Globalization
+@model ProductDetailsModel.ProductPriceModel
@inject IWorkContext workContext
<div class="prices d-flex justify-content-center align-items-start row px-3 flex-column" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
@@ -94,7 +95,7 @@
<span class="your-price price-value-@(Model.ProductId)">
<strong class="actual-price">@Html.Raw(Model.PriceWithDiscount)</strong>
</span>
- <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)" class="your-price price-value-@(Model.ProductId)" />
+ <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" class="your-price price-value-@(Model.ProductId)" />
</div>
}
if (!string.IsNullOrEmpty(Model.BasePricePAngV))
@@ -109,7 +110,7 @@
}
@if (string.IsNullOrWhiteSpace(Model.PriceWithDiscount))
{
- <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)" />
+ <meta itemprop="price" content="@Model.PriceValue.ToString("0.00", CultureInfo.InvariantCulture)" />
}
}
</div>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
index 568540510..ebae28709 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
@@ -1,22 +1,20 @@
@model ProductDetailsModel
-@using System.Text;
<div id="product-attributes"></div>
@{
//dynamic update support
- var attributesHaveAssociatedPictures = true;
var attributeChangeScriptsBuilder = new StringBuilder();
var attributeChangeHandlerFuncName = $"attribute_change_handler_{Model.Id}";
- var fileLink = @Url.RouteUrl("UploadFileProductAttribute");
+ var fileLink = Url.RouteUrl("UploadFileProductAttribute");
//generate change event script
foreach (var attribute in Model.ProductAttributes)
{
- string controlId = $"product_attribute_{attribute.Id}";
+ var controlId = $"product_attribute_{attribute.Id}";
switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}').addEventListener('change', function (){{{1}();}});\n", controlId, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}').addEventListener('change', function (){{{attributeChangeHandlerFuncName}();}});\n");
}
break;
case AttributeControlType.RadioList:
@@ -25,7 +23,7 @@
{
foreach (var attributeValue in attribute.Values)
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(e){{{2}();}},false);\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");
}
}
break;
@@ -34,12 +32,10 @@
{
foreach (var attributeValue in attribute.Values)
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(e){{{2}();}},false);\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");
}
}
break;
- default:
- break;
}
}
//render scripts
@@ -227,7 +223,7 @@
var form = document.getElementById('@($"product-details-form-{Model.Id}")');
var data = new FormData(form);
axios({
- url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = Model.Id, loadPicture = attributesHaveAssociatedPictures }))',
+ url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = Model.Id, loadPicture = true }))',
data: data,
method: 'post',
params: { product: '@Model.Id' },
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
index 8da0a6079..bdf260f51 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
@@ -1,22 +1,20 @@
@model IList<ProductDetailsModel.ProductAttributeModel>
-@using System.Text;
@{
//dynamic update support
- var attributesHaveAssociatedPictures = true;
var attributeChangeScriptsBuilder = new StringBuilder();
var bundleProductId = ViewData["BundleProductId"]?.ToString();
var productId = ViewData["ProductId"]?.ToString();
- var format = "attribute_change_handler_{0}";
+ const string format = "attribute_change_handler_{0}";
var attributeChangeHandlerFuncName = string.Format(format, productId);
//generate change event script
foreach (var attribute in Model)
{
- string controlId = $"product_attribute_{attribute.Id}";
+ var controlId = $"product_attribute_{attribute.Id}";
switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}').addEventListener('change', function (){{{1}();}});\n", controlId, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}').addEventListener('change', function (){{{attributeChangeHandlerFuncName}();}});\n");
}
break;
case AttributeControlType.RadioList:
@@ -25,7 +23,7 @@
{
foreach (var attributeValue in attribute.Values)
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(e){{{2}();}},false);\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");
}
}
break;
@@ -34,12 +32,10 @@
{
foreach (var attributeValue in attribute.Values)
{
- attributeChangeScriptsBuilder.AppendFormat("document.querySelector('#{0}_{1}').addEventListener('click',function(e){{{2}();}},false);\n", controlId, attributeValue.Id, attributeChangeHandlerFuncName);
+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");
}
}
break;
- default:
- break;
}
}
@@ -49,7 +45,7 @@
var form = document.getElementById('product-details-form');
var data = new FormData(form);
axios({
- url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = bundleProductId, loadPicture = attributesHaveAssociatedPictures }))',
+ url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = bundleProductId, loadPicture = true }))',
data: data,
method: 'post',
params: { product: '@bundleProductId' },
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
index ca61c5706..31f97c7a5 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
@@ -10,23 +10,25 @@
</div>
</div>
<div class="col-md-9 col-8">
- <h6 class="card-title">@item.Quantity x <a href="@Url.RouteUrl("Product", new { SeName = item.SeName })"> @item.Name </a>(@item.Price)</h6>
+ <h6 class="card-title">@item.Quantity x <a href="@Url.RouteUrl("Product", new { item.SeName })"> @item.Name </a>(@item.Price)</h6>
<p class="card-text small">@Html.Raw(item.ShortDescription)</p>
</div>
</div>
@if (item.ProductAttributes.Any())
{
- var dataDictAttributes = new ViewDataDictionary(ViewData);
- dataDictAttributes.Add("BundleProductId", Model.Id);
- dataDictAttributes.Add("ProductId", item.ProductId);
- dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", item.ProductId);
+ var dataDictAttributes = new ViewDataDictionary(ViewData)
+ {
+ { "BundleProductId", Model.Id },
+ { "ProductId", item.ProductId }
+ };
+ dataDictAttributes.TemplateInfo.HtmlFieldPrefix = $"attributes_{item.ProductId}";
<div class="col-12 pt-1">
<partial name="Partials/ProductAttributesBundle" model="item.ProductAttributes" view-data="dataDictAttributes" />
</div>
}
</div>
}
- @if (Model.ProductBundleModels.Where(x => x.ProductAttributes.Any()).Any())
+ @if (Model.ProductBundleModels.Any(x => x.ProductAttributes.Any()))
{
<template id="product-attributes-bundle" asp-header="true">
<div>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductReviewOverview.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductReviewOverview.cshtml
index e1275496f..b076c9ab3 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductReviewOverview.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductReviewOverview.cshtml
@@ -1,10 +1,10 @@
-@model ProductReviewOverviewModel
-@using System.Globalization
+@using System.Globalization
+@model ProductReviewOverviewModel
@{
- int ratingPercent = 0;
+ var ratingPercent = 0;
if (Model.TotalReviews != 0)
{
- ratingPercent = ((Model.RatingSum * 100) / Model.TotalReviews) / 5;
+ ratingPercent = Model.RatingSum * 100 / Model.TotalReviews / 5;
}
}
<div class="product-reviews-overview d-inline-flex align-items-center flex-wrap" @if (Model.TotalReviews > 0)
@@ -29,7 +29,7 @@
</template>
@{
@* rendering microdata info*@
- double value = ratingPercent / (double)20;
+ var value = ratingPercent / (double)20;
<span itemprop="ratingValue" class="d-none">(@value.ToString("0.0", new CultureInfo("en-US")))</span>
<span itemprop="reviewCount" class="d-none">@Model.TotalReviews</span>
}
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductSpecifications.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductSpecifications.cshtml
index 8cbf3f2bd..cea308bc9 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductSpecifications.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductSpecifications.cshtml
@@ -21,13 +21,10 @@
</div>
</td>
<td class="border-bottom border-top-0">
- @{
- var groupList2 = item.ToList();
- }
<div class="spec-value d-inline-flex w-100">
@foreach (var spec in groupList)
{
- @if (String.IsNullOrEmpty(spec.ColorSquaresRgb))
+ @if (string.IsNullOrEmpty(spec.ColorSquaresRgb))
{
<div class="mb-2 mr-2">
@Html.Raw(spec.ValueRaw)
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductTags.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductTags.cshtml
index b90fdc30e..7077d48ac 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductTags.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductTags.cshtml
@@ -1,9 +1,9 @@
@model IList<ProductTagModel>
<div class="product-tags-box col-12 px-0">
<div class="product-tags-list">
- @for (int i = 0; i < Model.Count; i++)
+ @for (var i = 0; i < Model.Count; i++)
{
- <a class="btn btn-light producttag" href="@Url.RouteUrl("ProductsByTagName", new { SeName = Model[i].SeName })">
+ <a class="btn btn-light producttag" href="@Url.RouteUrl("ProductsByTagName", new { Model[i].SeName })">
@Model[i].Name <span>@Loc["Products.Tags.Count", Model[i].ProductCount]</span>
</a>
}
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductsComparison.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductsComparison.cshtml
index f246ca0f4..e8daf6979 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductsComparison.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductsComparison.cshtml
@@ -1,7 +1,4 @@
@model ProductDetailsModel
-@{
- var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id });
-}
@if (Model.CompareProductsEnabled)
{
<a class="btn btn-secondary add-to-compare-list-button mr-1" onclick="AxiosCart.addproducttocomparelist('@Model.Id', '@Loc["Products.ProductHasBeenAddedToCompareList.Link"]', '@Url.RouteUrl("CompareProducts")')" v-b-tooltip.hover.bottom title="@Loc["Products.Compare.AddToCompareList"]">
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
index 06ca1e260..b32063056 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
@@ -1,6 +1,6 @@
-@model ProductDetailsModel
+@using System.Globalization
+@model ProductDetailsModel
@inject SeoSettings seoSettings
-@using System.Globalization
<div>
@if (Model.Parameters.Any())
{
diff --git a/src/Web/Grand.Web/Views/Product/Partials/Warehouses.cshtml b/src/Web/Grand.Web/Views/Product/Partials/Warehouses.cshtml
index 481925e07..14258157a 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/Warehouses.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/Warehouses.cshtml
@@ -15,7 +15,7 @@
{
<script asp-location="Footer" asp-order="300">
@{
- var attributeChangeHandlerFuncName = string.Format("attribute_change_handler_{0}();", Model.Id);
+ var attributeChangeHandlerFuncName = $"attribute_change_handler_{Model.Id}();";
}
document.addEventListener("DOMContentLoaded", function () {
document.getElementById('WarehouseId').addEventListener('change', function () { @attributeChangeHandlerFuncName });
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
index 32ee42c36..1c214bf98 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
@@ -6,14 +6,14 @@
Layout = "_SingleColumn";
//title, meta
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
//canonical URL
if (seoSettings.CanonicalUrlsEnabled)
{
- var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var productUrl = Url.RouteUrl("Product", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(productUrl);
}
}
@@ -27,7 +27,7 @@
<meta property="og:description" content="@Html.Encode(Model.MetaDescription)"/>
<meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl"/>
<meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl"/>
- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
+ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
<meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)"/>
}
@if (seoSettings.TwitterMetaTags)
@@ -37,7 +37,7 @@
<meta property="twitter:title" content="@Html.Encode(Model.Name)"/>
<meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)"/>
<meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl"/>
- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
}
}
@@ -73,7 +73,7 @@
@Model.Name
</h1>
</div>
- @if (!String.IsNullOrEmpty(Model.ShortDescription))
+ @if (!string.IsNullOrEmpty(Model.ShortDescription))
{
<div class="short-description mb-3">
@Html.Raw(Model.ShortDescription)
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
index 51ff089c1..b10b3459a 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
@@ -6,14 +6,14 @@
Layout = "_SingleColumn";
//title, meta
- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
//canonical URL
if (seoSettings.CanonicalUrlsEnabled)
{
- var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
+ var productUrl = Url.RouteUrl("Product", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);
pagebuilder.AddCanonicalUrlParts(productUrl);
}
}
@@ -26,7 +26,7 @@
<meta property="og:description" content="@Html.Encode(Model.MetaDescription)" />
<meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl" />
<meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl" />
- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
+ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
<meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)" />
}
@@ -37,7 +37,7 @@
<meta property="twitter:title" content="@Html.Encode(Model.Name)" />
<meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)" />
<meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl" />
- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
}
}
@@ -76,7 +76,7 @@
<partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview" />
}
<vc:widget widget-zone="productdetails_overview_top" additional-data="@Model.Id"></vc:widget>
- @if (!String.IsNullOrEmpty(Model.ShortDescription))
+ @if (!string.IsNullOrEmpty(Model.ShortDescription))
{
<div class="short-description generalMarginSupporter">
@Html.Raw(Model.ShortDescription)
@@ -88,7 +88,7 @@
<partial name="Partials/Collections" model="Model.ProductCollections" />
}
<!--availability-->
- @if (!String.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayOutOfStockSubscription)
+ @if (!string.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayOutOfStockSubscription)
{
<partial name="Partials/Availability" model="Model" />
}
@@ -163,7 +163,7 @@
</div>
</div>
</div>
- @if (!String.IsNullOrWhiteSpace(Model.PageShareCode))
+ @if (!string.IsNullOrWhiteSpace(Model.PageShareCode))
{
<div class="col-12 product-share px-0">
<partial name="Partials/ShareButton" model="Model" />
diff --git a/src/Web/Grand.Web/Views/Shared/Components/CategoryFeaturedProducts/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/CategoryFeaturedProducts/Default.cshtml
index 525c97f05..5bc5e0a2d 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/CategoryFeaturedProducts/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/CategoryFeaturedProducts/Default.cshtml
@@ -5,7 +5,7 @@
@foreach (var item in Model)
{
<div class="[email protected]_c_Xl [email protected]_c_Lg [email protected]_c_Md [email protected]_c_Sm [email protected]_c_Col categoryGrid mb-3">
- <a href="@Url.RouteUrl("Collection", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Collection", new { item.SeName })" title="@item.PictureModel.Title">
<article class="card">
<b-card-img-lazy src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-card-img-lazy>
<div class="card-body">
diff --git a/src/Web/Grand.Web/Views/Shared/Components/CollectionFeaturedProducts/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/CollectionFeaturedProducts/Default.cshtml
index c690d7180..7cdf0555a 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/CollectionFeaturedProducts/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/CollectionFeaturedProducts/Default.cshtml
@@ -5,7 +5,7 @@
@foreach (var item in Model)
{
<div class="[email protected]_m_Xl [email protected]_m_Lg [email protected]_m_Md [email protected]_m_Sm [email protected]_m_Col categoryGrid mb-3">
- <a href="@Url.RouteUrl("Collection", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Collection", new { item.SeName })" title="@item.PictureModel.Title">
<article class="card">
<b-card-img-lazy src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-card-img-lazy>
<div class="card-body">
diff --git a/src/Web/Grand.Web/Views/Shared/Components/CollectionNavigation/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/CollectionNavigation/Default.cshtml
index 432fd6e4e..2c3dc8466 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/CollectionNavigation/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/CollectionNavigation/Default.cshtml
@@ -7,7 +7,7 @@
@foreach (var collection in Model.Collections)
{
<li class="@(collection.IsActive ? "active" : "inactive")">
- <a href="@Url.RouteUrl("Collection", new { SeName = collection.SeName })">
+ <a href="@Url.RouteUrl("Collection", new { collection.SeName })">
@if (!string.IsNullOrEmpty(collection.Icon))
{
<span class="category-icon @collection.Icon"></span>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
index 4f00e5666..473f395dd 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Footer/Default.cshtml
@@ -21,7 +21,7 @@
}
@foreach (var mpage in Model.Pages.Where(x => x.IncludeInFooterRow1).ToList())
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { SeName = mpage.SeName })">@mpage.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { mpage.SeName })">@mpage.Name</a>
}
<a class="list-group-item list-group-item-action" href="@Url.RouteUrl("ContactUs")">@Loc["ContactUs"]</a>
<a class="list-group-item list-group-item-action" href="@Url.RouteUrl("ProductSearch")">@Loc["Search"]</a>
@@ -71,7 +71,7 @@
}
@foreach (var mpage in Model.Pages.Where(x => x.IncludeInFooterRow2).ToList())
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { SeName = mpage.SeName })" target="_blank">@mpage.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { mpage.SeName })" target="_blank">@mpage.Name</a>
}
</div>
</div>
@@ -79,7 +79,7 @@
<div class="pl-0 list-group list-pad">
@foreach (var mpage in Model.Pages.Where(x => x.IncludeInFooterRow3).ToList())
{
- <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { SeName = mpage.SeName })">@mpage.Name</a>
+ <a class="list-group-item list-group-item-action" href="@Url.RouteUrl("Page", new { mpage.SeName })">@mpage.Name</a>
}
</div>
</div>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
index 8cedba894..9e68c7e3a 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageBlog/Default.cshtml
@@ -18,7 +18,7 @@
}
<div class="card-header">
<h3 class="h5 mb-0">
- <b-link href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
+ <b-link href="@Url.RouteUrl("BlogPost", new { item.SeName })">
@item.Title
</b-link>
</h3>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageBrands/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageBrands/Default.cshtml
index 4118d8be8..7df109283 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageBrands/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageBrands/Default.cshtml
@@ -7,11 +7,11 @@
{
<div class="card picture-card mb-2">
- <a href="@Url.RouteUrl("Brand", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Brand", new { item.SeName })" title="@item.PictureModel.Title">
<b-card-img-lazy src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-card-img-lazy>
</a>
<h4 class="title">
- <a href="@Url.RouteUrl("Brand", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Brand", new { item.SeName })" title="@item.PictureModel.Title">
@item.Name
</a>
</h4>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageCategories/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageCategories/Default.cshtml
index b08846986..6e5c25bb3 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageCategories/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageCategories/Default.cshtml
@@ -7,11 +7,11 @@
{
<div class="card picture-card mb-2">
- <a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Category", new { item.SeName })" title="@item.PictureModel.Title">
<img src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"/>
</a>
<h4 class="title">
- <a href="@Url.RouteUrl("Category", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Category", new { item.SeName })" title="@item.PictureModel.Title">
@item.Name
</a>
</h4>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageCollections/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageCollections/Default.cshtml
index 08b7ece1b..298776f96 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageCollections/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageCollections/Default.cshtml
@@ -7,7 +7,7 @@
{
<div class="card picture-card mb-2">
- <a href="@Url.RouteUrl("Collection", new { SeName = item.SeName })" title="@item.PictureModel.Title">
+ <a href="@Url.RouteUrl("Collection", new { item.SeName })" title="@item.PictureModel.Title">
<b-card-img-lazy src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"></b-card-img-lazy>
</a>
</div>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
index 1c7d6f2ae..fa357e08b 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/HomePageNews/Default.cshtml
@@ -16,7 +16,7 @@
}
<div class="card-header">
<h3 class="h5 mb-0">
- <b-link href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">
+ <b-link href="@Url.RouteUrl("NewsItem", new { item.SeName })">
@item.Title
</b-link>
</h3>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Menu/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Menu/Default.cshtml
index 4f2851646..2fcfc0e4f 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Menu/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Menu/Default.cshtml
@@ -23,7 +23,7 @@
@foreach (var mpage in Model.Pages)
{
<li>
- <a href="@Url.RouteUrl("Page", new { SeName=mpage.SeName })">
+ <a href="@Url.RouteUrl("Page", new { mpage.SeName })">
<span class="title">@mpage.Name</span>
</a>
</li>
@@ -50,7 +50,7 @@
@foreach (var brand in Model.Brands)
{
<li>
- <a href="@Url.RouteUrl("Brand", new { SeName = brand.SeName })">
+ <a href="@Url.RouteUrl("Brand", new { brand.SeName })">
<span class="title">@brand.Name</span>
@if (!string.IsNullOrEmpty(brand.Icon))
{
@@ -85,7 +85,7 @@
@foreach (var collect in Model.Collections)
{
<li>
- <a href="@Url.RouteUrl("Collection", new { SeName = collect.SeName })">
+ <a href="@Url.RouteUrl("Collection", new { collect.SeName })">
<span class="title">@collect.Name</span>
@if (!string.IsNullOrEmpty(collect.Icon))
{
@@ -141,10 +141,4 @@
</li>
}
}
-@await Component.InvokeAsync("Widget", new { widgetZone = "header_menu_after" })
-
-@{
- var rootCategoriesResponsive = Model.Categories.ToList();
- //name it "Categories" if we have only categories. Otherwise, "Menu"
- var responsiveMenuTitle = (rootCategoriesResponsive.Any() && Model.Pages.Any()) ? Loc["Categories"] : Loc["Menu"];
-}
+@await Component.InvokeAsync("Widget", new { widgetZone = "header_menu_after" })
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Menu.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Menu.cshtml
index f81064a5c..320a7b115 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Menu.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Menu.cshtml
@@ -2,11 +2,11 @@
@if (Model.Category.IncludeInMenu)
{
- <li class="@(Model.Category.SubCategories.Count() == 0 ? "category": "category -hasSubmenu" )">
+ <li class="@(!Model.Category.SubCategories.Any() ? "category": "category -hasSubmenu")">
- @if (Model.Category.SubCategories.Count() == 0)
+ @if (Model.Category.SubCategories.Count == 0)
{
- <a href="@Url.RouteUrl("Category", new { SeName = Model.Category.SeName })">
+ <a href="@Url.RouteUrl("Category", new { Model.Category.SeName })">
@if (!string.IsNullOrEmpty(Model.Category.Icon))
{
<b-icon class="category-icon" icon="@Model.Category.Icon"></b-icon>
@@ -50,7 +50,7 @@
<span>@Loc["Mobile.Categories.Back"]</span>
</li>
<li class="sub-cat-name-container">
- <a class="bg-info" href="@Url.RouteUrl("Category", new { SeName = Model.Category.SeName })">
+ <a class="bg-info" href="@Url.RouteUrl("Category", new { Model.Category.SeName })">
<span>@Loc["Mobile.Category.Show"] @Model.Category.Name</span>
</a>
</li>
@@ -76,7 +76,7 @@
<span>@Loc["Mobile.Categories.Back"]</span>
</li>
<li class="sub-cat-name-container">
- <a class="bg-info" href="@Url.RouteUrl("Category", new { SeName = Model.Category.SeName })">
+ <a class="bg-info" href="@Url.RouteUrl("Category", new { Model.Category.SeName })">
<span>@Loc["Mobile.Category.Show"] @Model.Category.Name</span>
</a>
</li>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Navigation.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Navigation.cshtml
index 7d0d3565a..7fcbf6608 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Navigation.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Menu/Partials/CategoryLine.Navigation.cshtml
@@ -2,7 +2,7 @@
@functions{
public bool BreadCrumbContainsCurrentCategoryId(CategorySimpleModel category)
{
- if (String.IsNullOrEmpty(Model.CurrentCategoryId))
+ if (string.IsNullOrEmpty(Model.CurrentCategoryId))
return false;
if (category.Id == Model.CurrentCategoryId)
@@ -20,16 +20,16 @@
}
}
@{
- bool active = Model.Category.Id == Model.CurrentCategoryId || Model.Category.SubCategories.Count(BreadCrumbContainsCurrentCategoryId) > 0;
- bool last = Model.Category.Id == Model.CurrentCategoryId;
- string liClass = active ? "active" : "inactive";
+ var active = Model.Category.Id == Model.CurrentCategoryId || Model.Category.SubCategories.Count(BreadCrumbContainsCurrentCategoryId) > 0;
+ var last = Model.Category.Id == Model.CurrentCategoryId;
+ var liClass = active ? "active" : "inactive";
if (last)
{
liClass += " last";
}
}
<li class="@liClass">
- <a href="@Url.RouteUrl("Category", new { SeName = Model.Category.SeName })">
+ <a href="@Url.RouteUrl("Category", new { Model.Category.SeName })">
@if (!string.IsNullOrEmpty(Model.Category.Icon))
{
<span class="category-icon @Model.Category.Icon"></span>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/PageBlock/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/PageBlock/Default.cshtml
index ceba824be..3121b814e 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/PageBlock/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/PageBlock/Default.cshtml
@@ -46,7 +46,7 @@
@Loc["Page.EnterPassword"]
</div>
<div class="enter-password-form">
- @Html.Password("password", null, new { id = "password-" + @Model.Id, @class = "form-control mt-1" })
+ @Html.Password("password", null, new { id = "password-" + Model.Id, @class = "form-control mt-1" })
<b-button id="button-password" variant="secondary" class="page-password-button mt-1 mb-1">
@Loc["Page.Button"]
</b-button>
@@ -70,7 +70,7 @@
else
{
<div class="generalMarginSupporter">
- @if (!String.IsNullOrEmpty(Model.Title))
+ @if (!string.IsNullOrEmpty(Model.Title))
{
<h1 class="generalTitle h2 text-sm-center">@Model.Title</h1>
}
diff --git a/src/Web/Grand.Web/Views/Shared/Components/PagesBlock/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/PagesBlock/Default.cshtml
index d3d52375b..6054266fa 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/PagesBlock/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/PagesBlock/Default.cshtml
@@ -44,7 +44,7 @@
@Loc["Page.EnterPassword"]
</div>
<div class="enter-password-form">
- @Html.Password("password", null, new { id = "password-" + @Model.Id, @class = "form-control mt-1" })
+ @Html.Password("password", null, new { id = "password-" + Model.Id, @class = "form-control mt-1" })
<b-button id="button-password" variant="secondary" class="page-password-button mt-1 mb-1">
@Loc["Page.Button"]
</b-button>
@@ -68,7 +68,7 @@
else
{
<div class="generalMarginSupporter">
- @if (!String.IsNullOrEmpty(Model.Title))
+ @if (!string.IsNullOrEmpty(Model.Title))
{
<h1 class="generalTitle h2 text-sm-center">@Model.Title</h1>
}
diff --git a/src/Web/Grand.Web/Views/Shared/Components/PopularProductTags/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/PopularProductTags/Default.cshtml
index c7abf6243..97f9de97b 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/PopularProductTags/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/PopularProductTags/Default.cshtml
@@ -5,7 +5,7 @@
<div class="btn-toolbar btn-group-sm">
@foreach (var item in Model.Tags)
{
- <a class="btn btn-light d-flex align-items-center mr-2 mb-2" href="@Url.RouteUrl("ProductsByTagName", new { SeName = item.SeName })" style="font-size:@(Model.GetFontSize(item))%;">@item.Name</a>
+ <a class="btn btn-light d-flex align-items-center mr-2 mb-2" href="@Url.RouteUrl("ProductsByTagName", new { item.SeName })" style="font-size:@(Model.GetFontSize(item))%;">@item.Name</a>
}
@if (Model.TotalTags > Model.Tags.Count)
{
diff --git a/src/Web/Grand.Web/Views/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml
index bc9afb8fe..9c2f3c282 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml
@@ -5,16 +5,16 @@
<h2 class="generalTitle">@Loc["Products.RecentlyViewedProducts"]</h2>
<div class="col-12 px-0">
<div class="form-row">
- @for (int i = 0; i < Model.Count; i++)
+ @for (var i = 0; i < Model.Count; i++)
{
var product = Model[i];
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-4 col-6 mb-2">
<div class="card">
- <a class="text-center" href="@Url.RouteUrl("Product", new { SeName = product.SeName })">
+ <a class="text-center" href="@Url.RouteUrl("Product", new { product.SeName })">
<b-img-lazy class="img-fluid" alt="@product.DefaultPictureModel.AlternateText" src="@product.DefaultPictureModel.ImageUrl" title="@product.DefaultPictureModel.Title"></b-img-lazy>
</a>
<div class="card-body">
- <h5 class="h6"><a href="@Url.RouteUrl("Product", new { SeName = product.SeName })">@product.Name</a></h5>
+ <h5 class="h6"><a href="@Url.RouteUrl("Product", new { product.SeName })">@product.Name</a></h5>
</div>
</div>
</div>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
index 6f0d269fc..deaac8c8d 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/SearchBox/Default.cshtml
@@ -1,5 +1,6 @@
-@model SearchBoxModel
-@inject Grand.Domain.Blogs.BlogSettings blogSettings
+@using Grand.Domain.Blogs
+@model SearchBoxModel
+@inject BlogSettings blogSettings
@inject IWorkContext workContext
@{
var lang = workContext.WorkingLanguage.LanguageCulture;
diff --git a/src/Web/Grand.Web/Views/Shared/Components/VendorNavigation/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/VendorNavigation/Default.cshtml
index ba192678b..23db44ca2 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/VendorNavigation/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/VendorNavigation/Default.cshtml
@@ -6,7 +6,7 @@
<ul class="list">
@foreach (var vendor in Model.Vendors)
{
- <li><a href="@Url.RouteUrl("Vendor", new { SeName = vendor.SeName })">@vendor.Name</a>
+ <li><a href="@Url.RouteUrl("Vendor", new { vendor.SeName })">@vendor.Name</a>
</li>
}
</ul>
diff --git a/src/Web/Grand.Web/Views/Shared/Components/Widget/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/Widget/Default.cshtml
index 1751d3e53..5bb69f539 100644
--- a/src/Web/Grand.Web/Views/Shared/Components/Widget/Default.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Components/Widget/Default.cshtml
@@ -1,5 +1,5 @@
@model List<WidgetModel>
@foreach (var widget in Model)
{
- @await Component.InvokeAsync(widget.ViewComponentName, new { widgetZone = widget.WidgetZone, additionalData = widget.AdditionalData });
+ @await Component.InvokeAsync(widget.ViewComponentName, new { widgetZone = widget.WidgetZone, additionalData = widget.AdditionalData })
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/CatalogProductView.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/CatalogProductView.cshtml
index 9b0688bbc..e866a3a42 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/CatalogProductView.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/CatalogProductView.cshtml
@@ -2,43 +2,28 @@
@model ProductOverviewModel
@{
//prepare "Add to cart" Axios link
- string addtocartlink = "";
- string addtowishlistlink = "";
- string quickviewurl = Url.RouteUrl("QuickView-Product", new { productId = Model.Id });
+ var addtocartlink = "";
+ var addtowishlistlink = "";
+ var quickviewurl = Url.RouteUrl("QuickView-Product", new { productId = Model.Id });
- var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
- var quantity = 1;
+ const int shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
+ const int quantity = 1;
if (!Model.ShowQty)
{
- if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
- }
- else
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity });
- }
- addtowishlistlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist, quantity = 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 = shoppingCartTypeId, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
- }
- else
- {
- addtocartlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = 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 });
}
@await Component.InvokeAsync("Widget", new { widgetZone = "productbox_before_content", additionalData = Model })
<article v-bind:class="{ mobile: isMobile()}" class="card product-box mb-2">
<div class="picture-container">
- <a class="img-container" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title">
+ <a class="img-container" href="@Url.RouteUrl("Product", new { Model.SeName })" title="@Model.DefaultPictureModel.Title">
<b-card-img-lazy alt="@Model.DefaultPictureModel.AlternateText" class="main-product-img" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title"></b-card-img-lazy>
@if (!string.IsNullOrEmpty(Model.SecondPictureModel.ImageUrl))
{
@@ -58,7 +43,7 @@
</div>
<div class="card-body">
<h3 class="card-title mb-0">
- <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })">
+ <a href="@Url.RouteUrl("Product", new { Model.SeName })">
@Model.Name
</a>
</h3>
@@ -72,12 +57,12 @@
double ratingValue = 0;
if (Model.ReviewOverviewModel.TotalReviews != 0)
{
- ratingValue = Convert.ToDouble(((Model.ReviewOverviewModel.RatingSum * (double)100) / Model.ReviewOverviewModel.TotalReviews) / (double)100);
+ ratingValue = Convert.ToDouble(Model.ReviewOverviewModel.RatingSum * (double)100 / Model.ReviewOverviewModel.TotalReviews / 100);
}
<template>
<div class="rating">
<b-form-rating id="[email protected]" aria-label="Rating" class="p-0" variant="warning" no-border size="sm" show-value aria-valuenow="@(ratingValue.ToString("0.00", CultureInfo.InvariantCulture))" precision="2" readonly inline value="@(ratingValue.ToString("0.00", CultureInfo.InvariantCulture))"></b-form-rating>
- <b-link href="@Url.RouteUrl("Product", new { SeName = Model.SeName })">@Model.ReviewOverviewModel.TotalReviews @Loc["Reviews.Overview.Reviews"]</b-link>
+ <b-link href="@Url.RouteUrl("Product", new { Model.SeName })">@Model.ReviewOverviewModel.TotalReviews @Loc["Reviews.Overview.Reviews"]</b-link>
</div>
</template>
}
@@ -125,7 +110,7 @@
@(Model.ProductPrice.HighestBidValue > 0 ? Model.ProductPrice.HighestBid : Model.ProductPrice.StartPrice)
</div>
}
- @if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))
+ @if (!string.IsNullOrEmpty(Model.ProductPrice.OldPrice))
{
<div class="old-price price">
@Model.ProductPrice.OldPrice
@@ -155,9 +140,6 @@
</div>
</td>
<td>
- @{
- var groupList2 = item.ToList();
- }
<div class="spec-value">
@foreach (var spec in groupList)
{
@@ -197,12 +179,12 @@
case AttributeControlType.RadioList:
case AttributeControlType.Checkboxes:
case AttributeControlType.ReadonlyCheckboxes:
- <a class="btn btn-sm btn-light name" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })[email protected][email protected](spec.Name)">
+ <a class="btn btn-sm btn-light name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">
@Html.Raw(spec.Name)
</a>
break;
case AttributeControlType.ColorSquares:
- if ((spec.PictureModel.FullSizeImageUrl) != null)
+ if (spec.PictureModel.FullSizeImageUrl != null)
{
<a class="btn btn-sm btn-light name color-container" title="@spec.Name" @@click="productImage($event)" data-href="@spec.PictureModel.FullSizeImageUrl">
<span class="color" style="background-color:@spec.ColorSquaresRgb;">&nbsp;</span>
@@ -210,13 +192,13 @@
}
else
{
- <a class="btn btn-sm btn-light name color-container" title="@spec.Name" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })[email protected][email protected](spec.Name)">
+ <a class="btn btn-sm btn-light name color-container" title="@spec.Name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">
<span class="color" style="background-color:@spec.ColorSquaresRgb;">&nbsp;</span>
</a>
}
break;
case AttributeControlType.ImageSquares:
- if ((spec.PictureModel.FullSizeImageUrl) != null)
+ if (spec.PictureModel.FullSizeImageUrl != null)
{
<a class="btn btn-sm btn-light p-1 name image-container" v-on:click='productImage' data-href="@spec.PictureModel.FullSizeImageUrl">
<img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name" />
@@ -224,13 +206,11 @@
}
else
{
- <a class="btn btn-sm btn-light p-1 name image-container" href="@Url.RouteUrl("Product", new { SeName = Model.SeName })[email protected][email protected](spec.Name)">
+ <a class="btn btn-sm btn-light p-1 name image-container" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">
<img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name" />
</a>
}
break;
- default:
- break;
}
}
</div>
@@ -247,7 +227,7 @@
</div>
@if (Model.ShowQty)
{
- var qtyId = "addtocart_" + @Model.Id + "_EnteredQuantity";
+ var qtyId = "addtocart_" + Model.Id + "_EnteredQuantity";
<input class="form-control input-group-addon catalog-quantity" type="number" min="1" id="@qtyId" name="@qtyId" value="1">
}
<div class="btn-group">
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Cookie.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Cookie.cshtml
index ac868e1e5..310b4fa72 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Cookie.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Cookie.cshtml
@@ -1,5 +1,4 @@
-@using Grand.Domain.Customers
-@inject StoreInformationSettings storeInformationSettings
+@inject StoreInformationSettings storeInformationSettings
@inject IWorkContext workContext
@if (storeInformationSettings.DisplayCookieInformation && !workContext.CurrentCustomer.IsSystemAccount)
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/CreateOrUpdateAddress.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/CreateOrUpdateAddress.cshtml
index 6c52d9381..c252ad338 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/CreateOrUpdateAddress.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/CreateOrUpdateAddress.cshtml
@@ -304,9 +304,8 @@
{
<text>address_attribute_</text> @item.Id <text>: '@itemValue.Id',</text>
break;
- } else {
- <text>address_attribute_</text> @item.Id <text>: '',</text>
}
+ <text>address_attribute_</text> @item.Id <text>: '',</text>
}
}
break;
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/HeaderLinks.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/HeaderLinks.cshtml
index bf416ef97..6889cfa54 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/HeaderLinks.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/HeaderLinks.cshtml
@@ -1,12 +1,15 @@
-@inject Grand.Business.Core.Interfaces.Common.Directory.IGroupService groupService
+@using Grand.Business.Core.Interfaces.Common.Directory
+@using Grand.Business.Core.Interfaces.Common.Security
+@using Grand.Business.Core.Utilities.Common.Security
+@inject IGroupService groupService
@inject IWorkContext workContext
@inject IPageHeadBuilder pagebuilder
-@inject Grand.Business.Core.Interfaces.Common.Security.IPermissionService permissionService
+@inject IPermissionService permissionService
@{
- var registerUrl = Url.RouteUrl("Register", new { returnUrl = this.Context.Request.Query["returnUrl"] });
+ var registerUrl = Url.RouteUrl("Register", new { returnUrl = Context.Request.Query["returnUrl"] });
var isAuthenticated = await groupService.IsRegistered(workContext.CurrentCustomer);
var isCustomerImpersonated = workContext.OriginalCustomerIfImpersonated != null;
- var isAdminAccess = await permissionService.Authorize(Grand.Business.Core.Utilities.Common.Security.StandardPermission.AccessAdminPanel);
+ var isAdminAccess = await permissionService.Authorize(StandardPermission.AccessAdminPanel);
}
@await Component.InvokeAsync("Widget", new { widgetZone = "header_links_before" })
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Logo.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Logo.cshtml
index 21af6e480..9d95accc6 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Logo.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Logo.cshtml
@@ -1,6 +1,7 @@
-@inject StoreInformationSettings storeInformation
+@using Grand.Business.Core.Interfaces.Storage
+@inject StoreInformationSettings storeInformation
@inject IWorkContext workContext
-@inject Grand.Business.Core.Interfaces.Storage.IPictureService pictureService
+@inject IPictureService pictureService
@{
var urlLogo = await pictureService.GetPictureUrl(storeInformation.LogoPictureId);
}
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Notifications.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Notifications.cshtml
index a7828f301..20083602d 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Notifications.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Notifications.cshtml
@@ -1,26 +1,26 @@
-@using System.Text.Encodings.Web;
+@using System.Text.Encodings.Web
@{
//success messages
var successMessages = new List<string>();
- if (TempData[string.Format("Grand.notifications.{0}", NotifyType.Success)] != null)
+ if (TempData[$"Grand.notifications.{NotifyType.Success}"] != null)
{
- successMessages.AddRange(TempData[string.Format("Grand.notifications.{0}", NotifyType.Success)] as IList<string>);
+ successMessages.AddRange(TempData[$"Grand.notifications.{NotifyType.Success}"] as IList<string>);
}
- if (ViewData[string.Format("Grand.notifications.{0}", NotifyType.Success)] != null)
+ if (ViewData[$"Grand.notifications.{NotifyType.Success}"] != null)
{
- successMessages.AddRange(ViewData[string.Format("Grand.notifications.{0}", NotifyType.Success)] as IList<string>);
+ successMessages.AddRange(ViewData[$"Grand.notifications.{NotifyType.Success}"] as IList<string>);
}
//error messages
var errorMessages = new List<string>();
- if (TempData[string.Format("Grand.notifications.{0}", NotifyType.Error)] != null)
+ if (TempData[$"Grand.notifications.{NotifyType.Error}"] != null)
{
- errorMessages.AddRange(TempData[string.Format("Grand.notifications.{0}", NotifyType.Error)] as IList<string>);
+ errorMessages.AddRange(TempData[$"Grand.notifications.{NotifyType.Error}"] as IList<string>);
}
- if (ViewData[string.Format("Grand.notifications.{0}", NotifyType.Error)] != null)
+ if (ViewData[$"Grand.notifications.{NotifyType.Error}"] != null)
{
- errorMessages.AddRange(ViewData[string.Format("Grand.notifications.{0}", NotifyType.Error)] as IList<string>);
+ errorMessages.AddRange(ViewData[$"Grand.notifications.{NotifyType.Error}"] as IList<string>);
}
}
@foreach (var message in successMessages)
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
index 70e5e9a26..06c2876bd 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
@@ -1,6 +1,6 @@
@{
- var addtocart = @Url.RouteUrl("AddProductDetails");
- var updateitemcart = @Url.RouteUrl("UpdateItemCart");
+ var addtocart = Url.RouteUrl("AddProductDetails");
+ var updateitemcart = Url.RouteUrl("UpdateItemCart");
}
<template v-if="PopupQuickViewVueModal.AddToCart.UpdatedShoppingCartItemId !== null">
<input type="hidden" id="shoppingCartItemId" name="shoppingCartItemId" :value="UpdatedShoppingCartItemId" />
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToWishlist.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToWishlist.cshtml
index 5eb5681bf..f061d942c 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToWishlist.cshtml
@@ -1,5 +1,5 @@
@{
- var addtowishlist = @Url.RouteUrl("AddProductDetails");
+ var addtowishlist = Url.RouteUrl("AddProductDetails");
}
<template v-if="!PopupQuickViewVueModal.AddToCart.DisableWishlistButton">
<template v-if="PopupQuickViewVueModal.AddToCart.UpdatedShoppingCartItemId == null">
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
index 10fb1ad8c..155dc6e77 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
@@ -1,5 +1,5 @@
@{
- var fileLink = @Url.RouteUrl("UploadFileProductAttribute");
+ var fileLink = Url.RouteUrl("UploadFileProductAttribute");
}
<template id="product-attribute-quickview" asp-footer="true">
<tr>
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ProductsComparison.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ProductsComparison.cshtml
index f8bb0bfe5..6467088f3 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ProductsComparison.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ProductsComparison.cshtml
@@ -1,7 +1,4 @@
-@{
- var addtocomparelink = Url.RouteUrl("AddProductToCompare");
-}
-<template v-if="PopupQuickViewVueModal.CompareProductsEnabled">
+<template v-if="PopupQuickViewVueModal.CompareProductsEnabled">
<a class="btn btn-secondary add-to-compare-list-button mr-1" :onclick="'AxiosCart.addproducttocomparelist(`'+ PopupQuickViewVueModal.Id +'`, `@string.Format(Loc["Products.ProductHasBeenAddedToCompareList.Link"], Url.RouteUrl("CompareProducts"))`)'" v-b-tooltip.hover.bottom title="@Loc["Products.Compare.AddToCompareList"]">
<b-icon icon="shuffle"></b-icon>
<span class="sr-only">@Loc["Products.Compare.AddToCompareList"]</span>
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Warehouses.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Warehouses.cshtml
index dc5cd71bd..776f37f96 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Warehouses.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Warehouses.cshtml
@@ -1,5 +1,5 @@
@{
- var warehouseLink = @Url.Action("productdetails_warehousechange", "product");
+ var warehouseLink = Url.Action("productdetails_warehousechange", "product");
}
<template v-if="PopupQuickViewVueModal.AllowToSelectWarehouse">
<template v-if="PopupQuickViewVueModal.ProductWarehouses.length > 0">
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
index 26b64ffb1..37f9a49df 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Currency.cshtml
@@ -1,22 +1,18 @@
-@using System.Globalization
-@using Grand.Business.Core.Extensions
-
-@inject Grand.Business.Core.Interfaces.Common.Directory.ICurrencyService currencyService
+@using Grand.Business.Core.Extensions
+@using Grand.Business.Core.Interfaces.Common.Directory
+@using System.Globalization
+@inject ICurrencyService currencyService
@inject IWorkContext workContext
@{
var availableCurrencies = (await currencyService.GetAllCurrencies(storeId: workContext.CurrentStore.Id))
.Select(x =>
{
-//currency char
-var currencySymbol = "";
- if (!string.IsNullOrEmpty(x.DisplayLocale))
- currencySymbol = new RegionInfo(x.DisplayLocale).CurrencySymbol;
- else
- currencySymbol = x.CurrencyCode;
+ //currency char
+ var currencySymbol = !string.IsNullOrEmpty(x.DisplayLocale) ? new RegionInfo(x.DisplayLocale).CurrencySymbol : x.CurrencyCode;
-//model
-var currencyModel = new CurrencyModel
+ //model
+ var currencyModel = new CurrencyModel
{
Id = x.Id,
Name = x.GetTranslation(y => y.Name, workContext.WorkingLanguage.Id),
@@ -31,7 +27,7 @@ var currencyModel = new CurrencyModel
var returnUrl = Context?.Request?.GetEncodedPathAndQuery();
var currencies = availableCurrencies.Select(x => new
{
- Name = x.Name,
+ x.Name,
Text = x.CurrencyCode,
Value = Url.RouteUrl("ChangeCurrency", new { currencyCode = x.CurrencyCode, returnUrl }),
Selected = x.Id.Equals(workContext.WorkingCurrency.Id)
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Language.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Language.cshtml
index 365497000..3b02638c8 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Language.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Language.cshtml
@@ -1,4 +1,5 @@
-@inject Grand.Business.Core.Interfaces.Common.Localization.ILanguageService languageService
+@using Grand.Business.Core.Interfaces.Common.Localization
+@inject ILanguageService languageService
@inject IWorkContext workContext
@{
var availableLanguages = (await languageService.GetAllLanguages(storeId: workContext.CurrentStore.Id))
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Store.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Store.cshtml
index 32884342c..be4777da6 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Selector_Store.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Selector_Store.cshtml
@@ -1,6 +1,7 @@
-@inject CommonSettings commonSettings
-@using Grand.Business.Core.Extensions
-@inject Grand.Business.Core.Interfaces.Common.Stores.IStoreService storeService
+@using Grand.Business.Core.Extensions
+@using Grand.Business.Core.Interfaces.Common.Stores
+@inject CommonSettings commonSettings
+@inject IStoreService storeService
@inject IWorkContext workContext
@{
if (commonSettings.AllowToSelectStore)
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/Selector_TaxType.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/Selector_TaxType.cshtml
index c3584d116..3e83ea51f 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/Selector_TaxType.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/Selector_TaxType.cshtml
@@ -16,10 +16,10 @@
text = Loc["Tax.Exclusive"];
}
<b-dropdown class="mr-2" text="@text">
- <b-dropdown-item class="@className" href="@Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.IncludingTax), returnUrl })">
+ <b-dropdown-item class="@className" href="@Url.RouteUrl("ChangeTaxType", new { customertaxtype = (int)TaxDisplayType.IncludingTax, returnUrl })">
@Loc["Tax.Inclusive"]
</b-dropdown-item>
- <b-dropdown-item class="@className" href="@Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.ExcludingTax), returnUrl })">
+ <b-dropdown-item class="@className" href="@Url.RouteUrl("ChangeTaxType", new { customertaxtype = (int)TaxDisplayType.ExcludingTax, returnUrl })">
@Loc["Tax.Exclusive"]
</b-dropdown-item>
</b-dropdown>
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/ShoppingCartLinks.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/ShoppingCartLinks.cshtml
index cd457b7bd..ade52ae22 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/ShoppingCartLinks.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/ShoppingCartLinks.cshtml
@@ -1,14 +1,18 @@
-@inject IWorkContext workContext
-@inject Grand.Business.Core.Interfaces.Common.Security.IPermissionService permissionService
-@inject Grand.Business.Core.Interfaces.Checkout.Orders.IShoppingCartService shoppingCartService
+@using Grand.Business.Core.Interfaces.Common.Security
+@using Grand.Business.Core.Utilities.Common.Security
+@using Grand.Business.Core.Interfaces.Checkout.Orders
+@inject IWorkContext workContext
+@inject IPermissionService permissionService
+@inject IShoppingCartService shoppingCartService
@inject ShoppingCartSettings shoppingCartSettings
@inject CatalogSettings catalogSettings
-@using Grand.Business.Core.Utilities.Common.Security
@{
- var shoppingCartTypes = new List<ShoppingCartType>();
- shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);
- shoppingCartTypes.Add(ShoppingCartType.Auctions);
+ var shoppingCartTypes = new List<ShoppingCartType>
+ {
+ ShoppingCartType.ShoppingCart,
+ ShoppingCartType.Auctions
+ };
if (shoppingCartSettings.AllowOnHoldCart)
shoppingCartTypes.Add(ShoppingCartType.OnHoldCart);
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/SidebarShoppingCart.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/SidebarShoppingCart.cshtml
index 6947ac863..feb748289 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/SidebarShoppingCart.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/SidebarShoppingCart.cshtml
@@ -22,7 +22,7 @@
<li>
<b-sidebar id="sidebar-cart" backdrop @if (!supportRtl) { <text>right</text> }>
<template v-slot:title v-if="flycartindicator > 0">
- @Html.Raw(string.Format(Loc["ShoppingCart.Mini.ItemsText"], string.Format("<a href=\"{0}\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(Loc["ShoppingCart.Mini.Items"], "{{flycartindicator}}"))))
+ @Html.Raw(string.Format(Loc["ShoppingCart.Mini.ItemsText"], $"<a href=\"{Url.RouteUrl("ShoppingCart")}\">{string.Format(Loc["ShoppingCart.Mini.Items"], "{{flycartindicator}}")}</a>"))
</template>
<template v-slot:title v-else>
@Loc["ShoppingCart.Mini.NoItems"]
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/SidebarWishlist.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/SidebarWishlist.cshtml
index 03b36ae24..0bbd87c58 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/SidebarWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/SidebarWishlist.cshtml
@@ -17,7 +17,7 @@
<li>
<b-sidebar id="sidebar-wishlist" backdrop @if (!supportRtl) { <text>right</text> }>
<template v-slot:title v-if="wishindicator > 0">
- @Html.Raw(string.Format(Loc["Wishlist.Mini.ItemsText"], string.Format("<a href=\"{0}\">{1}</a>", Url.RouteUrl("Wishlist"), string.Format(Loc["Wishlist.Mini.Items"], "{{wishindicator}}"))))
+ @Html.Raw(string.Format(Loc["Wishlist.Mini.ItemsText"], $"<a href=\"{Url.RouteUrl("Wishlist")}\">{string.Format(Loc["Wishlist.Mini.Items"], "{{wishindicator}}")}</a>"))
</template>
<template v-slot:title v-else>
@Loc["Wishlist.Mini.NoItems"]
diff --git a/src/Web/Grand.Web/Views/Shared/_Layout.cshtml b/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
index 730c1aad0..571c4f8d1 100644
--- a/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_Layout.cshtml
@@ -1,4 +1,5 @@
-@inject Grand.Infrastructure.Configuration.PerformanceConfig config
+@using Grand.Infrastructure.Configuration
+@inject PerformanceConfig config
<!DOCTYPE html>
<html use-lang="true">
<head>
@@ -8,7 +9,7 @@
<meta-keywords>
<meta name="generator" content="grandnode">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
- @RenderSection("meta", required: false)
+ @await RenderSectionAsync("meta", required: false)
<head-custom>
<partial name="Partials/Head" />
<vc:widget widget-zone="head_html_tag" additional-data="null"></vc:widget>
@@ -21,7 +22,7 @@
}
<resources asp-type="HeadLink" />
<resources asp-type="HeadScript" />
- @RenderSection("head", required: false)
+ @await RenderSectionAsync("head", required: false)
</head>
<body>
@@ -40,7 +41,7 @@
@await Component.InvokeAsync("Widget", new { widgetZone = "content_before" })
@if (IsSectionDefined("Breadcrumb"))
{
- @RenderSection("Breadcrumb")
+ @await RenderSectionAsync("Breadcrumb")
}
@RenderBody()
@await Component.InvokeAsync("Widget", new { widgetZone = "content_after" })
diff --git a/src/Web/Grand.Web/Views/Shared/_SingleColumn.cshtml b/src/Web/Grand.Web/Views/Shared/_SingleColumn.cshtml
index 04da5faea..de4761bb4 100644
--- a/src/Web/Grand.Web/Views/Shared/_SingleColumn.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_SingleColumn.cshtml
@@ -3,14 +3,14 @@
}
@section Breadcrumb {
- @RenderSection("Breadcrumb", required: false)
+ @await RenderSectionAsync("Breadcrumb", required: false)
}
@await Component.InvokeAsync("Widget", new { widgetZone = "main_column_before" })
@RenderBody()
@await Component.InvokeAsync("Widget", new { widgetZone = "main_column_after" })
@section meta {
- @RenderSection("meta", required: false)
+ @await RenderSectionAsync("meta", required: false)
}
@section head {
- @RenderSection("head", required: false)
+ @await RenderSectionAsync("head", required: false)
}
diff --git a/src/Web/Grand.Web/Views/Shared/_TwoColumns.cshtml b/src/Web/Grand.Web/Views/Shared/_TwoColumns.cshtml
index 3f1603951..44d465bd3 100644
--- a/src/Web/Grand.Web/Views/Shared/_TwoColumns.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_TwoColumns.cshtml
@@ -2,7 +2,7 @@
Layout = "_Layout";
//current category ID
- string currentCategoryId = "";
+ var currentCategoryId = "";
if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
Url.ActionContext.RouteData.Values["action"].ToString().Equals("category", StringComparison.OrdinalIgnoreCase))
{
@@ -11,7 +11,7 @@
//current collection ID
- string currentCollectionId = "";
+ var currentCollectionId = "";
if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
Url.ActionContext.RouteData.Values["action"].ToString().Equals("collection", StringComparison.OrdinalIgnoreCase))
{
@@ -19,7 +19,7 @@
}
//current brand ID
- string currentBrandId = "";
+ var currentBrandId = "";
if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&
Url.ActionContext.RouteData.Values["action"].ToString().Equals("brand", StringComparison.OrdinalIgnoreCase))
{
@@ -27,7 +27,7 @@
}
//current product ID
- string currentProductId = "";
+ var currentProductId = "";
if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("product", StringComparison.OrdinalIgnoreCase) &&
Url.ActionContext.RouteData.Values["action"].ToString().Equals("productdetails", StringComparison.OrdinalIgnoreCase))
{
@@ -37,14 +37,14 @@
@if (IsSectionDefined("Breadcrumb"))
{
@section Breadcrumb {
- @RenderSection("Breadcrumb")
+ @await RenderSectionAsync("Breadcrumb")
}
}
@section meta {
- @RenderSection("meta", required: false)
+ @await RenderSectionAsync("meta", required: false)
}
@section head {
- @RenderSection("head", required: false)
+ @await RenderSectionAsync("head", required: false)
}
@if (!string.IsNullOrEmpty(currentCategoryId))
{
@@ -72,19 +72,19 @@
<div class="col-lg-3 col-md-12 generalLeftSide order-1">
@if (IsSectionDefined("left"))
{
- @RenderSection("left")
+ @await RenderSectionAsync("left")
}
else
{
if (IsSectionDefined("filters"))
{
- @RenderSection("filters")
+ @await RenderSectionAsync("filters")
}
@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_before" })
- @await Component.InvokeAsync("CategoryNavigation", new { currentCategoryId = currentCategoryId, currentProductId = currentProductId })
+ @await Component.InvokeAsync("CategoryNavigation", new { currentCategoryId, currentProductId })
@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_after_category_navigation" })
- @await Component.InvokeAsync("CollectionNavigation", new { currentCollectionId = currentCollectionId })
+ @await Component.InvokeAsync("CollectionNavigation", new { currentCollectionId })
@await Component.InvokeAsync("VendorNavigation")
@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_after" })
}
diff --git a/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml b/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml
index 70358edc5..833bebf79 100644
--- a/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml
+++ b/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml
@@ -60,8 +60,13 @@
}
<div asp-validation-summary="ModelOnly" class="message-error"></div>
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "Address";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "Address"
+ }
+ };
<partial name="Partials/CreateOrUpdateVendorAddress" model="Model.Address" view-data="dataDictAddress" />
}
@if (Model.TermsOfServiceEnabled)
diff --git a/src/Web/Grand.Web/Views/Vendor/Info.cshtml b/src/Web/Grand.Web/Views/Vendor/Info.cshtml
index 711ec5d73..b91a5c399 100644
--- a/src/Web/Grand.Web/Views/Vendor/Info.cshtml
+++ b/src/Web/Grand.Web/Views/Vendor/Info.cshtml
@@ -41,7 +41,7 @@
<div class="form-group">
<label asp-for="PictureUrl" class="col-form-label">@Loc["Account.VendorInfo.Picture"]:</label>
<b-form-file id="uploadedFile" name="uploadedFile" accept="image/*"></b-form-file>
- @if (!String.IsNullOrEmpty(Model.PictureUrl))
+ @if (!string.IsNullOrEmpty(Model.PictureUrl))
{
<div class="vendor-picture mt-3">
<img src="@(Model.PictureUrl)" alt="picture" style="width:100px; display:block" />
@@ -50,8 +50,13 @@
}
</div>
@{
- var dataDictAddress = new ViewDataDictionary(ViewData);
- dataDictAddress.TemplateInfo.HtmlFieldPrefix = "Address";
+ var dataDictAddress = new ViewDataDictionary(ViewData)
+ {
+ TemplateInfo =
+ {
+ HtmlFieldPrefix = "Address"
+ }
+ };
<partial name="Partials/CreateOrUpdateVendorAddress" model="Model.Address" view-data="dataDictAddress" />
}
</div>
diff --git a/src/Web/Grand.Web/Views/Wishlist/Index.cshtml b/src/Web/Grand.Web/Views/Wishlist/Index.cshtml
index f90fc6a43..4edb33ee1 100644
--- a/src/Web/Grand.Web/Views/Wishlist/Index.cshtml
+++ b/src/Web/Grand.Web/Views/Wishlist/Index.cshtml
@@ -15,7 +15,7 @@
}
else
{
- @String.Format(Loc["Wishlist.WishlistOf"], Model.CustomerFullname)
+ @string.Format(Loc["Wishlist.WishlistOf"], Model.CustomerFullname)
}
</h2>
<template v-if="vmwishlist.Model.Items.length > 0">
diff --git a/src/Web/Grand.Web/Views/Wishlist/Partials/ModelScript.cshtml b/src/Web/Grand.Web/Views/Wishlist/Partials/ModelScript.cshtml
index 7e3988200..936cb893f 100644
--- a/src/Web/Grand.Web/Views/Wishlist/Partials/ModelScript.cshtml
+++ b/src/Web/Grand.Web/Views/Wishlist/Partials/ModelScript.cshtml
@@ -1,6 +1,6 @@
@model WishlistModel
@{
- var addToCartUrl = Model.EmailWishlistEnabled && !Model.IsEditable ? Url.RouteUrl("AddItemToCartFromWishlist", new { customerGuid = @Model.CustomerGuid }) + "&shoppingcartId=" : Url.RouteUrl("AddItemToCartFromWishlist") + "?shoppingcartId=";
+ var addToCartUrl = Model.EmailWishlistEnabled && !Model.IsEditable ? Url.RouteUrl("AddItemToCartFromWishlist", new { customerGuid = Model.CustomerGuid }) + "&shoppingcartId=" : Url.RouteUrl("AddItemToCartFromWishlist") + "?shoppingcartId=";
}
<script asp-location="Footer" asp-order="300">
var vmwishlist = new Vue({
diff --git a/src/Web/Grand.Web/Views/_ViewImports.cshtml b/src/Web/Grand.Web/Views/_ViewImports.cshtml
index 6b290b81f..155c0214c 100644
--- a/src/Web/Grand.Web/Views/_ViewImports.cshtml
+++ b/src/Web/Grand.Web/Views/_ViewImports.cshtml
@@ -5,6 +5,7 @@
@addTagHelper *, Grand.Web
@addTagHelper *, MiniProfiler.AspNetCore.Mvc
+@using System.Text;
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.AspNetCore.Mvc.ViewFeatures
@@ -40,5 +41,6 @@
@using Grand.Domain.Seo
@using Grand.Domain.Stores
@using Grand.Infrastructure
+@using Grand.Web.Common.Localization
-@inject Grand.Web.Common.Localization.LocService Loc
+@inject LocService Loc