model and Dto
This commit is contained in:
9
Common/Common.csproj
Normal file
9
Common/Common.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
15
Common/Dtos/Auth/AuthFromCompanySideDto.cs
Normal file
15
Common/Dtos/Auth/AuthFromCompanySideDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Auth
|
||||
{
|
||||
public class AuthFromCompanySideDto
|
||||
{
|
||||
// username=wxper --- mobile=company
|
||||
public string UserNameORMobile { get; set; }
|
||||
public string PassWord { get; set; }
|
||||
}
|
||||
}
|
14
Common/Dtos/Auth/AuthFromUserSideDto.cs
Normal file
14
Common/Dtos/Auth/AuthFromUserSideDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Auth
|
||||
{
|
||||
public class AuthFromUserSideDto
|
||||
{
|
||||
public string? FullName { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Company.CompanyContentInfo
|
||||
{
|
||||
public class ADD_CompanyContentInfoDto
|
||||
{
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Company.CompanyContentInfo
|
||||
{
|
||||
public class ReadANDUpdate_CompanyContentInfoDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
20
Common/Dtos/Company/ReadANDUpdate_CompanyDto.cs
Normal file
20
Common/Dtos/Company/ReadANDUpdate_CompanyDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Company
|
||||
{
|
||||
public class ReadANDUpdate_CompanyDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string? FullNameManager { get; set; }
|
||||
public string? WebSite { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public bool Available { get; set; }
|
||||
public bool allowBot { get; set; }
|
||||
}
|
||||
}
|
16
Common/Dtos/Company/RegisterCompanyDto.cs
Normal file
16
Common/Dtos/Company/RegisterCompanyDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Company
|
||||
{
|
||||
public class RegisterCompanyDto
|
||||
{
|
||||
public string Mobile { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string FullName { get; set; }
|
||||
|
||||
}
|
||||
}
|
11
Common/Dtos/Conversation/ADD_ConversationDto.cs
Normal file
11
Common/Dtos/Conversation/ADD_ConversationDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
namespace Common.Dtos.Conversation
|
||||
{
|
||||
public class ADD_ConversationDto
|
||||
{
|
||||
public string Question { get; set; }
|
||||
public int? GroupID { get; set; }
|
||||
public int CompanyID { get; set; }
|
||||
public int? ExperID { get; set; }
|
||||
}
|
||||
}
|
13
Common/Dtos/Conversation/ADD_ConversationItemDto.cs
Normal file
13
Common/Dtos/Conversation/ADD_ConversationItemDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
namespace Common.Dtos.Conversation
|
||||
{
|
||||
public class ADD_ConversationItemDto
|
||||
{
|
||||
public int ConversationID { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string? FileName { get; set; }
|
||||
public string? FileType { get; set; }
|
||||
public byte[]? FileContent { get; set; }
|
||||
}
|
||||
|
||||
}
|
24
Common/Dtos/Conversation/Read_ConversationDto.cs
Normal file
24
Common/Dtos/Conversation/Read_ConversationDto.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Common.Enums;
|
||||
|
||||
namespace Common.Dtos.Conversation
|
||||
{
|
||||
public class Read_ConversationDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public ConversationStatus status { get; set; }
|
||||
|
||||
public int? GroupID { get; set; }
|
||||
public string? GroupName { get; set; }
|
||||
|
||||
public int UserID { get; set; }
|
||||
public string? UserFullName { get; set; }
|
||||
|
||||
public int? ExperID { get; set; }
|
||||
public string? ExperFullName { get; set; }
|
||||
|
||||
public string Cdate { get; set; }
|
||||
public string Ctime { get; set; }
|
||||
public int NoReadCount { get; set; } = 0;
|
||||
}
|
||||
}
|
19
Common/Dtos/Conversation/Read_ConversationItemDto.cs
Normal file
19
Common/Dtos/Conversation/Read_ConversationItemDto.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Common.Enums;
|
||||
|
||||
|
||||
namespace Common.Dtos.Conversation
|
||||
{
|
||||
public class Read_ConversationItemDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int ConversationID { get; set; }
|
||||
public int? ExperID { get; set; }
|
||||
public bool IsRead { get; set; } = false;
|
||||
public string ExperName { get; set; }
|
||||
public ConversationType Type { get; set; }
|
||||
public string text { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FileType { get; set; }
|
||||
public byte[] FileContent { get; set; }
|
||||
}
|
||||
}
|
15
Common/Dtos/Exper/ADD_ExperDto.cs
Normal file
15
Common/Dtos/Exper/ADD_ExperDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Exper
|
||||
{
|
||||
public class ADD_ExperDto
|
||||
{
|
||||
public string FullName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
16
Common/Dtos/Exper/Update_ExperDto.cs
Normal file
16
Common/Dtos/Exper/Update_ExperDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Exper
|
||||
{
|
||||
public class Update_ExperDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
// For Update
|
||||
public string FullName { get; set; }
|
||||
|
||||
}
|
||||
}
|
14
Common/Dtos/ExperGroup/ADD_ExperGroupDto.cs
Normal file
14
Common/Dtos/ExperGroup/ADD_ExperGroupDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.ExperGroup
|
||||
{
|
||||
public class ADD_ExperGroupDto
|
||||
{
|
||||
public int ExperID { get; set; }
|
||||
public int GroupID { get; set; }
|
||||
}
|
||||
}
|
16
Common/Dtos/ExperGroup/Read_ExperGroupDto.cs
Normal file
16
Common/Dtos/ExperGroup/Read_ExperGroupDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.ExperGroup
|
||||
{
|
||||
public class Read_ExperGroupDto
|
||||
{
|
||||
public int ExperID { get; set; }
|
||||
public string ExperName { get; set; }
|
||||
public int GroupID { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
}
|
16
Common/Dtos/Group/ADD_GroupDto.cs
Normal file
16
Common/Dtos/Group/ADD_GroupDto.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Group
|
||||
{
|
||||
public class ADD_GroupDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public string? Info { get; set; }
|
||||
public bool Available { get; set; } = true;
|
||||
}
|
||||
}
|
18
Common/Dtos/Group/Read_GroupDto.cs
Normal file
18
Common/Dtos/Group/Read_GroupDto.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos.Group
|
||||
{
|
||||
public class Read_GroupDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public string? Info { get; set; }
|
||||
public bool Available { get; set; }
|
||||
|
||||
}
|
||||
}
|
17
Common/Dtos/Read_UserDto.cs
Normal file
17
Common/Dtos/Read_UserDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Dtos
|
||||
{
|
||||
public class Read_UserDto
|
||||
{
|
||||
// CompanyUser OR Exper OR User
|
||||
public int ID { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string? Mobile { get; set; }
|
||||
}
|
||||
}
|
13
Common/Enums/ConversationStatus.cs
Normal file
13
Common/Enums/ConversationStatus.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Enums
|
||||
{
|
||||
public enum ConversationStatus
|
||||
{
|
||||
InProgress, Finished
|
||||
}
|
||||
}
|
13
Common/Enums/ConversationType.cs
Normal file
13
Common/Enums/ConversationType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Common.Enums
|
||||
{
|
||||
public enum ConversationType
|
||||
{
|
||||
EU = 1, UE = 2
|
||||
}
|
||||
}
|
21
Hushian.Application/Contracts/IGenericRepository.cs
Normal file
21
Hushian.Application/Contracts/IGenericRepository.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Application.Contracts.Persistence
|
||||
{
|
||||
public interface IGenericRepository<T> where T : class
|
||||
{
|
||||
IQueryable<T> Get();
|
||||
Task<T?> ADD(T entity);
|
||||
Task<ICollection<T>> ADD(ICollection<T> entities);
|
||||
Task<bool> ADDBool(T entity);
|
||||
Task<T?> UPDATE(T entity);
|
||||
Task<ICollection<T>> UPDATE(ICollection<T> entities);
|
||||
Task<bool> UPDATEBool(T entity);
|
||||
Task<bool> DELETE(T entity);
|
||||
Task<bool> DELETE(ICollection<T> entities);
|
||||
}
|
||||
}
|
14
Hushian.Application/Hushian.Application.csproj
Normal file
14
Hushian.Application/Hushian.Application.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Common.csproj" />
|
||||
<ProjectReference Include="..\Hushian.Domain\Hushian.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
14
Hushian.Domain/Abstracts/BaseEntity.cs
Normal file
14
Hushian.Domain/Abstracts/BaseEntity.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Abstracts
|
||||
{
|
||||
public interface BaseEntity
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public DateTime Cdatetime { get; set; }
|
||||
}
|
||||
}
|
41
Hushian.Domain/Entites/Company.cs
Normal file
41
Hushian.Domain/Entites/Company.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class Company : BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
public string Password { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string? FullNameManager { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string? WebSite { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public byte[]? img { get; set; }
|
||||
public bool Available { get; set; } = true;
|
||||
public bool allowBot { get; set; } = true;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
public ICollection<Group> Groups { get; set; }
|
||||
= new List<Group>();
|
||||
public ICollection<Exper> Expers { get; set; }
|
||||
= new List<Exper>();
|
||||
public ICollection<Conversation> Conversations { get; set; }
|
||||
= new List<Conversation>();
|
||||
public ICollection<CompanyContentInfo> CompanyContentInfos { get; set; }
|
||||
= new List<CompanyContentInfo>();
|
||||
#endregion
|
||||
}
|
||||
}
|
29
Hushian.Domain/Entites/CompanyContentInfo.cs
Normal file
29
Hushian.Domain/Entites/CompanyContentInfo.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class CompanyContentInfo : BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
public int CompanyID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public string Content { get; set; }
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("CompanyID")]
|
||||
public Company company { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
40
Hushian.Domain/Entites/Conversation.cs
Normal file
40
Hushian.Domain/Entites/Conversation.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Common.Enums;
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class Conversation : BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
public int CompanyID { get; set; }
|
||||
public int UserID { get; set; }
|
||||
public int? GroupID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public string Title { get; set; }
|
||||
public ConversationStatus Status { get; set; }
|
||||
public DateTime? FinishedDateTime { get; set; }
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("CompanyID")]
|
||||
public Company Company { get; set; }
|
||||
[ForeignKey("UserID")]
|
||||
public User User { get; set; }
|
||||
[ForeignKey("GroupID")]
|
||||
public Group? Group { get; set; }
|
||||
public ICollection<ConversationItem> conversationItems { get; set; }
|
||||
= new List<ConversationItem>();
|
||||
#endregion
|
||||
}
|
||||
}
|
41
Hushian.Domain/Entites/ConversationItem.cs
Normal file
41
Hushian.Domain/Entites/ConversationItem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Common.Enums;
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class ConversationItem : BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
public int ConversationID { get; set; }
|
||||
public string? ExperID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public bool IsRead { get; set; } = false;
|
||||
public ConversationType Type { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string? FileName { get; set; }
|
||||
public string? FileType { get; set; }
|
||||
public byte[]? FileContent { get; set; }
|
||||
public DateTime? ReadDateTime { get; set; }
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("ConversationID")]
|
||||
public Conversation conversation { get; set; }
|
||||
|
||||
[ForeignKey("ExperID")]
|
||||
public Exper? Exper { get; set; }
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
35
Hushian.Domain/Entites/Exper.cs
Normal file
35
Hushian.Domain/Entites/Exper.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class Exper : BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
public int CompanyID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
|
||||
public string FullName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Available { get; set; } = true;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("CompanyID")]
|
||||
public Company Company { get; set; }
|
||||
public ICollection<ExperGroup> EG { get; set; }
|
||||
= new List<ExperGroup>();
|
||||
#endregion
|
||||
}
|
||||
}
|
30
Hushian.Domain/Entites/ExperGroup.cs
Normal file
30
Hushian.Domain/Entites/ExperGroup.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class ExperGroup
|
||||
{
|
||||
#region Key
|
||||
public int ExperID { get; set; }
|
||||
public int GroupID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("ExperID")]
|
||||
public Exper Exper { get; set; }
|
||||
[ForeignKey("GroupID")]
|
||||
public Group Group { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
31
Hushian.Domain/Entites/Group.cs
Normal file
31
Hushian.Domain/Entites/Group.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class Group:BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
public int CompanyID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
public string Name { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
[ForeignKey("CompanyID")]
|
||||
public Company Company { get; set; }
|
||||
public ICollection<ExperGroup> EG { get; set; }
|
||||
= new List<ExperGroup>();
|
||||
#endregion
|
||||
}
|
||||
}
|
28
Hushian.Domain/Entites/User.cs
Normal file
28
Hushian.Domain/Entites/User.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Hushian.Domain.Abstracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Domain.Entites
|
||||
{
|
||||
public class User:BaseEntity
|
||||
{
|
||||
#region Key
|
||||
public int ID { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Fild
|
||||
public DateTime Cdatetime
|
||||
{ get; set; } = DateTime.Now;
|
||||
public string? FullName { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Navigation
|
||||
public ICollection<Conversation> Conversations { get; set; }
|
||||
= new List<Conversation>();
|
||||
#endregion
|
||||
}
|
||||
}
|
13
Hushian.Domain/Hushian.Domain.csproj
Normal file
13
Hushian.Domain/Hushian.Domain.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
42
Hushian.sln
42
Hushian.sln
@@ -3,10 +3,52 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35818.85 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hushian.Application", "Hushian.Application\Hushian.Application.csproj", "{E080DBF2-2DD1-4F88-A091-483C6793E112}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hushian.Domain", "Hushian.Domain\Hushian.Domain.csproj", "{1D284010-6533-44B4-A1BC-CE0AA0F90BFE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hushian.Infrastructure", "Infrastructure\Infrastructure\Hushian.Infrastructure.csproj", "{E2FC6095-8D42-4DD6-9425-8343B73CB452}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hushian.Persistence", "Infrastructure\Persistence\Hushian.Persistence.csproj", "{05D292C2-BB17-4524-B1F2-8A2B6B213C6A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{5E4ECC9D-90EB-4A5E-9308-99E359978FAE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E080DBF2-2DD1-4F88-A091-483C6793E112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E080DBF2-2DD1-4F88-A091-483C6793E112}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E080DBF2-2DD1-4F88-A091-483C6793E112}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E080DBF2-2DD1-4F88-A091-483C6793E112}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D284010-6533-44B4-A1BC-CE0AA0F90BFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D284010-6533-44B4-A1BC-CE0AA0F90BFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D284010-6533-44B4-A1BC-CE0AA0F90BFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D284010-6533-44B4-A1BC-CE0AA0F90BFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E2FC6095-8D42-4DD6-9425-8343B73CB452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E2FC6095-8D42-4DD6-9425-8343B73CB452}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E2FC6095-8D42-4DD6-9425-8343B73CB452}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E2FC6095-8D42-4DD6-9425-8343B73CB452}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5E4ECC9D-90EB-4A5E-9308-99E359978FAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5E4ECC9D-90EB-4A5E-9308-99E359978FAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5E4ECC9D-90EB-4A5E-9308-99E359978FAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5E4ECC9D-90EB-4A5E-9308-99E359978FAE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{E2FC6095-8D42-4DD6-9425-8343B73CB452} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{05D292C2-BB17-4524-B1F2-8A2B6B213C6A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F0E59B62-9EDF-47DC-AAFD-F841443D0AAE}
|
||||
EndGlobalSection
|
||||
|
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
124
Infrastructure/Persistence/GenericRepository.cs
Normal file
124
Infrastructure/Persistence/GenericRepository.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Hushian.Application.Contracts.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hushian.Persistence.Repositories
|
||||
{
|
||||
public class GenericRepository<T> : IGenericRepository<T> where T : class
|
||||
{
|
||||
private readonly HushianDbContext _context;
|
||||
private readonly DbSet<T> _query;
|
||||
|
||||
public GenericRepository(HushianDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_query = _context.Set<T>();
|
||||
}
|
||||
public async Task<T?> ADD(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _context.AddAsync(entity);
|
||||
if ((await _context.SaveChangesAsync() == 1))
|
||||
return entity;
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> ADDBool(T entity)
|
||||
{
|
||||
await _context.AddAsync(entity);
|
||||
return (await _context.SaveChangesAsync() == 1);
|
||||
}
|
||||
public async Task<ICollection<T>> ADD(ICollection<T> entities)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _context.AddRangeAsync(entities);
|
||||
if ((await _context.SaveChangesAsync() == entities.Count()))
|
||||
return entities;
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<T?> UPDATE(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
if ((await _context.SaveChangesAsync() == 1))
|
||||
return entity;
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> UPDATEBool(T entity)
|
||||
{
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
return (await _context.SaveChangesAsync() == 1);
|
||||
}
|
||||
public async Task<ICollection<T>> UPDATE(ICollection<T> entities)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
_context.Entry(entity).State = EntityState.Modified;
|
||||
|
||||
if ((await _context.SaveChangesAsync()) == entities.Count())
|
||||
return entities;
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async Task<bool> DELETE(T entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Set<T>().Remove(entity);
|
||||
return (await _context.SaveChangesAsync() == 1);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<bool> DELETE(ICollection<T> entities)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Set<T>().RemoveRange(entities);
|
||||
return (await _context.SaveChangesAsync() == entities.Count());
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public IQueryable<T> Get()
|
||||
{
|
||||
//No track
|
||||
return _query.AsNoTracking().AsQueryable();
|
||||
}
|
||||
}
|
||||
}
|
21
Infrastructure/Persistence/Hushian.Persistence.csproj
Normal file
21
Infrastructure/Persistence/Hushian.Persistence.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Hushian.Application\Hushian.Application.csproj" />
|
||||
<ProjectReference Include="..\..\Hushian.Domain\Hushian.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
36
Infrastructure/Persistence/HushianDbContext.cs
Normal file
36
Infrastructure/Persistence/HushianDbContext.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Hushian.Domain.Entites;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
namespace Hushian.Persistence
|
||||
{
|
||||
public class HushianDbContext : DbContext
|
||||
{
|
||||
public HushianDbContext(DbContextOptions<HushianDbContext> options)
|
||||
:base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Table
|
||||
public DbSet<Company> Companies { get; set; }
|
||||
public DbSet<Conversation> Conversations { get; set; }
|
||||
public DbSet<ConversationItem> ConversationItems { get; set; }
|
||||
public DbSet<Group> Groups { get; set; }
|
||||
public DbSet<Exper> Expers { get; set; }
|
||||
public DbSet<ExperGroup> EG { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
#endregion
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<ExperGroup>().HasKey(c => new { c.ExperID, c.GroupID });
|
||||
|
||||
modelBuilder
|
||||
.ApplyConfigurationsFromAssembly(typeof(HushianDbContext).Assembly);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
using Hushian.Application.Contracts.Persistence;
|
||||
using Hushian.Persistence.Repositories;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hushian.Persistence
|
||||
{
|
||||
public static class PersistenceServicesRegistration
|
||||
{
|
||||
public static IServiceCollection ConfigurePersistenceServices(this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
services.AddDbContext<HushianDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(configuration
|
||||
.GetConnectionString("MainConnectionString"));
|
||||
});
|
||||
services.AddScoped(typeof(IGenericRepository<>), typeof(GenericRepository<>));
|
||||
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user