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.

Remove redundant object ToString()

support139d864cb875
diff --git a/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs b/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
index 77f63b830..152b48525 100644
--- a/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
+++ b/src/Core/Grand.Domain/Data/LiteDb/LiteDBRepository.cs
@@ -536,7 +536,7 @@ namespace Grand.Domain.Data.LiteDb
var fieldName = ((MemberExpression)field.Body).Member.Name;
if (string.IsNullOrEmpty(id))
{
- var entities = collection.Find(Query.EQ($"{fieldName}[*] ANY", element.ToString())).ToList();
+ var entities = collection.Find(Query.EQ($"{fieldName}[*] ANY", element)).ToList();
foreach (var entity in entities)
{
UpdateEntity(entity);
diff --git a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
index c756cdba4..ab6dfa736 100644
--- a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
+++ b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
@@ -249,7 +249,7 @@ namespace Grand.SharedKernel.Extensions
var result = string.Empty;
foreach (var c in str)
if (c.ToString() != c.ToString().ToLower())
- result += " " + c.ToString();
+ result += " " + c;
else
result += c.ToString();
return result.TrimStart();
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
index 2cfa780a6..e8ded521d 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/CheckoutAttributes/CheckoutAttributeParserTests.cs
@@ -138,10 +138,10 @@ namespace Grand.Business.Checkout.Tests.Services.CheckoutAttributes
{
IList<CustomAttribute> attributes = new List<CustomAttribute>();
//color: green
- attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca1, cav1_1.Id.ToString()).ToList();
+ attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca1, cav1_1.Id).ToList();
//custom option: option 1, option 2
- attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca2, cav2_1.Id.ToString()).ToList();
- attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca2, cav2_2.Id.ToString()).ToList();
+ attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca2, cav2_1.Id).ToList();
+ attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca2, cav2_2.Id).ToList();
//custom text
attributes = _checkoutAttributeParser.AddCheckoutAttribute(attributes, ca3, "absolutely any value").ToList();
diff --git a/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs b/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
index 3519322e0..b0f390a1f 100644
--- a/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
+++ b/src/Tests/Grand.Data.Tests/MongoDb/CoreTestConfiguration.cs
@@ -133,7 +133,7 @@ namespace Grand.Data.Tests.MongoDb
{
__traceSource.TraceEvent(TraceEventType.Information, 0, $"CreateCluster: DescriptionChanged event handler called.");
__traceSource.TraceEvent(TraceEventType.Information, 0, $"CreateCluster: anyWritableServer = {anyWritableServer}.");
- __traceSource.TraceEvent(TraceEventType.Information, 0, $"CreateCluster: new description: {e.NewClusterDescription.ToString()}.");
+ __traceSource.TraceEvent(TraceEventType.Information, 0, $"CreateCluster: new description: {e.NewClusterDescription}.");
}
Interlocked.Exchange(ref hasWritableServer, anyWritableServer ? 1 : 0);
};
@@ -149,7 +149,7 @@ namespace Grand.Data.Tests.MongoDb
{
var message = string.Format(
"Test cluster has no writable server. Client view of the cluster is {0}.",
- cluster.Description.ToString());
+ cluster.Description);
throw new Exception(message);
}
diff --git a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs b/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs
index f096907a6..41927c72f 100644
--- a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs
@@ -155,7 +155,7 @@ namespace Grand.Web.Admin.Controllers
var ctrlAttributes = model.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.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
index c81c367e0..3fd25ae68 100644
--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs
@@ -1144,7 +1144,7 @@ namespace Grand.Web.Admin.Services
var cblAttributes = model.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(cblAttributes))
{
- foreach (var item in cblAttributes.ToString()
+ foreach (var item in cblAttributes
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
customattributes = Domain.Catalog.ProductExtensions.AddProductAttribute(
@@ -1174,7 +1174,7 @@ namespace Grand.Web.Admin.Services
var ctrlAttributes = model.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
- var enteredText = ctrlAttributes.ToString().Trim();
+ var enteredText = ctrlAttributes.Trim();
customattributes = Domain.Catalog.ProductExtensions.AddProductAttribute(customattributes,
attribute, enteredText).ToList();
}
diff --git a/src/Web/Grand.Web.Common/Validators/CaptchaValidator.cs b/src/Web/Grand.Web.Common/Validators/CaptchaValidator.cs
index b4ced6f7f..f3ed844e2 100644
--- a/src/Web/Grand.Web.Common/Validators/CaptchaValidator.cs
+++ b/src/Web/Grand.Web.Common/Validators/CaptchaValidator.cs
@@ -73,7 +73,7 @@ public class CaptchaValidator : BaseGrandValidator<ICaptchaValidModel>
//Captcha validate request
var recaptchaResponse = await _googleReCaptchaValidator.Validate(
!StringValues.IsNullOrEmpty(captchaResponseValue)
- ? captchaResponseValue.ToString()
+ ? captchaResponseValue
: gCaptchaResponseValue);
isValid = recaptchaResponse.IsValid;