Initial commit - ECommerce project

This commit is contained in:
2026-08-05 23:58:33 +03:00
commit bcebac18e7
63 changed files with 4543 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
namespace Commerce.Contracts.Constants;
public static class AppCon
{
public static class ConnectionStrings
{
public const string SQLServer = "server=(localdb)\\MSSQLLocalDB;database=Ecommerce;Integrated Security=true";
public const string MariaDB = "UserID=said;Password=aaa111!!!AAA;server=db;Port=3310;Database=ecommercedb;Protocol=TCP";
public const string Postgresql = "Host=localhost;Database=ecommerce;Username=said1996;Password=a44781680;";
}
}
+63
View File
@@ -0,0 +1,63 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Commerce.Contracts.Constants;
public static class AppEnum
{
public enum OrderStatus
{
FillingCart,
// Paid,
InQueue,
DeliveryInProgress,
Delivered,
UserNotFound,
Delayed,
// Reserved
}
public enum QueryOrder
{
[Display(Name = "Popular")]
Name,
Recent,
Oldest,
[Display(Name = "Lowest Price")]
Lowest,
[Display(Name = "Highest Price")]
Highest
}
public enum Roles
{
SuperAdmin,
Admin,
Moderator,
Standard
}
public enum ShippingMethod
{
[Display(Name = "Standard shipping - $10.00")] NormalShipping,
[Display(Name = "Fast shipping - $50.00")] FastShipping,
}
public enum SalesOrPurchases
{
None,
Purchase,
Sales,
}
}
@@ -0,0 +1,10 @@
namespace Commerce.Contracts.DTOs;
public class CategoryFilter
{
public string? Name { get; set; }
public bool? IsBundle { get; set; }
public string? Language { get; set; }
public bool? Random { get; set; } = false;
}
+25
View File
@@ -0,0 +1,25 @@
namespace Commerce.Contracts.DTOs;
public class CategoryVM
{
public Guid? Id { get; set; }
public string[]? Photos { get; set; }
public Guid? ParentCategoryId { get; set; }
public ICollection<CategoryVM>? ChildCategories { get; set; }
public bool IsBundle { get; set; }
public List<CategoryTranslationVM> Translations { get; set; } = new();
}
public class CategoryTranslationVM
{
public string Language { get; set; } = string.Empty;
public CategoryInfoVM Info { get; set; } = new();
}
public class CategoryInfoVM
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public List<TechnicalDetailVM> TechnicalDetails { get; set; } = new();
}
+14
View File
@@ -0,0 +1,14 @@
namespace Commerce.Contracts.DTOs;
public class ProductFilter
{
public string? Name { get; set; }
public double? Price { get; set; }
public double? Discount { get; set; }
public bool? IsBundle { get; set; }
public Guid? CategoryId { get; set; }
public string? Language { get; set; }
public bool? Random { get; set; } = false;
}
+38
View File
@@ -0,0 +1,38 @@
namespace Commerce.Contracts.DTOs;
public class ProductVM
{
public Guid? Id { get; set; }
public string[]? Photos { get; set; }
public double? Price { get; set; }
public double? Discount { get; set; }
public DateTime? Created { get; set; }
public string? CodeName { get; set; }
public string? CategoryName { get; set; }
public bool IsBundle { get; set; }
public ICollection<ProductVM>? ChildProducts { get; set; }
public Guid? CategoryId { get; set; }
public Guid? ParentCategoryId { get; set; }
public ICollection<CategoryVM>? ChildCategories { get; set; }
public List<ProductTranslationVM>? Translations { get; set; } = new();
}
public class ProductTranslationVM
{
public string Language { get; set; } = string.Empty;
public ProductInfoVM Info { get; set; } = new();
}
public class ProductInfoVM
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public List<TechnicalDetailVM> TechnicalDetails { get; set; } = new();
}
public class TechnicalDetailVM
{
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace Commerce.Contracts.DTOs;
public class TechnicalDetail
{
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
+18
View File
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="12.1.1" />
</ItemGroup>
<!-- <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.11" />
</ItemGroup> -->
</Project>
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Commerce.Contracts.Exceptions;
public class NotFoundException : Exception
{
public NotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Commerce.Contracts.Options;
public class JWT
{
public string Key { get; set; }
public string Issuer { get; set; }
public string Audience { get; set; }
public double DurationInMinutes { get; set; }
}
@@ -0,0 +1,12 @@
using FluentValidation;
using Commerce.Contracts.DTOs;
namespace Commerce.Contracts.Validators;
public class CategoryVMValidator : AbstractValidator<CategoryVM>
{
public CategoryVMValidator()
{
RuleFor(x => x.Translations).NotEmpty().WithMessage("At least one translation is required");
}
}
@@ -0,0 +1,14 @@
using FluentValidation;
using Commerce.Contracts.DTOs;
namespace Commerce.Contracts.Validators;
public class ProductVMValidator : AbstractValidator<ProductVM>
{
public ProductVMValidator()
{
RuleFor(x => x.Translations).NotEmpty().WithMessage("At least one translation is required");
RuleFor(x => x.Price).GreaterThan(0).When(x => x.Price.HasValue).WithMessage("Price must be greater than 0");
RuleFor(x => x.CategoryId).NotEmpty().When(x => !x.IsBundle).WithMessage("Category is required for products");
}
}