task full updated - fixed connectedPersonnel

This commit is contained in:
samsys
2024-07-10 20:25:54 +03:30
parent 39768f8074
commit aafafa27ce
123 changed files with 21086 additions and 1384 deletions

View File

@@ -422,4 +422,28 @@ public class AccountApplication : IAccountApplication
{
return _accountRepository.GetAccountLowerPositionvalue();
}
public OperationResult ReLogin()
{
var prAcc = _authHelper.CurrentAccountInfo();
var operation = new OperationResult();
var account = _accountRepository.GetIncludePositions(prAcc.Id);
if (account == null)
return operation.Failed("این اکانت وجود ندارد");
var permissions = _roleRepository.Get(account.RoleId)
.Permissions
.Select(x => x.Code)
.ToList();
_authHelper.SignOut();
var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname
, account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue);
_authHelper.Signin(authViewModel);
return operation.Succcedded(2);
}
}

View File

@@ -1,9 +1,8 @@
using System.Collections.Generic;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account;
using AccountManagement.Application.Contracts.Position;
using AccountManagement.Domain.AccountAgg;
using TaskManager.Application.Contract.Position;
using TaskManager.Domain.PositionAgg;
namespace TaskManager.Application;
@@ -52,7 +51,7 @@ public class PositionApplication:IPositionApplication
return operation.Succcedded(position.id);
}
//ذخیره لیست پرسنل برای سمت خود
public OperationResult SaveAccountPosition(List<AccountViewModel> command, long positionId)
public OperationResult SaveAccountPosition(List<long> accountIds, long positionId)
{
var operation = new OperationResult();
if (!_positionRepository.Exists(x=>x.id==positionId))
@@ -60,14 +59,14 @@ public class PositionApplication:IPositionApplication
return operation.Failed("چنین سمتی وجود ندارد");
}
if (command.Count<1)
if (accountIds.Count<1)
{
return operation.Failed("لطفا شخصی برای ذخیره انتخاب کنید");
}
foreach (var accountViewModel in command)
foreach (var id in accountIds)
{
var account = _accountRepository.Get(accountViewModel.Id);
var account = _accountRepository.Get(id);
account.SetPosition(positionId);
}
_accountRepository.SaveChanges();
@@ -79,6 +78,11 @@ public class PositionApplication:IPositionApplication
return _positionRepository.GetNoPositionAccounts();
}
public List<int> GetUnUsedPositionValues()
{
return _positionRepository.GetUnUsedPositionValues();
}
public OperationResult Remove(long id)
{
var operation = new OperationResult();

File diff suppressed because it is too large Load Diff

View File

@@ -73,8 +73,8 @@ public class TaskSubjectApplication : ITaskSubjectApplication
}
}
public List<TaskSubjectViewModel> GetAll()
public List<TaskSubjectViewModel> GetAll(string search)
{
return _taskSubjectRepository.GetAll();
return _taskSubjectRepository.GetAll(search);
}
}

View File

@@ -0,0 +1,768 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Task;
using AccountManagement.Application.Contracts.Ticket;
using AccountManagement.Domain.AccountAgg;
using AccountManagement.Domain.AdminResponseAgg;
using AccountManagement.Domain.AssignAgg;
using AccountManagement.Domain.ClientResponseAgg;
using AccountManagement.Domain.MediaAgg;
using AccountManagement.Domain.TaskAgg;
using AccountManagement.Domain.TicketAgg;
namespace AccountManagement.Application;
public class TicketApplication : ITicketApplication
{
private readonly ITicketRepository _ticketRepository;
private readonly IAccountRepository _accountRepository;
private readonly ITaskRepository _taskRepository;
private readonly IAssignRepository _assignRepository;
private readonly IMediaRepository _mediaRepository;
public TicketApplication(ITicketRepository ticketRepository, IAccountRepository accountRepository, ITaskRepository taskRepository, IAssignRepository assignRepository, IMediaRepository mediaRepository)
{
_ticketRepository = ticketRepository;
_accountRepository = accountRepository;
_taskRepository = taskRepository;
_assignRepository = assignRepository;
_mediaRepository = mediaRepository;
}
public OperationResult CreateTicket(CreateTicket command)
{
var operation = new OperationResult();
if (string.IsNullOrWhiteSpace(command.ContractingPartyName))
{
return operation.Failed("خطای سیستمی");
}
if (string.IsNullOrWhiteSpace(command.Title))
{
return operation.Failed("لطفا عنوان را وارد کنید");
}
if (string.IsNullOrWhiteSpace(command.Description))
{
return operation.Failed("لطفا توضیحات خودرا وارد کنید");
}
var ticket = new Ticket(command.Title, command.Description, command.SenderId, command.ContractingPartyName,
command.TicketType);
_ticketRepository.Create(ticket);
_ticketRepository.SaveChanges();
#region SaveDocuments
if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000)
|| (command.Document5?.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if (command.Document1?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document1.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document1.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
if (command.Document2?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document2.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document2.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
if (command.Document3?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document3.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document3.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
if (command.Document4?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document4.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document4.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
if (command.Document5?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document5.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document5.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
if (command.ScreenShot?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.ScreenShot.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.ScreenShot.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
#endregion
#region SaveVoice
if (command.Voice?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Voice.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Voice.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
#endregion
_mediaRepository.SaveChanges();
return operation.Succcedded(ticket.id);
}
public OperationResult AssignTicket(CreateTask command, long ticketId)
{
var operation = new OperationResult();
if (string.IsNullOrEmpty(command.Title))
{
return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید");
}
if (string.IsNullOrEmpty(command.EndTaskDate))
{
return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید");
}
if (string.IsNullOrEmpty(command.ContractingPartyName))
{
return operation.Failed("لطفا طرف حساب خودرا وارد کنید");
}
if (command.SenderId < 1)
{
return operation.Failed("خطای سیستمی!!!");
}
var sender = _accountRepository.GetIncludePositions(command.SenderId);
if (command.ReceiverId.Count < 1)
{
return operation.Failed("طرف وظیفه خود را وارد کنید");
}
var receivers = _accountRepository.GetAccountsByIds(command.ReceiverId);
if (sender.Position.PositionValue == 1)
{
}
else if (receivers.Any(x => sender.Position.PositionValue >= x.Position.PositionValue))
{
var checkReceiver = receivers.Where(x => sender.Position.PositionValue >= x.Position.PositionValue).ToList();
if (checkReceiver.All(x => x.id == sender.id))
{
}
else
{
return operation.Failed("شما نمیتوانید به سطح بالاتر خود یا هم سطح خود وظیفه ای دهید");
}
}
else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id))
{
}
var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime);
var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName, ticketId);
_taskRepository.Create(task);
_assignRepository.SaveChanges();
foreach (var receiver in receivers)
{
var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname,
receiver.Position.PositionValue);
_assignRepository.Create(assign);
}
#region SaveMedias
#region SaveDocuments
if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000)
|| (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if (command.Document1?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document1.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document1.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
if (command.Document2?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document2.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document2.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
if (command.Document3?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document3.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document3.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
if (command.Document4?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document4.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document4.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
if (command.Document5?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document5.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document5.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
if (command.Document6?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document6.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document6.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
#endregion
#region SaveVoice
if (command.Voice?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"Task", $"{task.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Voice.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Voice.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "صوت");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
#endregion
#endregion
_taskRepository.SaveChanges();
return operation.Succcedded(task.id);
}
public OperationResult CompleteTicket(long id)
{
var operation = new OperationResult();
if (!_ticketRepository.Exists(x => x.id == id))
{
return operation.Failed("چنین تیکتی وجود ندارد");
}
var ticket = _ticketRepository.Get(id);
ticket.Completed();
_ticketRepository.SaveChanges();
return operation.Succcedded(ticket.id);
}
public OperationResult AdminResponseTicket(ResponseTicket command)
{
var operation = new OperationResult();
if (string.IsNullOrWhiteSpace(command.Response))
{
return operation.Failed("لطفا پیغام خود را وارد کنبد");
}
var adminRes = new AdminResponse(command.Response, command.TicketId);
_ticketRepository.CreateAdminResponse(adminRes);
_ticketRepository.SaveChanges();
#region SaveDocuments
if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000)
|| (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if (command.Document1?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document1.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document1.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
if (command.Document2?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document2.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document2.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
if (command.Document3?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document3.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document3.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
if (command.Document4?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document4.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document4.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
if (command.Document5?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document5.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document5.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
if (command.Document6?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost",
"Storage",
"TicketAdminResponse", $"{adminRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document6.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document6.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
#endregion
_mediaRepository.SaveChanges();
return operation.Succcedded(adminRes.id);
}
public OperationResult ClientResponseTicket(ResponseTicket command)
{
var operation = new OperationResult();
if (string.IsNullOrWhiteSpace(command.Response))
{
return operation.Failed("لطفا پیغام خود را وارد کنبد");
}
var clientRes = new ClientResponse(command.Response, command.TicketId);
_ticketRepository.CreateClientResponse(clientRes);
_ticketRepository.SaveChanges();
#region SaveDocuments
if ((command.Document1?.Length > 5000000) || (command.Document2?.Length > 5000000) || (command.Document3?.Length > 5000000) || (command.Document4?.Length > 5000000)
|| (command.Document5?.Length > 5000000) || (command.Document6?.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if (command.Document1?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document1.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document1.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
if (command.Document2?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document2.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document2.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
if (command.Document3?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document3.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document3.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
if (command.Document4?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document4.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document4.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
if (command.Document5?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document5.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document5.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
if (command.Document6?.Length > 0)
{
var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost",
"Storage",
"TicketClientResponse", $"{clientRes.id}");
Directory.CreateDirectory(path);
string filepath = Path.Combine(path, command.Document6.FileName);
using (var stream = new FileStream(filepath, FileMode.Create))
{
command.Document6.CopyTo(stream);
}
var type = Path.GetExtension(filepath);
var media = new Media(filepath, type, "فایل");
_mediaRepository.Create(media);
_mediaRepository.SaveChanges();
_mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
#endregion
_mediaRepository.SaveChanges();
return operation.Succcedded(clientRes.id);
}
public EditTicket GetDetails(long id)
{
return _ticketRepository.GetDetails(id);
}
public List<TicketViewModel> GetAll(TicketSearchModel searchModel)
{
return _ticketRepository.GetAll(searchModel);
}
public bool IsExist(long id)
{
return _ticketRepository.Exists(x => x.id == id);
}
}