Compare commits

1 Commits

Author SHA1 Message Date
mmrbnjd
214112a92a ... 2025-10-24 14:26:20 +03:30
21 changed files with 559 additions and 2893 deletions

View File

@@ -411,10 +411,9 @@ namespace Hushian.Application.Services
}
return false;
}
public async Task<ResponseBase<ChatItemDto>> GetLastOpenChatInCompany(int CompanyID, int UserID)
public async Task<ChatItemDto?> GetLastOpenChatInCompany(int CompanyID, int UserID)
{
ResponseBase<ChatItemDto> Response = new();
Response.Value = await _ConversationRepository.Get()
return await _ConversationRepository.Get()
.Include(inc => inc.Group)
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
.Where(w => w.UserID == UserID && w.CompanyID == CompanyID && w.Status != ConversationStatus.Finished)
@@ -449,13 +448,11 @@ namespace Hushian.Application.Services
}).FirstOrDefaultAsync();
if (Response.Value != null) Response.Success = true;
return Response;
}
public async Task<ResponseBase<ChatItemDto>> GetChat(int ChatID, int UserID)
public async Task<ChatItemDto?> GetChat(int ChatID, int UserID)
{
ResponseBase<ChatItemDto> Response = new();
Response.Value = await _ConversationRepository.Get()
return await _ConversationRepository.Get()
.Include(inc => inc.Group)
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
.Where(w => w.UserID == UserID && w.ID == ChatID)
@@ -490,8 +487,7 @@ namespace Hushian.Application.Services
}).FirstOrDefaultAsync();
if (Response.Value != null) Response.Success = true;
return Response;
}
public async Task WriteInHubFromCompany(ChatItemResponseDto item, string ToUser)
{
@@ -524,5 +520,22 @@ namespace Hushian.Application.Services
.SendAsync("NewChat", CompanyID);
}
public async Task<(int, int)?> GetLastChat(int UserID)
{
int companyid = 0;
var request = _ConversationRepository.Get()
.Include(inc => inc.Group)
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
.Where(w => w.UserID == UserID)
.OrderByDescending(o => o.ID);
var item1=await request.Select(s => s.ID).FirstOrDefaultAsync();
if (item1 == null) return null;
else
{
companyid = await request.Select(s => s.CompanyID).FirstOrDefaultAsync();
}
return (item1,companyid);
}
}
}

View File

@@ -1,425 +0,0 @@
// <auto-generated />
using System;
using Hushian.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250724132732_InitalDB")]
partial class InitalDB
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullNameManager")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("Verified")
.HasColumnType("bit");
b.Property<string>("WebSite")
.HasColumnType("nvarchar(max)");
b.Property<bool>("allowBot")
.HasColumnType("bit");
b.Property<byte[]>("logo")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.ToTable("Companies");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("CompanyContentInfo");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<DateTime?>("FinishedDateTime")
.HasColumnType("datetime2");
b.Property<int?>("GroupID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.HasIndex("GroupID");
b.HasIndex("UserID");
b.ToTable("Conversations");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("ConversationID")
.HasColumnType("int");
b.Property<int?>("ExperID")
.HasColumnType("int");
b.Property<byte[]>("FileContent")
.HasColumnType("varbinary(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileType")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsRead")
.HasColumnType("bit");
b.Property<DateTime?>("ReadDateTime")
.HasColumnType("datetime2");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConversationID");
b.HasIndex("ExperID");
b.ToTable("ConversationItems");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Expers");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.Property<int>("ExperID")
.HasColumnType("int");
b.Property<int>("GroupID")
.HasColumnType("int");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.HasKey("ExperID", "GroupID");
b.HasIndex("GroupID");
b.ToTable("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Info")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("img")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("FullName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Users");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "company")
.WithMany("CompanyContentInfos")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Conversations")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany()
.HasForeignKey("GroupID");
b.HasOne("Hushian.Domain.Entites.User", "User")
.WithMany("Conversations")
.HasForeignKey("UserID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.HasOne("Hushian.Domain.Entites.Conversation", "conversation")
.WithMany("ConversationResponses")
.HasForeignKey("ConversationID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany()
.HasForeignKey("ExperID");
b.Navigation("Exper");
b.Navigation("conversation");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Expers")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany("EG")
.HasForeignKey("ExperID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany("EG")
.HasForeignKey("GroupID")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("Exper");
b.Navigation("Group");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Groups")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Navigation("CompanyContentInfos");
b.Navigation("Conversations");
b.Navigation("Expers");
b.Navigation("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Navigation("ConversationResponses");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Navigation("Conversations");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,425 +0,0 @@
// <auto-generated />
using System;
using Hushian.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250724140236_changetbeg")]
partial class changetbeg
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullNameManager")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("Verified")
.HasColumnType("bit");
b.Property<string>("WebSite")
.HasColumnType("nvarchar(max)");
b.Property<bool>("allowBot")
.HasColumnType("bit");
b.Property<byte[]>("logo")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.ToTable("Companies");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("CompanyContentInfo");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<DateTime?>("FinishedDateTime")
.HasColumnType("datetime2");
b.Property<int?>("GroupID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.HasIndex("GroupID");
b.HasIndex("UserID");
b.ToTable("Conversations");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("ConversationID")
.HasColumnType("int");
b.Property<int?>("ExperID")
.HasColumnType("int");
b.Property<byte[]>("FileContent")
.HasColumnType("varbinary(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileType")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsRead")
.HasColumnType("bit");
b.Property<DateTime?>("ReadDateTime")
.HasColumnType("datetime2");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConversationID");
b.HasIndex("ExperID");
b.ToTable("ConversationItems");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Expers");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.Property<int>("ExperID")
.HasColumnType("int");
b.Property<int>("GroupID")
.HasColumnType("int");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.HasKey("ExperID", "GroupID");
b.HasIndex("GroupID");
b.ToTable("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Info")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("img")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("FullName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Users");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "company")
.WithMany("CompanyContentInfos")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Conversations")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany()
.HasForeignKey("GroupID");
b.HasOne("Hushian.Domain.Entites.User", "User")
.WithMany("Conversations")
.HasForeignKey("UserID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.HasOne("Hushian.Domain.Entites.Conversation", "conversation")
.WithMany("ConversationResponses")
.HasForeignKey("ConversationID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany()
.HasForeignKey("ExperID");
b.Navigation("Exper");
b.Navigation("conversation");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Expers")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany("EG")
.HasForeignKey("ExperID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany("EG")
.HasForeignKey("GroupID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.Navigation("Exper");
b.Navigation("Group");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Groups")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Navigation("CompanyContentInfos");
b.Navigation("Conversations");
b.Navigation("Expers");
b.Navigation("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Navigation("ConversationResponses");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Navigation("Conversations");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,41 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class changetbeg : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EG_Expers_ExperID",
table: "EG");
migrationBuilder.AddForeignKey(
name: "FK_EG_Expers_ExperID",
table: "EG",
column: "ExperID",
principalTable: "Expers",
principalColumn: "ID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EG_Expers_ExperID",
table: "EG");
migrationBuilder.AddForeignKey(
name: "FK_EG_Expers_ExperID",
table: "EG",
column: "ExperID",
principalTable: "Expers",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -1,452 +0,0 @@
// <auto-generated />
using System;
using Hushian.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250724183709_tbverification")]
partial class tbverification
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullNameManager")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("Verified")
.HasColumnType("bit");
b.Property<string>("WebSite")
.HasColumnType("nvarchar(max)");
b.Property<bool>("allowBot")
.HasColumnType("bit");
b.Property<byte[]>("logo")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.ToTable("Companies");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("CompanyContentInfo");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<DateTime?>("FinishedDateTime")
.HasColumnType("datetime2");
b.Property<int?>("GroupID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.HasIndex("GroupID");
b.HasIndex("UserID");
b.ToTable("Conversations");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("ConversationID")
.HasColumnType("int");
b.Property<int?>("ExperID")
.HasColumnType("int");
b.Property<byte[]>("FileContent")
.HasColumnType("varbinary(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileType")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsRead")
.HasColumnType("bit");
b.Property<DateTime?>("ReadDateTime")
.HasColumnType("datetime2");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConversationID");
b.HasIndex("ExperID");
b.ToTable("ConversationItems");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Expers");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.Property<int>("ExperID")
.HasColumnType("int");
b.Property<int>("GroupID")
.HasColumnType("int");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.HasKey("ExperID", "GroupID");
b.HasIndex("GroupID");
b.ToTable("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Info")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("img")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("FullName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Users");
});
modelBuilder.Entity("Identity.Models.VerificationCode", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.ToTable("verificationCodes");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "company")
.WithMany("CompanyContentInfos")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Conversations")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany()
.HasForeignKey("GroupID");
b.HasOne("Hushian.Domain.Entites.User", "User")
.WithMany("Conversations")
.HasForeignKey("UserID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.HasOne("Hushian.Domain.Entites.Conversation", "conversation")
.WithMany("ConversationResponses")
.HasForeignKey("ConversationID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany()
.HasForeignKey("ExperID");
b.Navigation("Exper");
b.Navigation("conversation");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Expers")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany("EG")
.HasForeignKey("ExperID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany("EG")
.HasForeignKey("GroupID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.Navigation("Exper");
b.Navigation("Group");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Groups")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Navigation("CompanyContentInfos");
b.Navigation("Conversations");
b.Navigation("Expers");
b.Navigation("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Navigation("ConversationResponses");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Navigation("Conversations");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,38 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class tbverification : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "verificationCodes",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<int>(type: "int", nullable: false),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
Mobile = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_verificationCodes", x => x.ID);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "verificationCodes");
}
}
}

View File

@@ -1,490 +0,0 @@
// <auto-generated />
using System;
using Hushian.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250815213829_tbpromt")]
partial class tbpromt
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullNameManager")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("Verified")
.HasColumnType("bit");
b.Property<string>("WebSite")
.HasColumnType("nvarchar(max)");
b.Property<bool>("allowBot")
.HasColumnType("bit");
b.Property<byte[]>("logo")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.ToTable("Companies");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("CompanyContentInfo");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<DateTime?>("FinishedDateTime")
.HasColumnType("datetime2");
b.Property<int?>("GroupID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.HasIndex("GroupID");
b.HasIndex("UserID");
b.ToTable("Conversations");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("ConversationID")
.HasColumnType("int");
b.Property<int?>("ExperID")
.HasColumnType("int");
b.Property<byte[]>("FileContent")
.HasColumnType("varbinary(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileType")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsRead")
.HasColumnType("bit");
b.Property<DateTime?>("ReadDateTime")
.HasColumnType("datetime2");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConversationID");
b.HasIndex("ExperID");
b.ToTable("ConversationItems");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Expers");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.Property<int>("ExperID")
.HasColumnType("int");
b.Property<int>("GroupID")
.HasColumnType("int");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.HasKey("ExperID", "GroupID");
b.HasIndex("GroupID");
b.ToTable("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Info")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("img")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Test")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("prompts");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("FullName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Users");
});
modelBuilder.Entity("Identity.Models.VerificationCode", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.ToTable("verificationCodes");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "company")
.WithMany("CompanyContentInfos")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Conversations")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany()
.HasForeignKey("GroupID");
b.HasOne("Hushian.Domain.Entites.User", "User")
.WithMany("Conversations")
.HasForeignKey("UserID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.HasOne("Hushian.Domain.Entites.Conversation", "conversation")
.WithMany("ConversationResponses")
.HasForeignKey("ConversationID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany()
.HasForeignKey("ExperID");
b.Navigation("Exper");
b.Navigation("conversation");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Expers")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany("EG")
.HasForeignKey("ExperID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany("EG")
.HasForeignKey("GroupID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.Navigation("Exper");
b.Navigation("Group");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Groups")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("prompts")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Navigation("CompanyContentInfos");
b.Navigation("Conversations");
b.Navigation("Expers");
b.Navigation("Groups");
b.Navigation("prompts");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Navigation("ConversationResponses");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Navigation("Conversations");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,48 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class tbpromt : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "prompts",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false),
CompanyID = table.Column<int>(type: "int", nullable: false),
Test = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_prompts", x => x.ID);
table.ForeignKey(
name: "FK_prompts_Companies_CompanyID",
column: x => x.CompanyID,
principalTable: "Companies",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_prompts_CompanyID",
table: "prompts",
column: "CompanyID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "prompts");
}
}
}

View File

@@ -1,520 +0,0 @@
// <auto-generated />
using System;
using Hushian.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250817205731_newtable")]
partial class newtable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Hushian.Domain.Entites.AIA", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Request")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Response")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.ToTable("AIAs");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullNameManager")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("Verified")
.HasColumnType("bit");
b.Property<string>("WebSite")
.HasColumnType("nvarchar(max)");
b.Property<bool>("allowBot")
.HasColumnType("bit");
b.Property<byte[]>("logo")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.ToTable("Companies");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("CompanyContentInfo");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<DateTime?>("FinishedDateTime")
.HasColumnType("datetime2");
b.Property<int?>("GroupID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("UserID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.HasIndex("GroupID");
b.HasIndex("UserID");
b.ToTable("Conversations");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("ConversationID")
.HasColumnType("int");
b.Property<int?>("ExperID")
.HasColumnType("int");
b.Property<byte[]>("FileContent")
.HasColumnType("varbinary(max)");
b.Property<string>("FileName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FileType")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsRead")
.HasColumnType("bit");
b.Property<DateTime?>("ReadDateTime")
.HasColumnType("datetime2");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConversationID");
b.HasIndex("ExperID");
b.ToTable("ConversationItems");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Expers");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.Property<int>("ExperID")
.HasColumnType("int");
b.Property<int>("GroupID")
.HasColumnType("int");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.HasKey("ExperID", "GroupID");
b.HasIndex("GroupID");
b.ToTable("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<bool>("Available")
.HasColumnType("bit");
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Info")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("img")
.HasColumnType("varbinary(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("Groups");
});
modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<int>("CompanyID")
.HasColumnType("int");
b.Property<string>("Test")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.HasIndex("CompanyID");
b.ToTable("prompts");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("FullName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Users");
});
modelBuilder.Entity("Identity.Models.VerificationCode", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("Cdatetime")
.HasColumnType("datetime2");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("ID");
b.ToTable("verificationCodes");
});
modelBuilder.Entity("Hushian.Domain.Entites.CompanyContentInfo", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "company")
.WithMany("CompanyContentInfos")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Conversations")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany()
.HasForeignKey("GroupID");
b.HasOne("Hushian.Domain.Entites.User", "User")
.WithMany("Conversations")
.HasForeignKey("UserID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
b.Navigation("Group");
b.Navigation("User");
});
modelBuilder.Entity("Hushian.Domain.Entites.ConversationResponse", b =>
{
b.HasOne("Hushian.Domain.Entites.Conversation", "conversation")
.WithMany("ConversationResponses")
.HasForeignKey("ConversationID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany()
.HasForeignKey("ExperID");
b.Navigation("Exper");
b.Navigation("conversation");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Expers")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.ExperGroup", b =>
{
b.HasOne("Hushian.Domain.Entites.Exper", "Exper")
.WithMany("EG")
.HasForeignKey("ExperID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.HasOne("Hushian.Domain.Entites.Group", "Group")
.WithMany("EG")
.HasForeignKey("GroupID")
.OnDelete(DeleteBehavior.ClientCascade)
.IsRequired();
b.Navigation("Exper");
b.Navigation("Group");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("Groups")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Prompt", b =>
{
b.HasOne("Hushian.Domain.Entites.Company", "Company")
.WithMany("prompts")
.HasForeignKey("CompanyID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("Hushian.Domain.Entites.Company", b =>
{
b.Navigation("CompanyContentInfos");
b.Navigation("Conversations");
b.Navigation("Expers");
b.Navigation("Groups");
b.Navigation("prompts");
});
modelBuilder.Entity("Hushian.Domain.Entites.Conversation", b =>
{
b.Navigation("ConversationResponses");
});
modelBuilder.Entity("Hushian.Domain.Entites.Exper", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.Group", b =>
{
b.Navigation("EG");
});
modelBuilder.Entity("Hushian.Domain.Entites.User", b =>
{
b.Navigation("Conversations");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,39 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class newtable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AIAs",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false),
CompanyID = table.Column<int>(type: "int", nullable: false),
UserID = table.Column<int>(type: "int", nullable: false),
Request = table.Column<string>(type: "nvarchar(max)", nullable: false),
Response = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AIAs", x => x.ID);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AIAs");
}
}
}

View File

@@ -1,61 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class chngrtbai : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "UserID",
table: "AIAs");
migrationBuilder.AddColumn<string>(
name: "aiKeyUser",
table: "AIAs",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
migrationBuilder.CreateIndex(
name: "IX_AIAs_CompanyID",
table: "AIAs",
column: "CompanyID");
migrationBuilder.AddForeignKey(
name: "FK_AIAs_Companies_CompanyID",
table: "AIAs",
column: "CompanyID",
principalTable: "Companies",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AIAs_Companies_CompanyID",
table: "AIAs");
migrationBuilder.DropIndex(
name: "IX_AIAs_CompanyID",
table: "AIAs");
migrationBuilder.DropColumn(
name: "aiKeyUser",
table: "AIAs");
migrationBuilder.AddColumn<int>(
name: "UserID",
table: "AIAs",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Hushian.Persistence.Migrations
{
[DbContext(typeof(HushianDbContext))]
[Migration("20250818094257_chngrtbai")]
partial class chngrtbai
[Migration("20251023075422_Newdb")]
partial class Newdb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Hushian.Persistence.Migrations
{
/// <inheritdoc />
public partial class InitalDB : Migration
public partial class Newdb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -49,6 +49,45 @@ namespace Hushian.Persistence.Migrations
table.PrimaryKey("PK_Users", x => x.ID);
});
migrationBuilder.CreateTable(
name: "verificationCodes",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Type = table.Column<int>(type: "int", nullable: false),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
Mobile = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_verificationCodes", x => x.ID);
});
migrationBuilder.CreateTable(
name: "AIAs",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false),
CompanyID = table.Column<int>(type: "int", nullable: false),
aiKeyUser = table.Column<string>(type: "nvarchar(max)", nullable: false),
Request = table.Column<string>(type: "nvarchar(max)", nullable: false),
Response = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AIAs", x => x.ID);
table.ForeignKey(
name: "FK_AIAs_Companies_CompanyID",
column: x => x.CompanyID,
principalTable: "Companies",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CompanyContentInfo",
columns: table => new
@@ -118,6 +157,27 @@ namespace Hushian.Persistence.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "prompts",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Cdatetime = table.Column<DateTime>(type: "datetime2", nullable: false),
CompanyID = table.Column<int>(type: "int", nullable: false),
Test = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_prompts", x => x.ID);
table.ForeignKey(
name: "FK_prompts_Companies_CompanyID",
column: x => x.CompanyID,
principalTable: "Companies",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Conversations",
columns: table => new
@@ -168,8 +228,7 @@ namespace Hushian.Persistence.Migrations
name: "FK_EG_Expers_ExperID",
column: x => x.ExperID,
principalTable: "Expers",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
principalColumn: "ID");
table.ForeignKey(
name: "FK_EG_Groups_GroupID",
column: x => x.GroupID,
@@ -210,6 +269,11 @@ namespace Hushian.Persistence.Migrations
principalColumn: "ID");
});
migrationBuilder.CreateIndex(
name: "IX_AIAs_CompanyID",
table: "AIAs",
column: "CompanyID");
migrationBuilder.CreateIndex(
name: "IX_CompanyContentInfo_CompanyID",
table: "CompanyContentInfo",
@@ -254,11 +318,19 @@ namespace Hushian.Persistence.Migrations
name: "IX_Groups_CompanyID",
table: "Groups",
column: "CompanyID");
migrationBuilder.CreateIndex(
name: "IX_prompts_CompanyID",
table: "prompts",
column: "CompanyID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AIAs");
migrationBuilder.DropTable(
name: "CompanyContentInfo");
@@ -268,6 +340,12 @@ namespace Hushian.Persistence.Migrations
migrationBuilder.DropTable(
name: "EG");
migrationBuilder.DropTable(
name: "prompts");
migrationBuilder.DropTable(
name: "verificationCodes");
migrationBuilder.DropTable(
name: "Conversations");

View File

@@ -50,7 +50,18 @@ namespace Hushian.WebApi.Controllers.v1
int UserID = Convert.ToInt32(strUserID);
var response = await _chatService.GetLastOpenChatInCompany(CompanyID,UserID);
return response.Success ? Ok(response.Value) : Accepted() ;
return Ok(response);
}
[HttpGet("User/LastChat")]
[Authorize(Roles = "User")]
public async Task<ActionResult> GetLastChat()
{
string strUserID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
int UserID = Convert.ToInt32(strUserID);
var response = await _chatService.GetLastChat(UserID);
return Ok(response);
}
[HttpGet("User/Chat/{ChatID}")]
@@ -61,7 +72,7 @@ namespace Hushian.WebApi.Controllers.v1
int UserID = Convert.ToInt32(strUserID);
var response = await _chatService.GetChat(ChatID, UserID);
return response.Success ? Ok(response.Value) : Accepted();
return response==null ? NotFound() : Ok(response);
}
[HttpGet("ChatsAwaitingOurResponse")]

View File

@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"MainConnectionString": "Data Source=156.255.1.229;Initial Catalog=Hushian;User ID=sa;Password=SAPassw0rd;TrustServerCertificate=True"
"MainConnectionString": "Data Source=156.255.1.229;Initial Catalog=HushianIR;User ID=sa;Password=SAPassw0rd;TrustServerCertificate=True"
},
"EmailSettings": {
"ApiKey": "SendGrid_Key_Here",

View File

@@ -1,7 +1,18 @@
@using Common.Validation
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject AuthService AuthService
@inject VerificationService verificationService;
@inject NavigationManager navigationManager;
@page "/UserPanelLogin"
@layout UserPanelLayout
@inject ILocalStorageService localStorageService;
@inject ChatService chatService;
<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
<div class="login-container p-4 bg-white rounded shadow-sm" style="max-width: 400px; width: 100%;">
<div class="text-center mb-4">
<h4 class="text-primary mb-2">ورود به سیستم</h4>
</div>
<div class="login-form">
<div class="text-center mb-4">
<span class="badge bg-info p-2 rounded-pill">نیاز برای ارتباط با کارشناسان وارد شود</span>
@@ -70,11 +81,11 @@
}
</div>
</div>
</div>
</div>
@code {
private bool visible = false;
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public string Username { get; set; }
public int ID { get; set; } = 0;
private string _code = string.Empty;
@@ -144,7 +155,34 @@
{
visible = true;
if (await AuthService.Verificationlogin(ID, Code))
await OnMultipleOfThree.InvokeAsync();
{
int CompanyID = await localStorageService.GetItem<int>("CompanyID");
int GroupID = await localStorageService.GetItem<int>("GroupID");
int ChatID = await localStorageService.GetItem<int>("ChatID");
if (CompanyID==null || CompanyID == 0)
{
var response= await chatService.GetLastChat();
CompanyID = response.Value.Item2;
ChatID = response.Value.Item1;
//----------------------------------------
if (CompanyID!=null && CompanyID!=0) await localStorageService.SetItem("CompanyID", CompanyID);
if (ChatID!=null && ChatID!=0)
{
await localStorageService.RemoveItem("ChatID");
await localStorageService.SetItem("ChatID", ChatID);
}
}
string route = $"UserCP/{CompanyID}";
if (ChatID!=null && ChatID!=0) route += $"?ChatID={ChatID}";
if (GroupID!=null && GroupID!=0 && !(ChatID!=null && ChatID!=0)) route += $"?GroupID={GroupID}";
navigationManager.NavigateTo(route);
}
visible = false;
}
// private async Task MoveNext(ChangeEventArgs e)

View File

@@ -1,5 +1,4 @@
@page "/UserCP/{CompanyID:int}"
@page "/UserCP/{CompanyID:int}/{ChatID:int?}"
@using Common.Dtos.Company
@using Common.Dtos.Conversation
@using Common.Dtos.Group
@@ -13,6 +12,7 @@
{
<PageTitle>گفتگو با @CompanyInfo?.FullName</PageTitle>
}
@implements IAsyncDisposable
@inject NavigationManager NavigationManager
@inject ChatService ChatService
@@ -27,22 +27,23 @@
@inject ToastService toastService
@inject HttpClient _Http;
@layout UserPanelLayout
<ConfirmDialog @ref="dialog" />
<div class="container-fluid">
<div class="row" style="height:85vh">
@if (IsEndFirstProcess)
{
@if (IsLogin)
if (string.IsNullOrEmpty(Error))
{
<div class="col-md-12 d-flex flex-column" id="B">
<div class="input-group">
@if (LastOpenChat != null)
@if (Chat != null)
{
<p type="text" class="form-control fw-bold text-primary" style="border:none;align-self: center;" aria-describedby="basic-addon1">@ExperYou</p>
}
<div class="d-flex gap-2 ms-auto">
@if (LastOpenChat != null)
@if (Chat != null)
{
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" @onclick="NewChat" Class="new-conversation-btn">
@@ -56,15 +57,15 @@
</div>
<!-- B1: Chat area -->
<div class="flex-fill chat-area-container" id="B1">
@if (LastOpenChat != null && LastOpenChat.Responses != null)
@if (Chat != null && Chat.Responses != null)
{
<div class="chat-container p-3">
@{
bool target = false;
}
@foreach (var msg in LastOpenChat?.Responses)
@foreach (var msg in Chat?.Responses)
{
@if (!target && ((!msg.IsRead && msg.Type != Common.Enums.ConversationType.UE) || LastOpenChat.Responses.Last() == msg))
@if (!target && ((!msg.IsRead && msg.Type != Common.Enums.ConversationType.UE) || Chat.Responses.Last() == msg))
{
target = true;
<div id="target" class="chat-separator">
@@ -77,8 +78,8 @@
</div>
}
<div class="d-flex mb-2 @(msg.Type!=Common.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")">
<div class="chat-bubble @(msg.Type!=Common.Enums.ConversationType.UE ? "chat-mine": "chat-other")" data-id="@msg.ID">
<div class="d-flex mb-2 @(msg.Type != Common.Enums.ConversationType.UE ? "justify-content-end" : "justify-content-start")">
<div class="chat-bubble @(msg.Type != Common.Enums.ConversationType.UE ? "chat-mine" : "chat-other")" data-id="@msg.ID">
@if (msg.FileContent != null && msg.FileContent.Length > 0 && !string.IsNullOrWhiteSpace(msg.FileType))
{
@if (msg.FileType.StartsWith("image/"))
@@ -137,10 +138,10 @@
<div class="groups-container mt-4">
<h6 class="text-center mb-3 text-muted">انتخاب گروه:</h6>
<div class="groups-grid">
@foreach (var group in CompanyGroups.Where(w=>w.Available))
@foreach (var group in CompanyGroups.Where(w => w.Available))
{
<div class="group-card @(GroupID == group.ID ? "selected" : "")"
@onclick="() => SelectGroup(group.ID)">
@onclick="() => SelectGroup(group.ID)">
<div class="group-card-content">
@if (group.img == null || group.img.Length == 0)
{
@@ -163,7 +164,7 @@
</div>
@if (CompanyInfo != null && (LastOpenChat == null || (LastOpenChat != null && LastOpenChat.status != Common.Enums.ConversationStatus.Finished && LastOpenChat.Responses != null)))
@if (CompanyInfo != null && (Chat == null || (Chat != null && Chat.status != Common.Enums.ConversationStatus.Finished && Chat.Responses != null)))
{
<!-- B2: Message input -->
<div class="message-input-container" id="B2">
@@ -175,13 +176,12 @@
</Button>
<!-- Audio Recording Button -->
<Button Color="@(IsRecording ? ButtonColor.Danger : ButtonColor.Secondary)"
Size=ButtonSize.Small
Outline="true"
@onclick="ToggleAudioRecording"
class=@($"audio-btn {(IsRecording ? "recording" : "")}")
title="@(IsRecording ? "توقف ضبط" : "ضبط صدا")"
>
<Button Color="@(IsRecording? ButtonColor.Danger: ButtonColor.Secondary)"
Size=ButtonSize.Small
Outline="true"
@onclick="ToggleAudioRecording"
class=@($"audio-btn {(IsRecording ? "recording" : "")}")
title="@(IsRecording ? "توقف ضبط" : "ضبط صدا")">
@if (IsRecording)
{
<Icon Name="IconName.StopCircle" Class="recording-pulse" />
@@ -235,7 +235,7 @@
</div>
@if (LastOpenChat!=null && LastOpenChat.status == Common.Enums.ConversationStatus.InProgress)
@if (Chat != null && Chat.status == Common.Enums.ConversationStatus.InProgress)
{
<Button Color="ButtonColor.Danger" Size=ButtonSize.ExtraSmall Outline="true" @onclick="CloseChat" Class="finish-conversation-btn">
<Icon Name="IconName.Escape" Class="me-1" /> اتمام گفتگو
@@ -243,23 +243,25 @@
}
}
@if (LastOpenChat.status == Common.Enums.ConversationStatus.Finished)
@if (Chat?.status == Common.Enums.ConversationStatus.Finished)
{
<p style="color: red;text-align: center;font-weight: bold;">این گفتگو به پایان رسیده</p>
}
</div>
}
else
{
<div class="d-flex justify-content-center align-items-center" style="height: 100%;">
<div class="login-container p-4 bg-white rounded shadow-sm" style="max-width: 400px; width: 100%;">
<div class="text-center mb-4">
<h4 class="text-primary mb-2">ورود به سیستم</h4>
</div>
<LoginComponent OnMultipleOfThree="EventCallback.Factory.Create(this, Afterlogin)" />
<div class="text-center">
<Alert Color="AlertColor.Danger" Dismissable="false">
<Icon Name="IconName.ExclamationTriangleFill" class="me-2"></Icon>@Error </Alert>
</div>
</div>
}
}
else
{
@@ -270,36 +272,17 @@
</div>
</div>
}
</div>
</div>
@code {
[Parameter] public int CompanyID { get; set; }
[Parameter] public int? ChatID { get; set; }
private ConfirmDialog dialog = default!;
private HubConnection? hubConnection;
#region fild
private bool IsEndFirstProcess { get; set; } = false;
private bool _shouldObserveVisibility = false;
int? GroupID = null;
ReadANDUpdate_CompanyDto? CompanyInfo = new();
Common.Dtos.CurrentUserInfo CurrentUser = new();
List<Read_GroupDto> CompanyGroups = new();
ChatItemDto? LastOpenChat = null;
string MsgInput = string.Empty;
IBrowserFile? SelectedImageFile = null;
byte[]? SelectedImageBytes = null;
string? SelectedImagePreview = null;
// Audio recording properties
bool IsRecording = false;
string RecordingTime = "00:00";
byte[]? RecordedAudioBytes = null;
string? RecordedAudioUrl = null;
string RecordedAudioDuration = "00:00";
private System.Threading.Timer? recordingTimer;
private DateTime recordingStartTime;
bool chatloading = false;
public bool IsLogin { get; set; } = false;
public bool IsEndFirstProcess { get; set; } = false;
string ExperYou
{
get
@@ -311,23 +294,57 @@
value += "/" + CompanyGroups.FirstOrDefault(f => f.ID == GroupID.GetValueOrDefault()).Name;
}
if (LastOpenChat != null && LastOpenChat.Responses!=null)
if (Chat != null && Chat.Responses != null)
{
var model = LastOpenChat.Responses.OrderBy(o => o.ID).LastOrDefault(l => l.Type != Common.Enums.ConversationType.UE);
var model = Chat.Responses.OrderBy(o => o.ID).LastOrDefault(l => l.Type != Common.Enums.ConversationType.UE);
if (model!=null && model.Type==Common.Enums.ConversationType.CU && !string.IsNullOrEmpty(CompanyInfo.FullNameManager))
if (model != null && model.Type == Common.Enums.ConversationType.CU && !string.IsNullOrEmpty(CompanyInfo.FullNameManager))
{
value += "/" + CompanyInfo.FullNameManager;
}
else
if (!string.IsNullOrEmpty(LastOpenChat.ExperFullName))
value += "/" + LastOpenChat.ExperFullName;
if (!string.IsNullOrEmpty(Chat.ExperFullName))
value += "/" + Chat.ExperFullName;
}
return value;
}
}
string Error = "";
#endregion
#region Image
IBrowserFile? SelectedImageFile = null;
byte[]? SelectedImageBytes = null;
string? SelectedImagePreview = null;
#endregion
#region Audio recording properties
bool IsRecording = false;
string RecordingTime = "00:00";
byte[]? RecordedAudioBytes = null;
string? RecordedAudioUrl = null;
string RecordedAudioDuration = "00:00";
private System.Threading.Timer? recordingTimer;
private DateTime recordingStartTime;
#endregion
#region Parameter
[Parameter] public int CompanyID { get; set; }
// Audio recording methods
[SupplyParameterFromQuery(Name = "ChatID")]
private int? ChatID { get; set; }
[SupplyParameterFromQuery(Name = "GroupID")]
private int? GroupID { get; set; }
#endregion
ConfirmDialog dialog = default!;
HubConnection? hubConnection;
ReadANDUpdate_CompanyDto? CompanyInfo = null;
Common.Dtos.CurrentUserInfo CurrentUser = new();
List<Read_GroupDto> CompanyGroups = new();
ChatItemDto? Chat = null;
}
@functions{
#region Audio recording methods
private async Task ToggleAudioRecording()
{
if (IsRecording)
@@ -416,271 +433,10 @@
? string.Empty
: $"data:{fileType};base64,{Convert.ToBase64String(content)}";
#endregion
}
@functions {
async Task OnClickSendMsg()
{
if (!string.IsNullOrEmpty(MsgInput) || SelectedImageFile != null || RecordedAudioBytes != null)
{
if (LastOpenChat != null)
{
Common.Enums.ConversationType type = Common.Enums.ConversationType.UE;
ChatItemResponseDto? model;
if (SelectedImageFile != null)
{
var bytes = SelectedImageBytes ?? Array.Empty<byte>();
model = await chatService.ADDChatResponse(
LastOpenChat.ID,
MsgInput,
type,
SelectedImageFile.Name,
SelectedImageFile.ContentType,
bytes);
}
else if (RecordedAudioBytes != null)
{
// Send audio message
var fileName = $"audio_{DateTimeOffset.Now.ToUnixTimeSeconds()}.wav";
model = await chatService.ADDChatResponse(
LastOpenChat.ID,
MsgInput,
type,
fileName,
"audio/wav",
RecordedAudioBytes);
}
else
{
model = await chatService.ADDChatResponse(LastOpenChat.ID, MsgInput, type);
}
LastOpenChat?.Responses.Add(model);
LastOpenChat.LastText = MsgInput;
}
else
{
//TODO New Chat
var model = await chatService.NewChatFromCurrentUser(new ADD_ConversationDto()
{
CompanyID = CompanyID,
GroupID = GroupID,
Question = MsgInput,
UserID = 0
});
if (model != null)
{
LastOpenChat = model;
}
else toastService.Notify(new ToastMessage(ToastType.Danger, "خطا در گفتگو جدید"));
}
await Task.Yield();
// Scroll to bottom for user's own messages
await JS.InvokeVoidAsync("scrollToBottom", "B1");
MsgInput = string.Empty;
SelectedImageFile = null;
SelectedImageBytes = null;
SelectedImagePreview = null;
// Clear recorded audio after sending
RecordedAudioBytes = null;
RecordedAudioUrl = null;
RecordedAudioDuration = "00:00";
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (_shouldObserveVisibility)
{
_shouldObserveVisibility = false;
await JS.InvokeVoidAsync("observeVisibility", DotNetObjectReference.Create(this));
}
}
protected override async Task OnInitializedAsync()
{
await IsOnline();
//-------------hub
var token = await localStorageService.GetItem<string>("U/key");
string AddressHub = _Http.BaseAddress.AbsoluteUri.Replace("api/", "");
hubConnection = new HubConnectionBuilder()
.WithUrl($"{AddressHub}chatNotificationHub", options =>
{
options.AccessTokenProvider = () => Task.FromResult(token);
})
.WithAutomaticReconnect()
.Build();
hubConnection.On<ChatItemResponseDto>("ReceiveNewChatItemFromCompany",async (chatitem) =>
{
if (LastOpenChat.ID == chatitem.ChatItemID)
{
LastOpenChat.Responses.Add(chatitem);
StateHasChanged();
await MarkAsRead(chatitem.ID);
// Scroll to target if exists, otherwise scroll to bottom
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
}
});
//-------------------------------------
hubConnection.On<int>("CheckMarkAsRead", async (chatresponseid) =>
{
if (LastOpenChat.Responses.Any(a=>a.ID==chatresponseid && !a.IsRead && a.Type==Common.Enums.ConversationType.UE))
{
LastOpenChat.Responses.First(a => a.ID == chatresponseid).IsRead = true;
StateHasChanged();
}
});
await hubConnection.StartAsync();
//---------end hub
await base.OnInitializedAsync();
}
async Task IsOnline()
{
var token = await localStorageService.GetItem<string>("U/key");
if (string.IsNullOrEmpty(token))
{
IsLogin = false;
IsEndFirstProcess = true;
}
else
{
await baseController.RemoveToken();
await baseController.SetToken(token);
if (!await authService.IsOnline())
{
await baseController.RemoveToken();
IsLogin = false;
IsEndFirstProcess = true;
}
else
{
IsEndFirstProcess = true;
await Afterlogin();
}
}
}
async Task Afterlogin()
{
IsLogin = true;
CurrentUser = await userService.GetCurrentUserInfo();
await IsCompany();
}
async Task IsCompany()
{
CompanyInfo = await companyService.GetCompany(CompanyID);
if (CompanyInfo != null)
{ CompanyGroups = await groupService.GetGroupsCompany(CompanyID);
await IsLastChat();}
}
async Task IsLastChat()
{
if (CompanyInfo != null)
{
if (ChatID.HasValue) LastOpenChat = await ChatService.Getchat(ChatID.GetValueOrDefault());
else LastOpenChat = LastOpenChat = await ChatService.GetLastOpenChatInCompany(CompanyID);
if (LastOpenChat != null)
{
GroupID = LastOpenChat.GroupID;
// Always set up visibility observation for chat bubbles
_shouldObserveVisibility = true;
StateHasChanged();
// Wait for render to complete
await Task.Delay(200);
// Scroll to target if exists, otherwise scroll to bottom
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
}
}
}
[JSInvokable]
public async Task MarkAsRead(int id)
{
if (LastOpenChat == null) return;
var msg = LastOpenChat.Responses.FirstOrDefault(m => m.ID == id);
if (msg != null && !msg.IsRead && msg.Type != Common.Enums.ConversationType.UE)
{
msg.IsRead = true;
await chatService.MarkAsReadChatItemAsync(id);
// StateHasChanged();
}
await Task.CompletedTask;
}
// Method to handle new messages from other users
public async Task HandleNewMessage()
{
if (LastOpenChat?.Responses != null)
{
var hasUnreadMessages = LastOpenChat.Responses.Any(m => !m.IsRead && m.Type != Common.Enums.ConversationType.UE);
if (hasUnreadMessages)
{
await JS.InvokeVoidAsync("autoScrollToNewMessage");
}
}
}
async Task NewChat()
{
LastOpenChat = null;
GroupID = null;
}
async Task CloseChat()
{
var options = new ConfirmDialogOptions
{
YesButtonText = "بله",
YesButtonColor = ButtonColor.Success,
NoButtonText = "انصراف",
NoButtonColor = ButtonColor.Danger
};
var confirmation = await dialog.ShowAsync(
title: "پایان دادن به گفتگو",
message1: "اطمینان دارید ؟",
confirmDialogOptions: options);
if (confirmation)
{
if (await chatService.ChatIsFinishFromUser(LastOpenChat.ID))
{
LastOpenChat.status = Common.Enums.ConversationStatus.Finished;
StateHasChanged();
}
}
}
async Task Logout()
{
await baseController.RemoveToken();
await localStorageService.RemoveItem("U/key");
IsLogin = false;
StateHasChanged();
}
async Task SelectGroup(int groupId)
{
GroupID = groupId;
StateHasChanged();
}
private string GetImageSource(byte[] bytes)
=> $"data:image/jpeg;base64,{Convert.ToBase64String(bytes)}";
private async Task HandleKeyDown(KeyboardEventArgs e)
{
if (e.Key == "Enter") await OnClickSendMsg();
}
}
@functions {
#region Image
private async Task OpenFileDialog()
{
await JS.InvokeVoidAsync("triggerClick", "chatImageInput");
@@ -701,7 +457,7 @@
await file.OpenReadStream().CopyToAsync(memoryStream);
SelectedImageBytes = memoryStream.ToArray();
SelectedImagePreview = $"data:{file.ContentType};base64,{Convert.ToBase64String(SelectedImageBytes)}";
await ClearRecordedAudio();
await ClearRecordedAudio();
}
private Task ClearSelectedImage()
@@ -727,6 +483,58 @@
}
return $"image_{DateTimeOffset.Now.ToUnixTimeSeconds()}{ext}";
}
private string GetImageSource(byte[] bytes)
=> $"data:image/jpeg;base64,{Convert.ToBase64String(bytes)}";
#endregion
}
@functions {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (_shouldObserveVisibility)
{
_shouldObserveVisibility = false;
await JS.InvokeVoidAsync("observeVisibility", DotNetObjectReference.Create(this));
}
}
protected override async Task OnInitializedAsync()
{
Error = string.Empty;
IsEndFirstProcess = false;
if (await CheckLogin())
{
await GetCurrentUser();
if (await ExsistCompany())
{
await GetGroups();
if (ChatID.HasValue) await GetChatByID();
else if (GroupID.HasValue && !await ExsistGroup()) Error = $"گروه با شناسه {GroupID.Value} یافت برای شرکت {CompanyInfo.FullName} یافت نشد";
else await GetLastChat();
}
else Error = $"شرکت با شناسه {CompanyID} یافت نشد";
}
else await Login();
if (Chat != null)
{
GroupID = Chat.GroupID;
_shouldObserveVisibility = true;
StateHasChanged();
await Task.Delay(200);
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
}
if (string.IsNullOrEmpty(Error))
{
await ConectedToHub();
}
IsEndFirstProcess = true;
await base.OnInitializedAsync();
}
public async ValueTask DisposeAsync()
{
if (hubConnection is not null)
@@ -736,6 +544,254 @@
}
}
}
@functions {
//Login
async Task<bool> CheckLogin()
{
var token = await localStorageService.GetItem<string>("U/key");
if (string.IsNullOrEmpty(token)) return false;
else
{
await baseController.RemoveToken();
await baseController.SetToken(token);
if (!await authService.IsOnline())
{
await baseController.RemoveToken();
return false;
}
else return true;
}
}
async Task Login()
{
await localStorageService.RemoveItem("CompanyID");
await localStorageService.RemoveItem("ChatID");
await localStorageService.RemoveItem("GroupID");
await localStorageService.SetItem("CompanyID", CompanyID);
if (ChatID.HasValue) await localStorageService.SetItem("ChatID", ChatID.Value);
if (GroupID.HasValue) await localStorageService.SetItem("GroupID",GroupID.Value);
NavigationManager.NavigateTo("UserPanelLogin");
}
async Task GetCurrentUser()
{
CurrentUser = await userService.GetCurrentUserInfo();
}
async Task<bool> ExsistCompany()
{
CompanyInfo = await companyService.GetCompany(CompanyID);
return CompanyInfo != null;
}
async Task GetGroups()
{
CompanyGroups = await groupService.GetGroupsCompany(CompanyID);
}
async Task<bool> ExsistGroup()
{
if (GroupID.HasValue) return (CompanyGroups.Count > 0 && CompanyGroups.Any(a => a.ID == GroupID.Value));
else return true;
}
async Task GetChatByID()
{
if (ChatID.HasValue) Chat = await ChatService.Getchat(ChatID.Value);
if (Chat == null)
{
Error = $"گفتگو با شناسه {ChatID.Value} یافت با شرکت {CompanyInfo.FullName} یافت نشد";
}
}
async Task GetLastChat()
{
Chat = await ChatService.GetLastOpenChatInCompany(CompanyID);
}
async Task OnClickSendMsg()
{
if (!string.IsNullOrEmpty(MsgInput) || SelectedImageFile != null || RecordedAudioBytes != null)
{
if (Chat != null)
{
Common.Enums.ConversationType type = Common.Enums.ConversationType.UE;
ChatItemResponseDto? model;
if (SelectedImageFile != null)
{
var bytes = SelectedImageBytes ?? Array.Empty<byte>();
model = await chatService.ADDChatResponse(
Chat.ID,
MsgInput,
type,
SelectedImageFile.Name,
SelectedImageFile.ContentType,
bytes);
}
else if (RecordedAudioBytes != null)
{
// Send audio message
var fileName = $"audio_{DateTimeOffset.Now.ToUnixTimeSeconds()}.wav";
model = await chatService.ADDChatResponse(
Chat.ID,
MsgInput,
type,
fileName,
"audio/wav",
RecordedAudioBytes);
}
else
{
model = await chatService.ADDChatResponse(Chat.ID, MsgInput, type);
}
Chat?.Responses.Add(model);
Chat.LastText = MsgInput;
}
else
{
//TODO New Chat
var model = await chatService.NewChatFromCurrentUser(new ADD_ConversationDto()
{
CompanyID = CompanyID,
GroupID = GroupID,
Question = MsgInput,
UserID = 0
});
if (model != null)
{
Chat = model;
}
else toastService.Notify(new ToastMessage(ToastType.Danger, "خطا در گفتگو جدید"));
}
await Task.Yield();
// Scroll to bottom for user's own messages
await JS.InvokeVoidAsync("scrollToBottom", "B1");
MsgInput = string.Empty;
SelectedImageFile = null;
SelectedImageBytes = null;
SelectedImagePreview = null;
// Clear recorded audio after sending
RecordedAudioBytes = null;
RecordedAudioUrl = null;
RecordedAudioDuration = "00:00";
}
}
async Task ConectedToHub()
{
//-------------hub
var token = await localStorageService.GetItem<string>("U/key");
string AddressHub = _Http.BaseAddress.AbsoluteUri.Replace("api/", "");
hubConnection = new HubConnectionBuilder()
.WithUrl($"{AddressHub}chatNotificationHub", options =>
{
options.AccessTokenProvider = () => Task.FromResult(token);
})
.WithAutomaticReconnect()
.Build();
hubConnection.On<ChatItemResponseDto>("ReceiveNewChatItemFromCompany", async (chatitem) =>
{
if (Chat.ID == chatitem.ChatItemID)
{
Chat.Responses.Add(chatitem);
StateHasChanged();
await MarkAsRead(chatitem.ID);
// Scroll to target if exists, otherwise scroll to bottom
await JS.InvokeVoidAsync("scrollToTargetOrBottom");
}
});
//-------------------------------------
hubConnection.On<int>("CheckMarkAsRead", async (chatresponseid) =>
{
if (Chat.Responses.Any(a => a.ID == chatresponseid && !a.IsRead && a.Type == Common.Enums.ConversationType.UE))
{
Chat.Responses.First(a => a.ID == chatresponseid).IsRead = true;
StateHasChanged();
}
});
await hubConnection.StartAsync();
//---------end hub
}
async Task SelectGroup(int groupId)
{
GroupID = groupId;
StateHasChanged();
}
[JSInvokable]
public async Task MarkAsRead(int id)
{
if (Chat == null) return;
var msg = Chat.Responses.FirstOrDefault(m => m.ID == id);
if (msg != null && !msg.IsRead && msg.Type != Common.Enums.ConversationType.UE)
{
msg.IsRead = true;
await chatService.MarkAsReadChatItemAsync(id);
// StateHasChanged();
}
await Task.CompletedTask;
}
// Method to handle new messages from other users
public async Task HandleNewMessage()
{
if (Chat?.Responses != null)
{
var hasUnreadMessages =Chat.Responses.Any(m => !m.IsRead && m.Type != Common.Enums.ConversationType.UE);
if (hasUnreadMessages)
{
await JS.InvokeVoidAsync("autoScrollToNewMessage");
}
}
}
async Task NewChat()
{
Chat = null;
GroupID = null;
}
async Task CloseChat()
{
var options = new ConfirmDialogOptions
{
YesButtonText = "بله",
YesButtonColor = ButtonColor.Success,
NoButtonText = "انصراف",
NoButtonColor = ButtonColor.Danger
};
var confirmation = await dialog.ShowAsync(
title: "پایان دادن به گفتگو",
message1: "اطمینان دارید ؟",
confirmDialogOptions: options);
if (confirmation)
{
if (await chatService.ChatIsFinishFromUser(Chat.ID))
{
Chat.status = Common.Enums.ConversationStatus.Finished;
StateHasChanged();
}
}
}
async Task Logout()
{
await baseController.RemoveToken();
await localStorageService.RemoveItem("U/key");
NavigationManager.NavigateTo("UserPanelLogin");
}
private async Task HandleKeyDown(KeyboardEventArgs e)
{
if (e.Key == "Enter") await OnClickSendMsg();
}
}
<style>
.chat-bubble {
padding: 0.5rem 0.75rem;

View File

@@ -142,16 +142,16 @@ namespace HushianWebApp.Service
}
else if (result.StatusCode == System.Net.HttpStatusCode.Forbidden)
_ToastService.Notify(new ToastMessage(ToastType.Danger, "به این بخش دسترسی ندارید"));
else if (result.StatusCode == System.Net.HttpStatusCode.NotFound)
{
string From ="" ;
//else if (result.StatusCode == System.Net.HttpStatusCode.NotFound)
//{
// string From ="" ;
if (result.RequestMessage.RequestUri.AbsolutePath.ToString().Contains("GetCompany")) From = "شرکت";
// if (result.RequestMessage.RequestUri.AbsolutePath.ToString().Contains("GetCompany")) From = "شرکت";
_ToastService.Notify(new ToastMessage(ToastType.Danger, $"{From} یافت نشد"));
//_ToastService.Notify(new ToastMessage(ToastType.Danger, $"{From} یافت نشد"));
}
else if (!result.IsSuccessStatusCode)
//}
else if (!result.IsSuccessStatusCode && (result.StatusCode != System.Net.HttpStatusCode.NotFound))
{
_NavigationManager.NavigateTo("Unhandled");

View File

@@ -113,11 +113,19 @@ namespace HushianWebApp.Service
{
var response = await _baseController.Get($"{BaseRoute}User/LastOpenChatInCompany/{CompanyID}");
if (response.StatusCode==System.Net.HttpStatusCode.OK)
return await response.Content.ReadFromJsonAsync<ChatItemDto>();
return await response.Content.ReadFromJsonAsync<ChatItemDto?>();
return null;
}
public async Task<ChatItemDto?> Getchat(int ChatID)
public async Task<(int,int)?> GetLastChat()
{
var response = await _baseController.Get($"{BaseRoute}User/LastChat");
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return await response.Content.ReadFromJsonAsync<(int, int)?>();
return null;
}
public async Task<ChatItemDto?> Getchat(int ChatID)
{
var response = await _baseController.Get($"{BaseRoute}User/Chat/{ChatID}");
if (response.StatusCode == System.Net.HttpStatusCode.OK)

View File

@@ -57,14 +57,15 @@ namespace HushianWebApp.Service
}
return null;
}
public async Task<List<Read_GroupDto>?> GetGroupsCompany(int CompanyID)
public async Task<List<Read_GroupDto>> GetGroupsCompany(int CompanyID)
{
var response = await _baseController.Get($"{BaseRoute}GetGroupsCompany?CompanyID={CompanyID}");
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<List<Read_GroupDto>>();
var data= await response.Content.ReadFromJsonAsync<List<Read_GroupDto>>();
return data==null ?new() : data;
}
return null;
return new();
}
public async Task<List<Read_GroupDto>?> GetGroupsFromExperID(int ExperID)
{

View File

@@ -1,5 +1,5 @@
{
"BaseAddress": "https://service.hushian.ir/api/",
"BaseAddress": "http://localhost:5089/api/",
"Logging": {
"LogLevel": {
"Default": "Information",