forked from hosseinJavadi/vizhvizhBack
first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using Vizhvizh.Shared.Domain.TypeIds;
|
||||
using Vizhvizh.Shared.Domain.ValueObjects;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.Entities;
|
||||
|
||||
public class ModuleInformation : Entity<ModuleInformationId>
|
||||
{
|
||||
private List<(ModuleNameVO, AppVersionVO)> _modulesInformation = [];
|
||||
|
||||
public ModuleInformation()
|
||||
{
|
||||
_modulesInformation.Add(new (ModuleNameVO.UserAccess, new AppVersionVO(1,0,0,0)));
|
||||
_modulesInformation.Add(new (ModuleNameVO.Shop, new AppVersionVO(1,0,0,0)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain.Exceptions;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.Exceptions;
|
||||
|
||||
public class CharacterLimitException : ValueObjectValidationException
|
||||
{
|
||||
public CharacterLimitException(string name,short limit)
|
||||
: base(string.Format(ExceptionResources.CharacterLimitException, name, limit))
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain.Exceptions;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.Exceptions;
|
||||
|
||||
public class InvalidEmailException : ValueObjectValidationException
|
||||
{
|
||||
public InvalidEmailException() : base(ExceptionResources.InvalidEmailException)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain.Exceptions;
|
||||
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.Exceptions;
|
||||
public class InvalidPhoneNumberException : ValueObjectValidationException
|
||||
{
|
||||
public InvalidPhoneNumberException() : base(ExceptionResources.InvalidPhoneNumberException)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain.Exceptions;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.Exceptions;
|
||||
public class InvalidTelephoneException : ValueObjectValidationException
|
||||
{
|
||||
public InvalidTelephoneException() : base(ExceptionResources.InvalidTelephoneException)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.TypeIds;
|
||||
|
||||
public class ModuleInformationId : TypedIdValueBase<int>
|
||||
{
|
||||
public ModuleInformationId(int value) : base(value)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// MAJOR.MINOR.REVISION.BUILDNUMBER, where:
|
||||
/// MAJOR is a major release(usually many new features or changes to the UI or underlying OS)
|
||||
/// MINOR is a minor release(perhaps some new features) on a previous major release
|
||||
/// REVISION is usually a fix for a previous minor release(no new functionality)
|
||||
/// BUILDNUMBER is incremented for each latest build of a revision.
|
||||
/// </summary>
|
||||
public class AppVersionVO : ValueObject
|
||||
{
|
||||
public AppVersionVO(int major, int minor, int revision, int build)
|
||||
{
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
Revision = revision;
|
||||
Build = build;
|
||||
}
|
||||
public int Major { get; init; }
|
||||
public int Minor { get; init; }
|
||||
public int Revision { get; init; }
|
||||
public int Build { get; init; }
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Major}.{Minor}.{Revision}.{Build}";
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Globalization;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
public class DateTimeVO : ValueObject
|
||||
{
|
||||
public DateTime Value { get; }
|
||||
|
||||
private DateTimeVO(DateTime dateTime)
|
||||
=> Value = dateTime;
|
||||
|
||||
public static DateTimeVO CreateNew(DateTime dateTime)
|
||||
=> new DateTimeVO(dateTime);
|
||||
|
||||
public string ToShamsiDateTime()
|
||||
{
|
||||
var persianCalendar = new PersianCalendar();
|
||||
persianCalendar.ToDateTime(Value.Year, Value.Month, Value.Day, Value.Hour, Value.Minute, Value.Second, 0);
|
||||
return persianCalendar.ToString()!;
|
||||
}
|
||||
|
||||
public static implicit operator DateTimeVO(DateTime dateTime)
|
||||
=> CreateNew(dateTime);
|
||||
|
||||
public static implicit operator DateTime(DateTimeVO dateTime)
|
||||
=> dateTime.Value;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Vizhvizh.Shared.Domain.Exceptions;
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// توضیحات ، معرفی
|
||||
/// </summary>
|
||||
public class DescriptionVO : ValueObject
|
||||
{
|
||||
public const short Limit = 500;
|
||||
public string Value { get; }
|
||||
private DescriptionVO(string description)
|
||||
{
|
||||
if (description.Length > Limit)
|
||||
throw new CharacterLimitException(ValueObjectResources.Description, limit: Limit);
|
||||
|
||||
Value = description;
|
||||
}
|
||||
|
||||
public static DescriptionVO CreateNew(string description)
|
||||
=> new DescriptionVO(description);
|
||||
|
||||
public static implicit operator DescriptionVO(string value)
|
||||
=> CreateNew(value);
|
||||
|
||||
public static implicit operator string(DescriptionVO value)
|
||||
=> value.Value;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Net.Mail;
|
||||
using Vizhvizh.Shared.Domain.Exceptions;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
public class EmailVO : ValueObject
|
||||
{
|
||||
public const short Limit = 200;
|
||||
private EmailVO(string value)
|
||||
{
|
||||
if (value.Length > Limit)
|
||||
throw new CharacterLimitException("Email", Limit);
|
||||
try { new MailAddress(value); }
|
||||
catch
|
||||
{
|
||||
throw new InvalidEmailException();
|
||||
}
|
||||
|
||||
Value = value;
|
||||
}
|
||||
public static EmailVO CreateNew(string value)
|
||||
=> new EmailVO(value);
|
||||
public string Value { get; private set; }
|
||||
|
||||
public static implicit operator EmailVO(string value)
|
||||
=> CreateNew(value);
|
||||
|
||||
public static implicit operator string(EmailVO value)
|
||||
=> value.Value;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
public class ModuleNameVO : ValueObject
|
||||
{
|
||||
public static ModuleNameVO Shop = new(ModuleNamesEnum.Shop);
|
||||
public static ModuleNameVO UserAccess = new(ModuleNamesEnum.UserAccess);
|
||||
|
||||
|
||||
private ModuleNameVO(ModuleNamesEnum module)
|
||||
{
|
||||
Value = module;
|
||||
}
|
||||
public static ModuleNameVO CreateNew(ModuleNamesEnum module)
|
||||
=> new ModuleNameVO(module);
|
||||
|
||||
public ModuleNamesEnum Value { get; init; }
|
||||
}
|
||||
public enum ModuleNamesEnum
|
||||
{
|
||||
[Display(Name = nameof(EntityResources.ModuleNamesEnum_Shop), ResourceType = typeof(EntityResources))]
|
||||
Shop = 0,
|
||||
[Display(Name = nameof(EntityResources.ModuleNamesEnum_UserAccess), ResourceType = typeof(EntityResources))]
|
||||
UserAccess = 1
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Vizhvizh.Shared.Domain.Exceptions;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
public class PhoneNumberVO : ValueObject
|
||||
{
|
||||
public const short Limit = 11;
|
||||
private PhoneNumberVO(string value)
|
||||
{
|
||||
if(value.Length > Limit)
|
||||
throw new InvalidPhoneNumberException();
|
||||
|
||||
var reg = new Regex("(0?9)\\d{9}");
|
||||
if (!reg.IsMatch(value))
|
||||
throw new InvalidPhoneNumberException();
|
||||
|
||||
Value = value;
|
||||
|
||||
}
|
||||
public static PhoneNumberVO CreateNew(string value)
|
||||
=> new PhoneNumberVO(value);
|
||||
public string Value { get; private set; }
|
||||
|
||||
public static implicit operator PhoneNumberVO(string value)
|
||||
=> CreateNew(value);
|
||||
|
||||
public static implicit operator string(PhoneNumberVO value)
|
||||
=> value.Value;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
using Vizhvizh.Shared.Domain.Exceptions;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
|
||||
public class TelephoneVO : ValueObject
|
||||
{
|
||||
public const short Limit = 11;
|
||||
private TelephoneVO(string value)
|
||||
{
|
||||
if (value.Length > Limit)
|
||||
throw new InvalidTelephoneException();
|
||||
|
||||
var reg = new Regex("^0[0-9]{2,}[0-9]{7,}$");
|
||||
if (!reg.IsMatch(value))
|
||||
throw new InvalidTelephoneException();
|
||||
|
||||
Value = value;
|
||||
}
|
||||
public static TelephoneVO CreateNew(string value)
|
||||
=> new TelephoneVO(value);
|
||||
public string Value { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Vizhvizh.Shared.Domain.Exceptions;
|
||||
using Vizhvizh.Shared.Domain.Resource;
|
||||
using Vizhvizh.BuildingBlocks.Domain;
|
||||
|
||||
namespace Vizhvizh.Shared.Domain.ValueObjects;
|
||||
/// <summary>
|
||||
/// عنوان
|
||||
/// </summary>
|
||||
public class TitleVO : ValueObject
|
||||
{
|
||||
public const short Limit = 60;
|
||||
|
||||
public string Value { get; }
|
||||
|
||||
public static TitleVO CreateNew(string title)
|
||||
=> new TitleVO(title);
|
||||
|
||||
private TitleVO(string title)
|
||||
{
|
||||
if (title.Length > Limit)
|
||||
throw new CharacterLimitException(ValueObjectResources.Title,limit: Limit);
|
||||
|
||||
Value = title;
|
||||
}
|
||||
|
||||
|
||||
public static implicit operator TitleVO(string value)
|
||||
=> CreateNew(value);
|
||||
|
||||
public static implicit operator string(TitleVO value)
|
||||
=> value.Value;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VichVich.BuildingBlocks.Domain\Vizhvizh.BuildingBlocks.Domain.csproj" />
|
||||
<ProjectReference Include="..\VichVich.Shared.Domain.Resource\Vizhvizh.Shared.Domain.Resource.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user