├── Ecommerce ├── .gitignore ├── Business │ ├── Abstract │ │ ├── IAddressService.cs │ │ ├── IAuthService.cs │ │ ├── IBasketItemService.cs │ │ ├── IBasketService.cs │ │ ├── IBrandService.cs │ │ ├── ICategoryService.cs │ │ ├── IOptionService.cs │ │ ├── IOptionValueService.cs │ │ ├── IOrderService.cs │ │ ├── IOrderStatusService.cs │ │ ├── IProductImageService.cs │ │ ├── IProductService.cs │ │ ├── IRefreshTokenService.cs │ │ ├── IReviewService.cs │ │ ├── IRoleService.cs │ │ ├── ISliderService.cs │ │ ├── ITokenService.cs │ │ └── IUserService.cs │ ├── Business.csproj │ ├── Concrete │ │ ├── AddressManager.cs │ │ ├── AuthManager.cs │ │ ├── BasketItemManager.cs │ │ ├── BasketManager.cs │ │ ├── BrandManager.cs │ │ ├── CategoryManager.cs │ │ ├── OptionManager.cs │ │ ├── OptionValueManager.cs │ │ ├── OrderManager.cs │ │ ├── OrderStatusManager.cs │ │ ├── ProductImageManager.cs │ │ ├── ProductManager.cs │ │ ├── RefreshTokenManager.cs │ │ ├── ReviewManager.cs │ │ ├── RoleService.cs │ │ ├── SliderManager.cs │ │ ├── TokenManager.cs │ │ └── UserService.cs │ ├── Constants │ │ ├── FolderNames.cs │ │ └── Messages.cs │ ├── DependencyResolvers │ │ └── Autofac │ │ │ └── AutofacBusinessModule.cs │ ├── Mappings │ │ └── Automapper.cs │ └── ValidationRules │ │ └── FluentValidation │ │ ├── AddressValidator.cs │ │ ├── BasketValidator.cs │ │ ├── BrandValidator.cs │ │ ├── CategoryValidator.cs │ │ ├── ChangePasswordValidator.cs │ │ ├── ForgotPasswordValidator.cs │ │ ├── LoginValidator.cs │ │ ├── OptionValidator.cs │ │ ├── OptionValueValidator.cs │ │ ├── OrderValidator.cs │ │ ├── PasswordChangeByAdminValidator.cs │ │ ├── ProductOptionValueValidator.cs │ │ ├── ProductValidator.cs │ │ ├── RegisterValidator.cs │ │ ├── ResetPasswordValidator.cs │ │ ├── ReviewValidator.cs │ │ ├── RoleValidator.cs │ │ ├── SliderValidator.cs │ │ ├── UpdateProfileValidator.cs │ │ └── UpdateUserByAdminValidator.cs ├── Core │ ├── ActionFilters │ │ └── NullFilterAttribute.cs │ ├── Aspects │ │ └── Autofac │ │ │ ├── Caching │ │ │ ├── CacheAspect.cs │ │ │ └── CacheRemoveAspect.cs │ │ │ ├── Exception │ │ │ └── ExceptionLogAspect.cs │ │ │ ├── Logging │ │ │ └── LogAspect.cs │ │ │ ├── Performance │ │ │ └── PerformanceAspect.cs │ │ │ ├── Transaction │ │ │ └── TransactionScopeAspect.cs │ │ │ └── Validation │ │ │ └── ValidationAspect.cs │ ├── Configurations │ │ ├── EmailSettings.cs │ │ └── JWTOptions.cs │ ├── Core.csproj │ ├── CrossCuttingConcerns │ │ ├── Caching │ │ │ ├── ICacheManager.cs │ │ │ └── Microsoft │ │ │ │ └── MemoryCacheManager.cs │ │ ├── Logging │ │ │ ├── ErrorLog.cs │ │ │ ├── LogDetail.cs │ │ │ └── SeriLog │ │ │ │ ├── ConfigurationModels │ │ │ │ ├── FileLogConfiguration.cs │ │ │ │ └── MsSqlConfiguration.cs │ │ │ │ ├── LoggerServiceBase.cs │ │ │ │ └── Loggers │ │ │ │ ├── FileLogger.cs │ │ │ │ └── MsSqlLogger.cs │ │ └── Validation │ │ │ └── FluentValidation │ │ │ └── ValidationTool.cs │ ├── DataAccess │ │ ├── EntityFramework │ │ │ └── EfEntityRepositoryBase.cs │ │ └── IEntityRepository.cs │ ├── DependencyResolvers │ │ └── CoreModule.cs │ ├── Entities │ │ ├── IDTO.cs │ │ └── IEntity.cs │ ├── Exceptions │ │ └── ApiException.cs │ └── Utilities │ │ ├── EmailManager.cs │ │ ├── Extensions │ │ ├── ExceptionMiddleware.cs │ │ ├── ExceptionMiddlewareExtensions.cs │ │ ├── IQueryableExtensions.cs │ │ ├── LinqExtensionMethod.cs │ │ └── ServiceCollectionExtensions.cs │ │ ├── FileManager.cs │ │ ├── Helpers │ │ ├── SecurityKeyHelper.cs │ │ ├── SigningCredentialsHelper.cs │ │ └── SlugHelper.cs │ │ ├── IEmailService.cs │ │ ├── Interceptors │ │ ├── AspectInterceptorSelector.cs │ │ ├── MethodInterception.cs │ │ └── MethodInterceptionBaseAttribute.cs │ │ ├── IoC │ │ ├── ICoreModule.cs │ │ └── ServiceTool.cs │ │ └── Responses │ │ ├── Abstract │ │ ├── IDataResponse.cs │ │ ├── IErrorResponse.cs │ │ ├── IPagedDataResponse.cs │ │ ├── IResponse.cs │ │ └── ISuccessResponse.cs │ │ └── Concrete │ │ ├── DataResponse.cs │ │ ├── ErrorResponse.cs │ │ ├── PagedDataResponse.cs │ │ ├── Response.cs │ │ └── SuccessResponse.cs ├── DataAccess │ ├── Abstract │ │ ├── IAddressRepository.cs │ │ ├── IBasketItemRepository.cs │ │ ├── IBasketRepository.cs │ │ ├── IBrandRepository.cs │ │ ├── ICategoryRepository.cs │ │ ├── IOptionRepository.cs │ │ ├── IOptionValueRepository.cs │ │ ├── IOrderRepository.cs │ │ ├── IOrderStatusRepository.cs │ │ ├── IProductImageRepository.cs │ │ ├── IProductRepository.cs │ │ ├── IRefreshTokenRepository.cs │ │ ├── IReviewRepository.cs │ │ └── ISliderRepository.cs │ ├── Concrete │ │ └── EntityFramework │ │ │ ├── Contexts │ │ │ └── ECommerceContext.cs │ │ │ ├── EfAddressRepository.cs │ │ │ ├── EfBasketItemRepository.cs │ │ │ ├── EfBasketRepository.cs │ │ │ ├── EfBrandRepository.cs │ │ │ ├── EfCategoryRepository.cs │ │ │ ├── EfOptionRepository.cs │ │ │ ├── EfOptionValueRepository.cs │ │ │ ├── EfOrderRepository.cs │ │ │ ├── EfOrderStatusRepository.cs │ │ │ ├── EfProductImageRepository.cs │ │ │ ├── EfProductRepository.cs │ │ │ ├── EfRefreshTokenRepository.cs │ │ │ ├── EfReviewRepository.cs │ │ │ └── EfSliderRepository.cs │ ├── Configurations │ │ ├── AddressConfiguration.cs │ │ ├── BasketConfiguration.cs │ │ ├── BasketItemConfiguration.cs │ │ ├── BrandConfiguration.cs │ │ ├── CategoryConfiguration.cs │ │ ├── CategoryOptionConfiguration.cs │ │ ├── OptionConfiguration.cs │ │ ├── OptionValueConfiguration.cs │ │ ├── OrderConfiguration.cs │ │ ├── OrderItemConfiguration.cs │ │ ├── OrderStatusConfiguration.cs │ │ ├── ProductConfiguration.cs │ │ ├── ProductImageConfiguration.cs │ │ ├── ProductOptionValueConfiguration.cs │ │ ├── RefreshTokenConfiguration.cs │ │ ├── ReviewConfiguration.cs │ │ ├── RoleConfiguration.cs │ │ ├── SliderConfiguration.cs │ │ ├── UserConfiguration.cs │ │ └── UserRoleConfiguration.cs │ ├── DataAccess.csproj │ └── Migrations │ │ ├── 20211012210659_CreateDatabase.Designer.cs │ │ ├── 20211012210659_CreateDatabase.cs │ │ └── ECommerceContextModelSnapshot.cs ├── Ecommerce.sln ├── Entities │ ├── Concrete │ │ ├── Address.cs │ │ ├── Basket.cs │ │ ├── BasketItem.cs │ │ ├── Brand.cs │ │ ├── Category.cs │ │ ├── CategoryOption.cs │ │ ├── Option.cs │ │ ├── OptionValue.cs │ │ ├── Order.cs │ │ ├── OrderItem.cs │ │ ├── OrderStatus.cs │ │ ├── Product.cs │ │ ├── ProductImage.cs │ │ ├── ProductOptionValue.cs │ │ ├── RefreshToken.cs │ │ ├── Review.cs │ │ ├── Role.cs │ │ ├── Slider.cs │ │ └── User.cs │ ├── DTOs │ │ ├── AddUpdateBasketDTO.cs │ │ ├── AddressDTO.cs │ │ ├── AddressDetail.cs │ │ ├── AdminOrderDetailDTO.cs │ │ ├── AdminProductDetail.cs │ │ ├── AdminProductDetails.cs │ │ ├── AdminProductOptionValueDetailDTO.cs │ │ ├── AssignRole.cs │ │ ├── BasketDetail.cs │ │ ├── BrandDTO.cs │ │ ├── BrandDetailDTO.cs │ │ ├── CategoryDTO.cs │ │ ├── CategoryOptionDetailDTO.cs │ │ ├── ChangePasswordDTO.cs │ │ ├── ConfirmEmailDTO.cs │ │ ├── Filters │ │ │ ├── BrandFilter.cs │ │ │ ├── CategoryFilter.cs │ │ │ ├── OptionFilter.cs │ │ │ ├── OptionValueFilter.cs │ │ │ ├── ProductFilter.cs │ │ │ └── ProductOptionValueFilter.cs │ │ ├── ForgotPasswordDTO.cs │ │ ├── LoginDTO.cs │ │ ├── OptionDTO.cs │ │ ├── OptionValueDTO.cs │ │ ├── OptionValueDetailDTO.cs │ │ ├── OptionValuesWithOptionDTO.cs │ │ ├── OptionsAndValuesDTO.cs │ │ ├── OptionsWithValuesDTO.cs │ │ ├── OrderDTO.cs │ │ ├── OrderDetail.cs │ │ ├── PasswordChangeByAdminDTO.cs │ │ ├── ProductDTO.cs │ │ ├── ProductDetail.cs │ │ ├── ProductImageDTO.cs │ │ ├── ProductOptionDetailDTO.cs │ │ ├── ProductOptionValueDTO.cs │ │ ├── ProductOptionValueDetailDTO.cs │ │ ├── ProductWithMainImage.cs │ │ ├── RefreshTokenDTO.cs │ │ ├── RegisterDTO.cs │ │ ├── ResetPasswordDTO.cs │ │ ├── ReviewDTO.cs │ │ ├── ReviewDetail.cs │ │ ├── RoleDTO.cs │ │ ├── SliderDTO.cs │ │ ├── TokenDTO.cs │ │ ├── UpdateProfileDTO.cs │ │ ├── UserDTO.cs │ │ ├── UserDetail.cs │ │ ├── UserOrderDTO.cs │ │ └── UserWithRolesDTO.cs │ └── Entities.csproj └── WebAPI │ ├── Controllers │ ├── AddressesController.cs │ ├── AuthController.cs │ ├── BasketsController.cs │ ├── BrandsController.cs │ ├── CategoriesController.cs │ ├── OptionValuesController.cs │ ├── OptionsController.cs │ ├── OrderStatusesController.cs │ ├── OrdersController.cs │ ├── ProductImagesController.cs │ ├── ProductsController.cs │ ├── ReviewsController.cs │ ├── RolesController.cs │ ├── SlidersController.cs │ └── UsersController.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Startup.cs │ ├── Uploads │ └── Products │ │ └── 0a28aafb-_Asus-4.jpg │ ├── WebAPI.csproj │ ├── appsettings.Development.json │ └── appsettings.json ├── assets └── ecommerce.gif ├── quasarecommerce ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .postcssrc.js ├── .vscode │ ├── extensions.json │ └── settings.json ├── README.md ├── babel.config.js ├── jsconfig.json ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ └── icons │ │ ├── favicon-128x128.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ └── favicon-96x96.png ├── quasar.conf.js └── src │ ├── App.vue │ ├── boot │ ├── .gitkeep │ └── axios.js │ ├── components │ ├── Alert.vue │ ├── Brand.vue │ ├── Carousel.vue │ ├── Category.vue │ ├── Footer.vue │ ├── Header.vue │ ├── Product.vue │ ├── Search.vue │ └── account │ │ └── ProfileSidebar.vue │ ├── composables │ ├── useExportCsv.js │ ├── useImageUpload.js │ └── useMultipleImageUpload.js │ ├── config.js │ ├── css │ ├── app.scss │ └── quasar.variables.scss │ ├── index.template.html │ ├── layouts │ ├── DashboardLayout.vue │ └── MainLayout.vue │ ├── pages │ ├── AccessDenied.vue │ ├── Basket.vue │ ├── Checkout.vue │ ├── Home.vue │ ├── NotFound.vue │ ├── ProductDetail.vue │ ├── Products.vue │ ├── account │ │ ├── Address.vue │ │ ├── ChangePassword.vue │ │ ├── ForgotPassword.vue │ │ ├── OrderDetail.vue │ │ ├── Orders.vue │ │ ├── Profile.vue │ │ └── ResetPassword.vue │ ├── auth │ │ ├── ConfirmEmail.vue │ │ ├── Login.vue │ │ └── Register.vue │ └── dashboard │ │ ├── AddProduct.vue │ │ ├── Brands.vue │ │ ├── Categories.vue │ │ ├── OptionValues.vue │ │ ├── Options.vue │ │ ├── Orders.vue │ │ ├── Products.vue │ │ ├── Reviews.vue │ │ ├── Roles.vue │ │ ├── Sliders.vue │ │ ├── UpdateProduct.vue │ │ └── Users.vue │ ├── router │ ├── index.js │ └── routes.js │ ├── store │ ├── address │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── alert │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── auth │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── basket │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── brand │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── category │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── index.js │ ├── option │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── optionvalue │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── product │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── review │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── slider │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ ├── store-flag.d.ts │ └── user │ │ ├── actions.js │ │ ├── getters.js │ │ ├── index.js │ │ ├── mutations.js │ │ └── state.js │ └── utilities │ └── validators.js └── readme.md /Ecommerce/Business/Abstract/IAddressService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IAddressService 11 | { 12 | Task AddAsync(AddressDTO model); 13 | Task GetAllAsync(); 14 | Task GetUserAddresses(); 15 | Task GetByIdAsync(int id); 16 | Task UpdateAsync(AddressDTO model); 17 | Task RemoveAsync(int id); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using Entities.DTOs; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IAuthService 12 | { 13 | Task Register(RegisterDTO model); 14 | Task Login(LoginDTO model); 15 | Task ConfirmEmail(ConfirmEmailDTO model); 16 | Task CreateTokenByRefreshToken(RefreshTokenDTO model); 17 | Task GetAuthenticatedUserWithRoles(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IBasketItemService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IBasketItemService 10 | { 11 | Task RemoveFromBasket(int basketId,int productId); 12 | Task ClearBasket(int basketId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IBasketService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Core.Utilities.Responses.Concrete; 4 | using Entities.Concrete; 5 | using Entities.DTOs; 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IBasketService 12 | { 13 | Task AddToBasketAsync(AddUpdateBasketDTO model); 14 | Task RemoveFromBasket(int productid); 15 | Task ClearBasket(); 16 | Task CreateBasketForUserAsync(string userid); 17 | Task> GetBasketWithTotalPriceAsync(); 18 | Task GetBasketByUserId(string userid); 19 | Task> GetAllAsync(); 20 | Task GetByIdAsync(int id); 21 | Task UpdateAsync(AddUpdateBasketDTO model); 22 | Task RemoveAsync(int id); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IBrandService 11 | { 12 | Task AddAsync(BrandDTO model); 13 | Task GetAllAsync(); 14 | Task GetByIdAsync(int id); 15 | Task UpdateAsync(BrandDTO model); 16 | Task RemoveAsync(int id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/ICategoryService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface ICategoryService 11 | { 12 | Task GetCategoriesWithOptionsAsync(); 13 | Task GetCategoryWithOptionsByCategoryIdAsync(int categoryid); 14 | Task GetOptionsWithValuesByCategorySlug(string slug); 15 | Task GetOptionsWithValuesByCategoryId(int id); 16 | Task GetAllAsync(); 17 | Task GetByIdAsync(int id); 18 | Task RemoveAsync(int id); 19 | Task AddAsync(CategoryDTO model); 20 | Task UpdateAsync(CategoryDTO model); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IOptionService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IOptionService 11 | { 12 | Task AddAsync(OptionDTO model); 13 | Task GetAllAsync(); 14 | Task GetOptionsWithValuesAsync(); 15 | Task GetByIdAsync(int id); 16 | Task UpdateAsync(OptionDTO model); 17 | Task RemoveAsync(int id); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IOptionValueService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IOptionValueService 11 | { 12 | Task AddAsync(OptionValueDTO model); 13 | Task GetAllAsync(); 14 | Task GetOptionValuesWithOption(); 15 | Task GetOptionValuesByOptionIdAsync(int optionid); 16 | Task GetByIdAsync(int id); 17 | Task UpdateAsync(OptionValueDTO model); 18 | Task RemoveAsync(int id); 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IOrderService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IOrderService 11 | { 12 | Task AddAsync(OrderDTO model); 13 | Task GetUserOrdersAsync(); 14 | Task GetOrderDetailByOrderNumber(string ordernumber); 15 | Task GetAdminOrderDetailAsync(string ordernumber); 16 | Task GetAdminOrdersAsync(); 17 | Task UpdateAsync(AdminOrderDetailDTO model); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IOrderStatusService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IOrderStatusService 10 | { 11 | Task GetAllAsync(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IProductImageService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IProductImageService 11 | { 12 | Task RemoveAsync(int id); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IProductService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using Entities.DTOs.Filters; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Business.Abstract 12 | { 13 | public interface IProductService 14 | { 15 | Task GetByIdAsync(int id); 16 | Task> GetAllAsync(); 17 | Task GetProductWithImagesByCategoryIdAsync(int categoryid); 18 | Task AddAsync(ProductDTO model); 19 | Task UpdateAsync(ProductDTO model); 20 | Task RemoveAsync(int id); 21 | Task GetProductDetail(string slug); 22 | Task GetAdminProducts(); 23 | Task GetAdminProduct(int productid); 24 | IResponse GetProductsWithImage(ProductFilter filter); 25 | Task GetLast10ProductsWithImage(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IRefreshTokenService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Entities.Concrete; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface IRefreshTokenService 9 | { 10 | Task GetByCodeAsync(string code); 11 | Task GetByUserIdAsync(string userid); 12 | Task AddAsync(RefreshToken entity); 13 | Task> GetAllAsync(); 14 | Task GetByIdAsync(int id); 15 | Task UpdateAsync(RefreshToken entity); 16 | Task RemoveAsync(RefreshToken entity); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IReviewService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IReviewService 11 | { 12 | Task AddAsync(ReviewDTO model); 13 | Task GetAdminReviews(); 14 | Task RemoveAsync(int id); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IRoleService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using Entities.DTOs; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IRoleService 12 | { 13 | Task AddRole(RoleDTO model); 14 | Task UpdateRole(RoleDTO model); 15 | Task RemoveRole(string id); 16 | Task GetRole(string id); 17 | IResponse GetRoles(); 18 | Task GetAssignedRoles(string userid); 19 | Task RoleAssign(List models); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/ISliderService.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.Responses.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Threading.Tasks; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface ISliderService 11 | { 12 | Task AddAsync(SliderDTO model); 13 | Task GetAllAsync(); 14 | Task GetByIdAsync(int id); 15 | Task UpdateAsync(SliderDTO model); 16 | Task RemoveAsync(int id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/ITokenService.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using Entities.DTOs; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ITokenService 12 | { 13 | Task CreateToken(User user); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/Business/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using Entities.DTOs; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IUserService 12 | { 13 | Task UpdateProfile(UpdateProfileDTO model); 14 | Task ChangePassword(ChangePasswordDTO model); 15 | Task ForgotPassword(ForgotPasswordDTO model); 16 | Task ResetPassword(ResetPasswordDTO model); 17 | Task GetUsersWithRoles(); 18 | Task RemoveUser(string userid); 19 | Task PasswordChangeByAdmin(PasswordChangeByAdminDTO model); 20 | Task UpdateUserByAdmin(UserDTO model); 21 | Task GetUser(string userid); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ecommerce/Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Ecommerce/Business/Concrete/OrderStatusManager.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using Entities.Concrete; 6 | using DataAccess.Abstract; 7 | using System.Threading.Tasks; 8 | using Business.Abstract; 9 | using Core.Utilities.Responses.Abstract; 10 | using Core.Utilities.Responses.Concrete; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class OrderStatusManager : IOrderStatusService 15 | { 16 | private IOrderStatusRepository _orderStatusRepository; 17 | public OrderStatusManager(IOrderStatusRepository orderStatusRepository) 18 | { 19 | _orderStatusRepository = orderStatusRepository; 20 | } 21 | 22 | public async Task GetAllAsync() 23 | { 24 | var orderstatuses = await _orderStatusRepository.GetAllAsync(); 25 | return new DataResponse>(orderstatuses, 200); 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /Ecommerce/Business/Concrete/ProductImageManager.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using Entities.Concrete; 6 | using DataAccess.Abstract; 7 | using System.Threading.Tasks; 8 | using Business.Abstract; 9 | using Microsoft.AspNetCore.Http; 10 | using Core.Utilities.Responses.Abstract; 11 | using Core.Utilities; 12 | using Business.Constants; 13 | using Core.Utilities.Responses.Concrete; 14 | using Core.Exceptions; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class ProductImageManager : IProductImageService 19 | { 20 | private IProductImageRepository _productImageRepository; 21 | public ProductImageManager(IProductImageRepository productImageRepository) 22 | { 23 | _productImageRepository = productImageRepository; 24 | } 25 | 26 | public async Task RemoveAsync(int id) 27 | { 28 | var exist = await _productImageRepository.GetByIdAsync(id); 29 | if (exist != null) 30 | { 31 | FileManager.DeleteFile(exist.Image); 32 | await _productImageRepository.RemoveAsync(exist); 33 | return new SuccessResponse(200, Messages.DeletedSuccessfully); 34 | } 35 | else 36 | { 37 | throw new ApiException(404, Messages.NotFound); 38 | } 39 | } 40 | 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /Ecommerce/Business/Concrete/RefreshTokenManager.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using Entities.Concrete; 6 | using DataAccess.Abstract; 7 | using System.Threading.Tasks; 8 | using Business.Abstract; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class RefreshTokenManager : IRefreshTokenService 13 | { 14 | private IRefreshTokenRepository _refreshTokenRepository; 15 | public RefreshTokenManager(IRefreshTokenRepository refreshTokenRepository) 16 | { 17 | _refreshTokenRepository = refreshTokenRepository; 18 | } 19 | 20 | public async Task GetByIdAsync(int id) 21 | { 22 | return await _refreshTokenRepository.GetByIdAsync(id); 23 | } 24 | 25 | public async Task> GetAllAsync() 26 | { 27 | return await _refreshTokenRepository.GetAllAsync(); 28 | } 29 | 30 | public async Task AddAsync(RefreshToken entity) 31 | { 32 | return await _refreshTokenRepository.AddAsync(entity); 33 | } 34 | 35 | public async Task UpdateAsync(RefreshToken entity) 36 | { 37 | await _refreshTokenRepository.UpdateAsync(entity); 38 | } 39 | 40 | public async Task RemoveAsync(RefreshToken entity) 41 | { 42 | await _refreshTokenRepository.RemoveAsync(entity); 43 | } 44 | 45 | public async Task GetByCodeAsync(string code) 46 | { 47 | return await _refreshTokenRepository.GetAsync(x => x.Code == code); 48 | } 49 | 50 | public async Task GetByUserIdAsync(string userid) 51 | { 52 | return await _refreshTokenRepository.GetAsync(x => x.UserId == userid); 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /Ecommerce/Business/Constants/FolderNames.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Business.Constants 8 | { 9 | public static class FolderNames 10 | { 11 | public static string Sliders => "Sliders"; 12 | public static string Brands => "Brands"; 13 | public static string Products => "Products"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/AddressValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddAddressValidator : AbstractValidator 12 | { 13 | public AddAddressValidator() 14 | { 15 | RuleFor(x => x.Name).NotEmpty(); 16 | RuleFor(x => x.Country).NotEmpty(); 17 | RuleFor(x => x.City).NotEmpty(); 18 | RuleFor(x => x.ZipCode).NotEmpty(); 19 | RuleFor(x => x.Description).NotEmpty(); 20 | } 21 | } 22 | public class UpdateAddressValidator : AbstractValidator 23 | { 24 | public UpdateAddressValidator() 25 | { 26 | RuleFor(x => x.Id).NotEmpty(); 27 | RuleFor(x => x.Name).NotEmpty(); 28 | RuleFor(x => x.Country).NotEmpty(); 29 | RuleFor(x => x.City).NotEmpty(); 30 | RuleFor(x => x.ZipCode).NotEmpty(); 31 | RuleFor(x => x.Description).NotEmpty(); 32 | RuleFor(x => x.UserId).NotEmpty(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/BasketValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class BasketValidator:AbstractValidator 12 | { 13 | public BasketValidator() 14 | { 15 | RuleFor(x => x.ProductId).NotNull().NotEmpty(); 16 | RuleFor(x => x.Quantity).NotNull().NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/BrandValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddBrandValidator : AbstractValidator 12 | { 13 | public AddBrandValidator() 14 | { 15 | RuleFor(x => x.ImageFile).NotNull(); 16 | RuleFor(x => x.Name).NotEmpty(); 17 | } 18 | } 19 | public class UpdateBrandValidator : AbstractValidator 20 | { 21 | public UpdateBrandValidator() 22 | { 23 | RuleFor(x => x.Name).NotEmpty(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/CategoryValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddCategoryValidator:AbstractValidator 12 | { 13 | public AddCategoryValidator() 14 | { 15 | RuleFor(x => x.Name).NotEmpty(); 16 | RuleFor(x => x.OptionIds).NotNull().NotEmpty(); 17 | } 18 | } 19 | 20 | public class UpdateCategoryValidator : AbstractValidator 21 | { 22 | public UpdateCategoryValidator() 23 | { 24 | RuleFor(x => x.Id).NotEmpty(); 25 | RuleFor(x => x.Name).NotEmpty(); 26 | RuleFor(x => x.OptionIds).NotNull().NotEmpty(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ChangePasswordValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class ChangePasswordValidator:AbstractValidator 12 | { 13 | public ChangePasswordValidator() 14 | { 15 | RuleFor(x => x.CurrentPassword).NotNull().NotEmpty(); 16 | RuleFor(x => x.NewPassword).NotNull().NotEmpty(); 17 | RuleFor(x => x.ConfirmPassword).NotNull().NotEmpty(); 18 | RuleFor(x => x).Custom((x, context) => 19 | { 20 | if (x.NewPassword != x.ConfirmPassword) 21 | { 22 | context.AddFailure(nameof(x.NewPassword), "Passwords should match"); 23 | } 24 | }); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ForgotPasswordValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | class ForgotPasswordValidator:AbstractValidator 12 | { 13 | public ForgotPasswordValidator() 14 | { 15 | RuleFor(x => x.Email).NotNull().NotEmpty().EmailAddress(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/LoginValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class LoginValidator : AbstractValidator 12 | { 13 | public LoginValidator() 14 | { 15 | RuleFor(x => x.UserName).NotNull().NotEmpty(); 16 | RuleFor(x => x.Password).NotNull().NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/OptionValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddOptionValidator : AbstractValidator 12 | { 13 | public AddOptionValidator() 14 | { 15 | RuleFor(x => x.Name).NotEmpty(); 16 | } 17 | } 18 | public class UpdateOptionValidator : AbstractValidator 19 | { 20 | public UpdateOptionValidator() 21 | { 22 | RuleFor(x => x.Id).NotEmpty(); 23 | RuleFor(x => x.Name).NotEmpty(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/OptionValueValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddOptionValueValidator : AbstractValidator 12 | { 13 | public AddOptionValueValidator() 14 | { 15 | RuleFor(x => x.OptionId).NotEmpty(); 16 | RuleFor(x => x.Value).NotEmpty(); 17 | } 18 | } 19 | public class UpdateOptionValueValidator : AbstractValidator 20 | { 21 | public UpdateOptionValueValidator() 22 | { 23 | RuleFor(x => x.Id).NotEmpty(); 24 | RuleFor(x => x.OptionId).NotEmpty(); 25 | RuleFor(x => x.Value).NotEmpty(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/OrderValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddOrderValidator:AbstractValidator 12 | { 13 | public AddOrderValidator() 14 | { 15 | RuleFor(x => x.Cvc).NotEmpty(); 16 | RuleFor(x => x.CardNumber).NotEmpty(); 17 | RuleFor(x => x.CardName).NotEmpty(); 18 | RuleFor(x => x.ExpirationMonth).NotEmpty(); 19 | RuleFor(x => x.ExpirationYear).NotEmpty(); 20 | RuleFor(x => x.AddressId).NotEmpty(); 21 | } 22 | } 23 | 24 | public class UpdateOrderValidator : AbstractValidator 25 | { 26 | public UpdateOrderValidator() 27 | { 28 | RuleFor(x => x.Id).NotEmpty(); 29 | RuleFor(x => x.OrderStatusId).NotEmpty(); 30 | 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/PasswordChangeByAdminValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class PasswordChangeByAdminValidator : AbstractValidator 12 | { 13 | public PasswordChangeByAdminValidator() 14 | { 15 | RuleFor(x => x.Id).NotEmpty(); 16 | RuleFor(x => x.NewPassword).NotEmpty(); 17 | RuleFor(x => x.ConfirmPassword).NotEmpty(); 18 | RuleFor(x => x).Custom((x, context) => 19 | { 20 | if (x.NewPassword != x.ConfirmPassword) 21 | { 22 | context.AddFailure(nameof(x.NewPassword), "Passwords should match"); 23 | } 24 | }); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ProductOptionValueValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddProductOptionValueValidator:AbstractValidator 12 | { 13 | public AddProductOptionValueValidator() 14 | { 15 | RuleFor(x => x.OptionId).NotEmpty(); 16 | RuleFor(x => x.OptionValueId).NotEmpty(); 17 | } 18 | } 19 | 20 | public class UpdateProductOptionValueValidator : AbstractValidator 21 | { 22 | public UpdateProductOptionValueValidator() 23 | { 24 | RuleFor(x => x.OptionId).NotEmpty(); 25 | RuleFor(x => x.OptionValueId).NotEmpty(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ProductValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddProductValidator:AbstractValidator 12 | { 13 | public AddProductValidator() 14 | { 15 | RuleFor(x => x.BrandId).NotEmpty(); 16 | RuleFor(x => x.CategoryId).NotEmpty(); 17 | RuleFor(x => x.Image).NotNull(); 18 | RuleFor(x => x.Name).NotEmpty(); 19 | RuleFor(x => x.Description).NotEmpty(); 20 | RuleFor(x => x.Price).NotEmpty(); 21 | RuleForEach(x => x.OptionValues).SetValidator(new AddProductOptionValueValidator()); 22 | } 23 | } 24 | 25 | public class UpdateProductValidator : AbstractValidator 26 | { 27 | public UpdateProductValidator() 28 | { 29 | RuleFor(x => x.Id).NotEmpty(); 30 | RuleFor(x => x.BrandId).NotEmpty(); 31 | RuleFor(x => x.CategoryId).NotEmpty(); 32 | RuleFor(x => x.Name).NotEmpty(); 33 | RuleFor(x => x.Description).NotEmpty(); 34 | RuleFor(x => x.Price).NotEmpty(); 35 | RuleForEach(x => x.OptionValues).SetValidator(new UpdateProductOptionValueValidator()); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/RegisterValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class RegisterValidator : AbstractValidator 12 | { 13 | public RegisterValidator() 14 | { 15 | RuleFor(x => x.UserName).NotNull().NotEmpty(); 16 | RuleFor(x => x.FirstName).NotNull().NotEmpty(); 17 | RuleFor(x => x.LastName).NotNull().NotEmpty(); 18 | RuleFor(x => x.Email).NotNull().NotEmpty().EmailAddress(); 19 | RuleFor(x => x.Password).NotNull().NotEmpty(); 20 | RuleFor(x => x.ConfirmPassword).NotNull().NotEmpty(); 21 | RuleFor(x => x).Custom((x, context) => 22 | { 23 | if (x.Password != x.ConfirmPassword) 24 | { 25 | context.AddFailure(nameof(x.Password), "Passwords should match"); 26 | } 27 | }); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ResetPasswordValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Entities.DTOs; 7 | using FluentValidation; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | class ResetPasswordValidator:AbstractValidator 12 | { 13 | public ResetPasswordValidator() 14 | { 15 | RuleFor(x => x.Token).NotNull().NotEmpty(); 16 | RuleFor(x => x.Email).NotNull().NotEmpty().EmailAddress(); 17 | RuleFor(x => x.NewPassword).NotNull().NotEmpty(); 18 | RuleFor(x => x.ConfirmPassword).NotNull().NotEmpty(); 19 | RuleFor(x => x).Custom((x, context) => 20 | { 21 | if (x.NewPassword != x.ConfirmPassword) 22 | { 23 | context.AddFailure(nameof(x.NewPassword), "Passwords should match"); 24 | } 25 | }); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/ReviewValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddReviewValidator:AbstractValidator 12 | { 13 | public AddReviewValidator() 14 | { 15 | RuleFor(x => x.Description).NotEmpty(); 16 | RuleFor(x => x.ProductId).NotEmpty(); 17 | RuleFor(x => x.RatingValue).NotEmpty(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/RoleValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddRoleValidator:AbstractValidator 12 | { 13 | public AddRoleValidator() 14 | { 15 | RuleFor(x => x.Name).NotEmpty(); 16 | } 17 | } 18 | 19 | public class UpdateRoleValidator : AbstractValidator 20 | { 21 | public UpdateRoleValidator() 22 | { 23 | RuleFor(x => x.Id).NotEmpty(); 24 | RuleFor(x => x.Name).NotEmpty(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/SliderValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentValidation; 7 | using Entities.DTOs; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class AddSliderValidator:AbstractValidator 12 | { 13 | public AddSliderValidator() 14 | { 15 | RuleFor(x => x.ImageFile).NotNull(); 16 | RuleFor(x => x.Active).NotNull(); 17 | } 18 | } 19 | 20 | public class UpdateSliderValidator : AbstractValidator 21 | { 22 | public UpdateSliderValidator() 23 | { 24 | RuleFor(x => x.Id).NotNull(); 25 | RuleFor(x => x.Active).NotNull(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/UpdateProfileValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class UpdateProfileValidator:AbstractValidator 12 | { 13 | public UpdateProfileValidator() 14 | { 15 | RuleFor(x => x.FirstName).NotNull().NotEmpty(); 16 | RuleFor(x => x.LastName).NotNull().NotEmpty(); 17 | RuleFor(x => x.Email).NotNull().NotEmpty().EmailAddress(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ecommerce/Business/ValidationRules/FluentValidation/UpdateUserByAdminValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Business.ValidationRules.FluentValidation 10 | { 11 | public class UpdateUserByAdminValidator : AbstractValidator 12 | { 13 | public UpdateUserByAdminValidator() 14 | { 15 | RuleFor(x => x.Id).NotEmpty(); 16 | RuleFor(x => x.Email).NotEmpty().EmailAddress(); 17 | RuleFor(x => x.UserName).NotEmpty(); 18 | RuleFor(x => x.FirstName).NotEmpty(); 19 | RuleFor(x => x.LastName).NotEmpty(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ecommerce/Core/ActionFilters/NullFilterAttribute.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Exceptions; 3 | using Microsoft.AspNetCore.Mvc.Filters; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | 11 | namespace Core.ActionFilters 12 | { 13 | public class NullFilterAttribute : IActionFilter 14 | { 15 | public void OnActionExecuting(ActionExecutingContext context) 16 | { 17 | if (context.ActionArguments.Count > 0) 18 | { 19 | var param = context.ActionArguments.Select(p => p.Value is IDTO); 20 | if (param == null) 21 | { 22 | throw new ApiException(400, "Your request model is null,please check model or property types"); 23 | } 24 | } 25 | else 26 | { 27 | var param = context.ActionArguments.SingleOrDefault(p => p.Value is IDTO); 28 | if (param.Value == null) 29 | { 30 | throw new ApiException(400, "Your request model is null,please check model or property types"); 31 | } 32 | } 33 | } 34 | public void OnActionExecuted(ActionExecutedContext context) 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Ecommerce/Core/Aspects/Autofac/Caching/CacheAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using System.Linq; 10 | 11 | namespace Core.Aspects.Autofac.Caching 12 | { 13 | public class CacheAspect : MethodInterception 14 | { 15 | private readonly int _duration; 16 | private readonly ICacheManager _cacheManager; 17 | public CacheAspect(int duration = 60) 18 | { 19 | _duration = duration; 20 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | public override void Intercept(IInvocation invocation) 23 | { 24 | var methodName = string.Format($"{invocation.Method.ReflectedType.FullName}.{invocation.Method.Name}"); 25 | var arguments = invocation.Arguments.ToList(); 26 | var key = $"{methodName}({string.Join(",", arguments.Select(x => x?.ToString() ?? ""))})"; 27 | if (_cacheManager.IsAdd(key)) 28 | { 29 | invocation.ReturnValue = _cacheManager.Get(key); 30 | return; 31 | } 32 | invocation.Proceed(); 33 | _cacheManager.Add(key, invocation.ReturnValue, _duration); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Ecommerce/Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using System.Linq; 10 | 11 | namespace Core.Aspects.Autofac.Caching 12 | { 13 | public class CacheRemoveAspect : MethodInterception 14 | { 15 | private readonly string _pattern; 16 | private readonly ICacheManager _cacheManager; 17 | public CacheRemoveAspect(string pattern) 18 | { 19 | _pattern = pattern; 20 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | protected override void OnSuccess(IInvocation invocation) 23 | { 24 | _cacheManager.RemoveByPattern(_pattern); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Core/Aspects/Autofac/Performance/PerformanceAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.Aspects.Autofac.Performance 11 | { 12 | public class PerformanceAspect : MethodInterception 13 | { 14 | private int _interval; 15 | private Stopwatch _stopwatch; 16 | 17 | public PerformanceAspect(int interval) 18 | { 19 | _interval = interval; 20 | _stopwatch = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | protected override void OnBefore(IInvocation invocation) 24 | { 25 | _stopwatch.Start(); 26 | } 27 | 28 | protected override void OnAfter(IInvocation invocation) 29 | { 30 | if (_stopwatch.Elapsed.TotalSeconds > _interval) 31 | { 32 | Debug.WriteLine($"Performance : {invocation.Method.DeclaringType.FullName}.{invocation.Method.Name}-->{_stopwatch.Elapsed.TotalSeconds}"); 33 | } 34 | _stopwatch.Reset(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ecommerce/Core/Aspects/Autofac/Transaction/TransactionScopeAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Transactions; 7 | 8 | namespace Core.Aspects.Autofac.Transaction 9 | { 10 | public class TransactionScopeAspect : MethodInterception 11 | { 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | using (TransactionScope transactionScope = new TransactionScope()) 15 | { 16 | try 17 | { 18 | invocation.Proceed(); 19 | transactionScope.Complete(); 20 | } 21 | catch (System.Exception e) 22 | { 23 | transactionScope.Dispose(); 24 | throw; 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Ecommerce/Core/Aspects/Autofac/Validation/ValidationAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Validation.FluentValidation; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.Responses.Concrete; 5 | using FluentValidation; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | namespace Core.Aspects.Autofac.Validation 12 | { 13 | public class ValidationAspect : MethodInterception 14 | { 15 | private readonly Type _validatorType; 16 | public ValidationAspect(Type validatorType) 17 | { 18 | if (!typeof(IValidator).IsAssignableFrom(validatorType)) 19 | { 20 | throw new ArgumentException("Wrong validator type"); 21 | } 22 | _validatorType = validatorType; 23 | } 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 27 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; 28 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 29 | foreach (var entity in entities) 30 | { 31 | ValidatonTool.FluentValidate(validator, entity); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Ecommerce/Core/Configurations/EmailSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Configurations 8 | { 9 | public class EmailSettings 10 | { 11 | public string Email { get; set; } 12 | public string Password { get; set; } 13 | public string Host { get; set; } 14 | public int Port { get; set; } 15 | public bool EnableSSL { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ecommerce/Core/Configurations/JWTOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Configurations 8 | { 9 | public class JWTOptions 10 | { 11 | public List Audience { get; set; } 12 | public string Issuer { get; set; } 13 | public int AccessTokenExpiration { get; set; } 14 | public int RefreshTokenExpiration { get; set; } 15 | public string SecurityKey { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ecommerce/Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Caching/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Caching 6 | { 7 | public interface ICacheManager 8 | { 9 | T Get(string key); 10 | object Get(string key); 11 | void Add(string key, object data, int duration); 12 | void Add(string key, object data); 13 | bool IsAdd(string key); 14 | void Remove(string key); 15 | void RemoveByPattern(string pattern); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/ErrorLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Logging 6 | { 7 | public class ErrorLog 8 | { 9 | public string UserId { get; set; } 10 | public string Username { get; set; } 11 | public string ManagerName { get; set; } 12 | public string MethodName { get; set; } 13 | public List Errors { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/LogDetail.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Logging 6 | { 7 | public class LogDetail 8 | { 9 | public string UserId { get; set; } 10 | public string Username { get; set; } 11 | public string ManagerName { get; set; } 12 | public string MethodName { get; set; } 13 | public object Data { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/SeriLog/ConfigurationModels/FileLogConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels 6 | { 7 | public class FileLogConfiguration 8 | { 9 | public string FolderPath { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/SeriLog/ConfigurationModels/MsSqlConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels 6 | { 7 | public class MsSqlConfiguration 8 | { 9 | public string ConnectionString { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/SeriLog/LoggerServiceBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Serilog; 5 | 6 | namespace Core.CrossCuttingConcerns.Logging.SeriLog 7 | { 8 | public abstract class LoggerServiceBase 9 | { 10 | public ILogger Logger; 11 | public void Verbose(string message) => Logger.Verbose(message); 12 | public void Fatal(string message) => Logger.Fatal(message); 13 | public void Info(string message) => Logger.Information(message); 14 | public void Warn(string message) => Logger.Warning(message); 15 | public void Debug(string message) => Logger.Debug(message); 16 | public void Error(string message) => Logger.Error(message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/SeriLog/Loggers/FileLogger.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels; 2 | using Core.Utilities.IoC; 3 | using Microsoft.Extensions.Configuration; 4 | using Serilog; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Text; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace Core.CrossCuttingConcerns.Logging.SeriLog.Loggers 12 | { 13 | public class FileLogger : LoggerServiceBase 14 | { 15 | public FileLogger() 16 | { 17 | var configuration = ServiceTool.ServiceProvider.GetService(); 18 | 19 | var logConfig = configuration.GetSection("SeriLogConfigurations:FileLogConfiguration") 20 | .Get() ?? throw new Exception("Null"); 21 | 22 | var logFilePath = string.Format("{0}{1}", Directory.GetCurrentDirectory() + logConfig.FolderPath, ".txt"); 23 | 24 | Logger = new LoggerConfiguration() 25 | .WriteTo.File(logFilePath, 26 | rollingInterval: RollingInterval.Day, 27 | retainedFileCountLimit: null, 28 | fileSizeLimitBytes: 5000000, 29 | outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}") 30 | .CreateLogger(); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Logging/SeriLog/Loggers/MsSqlLogger.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Logging.SeriLog.ConfigurationModels; 2 | using Core.Utilities.IoC; 3 | using Microsoft.Extensions.Configuration; 4 | using Serilog; 5 | using Serilog.Sinks.MSSqlServer; 6 | using System; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace Core.CrossCuttingConcerns.Logging.SeriLog.Loggers 12 | { 13 | public class MsSqlLogger : LoggerServiceBase 14 | { 15 | public MsSqlLogger() 16 | { 17 | var configuration = ServiceTool.ServiceProvider.GetService(); 18 | 19 | var logConfig = configuration.GetSection("SeriLogConfigurations:MsSqlConfiguration") 20 | .Get() ?? throw new Exception("Null"); 21 | var sinkOpts = new MSSqlServerSinkOptions { TableName = "Logs", AutoCreateSqlTable = true}; 22 | 23 | var columnOptions = new ColumnOptions(); 24 | columnOptions.Store.Remove(StandardColumn.Message); 25 | columnOptions.Store.Remove(StandardColumn.Properties); 26 | columnOptions.Store.Remove(StandardColumn.Exception); 27 | 28 | var seriLogConfig = new LoggerConfiguration() 29 | .WriteTo.MSSqlServer(connectionString: logConfig.ConnectionString, sinkOptions: sinkOpts,columnOptions:columnOptions) 30 | .CreateLogger(); 31 | Logger = seriLogConfig; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Ecommerce/Core/CrossCuttingConcerns/Validation/FluentValidation/ValidationTool.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using FluentValidation; 3 | using FluentValidation.TestHelper; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Text; 10 | 11 | namespace Core.CrossCuttingConcerns.Validation.FluentValidation 12 | { 13 | public class ValidatonTool 14 | { 15 | public static void FluentValidate(IValidator validator, object entity) 16 | { 17 | var context = new ValidationContext(entity); 18 | var result = validator.Validate(context); 19 | if (!result.IsValid) 20 | { 21 | throw new ValidationException(result.Errors); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ecommerce/Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Linq.Expressions; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Core.DataAccess 10 | { 11 | public interface IEntityRepository where TEntity : class, IEntity, new() 12 | { 13 | TEntity Get(Expression> filter); 14 | Task GetAsync(Expression> filter); 15 | TEntity GetById(int id); 16 | Task GetByIdAsync(int id); 17 | IEnumerable GetAll(Expression> filter = null); 18 | Task> GetAllAsync(Expression> filter = null); 19 | TEntity Add(TEntity entity); 20 | Task AddAsync(TEntity entity); 21 | IEnumerable AddRange(IEnumerable entities); 22 | Task> AddRangeAsync(IEnumerable entities); 23 | void Update(TEntity entity); 24 | void UpdateRange(IEnumerable entities); 25 | Task UpdateAsync(TEntity entity); 26 | Task UpdateRangeAsync(IEnumerable entities); 27 | void Remove(TEntity entity); 28 | void RemoveRange(IEnumerable entities); 29 | Task RemoveAsync(TEntity entity); 30 | Task RemoveRangeAsync(IEnumerable entities); 31 | int Count(); 32 | Task CountAsync(); 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Ecommerce/Core/DependencyResolvers/CoreModule.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Configurations; 3 | using Core.CrossCuttingConcerns.Caching; 4 | using Core.CrossCuttingConcerns.Caching.Microsoft; 5 | using Core.CrossCuttingConcerns.Logging.SeriLog.Loggers; 6 | using Core.Utilities; 7 | using Core.Utilities.IoC; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Diagnostics; 14 | using System.Text; 15 | 16 | namespace Core.DependencyResolvers 17 | { 18 | public class CoreModule : ICoreModule 19 | { 20 | public void Load(IServiceCollection services, IConfiguration configuration) 21 | { 22 | services.AddMemoryCache(); 23 | services.AddSingleton(); 24 | services.AddSingleton(); 25 | services.AddSingleton(); 26 | services.Configure(configuration.GetSection("EmailSettings")); 27 | services.AddTransient(); 28 | services.AddTransient(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Ecommerce/Core/Entities/IDTO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Entities 8 | { 9 | public interface IDTO 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Ecommerce/Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Entities 8 | { 9 | public interface IEntity 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Ecommerce/Core/Exceptions/ApiException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Core.Exceptions 9 | { 10 | [Serializable] 11 | public class ApiException : Exception 12 | { 13 | public int StatusCode { get; } 14 | public List Errors { get; private set; } = new List(); 15 | 16 | public ApiException(int statuscode, List errors) 17 | { 18 | StatusCode = statuscode; 19 | Errors = errors; 20 | } 21 | public ApiException(int statuscode, string error) 22 | { 23 | StatusCode = statuscode; 24 | Errors.Add(error); 25 | } 26 | public ApiException(SerializationInfo info, StreamingContext context) : base(info, context) { } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Extensions/ExceptionMiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Extensions 7 | { 8 | public static class ExceptionMiddlewareExtensions 9 | { 10 | public static void UseCustomExceptionMiddleware(this IApplicationBuilder app) 11 | { 12 | app.UseMiddleware(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Extensions/IQueryableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Utilities.Extensions 8 | { 9 | public static class IQueryableExtensions 10 | { 11 | public static IQueryable ApplyPaging(this IQueryable query, int page,int pagesize) 12 | { 13 | if (page <= 0) 14 | page = 1; 15 | if (pagesize <= 0) 16 | pagesize = 10; 17 | return query.Skip((page - 1) * pagesize).Take(pagesize); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Extensions/LinqExtensionMethod.cs: -------------------------------------------------------------------------------- 1 | using LinqKit; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Linq.Expressions; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace DataAccess.Concrete 10 | { 11 | public static class LinqExtensionMethod 12 | { 13 | public static IQueryable WhereAll(this IQueryable dbq, IEnumerable searchTerms, Expression> testFne) 14 | { 15 | var pred = PredicateBuilder.New(); 16 | foreach (var s in searchTerms) 17 | pred = pred.And(r => testFne.Invoke(r, s)); 18 | return dbq.Where((Expression>)pred.Expand()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Utilities.IoC; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Core.Utilities.Extensions 10 | { 11 | public static class ServiceCollectionExtensions 12 | { 13 | public static IServiceCollection AddDependencyResolvers(this IServiceCollection services, IConfiguration configuration,ICoreModule[] modules) 14 | { 15 | foreach (var module in modules) 16 | { 17 | module.Load(services,configuration); 18 | } 19 | return ServiceTool.Create(services); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/FileManager.cs: -------------------------------------------------------------------------------- 1 | using Core.Exceptions; 2 | using Core.Utilities.IoC; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace Core.Utilities 14 | { 15 | public static class FileManager 16 | { 17 | public static string SaveFile(string foldername, IFormFile file) 18 | { 19 | string filename = Guid.NewGuid().ToString().Substring(0, 9) + "_" + file.FileName; 20 | if (!Directory.Exists(@"Uploads//" + foldername)) 21 | Directory.CreateDirectory(@"Uploads//" + foldername); 22 | var path = Path.Combine(Directory.GetCurrentDirectory(), "Uploads//" + foldername, filename); 23 | using (var stream = new FileStream(path, FileMode.Create)) 24 | { 25 | file.CopyTo(stream); 26 | } 27 | return "Uploads/" + foldername + "/" + filename; 28 | } 29 | 30 | public static void DeleteFile(string filename) 31 | { 32 | var path = Path.Combine(Directory.GetCurrentDirectory(), filename); 33 | if (System.IO.File.Exists(path)) 34 | System.IO.File.Delete(path); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Helpers/SecurityKeyHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Core.Utilities.Helpers 9 | { 10 | public static class SecurityKeyHelper 11 | { 12 | public static SecurityKey GetSymmetricSecurityKey(string securityKey) 13 | { 14 | return new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Helpers/SigningCredentialsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Core.Utilities.Helpers 9 | { 10 | public static class SigningCredentialsHelper 11 | { 12 | public static SigningCredentials CreateSigningCredentials(SecurityKey securityKey) 13 | { 14 | return new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/IEmailService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Core.Utilities 8 | { 9 | public interface IEmailService 10 | { 11 | Task ConfirmationMailAsync(string link, string email); 12 | Task ForgetPasswordMailAsync(string link, string email); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Aspects.Autofac.Exception; 3 | using Core.CrossCuttingConcerns.Logging.SeriLog.Loggers; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Text; 9 | 10 | namespace Core.Utilities.Interceptors 11 | { 12 | public class AspectInterceptorSelector : IInterceptorSelector 13 | { 14 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 15 | { 16 | var classAttributes = type.GetCustomAttributes(true).ToList(); 17 | var methodAttributes = type.GetMethod(method.Name).GetCustomAttributes(true); 18 | classAttributes.AddRange(methodAttributes); 19 | //classAttributes.Add(new ExceptionLogAspect(typeof(MsSqlLogger))); 20 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)] 9 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 10 | { 11 | public int Priority { get; set; } 12 | 13 | public virtual void Intercept(IInvocation invocation) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/IoC/ICoreModule.cs: -------------------------------------------------------------------------------- 1 |  2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Core.Utilities.IoC 9 | { 10 | public interface ICoreModule 11 | { 12 | void Load(IServiceCollection serviceCollection, IConfiguration configuration); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/IoC/ServiceTool.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.IoC 7 | { 8 | public static class ServiceTool 9 | { 10 | public static IServiceProvider ServiceProvider { get; set; } 11 | 12 | public static IServiceCollection Create(IServiceCollection services) 13 | { 14 | ServiceProvider = services.BuildServiceProvider(); 15 | return services; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Abstract/IDataResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Responses.Abstract 6 | { 7 | public interface IDataResponse : IResponse 8 | { 9 | T Data { get; } 10 | string Message { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Abstract/IErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Responses.Abstract 6 | { 7 | public interface IErrorResponse : IResponse 8 | { 9 | List Errors { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Abstract/IPagedDataResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Responses.Abstract 6 | { 7 | interface IPagedDataResponse : IResponse 8 | { 9 | int TotalItems { get; } 10 | T Data { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Abstract/IResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Responses.Abstract 6 | { 7 | public interface IResponse 8 | { 9 | bool Success { get; } 10 | int StatusCode { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Abstract/ISuccessResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Responses.Abstract 6 | { 7 | public interface ISuccessResponse : IResponse 8 | { 9 | string Message { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Concrete/DataResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Responses.Concrete 7 | { 8 | public class DataResponse : IDataResponse 9 | { 10 | public bool Success { get; } = true; 11 | public T Data { get; } 12 | 13 | public int StatusCode { get; } 14 | public string Message { get; set; } 15 | public DataResponse(T data, int statuscode) 16 | { 17 | Data = data; 18 | StatusCode = statuscode; 19 | } 20 | public DataResponse(T data, int statuscode,string message) 21 | { 22 | Data = data; 23 | StatusCode = statuscode; 24 | Message = message; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Concrete/ErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Responses.Concrete 7 | { 8 | public class ErrorResponse : IErrorResponse 9 | { 10 | public bool Success { get; } = false; 11 | public int StatusCode { get; } 12 | public List Errors { get; private set; } = new List(); 13 | 14 | public ErrorResponse(int statuscode, List errors) 15 | { 16 | StatusCode = statuscode; 17 | Errors = errors; 18 | } 19 | 20 | public ErrorResponse(int statuscode, string error) 21 | { 22 | StatusCode = statuscode; 23 | Errors.Add(error); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Concrete/PagedDataResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Responses.Concrete 7 | { 8 | public class PagedDataResponse : IPagedDataResponse 9 | { 10 | public bool Success { get; } = true; 11 | public int TotalItems { get; } 12 | 13 | public T Data { get; } 14 | 15 | public int StatusCode { get; } 16 | 17 | public PagedDataResponse(T data, int statuscode, int totalitems) 18 | { 19 | Data = data; 20 | StatusCode = statuscode; 21 | TotalItems = totalitems; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Concrete/Response.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities 7 | { 8 | public class Response : IResponse 9 | { 10 | public bool Success { get; } 11 | 12 | public int StatusCode { get; } 13 | 14 | public Response(bool success,int statuscode) 15 | { 16 | Success = success; 17 | StatusCode = statuscode; 18 | } 19 | 20 | public Response(bool success) 21 | { 22 | Success = success; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Ecommerce/Core/Utilities/Responses/Concrete/SuccessResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Responses.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Responses.Concrete 7 | { 8 | public class SuccessResponse : ISuccessResponse 9 | { 10 | public bool Success { get; } = true; 11 | public string Message { get; } 12 | public int StatusCode { get; } 13 | 14 | 15 | public SuccessResponse() 16 | { 17 | 18 | } 19 | 20 | public SuccessResponse(int statuscode, string message) 21 | { 22 | StatusCode = statuscode; 23 | Message = message; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/IAddressRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using Core.DataAccess; 4 | using Entities.Concrete; 5 | namespace DataAccess.Abstract 6 | { 7 | public interface IAddressRepository : IEntityRepository
8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/IBasketItemRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using Core.DataAccess; 4 | using Entities.Concrete; 5 | namespace DataAccess.Abstract 6 | { 7 | public interface IBasketItemRepository : IEntityRepository 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/IBasketRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Threading.Tasks; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | namespace DataAccess.Abstract 7 | { 8 | public interface IBasketRepository : IEntityRepository 9 | { 10 | Task GetBasketByUserId(string userid); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/IBrandRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using Core.DataAccess; 4 | using Entities.Concrete; 5 | namespace DataAccess.Abstract 6 | { 7 | public interface IBrandRepository : IEntityRepository 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/ICategoryRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | using Core.DataAccess; 6 | using Entities.Concrete; 7 | using Entities.DTOs; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICategoryRepository : IEntityRepository 12 | { 13 | Task> GetCategoriesWithOptionsAsync(); 14 | Task GetOptionsWithValuesByCategorySlug(string slug); 15 | Task GetOptionsWithValuesByCategoryId(int id); 16 | Task GetCategoryWithOptionsByCategoryIdAsync(int categoryid); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Ecommerce/DataAccess/Abstract/IOptionRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | using Core.DataAccess; 6 | using Entities.Concrete; 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IOptionRepository : IEntityRepository