TaskAndTicket - Fine, reward.... - SubAccountRoll Create And edit - HeaderAndFooter
This commit is contained in:
@@ -10,11 +10,11 @@ using AccountManagement.Domain.MediaAgg;
|
||||
using AccountManagement.Domain.TaskAgg;
|
||||
using AccountManagement.Domain.TaskMediaAgg;
|
||||
using AccountManagement.Domain.TaskSubjectAgg;
|
||||
using TaskManager.Domain.PositionAgg;
|
||||
using AccountManagement.Domain.AdminResponseAgg;
|
||||
using AccountManagement.Domain.AdminResponseMediaAgg;
|
||||
using AccountManagement.Domain.ClientResponseAgg;
|
||||
using AccountManagement.Domain.ClientResponseMediaAgg;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using AccountManagement.Domain.TicketAgg;
|
||||
using AccountManagement.Domain.TicketMediasAgg;
|
||||
using AccountManagement.Domain.TaskMessageAgg;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using TaskManager.Domain.PositionAgg;
|
||||
|
||||
namespace TaskManager.Infrastructure.EFCore.Mapping;
|
||||
|
||||
|
||||
1254
AccountMangement.Infrastructure.EFCore/Migrations/20250111173142_AddIsDeleteToicket.Designer.cs
generated
Normal file
1254
AccountMangement.Infrastructure.EFCore/Migrations/20250111173142_AddIsDeleteToicket.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddIsDeleteToicket : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDeleted",
|
||||
table: "Tickets",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDeleted",
|
||||
table: "Tickets");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,6 +364,30 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
b.ToTable("Medias", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("PositionName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("PositionValue")
|
||||
.HasMaxLength(2)
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Positions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -800,6 +824,9 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("ntext");
|
||||
|
||||
b.Property<bool>("IsDeleted")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<long>("SenderId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
@@ -845,33 +872,9 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
b.ToTable("TicketMedias", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("PositionName")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<int>("PositionValue")
|
||||
.HasMaxLength(2)
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Positions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b =>
|
||||
{
|
||||
b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position")
|
||||
b.HasOne("AccountManagement.Domain.PositionAgg.Position", "Position")
|
||||
.WithMany("Accounts")
|
||||
.HasForeignKey("PositionId");
|
||||
|
||||
@@ -1187,6 +1190,11 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
b.Navigation("TicketMedias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.PositionAgg.Position", b =>
|
||||
{
|
||||
b.Navigation("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b =>
|
||||
{
|
||||
b.Navigation("Accounts");
|
||||
@@ -1237,11 +1245,6 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations
|
||||
|
||||
b.Navigation("TicketMedias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b =>
|
||||
{
|
||||
b.Navigation("Accounts");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using AccountManagement.Domain.RoleAgg;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using TaskManager.Domain.PositionAgg;
|
||||
|
||||
namespace AccountMangement.Infrastructure.EFCore.Repository;
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ using _0_Framework.InfraStructure;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountManagement.Application.Contracts.Position;
|
||||
using AccountManagement.Domain.AccountAgg;
|
||||
using AccountManagement.Domain.PositionAgg;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TaskManager.Domain.PositionAgg;
|
||||
|
||||
namespace TaskManager.Infrastructure.EFCore.Repository;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,99 +18,129 @@ namespace AccountMangement.Infrastructure.EFCore.Repository;
|
||||
|
||||
public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
{
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
public TicketRepository(AccountContext accountContext, IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopRepository workshopRepository) : base(accountContext)
|
||||
{
|
||||
_accountContext = accountContext;
|
||||
_authHelper = authHelper;
|
||||
_passwordHasher = passwordHasher;
|
||||
_workshopRepository = workshopRepository;
|
||||
}
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
private readonly IPasswordHasher _passwordHasher;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
public TicketRepository(AccountContext accountContext, IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopRepository workshopRepository) : base(accountContext)
|
||||
{
|
||||
_accountContext = accountContext;
|
||||
_authHelper = authHelper;
|
||||
_passwordHasher = passwordHasher;
|
||||
_workshopRepository = workshopRepository;
|
||||
}
|
||||
|
||||
public List<TicketViewModel> GetAll(TicketSearchModel searchModel)
|
||||
{
|
||||
var query = _accountContext.Tickets.OrderBy(x => x.Status == "بسته شده").ThenBy(x => x.Status == "پاسخ داده شده")
|
||||
.ThenBy(x => x.Status == "درحال بررسی").ThenBy(x => "باز").Select(x => new TicketViewModel()
|
||||
{
|
||||
Description = x.Description,
|
||||
SenderId = x.SenderId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
TicketType = x.TicketType,
|
||||
Status = x.Status,
|
||||
CreationDateTimeGr = x.CreationDate,
|
||||
CreationDateTime = x.CreationDate.ToFarsiFull(),
|
||||
TicketNumber = $"TKC_{x.TicketNumber}",
|
||||
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName,
|
||||
HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)),
|
||||
WorkshopId = x.WorkshopId,
|
||||
RawTicketNumber = x.TicketNumber
|
||||
});
|
||||
var query = _accountContext.Tickets.Where(x => !x.IsDeleted).OrderBy(x => x.Status == "بسته شده")
|
||||
.ThenBy(x => x.Status == "پاسخ داده شده")
|
||||
.ThenBy(x => x.Status == "درحال بررسی")
|
||||
.ThenBy(x => "باز")
|
||||
.ThenByDescending(x => new[]
|
||||
{
|
||||
x.ClientResponses.Max(r => r.CreationDate), x.AdminResponses.Max(r => r.CreationDate)
|
||||
|
||||
#region Search
|
||||
}.Max()).Select(x => new TicketViewModel()
|
||||
{
|
||||
Description = x.Description,
|
||||
SenderId = x.SenderId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
TicketType = x.TicketType,
|
||||
Status = x.Status,
|
||||
CreationDateTimeGr = x.CreationDate,
|
||||
CreationDateTime = x.CreationDate.ToFarsiFull(),
|
||||
TicketNumber = $"TKC_{x.TicketNumber}",
|
||||
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName,
|
||||
HasTask = _accountContext.Tasks.Include(t => t.Assigns)
|
||||
.Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)),
|
||||
WorkshopId = x.WorkshopId,
|
||||
RawTicketNumber = x.TicketNumber
|
||||
});
|
||||
#region Search
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status);
|
||||
}
|
||||
|
||||
if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate)))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var startDate = searchModel.StartDate.ToGeorgianDateTime();
|
||||
var endDate = searchModel.EndDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => startDate < x.CreationDateTimeGr && endDate > x.CreationDateTimeGr);
|
||||
}
|
||||
}
|
||||
if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate)))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var startDate = searchModel.StartDate.ToGeorgianDateTime();
|
||||
var endDate = searchModel.EndDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => startDate < x.CreationDateTimeGr && endDate > x.CreationDateTimeGr);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var oneDay = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDateTimeGr.Date == oneDay.Date);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var oneDay = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDateTimeGr.Date == oneDay.Date);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
|
||||
{
|
||||
|
||||
query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch) || x.ContractingPartyName.Contains(searchModel.GeneralSearch) || x.WorkshopName.Contains(searchModel.GeneralSearch));
|
||||
}
|
||||
query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch) || x.ContractingPartyName.Contains(searchModel.GeneralSearch) || x.WorkshopName.Contains(searchModel.GeneralSearch));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var day = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDateTimeGr.Date == day.Date);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.OneDay))
|
||||
{
|
||||
var day = searchModel.OneDay.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDateTimeGr.Date == day.Date);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName))
|
||||
{
|
||||
query = query.Where(x => x.ContractingPartyName == searchModel.ContractingPartyName.Trim());
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName))
|
||||
{
|
||||
query = query.Where(x => x.ContractingPartyName == searchModel.ContractingPartyName.Trim());
|
||||
}
|
||||
|
||||
if (searchModel.WorkshopId > 0)
|
||||
{
|
||||
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
}
|
||||
if (searchModel.WorkshopId > 0)
|
||||
{
|
||||
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.TicketNumber))
|
||||
{
|
||||
query = query.Where(x => x.RawTicketNumber == searchModel.TicketNumber);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.TicketNumber))
|
||||
{
|
||||
query = query.Where(x => x.RawTicketNumber == searchModel.TicketNumber);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status.Trim());
|
||||
}
|
||||
#endregion
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Status))
|
||||
{
|
||||
query = query.Where(x => x.Status == searchModel.Status.Trim());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
return query.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
return query.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
|
||||
public List<TicketViewModel> GetDeletedTicket()
|
||||
{
|
||||
var query = _accountContext.Tickets.Where(x => x.IsDeleted).OrderByDescending(x => x.CreationDate).Select(x => new TicketViewModel()
|
||||
{
|
||||
Description = x.Description,
|
||||
SenderId = x.SenderId,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
TicketType = x.TicketType,
|
||||
Status = x.Status,
|
||||
CreationDateTimeGr = x.CreationDate,
|
||||
CreationDateTime = x.CreationDate.ToFarsiFull(),
|
||||
TicketNumber = $"TKC_{x.TicketNumber}",
|
||||
WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName,
|
||||
HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)),
|
||||
WorkshopId = x.WorkshopId,
|
||||
RawTicketNumber = x.TicketNumber
|
||||
});
|
||||
return query.ToList();
|
||||
|
||||
}
|
||||
|
||||
public List<TicketViewModel> GetTicketsForClients(TicketSearchModel searchModel)
|
||||
{
|
||||
@@ -129,7 +159,7 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
query = _accountContext.Tickets.Where(x => x.SenderId == accountInfo.Id);
|
||||
}
|
||||
|
||||
if (accountInfo.SubAccountId > 0)
|
||||
if (accountInfo.SubAccountId>0)
|
||||
{
|
||||
query = query.Where(x => x.SubAccountSenderId == accountInfo.SubAccountId);
|
||||
}
|
||||
@@ -191,15 +221,16 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
return res.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
}
|
||||
|
||||
public void CreateAdminResponse(AdminResponse command)
|
||||
{
|
||||
_accountContext.Add(command);
|
||||
}
|
||||
|
||||
public void CreateClientResponse(ClientResponse command)
|
||||
{
|
||||
_accountContext.Add(command);
|
||||
}
|
||||
public void CreateAdminResponse(AdminResponse command)
|
||||
{
|
||||
_accountContext.Add(command);
|
||||
}
|
||||
|
||||
public void CreateClientResponse(ClientResponse command)
|
||||
{
|
||||
_accountContext.Add(command);
|
||||
}
|
||||
|
||||
public EditTicket GetDetails(long id)
|
||||
{
|
||||
@@ -273,8 +304,9 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
WorkshopId = entity.WorkshopId,
|
||||
TicketNumber = $"TKC_{entity.TicketNumber}",
|
||||
Status = entity.Status,
|
||||
HasTask = _accountContext.Tasks.Any(x => x.TicketId == entity.id)
|
||||
};
|
||||
HasTask = _accountContext.Tasks.Any(x => x.TicketId == entity.id),
|
||||
IsDeleted = entity.IsDeleted
|
||||
};
|
||||
|
||||
editTicketViewModel.ResponseViewModels = MergeResponses(editTicketViewModel.ClientResponseViewModels, editTicketViewModel.AdminResponseViewModels);
|
||||
|
||||
@@ -359,38 +391,37 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
return editTicketViewModel;
|
||||
}
|
||||
|
||||
|
||||
public int GetLastTicketNumber()
|
||||
{
|
||||
var res = _accountContext.Tickets.Any(x => x.TicketNumber != null) ? _accountContext.Tickets.Max(x => Convert.ToInt32(x.TicketNumber)) : 0;
|
||||
return res;
|
||||
}
|
||||
{
|
||||
var res = _accountContext.Tickets.Any(x => x.TicketNumber != null) ? _accountContext.Tickets.Max(x => Convert.ToInt32(x.TicketNumber)) : 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
public AdminResponse GetAdminResponse(long adminResId)
|
||||
{
|
||||
return _accountContext.AdminResponses.FirstOrDefault(x => x.id == adminResId);
|
||||
}
|
||||
public AdminResponse GetAdminResponse(long adminResId)
|
||||
{
|
||||
return _accountContext.AdminResponses.FirstOrDefault(x => x.id == adminResId);
|
||||
}
|
||||
|
||||
public ClientResponse GetClientResponse(long clientResId)
|
||||
{
|
||||
return _accountContext.ClientResponses.FirstOrDefault(x => x.id == clientResId);
|
||||
}
|
||||
public ClientResponse GetClientResponse(long clientResId)
|
||||
{
|
||||
return _accountContext.ClientResponses.FirstOrDefault(x => x.id == clientResId);
|
||||
}
|
||||
|
||||
public void RemoveAdminResponse(long adminResId)
|
||||
{
|
||||
public void RemoveAdminResponse(long adminResId)
|
||||
{
|
||||
|
||||
var adminRes = _accountContext.AdminResponses.Include(x => x.AdminResponseMedias).ThenInclude(x => x.Media).FirstOrDefault(x => x.id == adminResId);
|
||||
if (adminRes != null)
|
||||
{
|
||||
_accountContext.RemoveRange(adminRes.AdminResponseMedias);
|
||||
_accountContext.Remove(adminRes);
|
||||
}
|
||||
var adminRes = _accountContext.AdminResponses.Include(x => x.AdminResponseMedias).ThenInclude(x => x.Media).FirstOrDefault(x => x.id == adminResId);
|
||||
if (adminRes != null)
|
||||
{
|
||||
_accountContext.RemoveRange(adminRes.AdminResponseMedias);
|
||||
_accountContext.Remove(adminRes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public TypesCountOfTicketViewModel GetTypesCountOfTicketForAdmin()
|
||||
{
|
||||
var tickets = _accountContext.Tickets.AsQueryable();
|
||||
var tickets = _accountContext.Tickets.AsQueryable().Where(x=>!x.IsDeleted);
|
||||
return new TypesCountOfTicketViewModel()
|
||||
{
|
||||
All = tickets.Count(),
|
||||
@@ -398,23 +429,58 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
Closed = tickets.Count(x => x.Status == "بسته شده"),
|
||||
Open = tickets.Count(x => x.Status == "باز"),
|
||||
Pending = tickets.Count(x => x.Status == "درحال بررسی")
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public TypesCountOfTicketViewModel GetTypesCountOfTicketForClient(long workshopId)
|
||||
{
|
||||
var tickets = _accountContext.Tickets.Where(x => x.WorkshopId == workshopId);
|
||||
return new TypesCountOfTicketViewModel()
|
||||
{
|
||||
All = tickets.Count(),
|
||||
Answered = tickets.Count(x => x.Status == "پاسخ داده شده"),
|
||||
Closed = tickets.Count(x => x.Status == "بسته شده"),
|
||||
Open = tickets.Count(x => x.Status == "باز"),
|
||||
Pending = tickets.Count(x => x.Status == "درحال بررسی")
|
||||
public TypesCountOfTicketViewModel GetTypesCountOfTicketForClient(long workshopId)
|
||||
{
|
||||
var tickets = _accountContext.Tickets.Where(x => x.WorkshopId == workshopId);
|
||||
return new TypesCountOfTicketViewModel()
|
||||
{
|
||||
All = tickets.Count(),
|
||||
Answered = tickets.Count(x => x.Status == "پاسخ داده شده"),
|
||||
Closed = tickets.Count(x => x.Status == "بسته شده"),
|
||||
Open = tickets.Count(x => x.Status == "باز"),
|
||||
Pending = tickets.Count(x => x.Status == "درحال بررسی")
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public List<Response> MergeResponses(List<ClientResponseViewModel> clientResponseList, List<AdminResponseViewModel> adminResponseList)
|
||||
{
|
||||
var list = new List<Response>();
|
||||
var adminList = adminResponseList.Select(x => new Response()
|
||||
{
|
||||
TicketId = x.TicketId,
|
||||
ResponseMessage = x.Response,
|
||||
IsClient = false,
|
||||
IsAdmin = true,
|
||||
IsActive = x.IsActive,
|
||||
FullName = x.FullName,
|
||||
CreationDate = x.CreationDate,
|
||||
CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}",
|
||||
MediaViewModels = x.MediaViewModels,
|
||||
AdminResponseId = x.Id,
|
||||
AdminAccountId = x.AdminAccountId
|
||||
}).ToList();
|
||||
var clientList = clientResponseList.Select(x => new Response()
|
||||
{
|
||||
TicketId = x.TicketId,
|
||||
ResponseMessage = x.Response,
|
||||
IsClient = true,
|
||||
IsAdmin = false,
|
||||
CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}",
|
||||
CreationDate = x.CreationDate,
|
||||
MediaViewModels = x.MediaViewModels,
|
||||
ClientResponseId = x.Id
|
||||
}).ToList();
|
||||
|
||||
list.Capacity = (adminList.Count + clientList.Count);
|
||||
list.AddRange(adminList);
|
||||
list.AddRange(clientList);
|
||||
return list.OrderBy(x => x.CreationDate).ToList();
|
||||
}
|
||||
|
||||
#region Vafa
|
||||
public int GetAdminTicketsCount()
|
||||
@@ -422,40 +488,4 @@ public class TicketRepository : RepositoryBase<long, Ticket>, ITicketRepository
|
||||
return _accountContext.Tickets.Count(x => x.Status == "باز");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public List<Response> MergeResponses(List<ClientResponseViewModel> clientResponseList, List<AdminResponseViewModel> adminResponseList)
|
||||
{
|
||||
var list = new List<Response>();
|
||||
var adminList = adminResponseList.Select(x => new Response()
|
||||
{
|
||||
TicketId = x.TicketId,
|
||||
ResponseMessage = x.Response,
|
||||
IsClient = false,
|
||||
IsAdmin = true,
|
||||
IsActive = x.IsActive,
|
||||
FullName = x.FullName,
|
||||
CreationDate = x.CreationDate,
|
||||
CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}",
|
||||
MediaViewModels = x.MediaViewModels,
|
||||
AdminResponseId = x.Id,
|
||||
AdminAccountId = x.AdminAccountId
|
||||
}).ToList();
|
||||
var clientList = clientResponseList.Select(x => new Response()
|
||||
{
|
||||
TicketId = x.TicketId,
|
||||
ResponseMessage = x.Response,
|
||||
IsClient = true,
|
||||
IsAdmin = false,
|
||||
CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}",
|
||||
CreationDate = x.CreationDate,
|
||||
MediaViewModels = x.MediaViewModels,
|
||||
ClientResponseId = x.Id
|
||||
}).ToList();
|
||||
|
||||
list.Capacity = (adminList.Count + clientList.Count);
|
||||
list.AddRange(adminList);
|
||||
list.AddRange(clientList);
|
||||
return list.OrderBy(x => x.CreationDate).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user