2024-04-14 16:09:36 +03:30
|
|
|
|
using Back.Common;
|
|
|
|
|
using Back.Common.Enums;
|
|
|
|
|
using Back.Data.Contracts;
|
|
|
|
|
using Back.Data.Models;
|
|
|
|
|
using Shared.DTOs;
|
|
|
|
|
|
|
|
|
|
namespace Back.Services
|
|
|
|
|
{
|
|
|
|
|
public class servTicket
|
|
|
|
|
{
|
|
|
|
|
private readonly IAsyncRepository<TiceketUnknownPeople> _ticketUnknownPeopleRepo;
|
|
|
|
|
private readonly IAsyncRepository<Ticket> _ticketRepo;
|
|
|
|
|
private readonly IAsyncRepository<SubTicket> _subticketRepo;
|
|
|
|
|
public servTicket(IAsyncRepository<TiceketUnknownPeople> ticketUnknownPeopleRepo
|
|
|
|
|
,IAsyncRepository<Ticket> ticketRepo
|
|
|
|
|
,IAsyncRepository<SubTicket> subticketRepo
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
_ticketUnknownPeopleRepo = ticketUnknownPeopleRepo;
|
|
|
|
|
_ticketRepo = ticketRepo;
|
|
|
|
|
_subticketRepo = subticketRepo;
|
|
|
|
|
}
|
|
|
|
|
public async Task<int?> NewPepole(string FullName, string Mobile)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-04-16 22:56:02 +03:30
|
|
|
|
var ID= _ticketUnknownPeopleRepo.Get(w=>w.Mobile==Mobile).Select(s=>s.ID).FirstOrDefault();
|
|
|
|
|
if (ID!=null && ID > 0)
|
|
|
|
|
return ID;
|
|
|
|
|
var item=await _ticketUnknownPeopleRepo.AddAsync(new TiceketUnknownPeople
|
2024-04-14 16:09:36 +03:30
|
|
|
|
{
|
|
|
|
|
FullName = FullName,
|
|
|
|
|
Mobile = Mobile
|
|
|
|
|
});
|
|
|
|
|
//_contextMongodb.InsertItem(new SysLog()
|
|
|
|
|
//{
|
|
|
|
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
|
|
|
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewPepole",
|
|
|
|
|
// Value = JsonConvert.SerializeObject(item),
|
|
|
|
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
|
|
|
|
// Type = "User"
|
|
|
|
|
//});
|
|
|
|
|
return item.ID;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//_contextMongodb.InsertItem(new SysLog()
|
|
|
|
|
//{
|
|
|
|
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
|
|
|
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewPepole",
|
|
|
|
|
// Value = ex.Message,
|
|
|
|
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
|
|
|
|
// Type = "catch"
|
|
|
|
|
//});
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public async Task<Ticket?> NewTicket(CTicketDto item, StatusTicket status = StatusTicket.Awaitingreview)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var ticket=await _ticketRepo.AddAsync(new Ticket
|
|
|
|
|
{
|
|
|
|
|
CompanyIDOrMobile = item.CompanyID,
|
|
|
|
|
CreateDate = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
CreateTime = DateTime.Now.ToString("hh:mm tt"),
|
|
|
|
|
Title = item.Title,
|
|
|
|
|
Status = status
|
|
|
|
|
});
|
|
|
|
|
await _subticketRepo.AddAsync(new SubTicket
|
|
|
|
|
{
|
|
|
|
|
Date = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
Time = DateTime.Now.ToString("hh:mm tt"),
|
|
|
|
|
TicketID = ticket.ID,
|
|
|
|
|
Text = item.Text,
|
|
|
|
|
Type = SideType.Customer
|
|
|
|
|
});
|
|
|
|
|
//_contextMongodb.InsertItem(new SysLog()
|
|
|
|
|
//{
|
|
|
|
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
|
|
|
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewTicket",
|
|
|
|
|
// Value = JsonConvert.SerializeObject(item),
|
|
|
|
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
|
|
|
|
// Type = "User"
|
|
|
|
|
//});
|
|
|
|
|
return ticket;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//_contextMongodb.InsertItem(new SysLog()
|
|
|
|
|
//{
|
|
|
|
|
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
|
|
|
|
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
|
|
|
|
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/NewTicket",
|
|
|
|
|
// Value = ex.Message,
|
|
|
|
|
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
|
|
|
|
// Type = "catch"
|
|
|
|
|
//});
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|