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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor changes - remove using to mongodb
KrzysztofPajak63f78d5bbf40
diff --git a/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs b/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.csindex 71554c402..a88762fdc 100644--- a/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs+++ b/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs@@ -7,9 +7,11 @@ using Microsoft.AspNetCore.Authentication.Facebook;using Microsoft.AspNetCore.Authentication.OAuth;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-using MongoDB.Bson.Serialization;+using Serilog;+using System;using System.Linq;using System.Net;+using System.Text.Json;using System.Threading.Tasks;namespace Authentication.Facebook.Infrastructure@@ -33,18 +35,18 @@ namespace Authentication.Facebook.Infrastructurevar fbSettings = new Repository<Setting>(DataSettingsHelper.ConnectionString()).Table.Where(x => x.Name.StartsWith("facebookexternalauthsettings"));if (fbSettings.Any()){- settings = BsonSerializer.Deserialize<FacebookExternalAuthSettings>(fbSettings.FirstOrDefault().Metadata);+ var metadata = fbSettings.FirstOrDefault().Metadata.ToString();+ settings = JsonSerializer.Deserialize<FacebookExternalAuthSettings>(metadata);}}- catch { };+ catch (Exception ex) { Log.Error(ex, "AddFacebook"); };//no empty values allowed. otherwise, an exception could be thrown on application startupoptions.AppId = !string.IsNullOrWhiteSpace(settings.ClientKeyIdentifier) ? settings.ClientKeyIdentifier : "000";options.AppSecret = !string.IsNullOrWhiteSpace(settings.ClientSecret) ? settings.ClientSecret : "000";options.SaveTokens = true;//handles exception thrown by external auth provider- options.Events = new OAuthEvents()- {+ options.Events = new OAuthEvents() {OnRemoteFailure = ctx =>{ctx.HandleResponse();diff --git a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.csindex 81947a40b..21c4b63ee 100644--- a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs+++ b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs@@ -7,9 +7,11 @@ using Microsoft.AspNetCore.Authentication.Google;using Microsoft.AspNetCore.Authentication.OAuth;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-using MongoDB.Bson.Serialization;+using Serilog;+using System;using System.Linq;using System.Net;+using System.Text.Json;using System.Threading.Tasks;namespace Authentication.Google.Infrastructure@@ -33,18 +35,18 @@ namespace Authentication.Google.Infrastructurevar gSettings = new Repository<Setting>(DataSettingsHelper.ConnectionString()).Table.Where(x => x.Name.StartsWith("googleexternalauthsettings"));if (gSettings.Any()){- settings = BsonSerializer.Deserialize<GoogleExternalAuthSettings>(gSettings.FirstOrDefault().Metadata);+ var metadata = gSettings.FirstOrDefault().Metadata.ToString();+ settings = JsonSerializer.Deserialize<GoogleExternalAuthSettings>(metadata);}}- catch { };+ catch (Exception ex) { Log.Error(ex, "AddGoogle"); };options.ClientId = !string.IsNullOrWhiteSpace(settings.ClientKeyIdentifier) ? settings.ClientKeyIdentifier : "000";options.ClientSecret = !string.IsNullOrWhiteSpace(settings.ClientSecret) ? settings.ClientSecret : "000";options.SaveTokens = true;//handles exception thrown by external auth provider- options.Events = new OAuthEvents()- {+ options.Events = new OAuthEvents() {OnRemoteFailure = ctx =>{ctx.HandleResponse();diff --git a/src/Plugins/Shipping.FixedRateShipping/Controllers/ShippingFixedRateController.cs b/src/Plugins/Shipping.FixedRateShipping/Controllers/ShippingFixedRateController.csindex 7dcc5d53a..ad0d8b91a 100644--- a/src/Plugins/Shipping.FixedRateShipping/Controllers/ShippingFixedRateController.cs+++ b/src/Plugins/Shipping.FixedRateShipping/Controllers/ShippingFixedRateController.cs@@ -6,10 +6,7 @@ using Grand.Web.Common.Controllers;using Grand.Web.Common.DataSource;using Grand.Web.Common.Filters;using Microsoft.AspNetCore.Mvc;-using MongoDB.Bson;-using MongoDB.Bson.Serialization.Attributes;using Shipping.FixedRateShipping.Models;-using System;using System.Collections.Generic;using System.Threading.Tasks;diff --git a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.csindex 8f1693b76..a76ab486f 100644--- a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs+++ b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs@@ -1,8 +1,6 @@using Grand.Domain;using Grand.Domain.Data;using Grand.Infrastructure.Caching;-using MongoDB.Driver;-using MongoDB.Driver.Linq;using Shipping.ShippingPoint.Domain;using System;using System.Linq;@@ -56,7 +54,7 @@ namespace Shipping.ShippingPoint.Serviceswhere (gp.StoreId == storeId || string.IsNullOrEmpty(gp.StoreId)) || storeId == ""select gp;- var records = await query.ToListAsync();+ var records = query.ToList();//pagingreturn await Task.FromResult(new PagedList<ShippingPoints>(records, pageIndex, pageSize));@@ -69,9 +67,9 @@ namespace Shipping.ShippingPoint.Services/// <returns></returns>public virtual Task<ShippingPoints> GetStoreShippingPointByPointName(string pointName){- return (from shippingOoint in _shippingPointRepository.Table+ return Task.FromResult((from shippingOoint in _shippingPointRepository.Tablewhere shippingOoint.ShippingPointName == pointName- select shippingOoint).FirstOrDefaultAsync();+ select shippingOoint).FirstOrDefault());}/// <summary>diff --git a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs b/src/Plugins/Widgets.Slider/Domain/PictureSlider.csindex 820277071..8cb4fe55b 100644--- a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs+++ b/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs@@ -19,17 +19,8 @@ namespace Widgets.Slider.Domainpublic int DisplayOrder { get; set; }public bool FullWidth { get; set; }public bool Published { get; set; }- public int SliderTypeId { get; set; }public string ObjectEntry { get; set; }- public SliderType SliderType {- get {- return (SliderType)SliderTypeId;- }- set {- SliderTypeId = (int)value;- }-- }+ public SliderType SliderTypeId { get; set; }public bool LimitedToStores { get; set; }public IList<string> Stores { get; set; }public IList<TranslationEntity> Locales { get; set; }diff --git a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.csindex 0ac19daab..ea1cc4a5b 100644--- a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs+++ b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs@@ -22,7 +22,7 @@ namespace Widgets.Slider.Infrastructure.Mapper}protected string GetCategoryId(PictureSlider pictureSlider){- if (pictureSlider.SliderType == SliderType.Category)+ if (pictureSlider.SliderTypeId == SliderType.Category)return pictureSlider.ObjectEntry;return "";@@ -30,7 +30,7 @@ namespace Widgets.Slider.Infrastructure.Mapperprotected string GetCollectionId(PictureSlider pictureSlider){- if (pictureSlider.SliderType == SliderType.Collection)+ if (pictureSlider.SliderTypeId == SliderType.Collection)return pictureSlider.ObjectEntry;return "";@@ -53,8 +53,7 @@ namespace Widgets.Slider.Infrastructure.MapperCreateMap<PictureSlider, SlideListModel>().ForMember(dest => dest.UserFields, mo => mo.Ignore())- .ForMember(dest => dest.PictureUrl, mo => mo.Ignore())- .ForMember(dest => dest.ObjectType, mo => mo.MapFrom(y => y.SliderType.ToString()));+ .ForMember(dest => dest.PictureUrl, mo => mo.Ignore());}public int Order{diff --git a/src/Plugins/Widgets.Slider/Services/SliderService.cs b/src/Plugins/Widgets.Slider/Services/SliderService.csindex 9f77379ce..2ebb3468f 100644--- a/src/Plugins/Widgets.Slider/Services/SliderService.cs+++ b/src/Plugins/Widgets.Slider/Services/SliderService.cs@@ -2,8 +2,6 @@using Grand.Domain.Data;using Grand.Infrastructure;using Grand.Infrastructure.Caching;-using MongoDB.Driver;-using MongoDB.Driver.Linq;using System;using System.Collections.Generic;using System.Linq;@@ -33,6 +31,7 @@ namespace Widgets.Slider.Servicespublic const string SLIDERS_PATTERN_KEY = "Grand.slider";#endregion+public SliderService(IRepository<PictureSlider> reporistoryPictureSlider,IWorkContext workContext, IAclService aclService,ICacheBase cacheManager)@@ -63,7 +62,7 @@ namespace Widgets.Slider.Services/// <returns>Picture Sliders</returns>public virtual async Task<IList<PictureSlider>> GetPictureSliders(){- return await _reporistoryPictureSlider.Table.OrderBy(x => x.SliderTypeId).ThenBy(x => x.DisplayOrder).ToListAsync();+ return await Task.FromResult(_reporistoryPictureSlider.Table.OrderBy(x => x.SliderTypeId).ThenBy(x => x.DisplayOrder).ToList());}/// <summary>@@ -76,14 +75,14 @@ namespace Widgets.Slider.Servicesreturn await _cacheBase.GetAsync(cacheKey, async () =>{var query = from s in _reporistoryPictureSlider.Table- where s.SliderTypeId == (int)sliderType && s.Published+ where s.SliderTypeId == sliderType && s.Publishedselect s;if (!string.IsNullOrEmpty(objectEntry))query = query.Where(x => x.ObjectEntry == objectEntry);- var items = await query.ToListAsync();- return items.Where(c => _aclService.Authorize(c, _workContext.CurrentStore.Id)).ToList();+ var items = query.ToList();+ return await Task.FromResult(items.Where(c => _aclService.Authorize(c, _workContext.CurrentStore.Id)).ToList());});}@@ -95,7 +94,7 @@ namespace Widgets.Slider.Services/// <returns>Tax rate</returns>public virtual Task<PictureSlider> GetById(string slideId){- return _reporistoryPictureSlider.Table.FirstOrDefaultAsync(x => x.Id == slideId);+ return _reporistoryPictureSlider.FirstOrDefaultAsync(x => x.Id == slideId);}/// <summary>diff --git a/src/Plugins/Widgets.Slider/StartupApplication.cs b/src/Plugins/Widgets.Slider/StartupApplication.csindex 5fde921e7..dac074a35 100644--- a/src/Plugins/Widgets.Slider/StartupApplication.cs+++ b/src/Plugins/Widgets.Slider/StartupApplication.cs@@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.FileProviders;-using MongoDB.Bson.Serialization;using Widgets.Slider.Domain;using Widgets.Slider.Services;@@ -17,12 +16,6 @@ namespace Widgets.Sliderpublic void ConfigureServices(IServiceCollection services, IConfiguration configuration){services.AddScoped<IWidgetProvider, SliderWidgetProvider>();-- BsonClassMap.RegisterClassMap<PictureSlider>(cm =>- {- cm.AutoMap();- cm.UnmapMember(c => c.SliderType);- });services.AddScoped<ISliderService, SliderService>();services.Configure<MvcRazorRuntimeCompilationOptions>(options =>