diff --git a/0_Framework/Application/Version.cs b/0_Framework/Application/Version.cs
index 13f01541..e9c4589a 100644
--- a/0_Framework/Application/Version.cs
+++ b/0_Framework/Application/Version.cs
@@ -10,8 +10,8 @@ public static class Version
{
static Version()
{
- StyleVersion = "2.11.28";
- AdminVersion = "2.5.13";
+ StyleVersion = "2.11.31";
+ AdminVersion = "2.5.16";
CameraVersion = "1.0.3";
}
diff --git a/AccountManagement.Application.Contracts/Task/CreateTask.cs b/AccountManagement.Application.Contracts/Task/CreateTask.cs
index a88b849f..8b951b5f 100644
--- a/AccountManagement.Application.Contracts/Task/CreateTask.cs
+++ b/AccountManagement.Application.Contracts/Task/CreateTask.cs
@@ -12,15 +12,9 @@ public class CreateTask
public string EndTaskTime { get; set; }
public string ContractingPartyName { get; set; }
public string? Description { get; set; }
- public IFormFile Document1 { get; set; }
- public IFormFile Document2 { get; set; }
- public IFormFile Document3 { get; set; }
- public IFormFile Document4 { get; set; }
- public IFormFile Document5 { get; set; }
- public IFormFile Document6 { get; set; }
public List PositionId { get; set; }
-
- public IFormFile Voice{ get; set; }
+ public List UploadedMedia { get; set; }
+ public long UploadedVoiceMedia { get; set; }
diff --git a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs
index 39d18075..b2cf6640 100644
--- a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs
+++ b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using _0_Framework.Application;
using AccountManagement.Application.Contracts.Assign;
+using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application.Contracts.Task;
@@ -40,10 +41,14 @@ public interface ITaskApplication
OperationResult RejectCompleteRequest(long taskId);
OperationResult CreateTaskByPosition(CreateTask command, List positionIds);
- List GetAllRequestedTasks(TaskSearchModel searchModel);
+ List GetRequestedTasks(TaskSearchModel searchModel);
+ List AllRequestedTasks(TaskSearchModel searchModel);
int GetRequestedTasksCount();
OperationResult ChangeRequestTimeAndAccept(string time,long taskId);
TaskViewModel GetRequestDetails(long id);
+ OperationResult UploadMedia(IFormFile mediaFile,long senderId);
+ OperationResult RemoveMedia(long mediaId);
+ void RemoveTempUploadedFiles(long userId);
}
\ No newline at end of file
diff --git a/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs b/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs
index f40ff119..09936fcf 100644
--- a/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs
+++ b/AccountManagement.Application.Contracts/Task/TaskSearchModel.cs
@@ -12,7 +12,7 @@ public class TaskSearchModel
public string IsCancelRequest { get; set; }
public string IsTimeRequest { get; set; }
public string TimeRequestAccepted { get; set; }
- public string TypeOfTicket { get; set; }
+ public string TypeOfTask { get; set; }
public string GeneralSearch { get; set; }
diff --git a/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs
index 0182e371..5821c6e1 100644
--- a/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs
+++ b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs
@@ -10,11 +10,7 @@ public class CreateTicket
public long SenderId { get; set; }
public string ContractingPartyName { get; set; }
public string TicketType { get; set; }
- public IFormFile Document1 { get; set; }
- public IFormFile Document2 { get; set; }
- public IFormFile Document3 { get; set; }
- public IFormFile Document4 { get; set; }
- public IFormFile Document5 { get; set; }
- public IFormFile ScreenShot { get; set; }
- public IFormFile Voice { get; set; }
+ public List UploadedMediaIds { get; set; }
+ public long ScreenShotId { get; set; }
+ public long VoiceId { get; set; }
}
\ No newline at end of file
diff --git a/AccountManagement.Application.Contracts/Ticket/EditTicket.cs b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs
index 5509fd95..77ec0ae0 100644
--- a/AccountManagement.Application.Contracts/Ticket/EditTicket.cs
+++ b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs
@@ -7,4 +7,6 @@ public class EditTicket:CreateTicket
{
public long Id { get; set; }
public List MediaViewModels { get; set; }
+ public List AdminResponseViewModels{ get; set; }
+ public List ClientResponseViewModels { get; set; }
}
\ No newline at end of file
diff --git a/AccountManagement.Application.Contracts/Ticket/Response.cs b/AccountManagement.Application.Contracts/Ticket/Response.cs
new file mode 100644
index 00000000..5b09069a
--- /dev/null
+++ b/AccountManagement.Application.Contracts/Ticket/Response.cs
@@ -0,0 +1,16 @@
+using AccountManagement.Application.Contracts.Media;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccountManagement.Application.Contracts.Ticket;
+public class Response
+{
+ public long TicketId { get; set; }
+ public string ResponseMessage { get; set; }
+ public bool IsAdmin { get; set; }
+ public bool IsClient { get; set; }
+ public List MediaViewModels { get; set; }
+}
\ No newline at end of file
diff --git a/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs
index 9843cf83..a233e0d9 100644
--- a/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs
+++ b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs
@@ -6,11 +6,6 @@ public class ResponseTicket
{
public long TicketId { get; set; }
public string Response { get; set; }
- public IFormFile Document1 { get; set; }
- public IFormFile Document2 { get; set; }
- public IFormFile Document3 { get; set; }
- public IFormFile Document4 { get; set; }
- public IFormFile Document5 { get; set; }
- public IFormFile Document6 { get; set; }
- public IFormFile Voice { get; set; }
+ public List UploadedFileIds { get; set; }
+ public long VoiceId { get; set; }
}
\ No newline at end of file
diff --git a/AccountManagement.Application/AccountManagement.Application.csproj b/AccountManagement.Application/AccountManagement.Application.csproj
index 1d0d8fd6..cab6f7be 100644
--- a/AccountManagement.Application/AccountManagement.Application.csproj
+++ b/AccountManagement.Application/AccountManagement.Application.csproj
@@ -7,8 +7,7 @@
-
-
+
diff --git a/AccountManagement.Application/TaskApplication.cs b/AccountManagement.Application/TaskApplication.cs
index 132ec015..1bc26aec 100644
--- a/AccountManagement.Application/TaskApplication.cs
+++ b/AccountManagement.Application/TaskApplication.cs
@@ -1,6 +1,7 @@
using _0_Framework.Application;
using System;
using System.Collections.Generic;
+using System.Data.OleDb;
using System.IO;
using System.Linq;
using AccountManagement.Application.Contracts.Assign;
@@ -12,7 +13,7 @@ using AccountManagement.Domain.TaskAgg;
using IPE.SmsIrClient.Models.Results;
using TaskManager.Domain.PositionAgg;
using System.Reflection;
-using Microsoft.AspNetCore.Hosting;
+
using Microsoft.AspNetCore.Http;
using System.Globalization;
@@ -20,1155 +21,880 @@ using System.Globalization;
namespace AccountManagement.Application;
public class TaskApplication : ITaskApplication
{
- private readonly ITaskRepository _taskRepository;
- private readonly IAccountRepository _accountRepository;
- private readonly IMediaRepository _mediaRepository;
- private readonly IPositionRepository _positionRepository;
- private readonly IAssignRepository _assignRepository;
- private readonly IHttpContextAccessor _contextAccessor;
- private readonly IWebHostEnvironment _webHostEnvironment;
- private readonly IAuthHelper _authHelper;
+ private readonly ITaskRepository _taskRepository;
+ private readonly IAccountRepository _accountRepository;
+ private readonly IMediaRepository _mediaRepository;
+ private readonly IPositionRepository _positionRepository;
+ private readonly IAssignRepository _assignRepository;
+ private readonly IHttpContextAccessor _contextAccessor;
+
+ private readonly IAuthHelper _authHelper;
- public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository, IWebHostEnvironment webHostEnvironment, IAuthHelper authHelper)
- {
- _taskRepository = taskRepository;
- _accountRepository = accountRepository;
- _mediaRepository = mediaRepository;
- _assignRepository = assignRepository;
- _contextAccessor = contextAccessor;
- _positionRepository = positionRepository;
- _webHostEnvironment = webHostEnvironment;
- _authHelper = authHelper;
- }
- //غیرفعال سازی تسک
- public OperationResult DeActiveTask(long TaskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == TaskId))
+ public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository, IAuthHelper authHelper)
+ {
+ _taskRepository = taskRepository;
+ _accountRepository = accountRepository;
+ _mediaRepository = mediaRepository;
+ _assignRepository = assignRepository;
+ _contextAccessor = contextAccessor;
+ _positionRepository = positionRepository;
+
+ _authHelper = authHelper;
+ }
+ //غیرفعال سازی تسک
+ public OperationResult DeActiveTask(long TaskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == TaskId))
+ {
+ return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!");
+ }
+
+ var task = _taskRepository.Get(TaskId);
+ task.DeActive();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+
+ }
+ //حذف کامل تسک
+ public OperationResult RemoveTask(long TaskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == TaskId))
+ {
+ return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!");
+ }
+
+ var task = _taskRepository.Get(TaskId);
+ var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
+ var sender = _accountRepository.GetIncludePositions(task.SenderId);
+ if (sender.Position.PositionValue < positionValue)
+ {
+ return operation.Failed("شما نمیتواند وظیفه ای که سطحی از شما پایین تر دارد را حذف کنید");
+ }
+ var medias = _mediaRepository.GetMediaByTaskId(TaskId);
+ if (task.IsCanceledRequest || task.IsDone || task.IsCancel || task.TimeRequest || task.AcceptedTimeRequest > 0)
+ {
+ task.DeActive();
+ }
+ else
+ {
+ foreach (var item in medias)
+ {
+ RemoveFile(item.Id);
+ }
+ _taskRepository.Remove(task.id);
+
+ }
+
+ _taskRepository.SaveChanges();
+ return operation.Succcedded();
+ }
+ //حذف فایلی در تسک
+ public OperationResult RemoveFile(long MediaId)
+ {
+ var operation = new OperationResult();
+ if (!_mediaRepository.Exists(x => x.id == MediaId))
+ {
+ operation.Failed("چنین فایلی وجود ندارد");
+ }
+ var media = _mediaRepository.Get(MediaId);
+ File.Delete(media.Path);
+ _mediaRepository.Remove(media.id);
+ _mediaRepository.SaveChanges();
+ return operation.Succcedded();
+ }
+ //ویرایش تسک
+ public OperationResult Edit(EditTask command)
+ {
+ var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
+ var operation = new OperationResult();
+ if (string.IsNullOrEmpty(command.Title))
+ {
+ return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید");
+ }
+
+ if (string.IsNullOrEmpty(command.EndTaskDate))
+ {
+ return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید");
+ }
+
+ if (command.ReceiverId.Count < 1)
+ {
+ return operation.Failed("طرف وظیفه خود را وارد کنید");
+ }
+
+ if (command.SenderId < 1)
+ {
+ return operation.Failed("خطای سیستمی!!!");
+ }
+
+ var sender = _accountRepository.GetIncludePositions(command.SenderId);
+ if (sender.Position.PositionValue < posValue)
+ {
+ 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 if (checkReceiver.Any(x => sender.Position.PositionValue > x.Position.PositionValue))
+ {
+ return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید");
+ }
+
+ }
+ else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id))
+ {
+
+ }
+ var task = _taskRepository.Get(command.Id);
+ var endTask = command.EndTaskDate.ToGeorgianDateTime();
+ var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
+ if (endTask == errorDateTime)
+ {
+ return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
+ }
+
+ task.Edit(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
+ _taskRepository.SaveChanges();
+ _assignRepository.RemoveRangeAssigns(task.id);
+ 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);
+ }
+ _assignRepository.SaveChanges();
+
+ #region ChangeMedias
+
+
+ #region SaveDocuments
+
+ if (command.UploadedMedia?.Count>0)
+ {
+ foreach (var mediaId in command.UploadedMedia)
+ {
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
+
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
+ }
+ }
+
+
+
+
+
+ #endregion
+
+
+
+ if (command.UploadedVoiceMedia > 0)
+ {
+ var media = _mediaRepository.Get(command.UploadedVoiceMedia);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
+
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, "صوت");
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
+
+ }
+ #region DeleteMedias
+
+ if (command.DeletedFileIds?.Count > 0)
+ {
+ foreach (var mediaId in command.DeletedFileIds)
+ {
+ var media = _mediaRepository.Get(mediaId);
+ _mediaRepository.Remove(media.id);
+ File.Delete(media.Path);
+ }
+ }
+
+ _mediaRepository.SaveChanges();
+
+ #endregion
+
+ #endregion
+
+
+ _taskRepository.SaveChanges();
+ return operation.Succcedded();
+ }
+ //ساخت یک ارجاع دهنده
+ public OperationResult CreateAssign(CreateAssign command)
+ {
+ var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == command.TaskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ if (!_accountRepository.Exists(x => x.id == command.AssignerId))
+ {
+ return operation.Failed("خطای سیستمی!!");
+ }
+
+ foreach (var assignedId in command.AssignedId)
+ {
+ if (!_accountRepository.Exists(x => x.id == assignedId))
+ {
+ return operation.Failed("چنین شخصی برای ارجاع وجود ندارد.");
+ }
+
+ }
+
+ var assigner = _accountRepository.GetIncludePositions(command.AssignerId);
+ foreach (var assignedId in command.AssignedId)
+ {
+ var assigned = _accountRepository.GetIncludePositions(assignedId);
+
+ var assign = new Assign(command.TaskId, command.AssignerId, assignedId, assigner.Position.PositionValue,
+ assigned.Fullname, assigned.Position.PositionValue);
+ _assignRepository.Create(assign);
+ }
+ _assignRepository.SaveChanges();
+ return operation.Succcedded();
+ }
+ //ساخت تسک
+ public OperationResult CreateTask(CreateTask command)
+ {
+ var operation = new OperationResult();
+ if (string.IsNullOrEmpty(command.Title))
+ {
+ return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید");
+ }
+ var now = DateTime.Now.Date;
+ 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.PositionId?.Count > 0 && command.ReceiverId?.Count > 0)
+ {
+ if (command.PositionId.Any(x => x > 0))
+ {
+ return operation.Failed("شما نمیتوانید همرمان به صورت انفرادی و هم به صورت گروهی تسک دهید. ");
+ }
+ }
+ else if (command.PositionId?.Count > 0)
+ {
+ var res = CreateTaskByPosition(command);
+ return res;
+ }
+ 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 if (checkReceiver.Any(x => sender.Position.PositionValue > x.Position.PositionValue))
+ {
+ return operation.Failed("شما نمیتوانید به سطح بالاتر خود یا هم سطح خود وظیفه ای دهید");
+ }
+
+ }
+ else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id))
+ {
+
+ }
+
+
+ var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) || command.EndTaskTime == "00:00" ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime);
+
+ var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
+ if (endTask == errorDateTime)
+ {
+ return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
+ }
+
+ if (endTask.Date < now)
+ {
+ return operation.Failed("لطفا تاریخ آینده را وارد کنید");
+ }
+ var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
+ _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.UploadedMedia?.Count > 0)
{
- return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!");
- }
-
- var task = _taskRepository.Get(TaskId);
- task.DeActive();
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
-
- }
- //حذف کامل تسک
- public OperationResult RemoveTask(long TaskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == TaskId))
- {
- return operation.Failed("چنین وظیفه ای برای حذف وجود ندارد!");
- }
-
- var task = _taskRepository.Get(TaskId);
- var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
- var sender = _accountRepository.GetIncludePositions(task.SenderId);
- if (sender.Position.PositionValue < positionValue)
- {
- return operation.Failed("شما نمیتواند وظیفه ای که سطحی از شما پایین تر دارد را حذف کنید");
- }
- var medias = _mediaRepository.GetMediaByTaskId(TaskId);
- if (task.IsCanceledRequest || task.IsDone || task.IsCancel || task.TimeRequest || task.AcceptedTimeRequest > 0)
- {
- task.DeActive();
- }
- else
- {
- foreach (var item in medias)
- {
- RemoveFile(item.Id);
- }
- _taskRepository.Remove(task.id);
-
- }
-
- _taskRepository.SaveChanges();
- return operation.Succcedded();
- }
- //حذف فایلی در تسک
- public OperationResult RemoveFile(long MediaId)
- {
- var operation = new OperationResult();
- if (!_mediaRepository.Exists(x => x.id == MediaId))
- {
- operation.Failed("چنین فایلی وجود ندارد");
- }
- var media = _mediaRepository.Get(MediaId);
- File.Delete(media.Path);
- _mediaRepository.Remove(media.id);
- _mediaRepository.SaveChanges();
- return operation.Succcedded();
- }
- //ویرایش تسک
- public OperationResult Edit(EditTask command)
- {
- var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
- var operation = new OperationResult();
- if (string.IsNullOrEmpty(command.Title))
- {
- return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید");
- }
-
- if (string.IsNullOrEmpty(command.EndTaskDate))
- {
- return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید");
- }
-
- if (command.ReceiverId.Count < 1)
- {
- return operation.Failed("طرف وظیفه خود را وارد کنید");
- }
-
- if (command.SenderId < 1)
- {
- return operation.Failed("خطای سیستمی!!!");
- }
-
- var sender = _accountRepository.GetIncludePositions(command.SenderId);
- if (sender.Position.PositionValue < posValue)
- {
- 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 task = _taskRepository.Get(command.Id);
- var endTask = command.EndTaskDate.ToGeorgianDateTime();
- var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
- if (endTask == errorDateTime)
- {
- return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
- }
-
- task.Edit(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
- _taskRepository.SaveChanges();
- _assignRepository.RemoveRangeAssigns(task.id);
- 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);
- }
- _assignRepository.SaveChanges();
-
- #region ChangeMedias
-
- #region DeleteMedias
-
- if (command.DeletedFileIds?.Count > 0)
- {
- foreach (var mediaId in command.DeletedFileIds)
+ foreach (var mediaId in command.UploadedMedia)
{
var media = _mediaRepository.Get(mediaId);
- _mediaRepository.Remove(media.id);
- File.Delete(media.Path);
- }
- }
-
- _mediaRepository.SaveChanges();
-
- #endregion
-
-
-
-
- #region SaveDocuments
-
- if ((command.Document1?.Length > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000))
- return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد");
-
- if (command.Document1?.Length > 0)
- {
- var path = Path.Combine($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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
-
-
-
- if (command.Voice?.Length > 0)
- {
- var path = Path.Combine($"{_webHostEnvironment.ContentRootPath}", "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
-
-
- _taskRepository.SaveChanges();
- return operation.Succcedded();
- }
- //ساخت یک ارجاع دهنده
- public OperationResult CreateAssign(CreateAssign command)
- {
- var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == command.TaskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- if (!_accountRepository.Exists(x => x.id == command.AssignerId))
- {
- return operation.Failed("خطای سیستمی!!");
- }
-
- foreach (var assignedId in command.AssignedId)
- {
- if (!_accountRepository.Exists(x => x.id == assignedId))
- {
- return operation.Failed("چنین شخصی برای ارجاع وجود ندارد.");
- }
-
- }
-
- var assigner = _accountRepository.GetIncludePositions(command.AssignerId);
- foreach (var assignedId in command.AssignedId)
- {
- var assigned = _accountRepository.GetIncludePositions(assignedId);
-
- var assign = new Assign(command.TaskId, command.AssignerId, assignedId, assigner.Position.PositionValue,
- assigned.Fullname, assigned.Position.PositionValue);
- _assignRepository.Create(assign);
- }
- _assignRepository.SaveChanges();
- return operation.Succcedded();
- }
- //ساخت تسک
- public OperationResult CreateTask(CreateTask command)
- {
- 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.PositionId?.Count > 0 && command.ReceiverId?.Count > 0)
- {
- if (command.PositionId.Any(x => x > 0))
- {
- return operation.Failed("شما نمیتوانید همرمان به صورت انفرادی و هم به صورت گروهی تسک دهید. ");
- }
- }
- else if (command.PositionId?.Count > 0)
- {
- var res = CreateTaskByPosition(command);
- return res;
- }
- 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.EndTaskTime=="00:00" ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime);
-
- var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
- if (endTask == errorDateTime)
- {
- return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
- }
-
- var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
- _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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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
-
-
-
- if (command.Voice?.Length > 0)
- {
- var path = Path.Combine($"{_webHostEnvironment.ContentRootPath}", "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
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
-
- public OperationResult CreateTaskByPosition(CreateTask command)
- {
- var operation = new OperationResult();
- var sender = _accountRepository.GetIncludePositions(command.SenderId);
-
- var receivers = _positionRepository.GetAccountsByIds(command.PositionId);
-
-
- if (sender.Position.PositionValue == 1)
- {
-
- }
- else if (receivers.Any(x => sender.Position.PositionValue > x.Position.PositionValue))
- {
- return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید");
- }
- else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id))
- {
-
- }
- else if (receivers.Any(x => sender.Position.PositionValue == x.Position.PositionValue))
- {
- return operation.Failed("شما نمیتوانید به هم سطح خود وظیفه ای دهید");
- }
-
-
- DateTime endTask;
- if (string.IsNullOrWhiteSpace(command.EndTaskTime))
- {
- endTask = command.EndTaskDate.ToGeorgianDateTime2();
- }
- else
- {
- endTask = command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime);
- }
-
-
-
- var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
- _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 > 2000000) || (command.Document2?.Length > 2000000) || (command.Document3?.Length > 2000000))
- return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد");
-
- if (command.Document1?.Length > 0)
- {
- var path = Path.Combine($"{_webHostEnvironment.ContentRootPath}", "Storage",
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
"Task", $"{task.id}");
- Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
- string filepath = Path.Combine(path, command.Document1.FileName);
- using (var stream = new FileStream(filepath, FileMode.Create))
- {
- command.Document1.CopyTo(stream);
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
-
- 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($"{_webHostEnvironment.ContentRootPath}", "Storage",
- "Task", $"{task.id}");
- Directory.CreateDirectory(path);
+
- string filepath = Path.Combine(path, command.Document2.FileName);
+ #endregion
- 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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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($"{_webHostEnvironment.ContentRootPath}", "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);
- }
+ if (command.UploadedVoiceMedia > 0)
+ {
+ var media = _mediaRepository.Get(command.UploadedVoiceMedia);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
- #endregion
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, "صوت");
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
+
+ }
+
+ #endregion
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+
+ public OperationResult CreateTaskByPosition(CreateTask command)
+ {
+ var operation = new OperationResult();
+ var sender = _accountRepository.GetIncludePositions(command.SenderId);
+
+ var receivers = _positionRepository.GetAccountsByIds(command.PositionId);
+
+
+ if (sender.Position.PositionValue == 1)
+ {
+
+ }
+ else if (receivers.Any(x => sender.Position.PositionValue > x.Position.PositionValue))
+ {
+ return operation.Failed("شما نمیتوانید به سطح بالاتر خود وظیفه ای دهید");
+ }
+ else if (receivers.Count == 1 && receivers.Any(x => sender.id == x.id))
+ {
+
+ }
- if (command.Voice?.Length > 0)
- {
- var path = Path.Combine($"{_webHostEnvironment.ContentRootPath}", "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);
-
- }
+ DateTime endTask;
+ if (string.IsNullOrWhiteSpace(command.EndTaskTime))
+ {
+ endTask = command.EndTaskDate.ToGeorgianDateTime2();
+ }
+ else
+ {
+ endTask = command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime);
+ }
- #endregion
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
-
- // ویرایش تسک
- public EditTask GetDetails(long taskId)
- {
- return _taskRepository.GetDetails(taskId);
- }
-
- //لیست کامل تسک ها
- public List GetTasks(TaskSearchModel searchModel)
- {
- var test = _taskRepository.GetTasks(searchModel);
-
- return test;
- }
-
- public List GetSelfTasks(TaskSearchModel searchModel)
- {
- return _taskRepository.GetSelfTasks(searchModel);
- }
-
- public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel)
- {
- return _taskRepository.GetAllNotSelfIncludedTasks(searchModel);
- }
-
- public List GetReceivedTasks(TaskSearchModel searchModel)
- {
- return _taskRepository.GetReceivedTasks(searchModel);
- }
-
- public List GetSentTasks(TaskSearchModel searchModel)
- {
- return _taskRepository.GetSentTasks(searchModel);
- }
-
- //ساخت درخواست مهلت
- public OperationResult CreateRequestTime(CreateTaskTimeRequest command)
- {
- var accountId = _authHelper.CurrentAccountId();
- var operation = new OperationResult();
- if (command.TaskId == 0)
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
-
- if (string.IsNullOrWhiteSpace(command.Description))
- {
- return operation.Failed("توضیحات خود را وارد کنید");
- }
-
- if (string.IsNullOrWhiteSpace(command.RequestTime))
- {
- return operation.Failed("مهلت درخواستی خود را وارد کنید");
- }
-
-
- var task = _taskRepository.Get(command.TaskId);
- var requestTime = command.RequestTime.ToGeorgianDateTime();
- var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
- if (requestTime == errorDateTime)
- {
- return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
- }
- if (task.SenderId==accountId)
- {
- task.ChangeTimeTask(requestTime);
- }
- else
- {
- task.CreateTimeRequest(requestTime, command.Description);
- }
-
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
- //تایید درخواست مهلت
- public OperationResult AcceptRequestDatetime(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
-
- var task = _taskRepository.Get(taskId);
- if (!task.TimeRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
- }
-
- if (task.RequestDate == null)
- {
- return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است");
- }
- task.AcceptTimeRequest();
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
- //ساخت درخواست کنسل
- public OperationResult CreateCancelRequest(CreateTaskCancel command)
- {
- var accountId = _authHelper.CurrentAccountId();
- var operation = new OperationResult();
- if (string.IsNullOrWhiteSpace(command.Description))
- {
- return operation.Failed("توضیحات خود را وارد کنید");
- }
-
- if (!_taskRepository.Exists(x => x.id == command.TaskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(command.TaskId);
- task.CreateCancelRequest(command.Description);
- if (task.SenderId==accountId)
- {
- task.AcceptCancelRequest();
- }
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
- //تایید درخواست کنسل
- public OperationResult AcceptCancelRequest(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(taskId);
- if (!task.IsCanceledRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
- }
- task.AcceptCancelRequest();
- _taskRepository.SaveChanges();
- return operation.Succcedded(taskId);
- }
- //انجام شدن تسک
- public OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command)
- {
- var accountId = _authHelper.CurrentAccountId();
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == command.Id))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(command.Id);
- task.CompleteRequest(command.Description);
- if (task.SenderId==accountId)
- {
- task.Completed();
- }
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
-
- public OperationResult AcceptCompleteRequest(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(taskId);
- if (!task.IsDoneRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای تایید ندارد");
- }
- task.Completed();
- _taskRepository.SaveChanges();
- return operation.Succcedded(taskId);
- }
-
- public OperationResult RejectCompleteRequest(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(taskId);
- if (!task.IsDoneRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
- }
- task.RejectCompleteRequest();
- _taskRepository.SaveChanges();
- return operation.Succcedded(taskId);
- }
-
- //لغو درخواست کنسل تسک
- public OperationResult RejectCancelRequest(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(taskId);
- if (!task.IsCanceledRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
- }
- task.RejectCancel();
- _taskRepository.SaveChanges();
- return operation.Succcedded(taskId);
- }
- //لغو درخواست مهلت تسک
- public OperationResult RejectTimeRequest(long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
-
- var task = _taskRepository.Get(taskId);
- if (!task.TimeRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
- }
- task.RejectTimeRequest();
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
-
- public OperationResult CreateTaskByPosition(CreateTask command, List positionIds)
- {
- var operation = new OperationResult();
- var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
- var positions = new List();
- foreach (var positionId in positionIds)
- {
- var position = _positionRepository.Get(positionId);
- positions.Add(position);
- }
+ var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName);
+ _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);
+ }
- if (positions.Any(x => x.PositionValue <= positionValue))
- {
- return operation.Failed("شما نمیتوانید به گروه هم سطح یا سطح بالاتر خود تسکی دهد");
- }
- var receiverIds = new List();
- foreach (var positionId in positionIds)
- {
- var acc = _accountRepository.GetAccountsByPositionId(positionId).Select(x => x.Id).ToList();
- receiverIds.AddRange(acc);
- }
+ #region SaveMedias
- command.ReceiverId = receiverIds;
- operation = CreateTask(command);
- return operation;
- }
+ #region SaveDocuments
- public List GetAllRequestedTasks(TaskSearchModel searchModel)
- {
- return _taskRepository.GetAllRequestedTasks(searchModel);
- }
+ foreach (var mediaId in command.UploadedMedia)
+ {
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
- public int GetRequestedTasksCount()
- {
- return _taskRepository.GetRequestedTasksCount();
- }
- public OperationResult ChangeRequestTimeAndAccept(string time, long taskId)
- {
- var operation = new OperationResult();
- if (!_taskRepository.Exists(x => x.id == taskId))
- {
- return operation.Failed("چنین وظیفه ای وجود ندارد");
- }
- var task = _taskRepository.Get(taskId);
- if (!task.TimeRequest)
- {
- return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
- }
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
- if (task.RequestDate == null)
- {
- return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است");
- }
+ media.Edit(filepath, media.Type, media.Category);
- DateTime timeGr = time.ToGeorgianDateTime2();
- task.ChangeTimeTask(timeGr);
- _taskRepository.SaveChanges();
- return operation.Succcedded(task.id);
- }
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
+ }
- public TaskViewModel GetRequestDetails(long id)
- {
- return _taskRepository.GetRequestDetails(id);
- }
+ #endregion
+
+ if (command.UploadedVoiceMedia > 0)
+ {
+ var media = _mediaRepository.Get(command.UploadedVoiceMedia);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
+
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, "صوت");
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
+
+ }
+
+ #endregion
+
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+
+ // ویرایش تسک
+ public EditTask GetDetails(long taskId)
+ {
+ return _taskRepository.GetDetails(taskId);
+ }
+
+ //لیست کامل تسک ها
+ public List GetTasks(TaskSearchModel searchModel)
+ {
+ var test = _taskRepository.GetTasks(searchModel);
+
+ return test;
+ }
+
+ public List GetSelfTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.GetSelfTasks(searchModel);
+ }
+
+ public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.GetAllNotSelfIncludedTasks(searchModel);
+ }
+
+ public List GetReceivedTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.GetReceivedTasks(searchModel);
+ }
+
+ public List GetSentTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.GetSentTasks(searchModel);
+ }
+
+ //ساخت درخواست مهلت
+ public OperationResult CreateRequestTime(CreateTaskTimeRequest command)
+ {
+ var accountId = _authHelper.CurrentAccountId();
+ var operation = new OperationResult();
+ if (command.TaskId == 0)
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+
+ if (string.IsNullOrWhiteSpace(command.Description))
+ {
+ return operation.Failed("توضیحات خود را وارد کنید");
+ }
+
+ if (string.IsNullOrWhiteSpace(command.RequestTime))
+ {
+ return operation.Failed("مهلت درخواستی خود را وارد کنید");
+ }
+
+
+ var task = _taskRepository.Get(command.TaskId);
+ var requestTime = command.RequestTime.ToGeorgianDateTime();
+ var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar());
+ if (requestTime == errorDateTime)
+ {
+ return operation.Failed("لطفا تاریخ را به درستی وارد کنید");
+ }
+ if (task.SenderId == accountId)
+ {
+ task.ChangeTimeTask(requestTime);
+ }
+ else
+ {
+ task.CreateTimeRequest(requestTime, command.Description);
+ }
+
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+ //تایید درخواست مهلت
+ public OperationResult AcceptRequestDatetime(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+
+ var task = _taskRepository.Get(taskId);
+ if (!task.TimeRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
+ }
+
+ if (task.RequestDate == null)
+ {
+ return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است");
+ }
+ task.AcceptTimeRequest();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+ //ساخت درخواست کنسل
+ public OperationResult CreateCancelRequest(CreateTaskCancel command)
+ {
+ var accountId = _authHelper.CurrentAccountId();
+ var operation = new OperationResult();
+ if (string.IsNullOrWhiteSpace(command.Description))
+ {
+ return operation.Failed("توضیحات خود را وارد کنید");
+ }
+
+ if (!_taskRepository.Exists(x => x.id == command.TaskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(command.TaskId);
+ task.CreateCancelRequest(command.Description);
+ if (task.SenderId == accountId)
+ {
+ task.AcceptCancelRequest();
+ }
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+ //تایید درخواست کنسل
+ public OperationResult AcceptCancelRequest(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(taskId);
+ if (!task.IsCanceledRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
+ }
+ task.AcceptCancelRequest();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(taskId);
+ }
+ //انجام شدن تسک
+ public OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command)
+ {
+ var accountId = _authHelper.CurrentAccountId();
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == command.Id))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(command.Id);
+ task.CompleteRequest(command.Description);
+ if (task.SenderId == accountId)
+ {
+ task.Completed();
+ }
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+
+ public OperationResult AcceptCompleteRequest(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(taskId);
+ if (!task.IsDoneRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای تایید ندارد");
+ }
+ task.Completed();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(taskId);
+ }
+
+ public OperationResult RejectCompleteRequest(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(taskId);
+ if (!task.IsDoneRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
+ }
+ task.RejectCompleteRequest();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(taskId);
+ }
+
+ //لغو درخواست کنسل تسک
+ public OperationResult RejectCancelRequest(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+ var task = _taskRepository.Get(taskId);
+ if (!task.IsCanceledRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد");
+ }
+ task.RejectCancel();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(taskId);
+ }
+ //لغو درخواست مهلت تسک
+ public OperationResult RejectTimeRequest(long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+
+ var task = _taskRepository.Get(taskId);
+ if (!task.TimeRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
+ }
+ task.RejectTimeRequest();
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+
+ public OperationResult CreateTaskByPosition(CreateTask command, List positionIds)
+ {
+ var operation = new OperationResult();
+ var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
+ var positions = new List();
+ foreach (var positionId in positionIds)
+ {
+ var position = _positionRepository.Get(positionId);
+ positions.Add(position);
+ }
+
+
+ if (positions.Any(x => x.PositionValue < positionValue))
+ {
+ return operation.Failed("شما نمیتوانید به سطح بالاتر خود تسکی دهد");
+ }
+
+ var receiverIds = new List();
+ foreach (var positionId in positionIds)
+ {
+ var acc = _accountRepository.GetAccountsByPositionId(positionId).Select(x => x.Id).ToList();
+ receiverIds.AddRange(acc);
+ }
+
+ command.ReceiverId = receiverIds;
+ operation = CreateTask(command);
+ return operation;
+ }
+
+ public List GetRequestedTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.GetRequestedTasks(searchModel);
+ }
+
+ public List AllRequestedTasks(TaskSearchModel searchModel)
+ {
+ return _taskRepository.AllRequestedTasks(searchModel);
+ }
+
+ public int GetRequestedTasksCount()
+ {
+ return _taskRepository.GetRequestedTasksCount();
+ }
+
+ public OperationResult ChangeRequestTimeAndAccept(string time, long taskId)
+ {
+ var operation = new OperationResult();
+ if (!_taskRepository.Exists(x => x.id == taskId))
+ {
+ return operation.Failed("چنین وظیفه ای وجود ندارد");
+ }
+
+ var task = _taskRepository.Get(taskId);
+ if (!task.TimeRequest)
+ {
+ return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد");
+ }
+
+ if (task.RequestDate == null)
+ {
+ return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است");
+ }
+
+ DateTime timeGr = time.ToGeorgianDateTime2();
+ task.ChangeTimeTask(timeGr);
+ _taskRepository.SaveChanges();
+ return operation.Succcedded(task.id);
+ }
+
+ public TaskViewModel GetRequestDetails(long id)
+ {
+ return _taskRepository.GetRequestDetails(id);
+ }
+ public OperationResult UploadMedia(IFormFile mediaFile, long senderId)
+ {
+ var operation = new OperationResult();
+ if ((mediaFile.Length > 2000000) || (mediaFile.Length > 2000000) || (mediaFile.Length > 2000000))
+ return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد");
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "temp", $"{senderId}");
+ Directory.CreateDirectory(path);
+
+ string uniqueFileName = $"{Path.GetFileNameWithoutExtension(mediaFile.FileName)}_{DateTime.Now.Ticks}{Path.GetExtension(mediaFile.FileName)}";
+ string filepath = Path.Combine(path, uniqueFileName);
+
+ using (var stream = new FileStream(filepath, FileMode.Create))
+ {
+ mediaFile.CopyTo(stream);
+
+ }
+ var type = Path.GetExtension(filepath);
+ var media = new Media(filepath, type, "فایل");
+ _mediaRepository.Create(media);
+ _mediaRepository.SaveChanges();
+ return operation.Succcedded(media.id);
+
+ }
+
+ public OperationResult RemoveMedia(long mediaId)
+ {
+ var operation = new OperationResult();
+ try
+ {
+ var media = _mediaRepository.Get(mediaId);
+ var path = media.Path;
+ if (File.Exists(path))
+ {
+ File.Delete(path);
+ }
+ _mediaRepository.Remove(mediaId);
+ return operation.Succcedded();
+ }
+ catch
+ {
+ return operation.Failed("مشکلی در حذف این فایل وجود دارد");
+ }
+
+ }
+
+ public void RemoveTempUploadedFiles(long userId)
+ {
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "temp", $"{userId}");
+
+
+ if (Directory.Exists(path))
+ {
+
+ Directory.Delete(path, true);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/AccountManagement.Application/TicketApplication.cs b/AccountManagement.Application/TicketApplication.cs
index 38b42ae5..bb665d9d 100644
--- a/AccountManagement.Application/TicketApplication.cs
+++ b/AccountManagement.Application/TicketApplication.cs
@@ -13,6 +13,7 @@ using AccountManagement.Domain.ClientResponseAgg;
using AccountManagement.Domain.MediaAgg;
using AccountManagement.Domain.TaskAgg;
using AccountManagement.Domain.TicketAgg;
+using Microsoft.AspNetCore.Hosting;
namespace AccountManagement.Application;
@@ -59,117 +60,41 @@ public class TicketApplication : ITicketApplication
_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)
+ if (command.UploadedMediaIds?.Count>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))
+ foreach (var mediaId in command.UploadedMediaIds)
{
- command.Document1.CopyTo(stream);
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Ticket", $"{ticket.id}");
+ Directory.CreateDirectory(path);
+
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateTicketMedia(ticket.id, media.id);
}
- 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)
+ if (command.ScreenShotId > 0)
{
- var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
+ var media = _mediaRepository.Get(command.ScreenShotId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
- string filepath = Path.Combine(path, command.Document2.FileName);
+ string filepath = Path.Combine(path, Path.GetFileName(path));
+ File.Move(oldPath, filepath);
- using (var stream = new FileStream(filepath, FileMode.Create))
- {
- command.Document2.CopyTo(stream);
- }
- var type = Path.GetExtension(filepath);
+ media.Edit(filepath, media.Type, media.Category);
- 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);
}
@@ -178,22 +103,19 @@ public class TicketApplication : ITicketApplication
#endregion
#region SaveVoice
- if (command.Voice?.Length > 0)
+ if (command.VoiceId > 0)
{
-
- var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
+ var media = _mediaRepository.Get(command.ScreenShotId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
"Ticket", $"{ticket.id}");
Directory.CreateDirectory(path);
- string filepath = Path.Combine(path, command.Voice.FileName);
+ string filepath = Path.Combine(path, Path.GetFileName(path));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, "صوت");
- 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);
@@ -279,160 +201,52 @@ public class TicketApplication : ITicketApplication
#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)
+ if (command.UploadedMedia?.Count>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))
+ foreach (var mediaId in command.UploadedMedia)
{
- command.Document1.CopyTo(stream);
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "Task", $"{task.id}");
+ Directory.CreateDirectory(path);
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
-
- 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)
+
+ if (command.UploadedVoiceMedia > 0)
{
- var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "ServiceHost", "Storage",
+ var media = _mediaRepository.Get(command.UploadedVoiceMedia);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "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);
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, "صوت");
+
_mediaRepository.SaveChanges();
_mediaRepository.CreateMediaWithTaskMedia(task.id, media.id);
}
#endregion
+
-
-
-
- #endregion
_taskRepository.SaveChanges();
return operation.Succcedded(task.id);
@@ -465,138 +279,30 @@ public class TicketApplication : ITicketApplication
#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)
+ if (command.UploadedFileIds?.Count>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))
+ foreach (var mediaId in command.UploadedFileIds)
{
- command.Document1.CopyTo(stream);
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "TicketAdminResponse", $"{adminRes.id}");
+ Directory.CreateDirectory(path);
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id);
}
-
- 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();
+ _mediaRepository.SaveChanges();
return operation.Succcedded(adminRes.id);
@@ -615,135 +321,26 @@ public class TicketApplication : ITicketApplication
_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)
+ if (command.UploadedFileIds?.Count>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))
+ foreach (var mediaId in command.UploadedFileIds)
{
- command.Document1.CopyTo(stream);
+ var media = _mediaRepository.Get(mediaId);
+ var oldPath = media.Path;
+ var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
+ "TicketClientResponse", $"{clientRes.id}");
+ Directory.CreateDirectory(path);
+
+
+ string filepath = Path.Combine(path, Path.GetFileName(oldPath));
+ File.Move(oldPath, filepath);
+
+ media.Edit(filepath, media.Type, media.Category);
+
+ _mediaRepository.SaveChanges();
+ _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id);
}
-
- 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
diff --git a/AccountManagement.Domain/MediaAgg/Media.cs b/AccountManagement.Domain/MediaAgg/Media.cs
index 9adca572..d1ce763f 100644
--- a/AccountManagement.Domain/MediaAgg/Media.cs
+++ b/AccountManagement.Domain/MediaAgg/Media.cs
@@ -7,27 +7,35 @@ using AccountManagement.Domain.TicketMediasAgg;
namespace AccountManagement.Domain.MediaAgg;
-public class Media:EntityBase
+public class Media : EntityBase
{
- public Media( string path, string type, string category)
+ public Media(string path, string type, string category)
{
-
+
Path = path;
Type = type;
Category = category;
}
-
+
//مسیر ذخیره فایل
public string Path { get; private set; }
-
+
//نوع ذخیره فایل
public string Type { get; private set; }
//دسته بندی ذخیره فایل
- public string Category { get; set; }
+ public string Category { get; private set; }
public List TaskMedias { get; set; }
public List AdminResponseMedias { get; set; }
public List ClientResponseMedias { get; set; }
public List TicketMedias { get; set; }
+
+ public void Edit(string path, string type, string category)
+ {
+ Path = path;
+ Type = type;
+ Category = category;
+ }
+
}
\ No newline at end of file
diff --git a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs
index 4d8469b6..571c7f6e 100644
--- a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs
+++ b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs
@@ -11,17 +11,15 @@ public interface ITaskRepository:IRepository
void Remove(long id);
//گرفتن تمامی وظایف
List GetTasks(TaskSearchModel searchModel);
- List GetAllRequestedTasks(TaskSearchModel searchModel);
+ List GetRequestedTasks(TaskSearchModel searchModel);
List GetSelfTasks(TaskSearchModel searchModel);
List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel);
List GetReceivedTasks(TaskSearchModel searchModel);
List GetSentTasks(TaskSearchModel searchModel);
+ List AllRequestedTasks(TaskSearchModel searchModel);
string SetTasksColors(DateTime time,bool isCancel);
int GetRequestedTasksCount();
TaskViewModel GetRequestDetails(long id);
-
-
-
-
+ string GetWebEnvironmentPath();
}
\ No newline at end of file
diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs
index eb2f76b2..df1839c3 100644
--- a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs
+++ b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs
@@ -217,7 +217,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito
var account = GetIncludePositions(int.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value));
return _context.Accounts.Include(x => x.Position)
- .Where(x => x.Position.PositionValue > account.Position.PositionValue && x.IsActiveString == "true").Select(x => new AccountViewModel()
+ .Where(x => x.Position.PositionValue >= account.Position.PositionValue && x.IsActiveString == "true").Select(x => new AccountViewModel()
{
PositionValue = x.Position.PositionValue,
Id = x.id,
diff --git a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs
index 844fab90..b50e3ff1 100644
--- a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs
+++ b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs
@@ -42,15 +42,11 @@ public class PositionRepository : RepositoryBase, IPositionRepos
public List GetLowerPosition()
{
var posValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
- return _accountContext.Positions.Where(x => x.PositionValue > posValue).Select(x => new PositionViewModel()
+ return _accountContext.Positions.Where(x => x.PositionValue >= posValue).Select(x => new PositionViewModel()
{
Value = x.PositionValue,
Id = x.id,
Name = x.PositionName
-
-
-
-
}).OrderBy(x => x.Value).ToList();
}
diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs
index 6711fecc..30a588b0 100644
--- a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs
+++ b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs
@@ -15,6 +15,7 @@ using TaskManager.Domain.PositionAgg;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
using Microsoft.Identity.Client;
using Newtonsoft.Json.Linq;
+using Microsoft.AspNetCore.Hosting;
namespace AccountMangement.Infrastructure.EFCore.Repository;
@@ -24,14 +25,16 @@ public class TaskRepository : RepositoryBase, ITaskRepository
private readonly IHttpContextAccessor _contextAccessor;
private readonly IAccountRepository _accountRepository;
public readonly IPositionRepository _PositionRepository;
+ private readonly IWebHostEnvironment _webHostEnvironment;
public TaskRepository(IHttpContextAccessor contextAccessor, AccountContext accountContext,
- IAccountRepository accountRepository, IPositionRepository positionRepository) : base(accountContext)
+ IAccountRepository accountRepository, IPositionRepository positionRepository, IWebHostEnvironment webHostEnvironment) : base(accountContext)
{
_contextAccessor = contextAccessor;
_accountContext = accountContext;
_accountRepository = accountRepository;
_PositionRepository = positionRepository;
+ _webHostEnvironment = webHostEnvironment;
}
public EditTask GetDetails(long TaskId)
@@ -69,7 +72,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
- public List GetAllRequestedTasks(TaskSearchModel searchModel)
+ public List GetRequestedTasks(TaskSearchModel searchModel)
{
var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value);
var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
@@ -84,7 +87,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
query = _accountContext.Assigns.Include(x => x.Task).Where(x =>
x.Task.IsDone == false && x.Task.IsActiveString == "true" &&
- (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)).Select(x =>
+ (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest) && accountId == x.Task.SenderId).Select(x =>
new TaskViewModel()
{
@@ -113,7 +116,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
query = _accountContext.Assigns.Include(x => x.Task).Where(x =>
!x.Task.IsDone && x.Task.IsActiveString == "true" &&
- (x.Task.IsCanceledRequest || x.Task.TimeRequest || x.Task.IsDoneRequest) && (accountId == x.Task.SenderId || positionValue < x.AssignerPositionValue)).Select(x =>
+ (x.Task.IsCanceledRequest || x.Task.TimeRequest || x.Task.IsDoneRequest) && (accountId == x.Task.SenderId || x.AssignedId == accountId)).Select(x =>
new TaskViewModel()
{
@@ -160,12 +163,10 @@ public class TaskRepository : RepositoryBase, ITaskRepository
SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId).ToList(),
+
+ CreateDate = x.CreateDate,
EndTaskDateFA = x.EndTaskDateFA,
IsDone = x.IsDone,
EndTaskDateGE = x.EndTaskDateGE,
@@ -256,7 +257,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
var AddAssign = finalList.Select(x => new TaskViewModel()
{
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
.Select(a => new AssignViewModel()
{
AssignedName = a.Fullname,
@@ -294,12 +295,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
var finalAssign = AddAssign.Select(x => new TaskViewModel()
{
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
{
AssignViewModels = a.ToList(),
PosValue = a.Key
@@ -382,7 +378,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest))
+ x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest))
.Select(x =>
new TaskViewModel()
{
@@ -412,7 +408,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && (x.AssignedId == accountId || x.AssignerId == accountId) && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest))
+ x.Task.IsActiveString == "true" && (x.AssignedId == accountId || x.AssignerId == accountId) && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest))
.Select(x =>
new TaskViewModel()
{
@@ -442,230 +438,216 @@ public class TaskRepository : RepositoryBase, ITaskRepository
//res = res.GroupBy(x => x.Id).Select(x => x.First());
//res = res.OrderBy(x => x.IsDone ? 1 : 0)
// .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1);
- if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
+ var res = query.Select(x => new TaskViewModel()
{
- query = query.Where(x =>
- (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
- || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
- || x.Name.Contains(searchModel.GeneralSearch));
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
+
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId)
+ .ToList(),
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
}
- var res = query.Select(x => new TaskViewModel()
- {
- Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
- {
- PositionValue = a.Position.PositionValue,
- Id = a.id,
- Fullname = a.Fullname,
- }).FirstOrDefault(a => a.Id == x.AssignerId),
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
- SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- });
- if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
- {
- var start = searchModel.StartDate.ToGeorgianDateTime();
- var end = searchModel.EndDate.ToGeorgianDateTime();
- res = res.Where(x =>
- ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
- (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
- (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
- {
- bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
- res = res.Where(x => x.IsDoneRequest == isDoneReq);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
- {
- bool isDone = bool.Parse(searchModel.IsDone);
- res = res.Where(x => x.IsDone == isDone);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
- {
- bool isCancel = bool.Parse(searchModel.IsCanceled);
- res = res.Where(x => x.IsCancel == isCancel);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
- {
- bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
- res = res.Where(x => x.RequestTime == isTimeRequest);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
- {
- res = res.Where(x => x.AcceptedTimeRequest > 0);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
- {
- bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
- res = res.Where(x => x.IsCancelRequest == isCancelReq);
-
- }
+ }
- var resEnum = res.AsEnumerable();
- var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
- if (searchModel.AccountId > 0)
- {
- result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
- }
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
- var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
- .ThenBy(x => x.EndTaskDateGE);
+ var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE);
- var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+ var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
- .Select(a => new AssignViewModel()
- {
- AssignedName = a.Fullname,
- AssignedPositionValue = a.Position.PositionValue
- }).ToList(),
- Sender = x.Sender,
- SelfAssigner = x.Sender.Id == accountId ? true : false,
- Assigned = x.Assigned,
- SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- SelfName = x.SelfName,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
+ final = final.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList(),
- Sender = x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
- MediaCount = x.MediaCount,
- HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
- SelfName = x.SelfName,
- SelfAssigned = x.SelfAssigned,
- SelfAssigner = x.SelfAssigner,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
- Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
- {
- PositionValue = 0,
- Fullname = "-"
- } : x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.Color,
- MediaCount = x.MediaCount,
- HasAttachment = x.HasAttachment,
- SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
- EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
- ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
- : "",
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest,
- CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
- CanDelete = x.Sender.Id == accountId,
- CanEdit = x.Sender.Id == accountId,
- Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
+ CanDelete = x.Sender.Id == accountId,
+ CanEdit = x.Sender.Id == accountId,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
- }).ToList();
- return final;
+ }).ToList();
+ return final;
- }
+ }
public List GetSentTasks(TaskSearchModel searchModel)
{
@@ -682,7 +664,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId != accountId) && x.Task.SenderId == accountId && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest))
+ x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId != accountId) && x.Task.SenderId == accountId && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest))
.Select(x =>
new TaskViewModel()
{
@@ -739,231 +721,484 @@ public class TaskRepository : RepositoryBase, ITaskRepository
}
- if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
- {
- query = query.Where(x =>
- (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
- || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
- || x.Name.Contains(searchModel.GeneralSearch));
- }
+ var res = query.Select(x => new TaskViewModel()
+ {
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
+
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId)
+ .ToList(),
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
+
+ }
+
+
+
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
+
+
+ var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE);
+
+
+ var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+
+ final = final.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+
+ }).ToList();
+
+
+ final = final.Select(x => new TaskViewModel()
+ {
+
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
+
+ final = final.Select(x => new TaskViewModel()
+ {
+
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
+ CanDelete = x.Sender.Id == accountId,
+ CanEdit = x.Sender.Id == accountId,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+
+ }).ToList();
+ return final;
+ }
+
+ public List AllRequestedTasks(TaskSearchModel searchModel)
+ {
+ var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value);
+ var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value);
+ var emptyAcc = new AccountViewModel()
+ {
+ Fullname = "-",
+ PositionValue = 0
+ };
+ IQueryable query;
+
+ if (positionValue == 1)
+ {
+ query = _accountContext.Assigns.Include(x => x.Task).Where(x =>
+ x.Task.IsDone == false && x.Task.IsActiveString == "true" &&
+ (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)).Select(x =>
+ new TaskViewModel()
+ {
+
+ AssignedId = x.AssignedId,
+ AssignerId = x.AssignerId,
+ CreateDate = x.Task.CreationDate.ToFarsi(),
+ EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(),
+ IsDone = x.Task.IsDone,
+ EndTaskDateGE = x.Task.EndTaskDate,
+ Name = x.Task.Title,
+ RequestCancel = x.Task.IsCanceledRequest,
+ RequestTime = x.Task.TimeRequest,
+ Id = x.Task.id,
+ CreateTaskDateGE = x.Task.CreationDate,
+ IsCancel = x.Task.IsCancel,
+ AcceptedTimeRequest = x.Task.AcceptedTimeRequest,
+ IsCancelRequest = x.Task.IsCanceledRequest,
+ ContractingPartyName = x.Task.ContractingPartyName,
+ MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id),
+ Description = x.Task.Description,
+ IsDoneRequest = x.Task.IsDoneRequest
+
+ });
+ }
+ else
+ {
+ return new();
+ }
+ //res = res.GroupBy(x => x.Id).Select(x => x.First());
+ //res = res.OrderBy(x => x.IsDone ? 1 : 0)
+ // .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1);
+ if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
+ {
+ query = query.Where(x =>
+ (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
+ || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
+ || x.Name.Contains(searchModel.GeneralSearch));
+ }
var res = query.Select(x => new TaskViewModel()
- {
- Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
- {
- PositionValue = a.Position.PositionValue,
- Id = a.id,
- Fullname = a.Fullname,
- }).FirstOrDefault(a => a.Id == x.AssignerId),
+ {
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
- SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- });
- if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
- {
- var start = searchModel.StartDate.ToGeorgianDateTime();
- var end = searchModel.EndDate.ToGeorgianDateTime();
- res = res.Where(x =>
- ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId).ToList(),
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
- }
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
- {
- bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
- res = res.Where(x => x.IsDoneRequest == isDoneReq);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
- {
- bool isDone = bool.Parse(searchModel.IsDone);
- res = res.Where(x => x.IsDone == isDone);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
- {
- bool isCancel = bool.Parse(searchModel.IsCanceled);
- res = res.Where(x => x.IsCancel == isCancel);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
- {
- bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
- res = res.Where(x => x.RequestTime == isTimeRequest);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
- {
- res = res.Where(x => x.AcceptedTimeRequest > 0);
- }
-
- if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
- {
- bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
- res = res.Where(x => x.IsCancelRequest == isCancelReq);
-
- }
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
+ }
- var resEnum = res.AsEnumerable();
- var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
- if (searchModel.AccountId > 0)
- {
- result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
+
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
+
+ }
- var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
- .ThenBy(x => x.EndTaskDateGE);
+
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
- var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+ var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1);
+ var finalList = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
- .Select(a => new AssignViewModel()
- {
- AssignedName = a.Fullname,
- AssignedPositionValue = a.Position.PositionValue
- }).ToList(),
- Sender = x.Sender,
- SelfAssigner = x.Sender.Id == accountId ? true : false,
- Assigned = x.Assigned,
- SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- SelfName = x.SelfName,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
-
- }).ToList();
+ var AddAssign = finalList.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
- final = final.Select(x => new TaskViewModel()
- {
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList(),
- Sender = x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
- MediaCount = x.MediaCount,
- HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
- SelfName = x.SelfName,
- SelfAssigned = x.SelfAssigned,
- SelfAssigner = x.SelfAssigner,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
- Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
- {
- PositionValue = 0,
- Fullname = "-"
- } : x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.Color,
- MediaCount = x.MediaCount,
- HasAttachment = x.HasAttachment,
- SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
- EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
- ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
- : "",
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest,
- CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
- CanDelete = x.Sender.Id == accountId,
- CanEdit = x.Sender.Id == accountId,
- Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ }).ToList();
- }).ToList();
- return final;
- }
- public string SetTasksColors(DateTime date, bool isCancel)
+ var finalAssign = AddAssign.Select(x => new TaskViewModel()
+ {
+
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest ? SetRequestTasksColors(x.RequestTime, x.IsCancelRequest, x.IsDoneRequest) : "",
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0),
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
+
+ var final = finalAssign.Select(x => new TaskViewModel()
+ {
+
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanCheckRequests = x.Sender.PositionValue >= positionValue,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ }).ToList();
+ return final;
+ }
+
+
+ public string SetTasksColors(DateTime date, bool isCancel)
{
if (isCancel)
{
@@ -1016,7 +1251,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
{
return _accountContext.Assigns.Include(x => x.Task).Where(x =>
x.Task.IsDone == false && x.Task.IsActiveString == "true" &&
- (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)).GroupBy(x => x.TaskId)
+ (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)&& accountId == x.Task.SenderId).GroupBy(x => x.TaskId)
.Select(x => x.First()).Count();
}
else
@@ -1046,6 +1281,12 @@ public class TaskRepository : RepositoryBase, ITaskRepository
}).FirstOrDefault();
}
+ public string GetWebEnvironmentPath()
+ {
+ return _webHostEnvironment.ContentRootPath;
+ }
+
+
public List GetSelfTasks(TaskSearchModel searchModel)
{
var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value);
@@ -1058,7 +1299,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
var query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId == accountId) && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest))
+ x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId == accountId) && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest))
.Select(x =>
new TaskViewModel()
{
@@ -1082,228 +1323,215 @@ public class TaskRepository : RepositoryBase, ITaskRepository
IsDoneRequest = x.Task.IsDoneRequest,
});
- if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
- {
- query = query.Where(x =>
- (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
- || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
- || x.Name.Contains(searchModel.GeneralSearch));
- }
var res = query.Select(x => new TaskViewModel()
- {
- Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
- {
- PositionValue = a.Position.PositionValue,
- Id = a.id,
- Fullname = a.Fullname,
- }).FirstOrDefault(a => a.Id == x.AssignerId),
+ {
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
- SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- });
- if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
- {
- var start = searchModel.StartDate.ToGeorgianDateTime();
- var end = searchModel.EndDate.ToGeorgianDateTime();
- res = res.Where(x =>
- ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId)
+ .ToList(),
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
- }
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
- {
- bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
- res = res.Where(x => x.IsDoneRequest == isDoneReq);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
- {
- bool isDone = bool.Parse(searchModel.IsDone);
- res = res.Where(x => x.IsDone == isDone);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
- {
- bool isCancel = bool.Parse(searchModel.IsCanceled);
- res = res.Where(x => x.IsCancel == isCancel);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
- {
- bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
- res = res.Where(x => x.RequestTime == isTimeRequest);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
- {
- res = res.Where(x => x.AcceptedTimeRequest > 0);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
- {
- bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
- res = res.Where(x => x.IsCancelRequest == isCancelReq);
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
- }
+ }
- var resEnum = res.AsEnumerable();
- var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
- if (searchModel.AccountId > 0)
- {
- result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
- }
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
- var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
- .ThenBy(x => x.EndTaskDateGE);
+ var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE);
- var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+ var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
- .Select(a => new AssignViewModel()
- {
- AssignedName = a.Fullname,
- AssignedPositionValue = a.Position.PositionValue
- }).ToList(),
- Sender = x.Sender,
- SelfAssigner = x.Sender.Id == accountId ? true : false,
- Assigned = x.Assigned,
- SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- SelfName = x.SelfName,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
+ final = final.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList(),
- Sender = x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
- MediaCount = x.MediaCount,
- HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
- SelfName = x.SelfName,
- SelfAssigned = x.SelfAssigned,
- SelfAssigner = x.SelfAssigner,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
- Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
- {
- PositionValue = 0,
- Fullname = "-"
- } : x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.Color,
- MediaCount = x.MediaCount,
- HasAttachment = x.HasAttachment,
- SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
- EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
- ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
- : "",
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest,
- CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
- CanDelete = x.Sender.Id == accountId,
- CanEdit = x.Sender.Id == accountId,
- Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
+ CanDelete = x.Sender.Id == accountId,
+ CanEdit = x.Sender.Id == accountId,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
- }).ToList();
- return final;
- }
+ }).ToList();
+ return final;
+ }
public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel)
{
@@ -1317,7 +1545,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
var query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest) &&
+ x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest) &&
x.AssignerId != accountId)
.Select(x =>
new TaskViewModel()
@@ -1343,230 +1571,217 @@ public class TaskRepository : RepositoryBase, ITaskRepository
IsDoneRequest = x.Task.IsDoneRequest,
});
- if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
- {
- query = query.Where(x =>
- (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
- || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
- || x.Name.Contains(searchModel.GeneralSearch));
- }
var res = query.Select(x => new TaskViewModel()
- {
- Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
- {
- PositionValue = a.Position.PositionValue,
- Id = a.id,
- Fullname = a.Fullname,
- }).FirstOrDefault(a => a.Id == x.AssignerId),
+ {
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
- SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- });
- if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
- {
- var start = searchModel.StartDate.ToGeorgianDateTime();
- var end = searchModel.EndDate.ToGeorgianDateTime();
- res = res.Where(x =>
- ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId)
+ .ToList(),
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
- }
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
- {
- bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
- res = res.Where(x => x.IsDoneRequest == isDoneReq);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
- {
- bool isDone = bool.Parse(searchModel.IsDone);
- res = res.Where(x => x.IsDone == isDone);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
- {
- bool isCancel = bool.Parse(searchModel.IsCanceled);
- res = res.Where(x => x.IsCancel == isCancel);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
- {
- bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
- res = res.Where(x => x.RequestTime == isTimeRequest);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
- {
- res = res.Where(x => x.AcceptedTimeRequest > 0);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
- {
- bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
- res = res.Where(x => x.IsCancelRequest == isCancelReq);
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
- }
+ }
- var resEnum = res.AsEnumerable();
- var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
- if (searchModel.AccountId > 0)
- {
- result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
- }
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
- var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
- .ThenBy(x => x.EndTaskDateGE);
+ var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE);
- var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+ var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
- .Select(a => new AssignViewModel()
- {
- AssignedName = a.Fullname,
- AssignedPositionValue = a.Position.PositionValue
- }).ToList(),
- Sender = x.Sender,
- SelfAssigner = x.Sender.Id == accountId ? true : false,
- Assigned = x.Assigned,
- SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- SelfName = x.SelfName,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
+ final = final.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList(),
- Sender = x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
- MediaCount = x.MediaCount,
- HasAttachment = x.MediaCount > 0,
- SelfName = x.SelfName,
- SelfAssigned = x.SelfAssigned,
- SelfAssigner = x.SelfAssigner,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
- Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
- {
- PositionValue = 0,
- Fullname = "-"
- } : x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.Color,
- MediaCount = x.MediaCount,
- HasAttachment = x.HasAttachment,
- SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
- EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
- ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
- : "",
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest,
- CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
- CanDelete = x.Sender.Id == accountId,
- CanEdit = x.Sender.Id == accountId,
- Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
+ CanDelete = x.Sender.Id == accountId,
+ CanEdit = x.Sender.Id == accountId,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
- }).ToList();
- return final;
+ }).ToList();
+ return final;
- }
+ }
public List GetReceivedTasks(TaskSearchModel searchModel)
{
@@ -1580,7 +1795,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository
var raw = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media)
.Where(x =>
- x.Task.IsActiveString == "true" && x.AssignedId == accountId && (!x.Task.IsCanceledRequest || !x.Task.TimeRequest || !x.Task.IsDoneRequest));
+ x.Task.IsActiveString == "true" && x.AssignedId == accountId && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest));
if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
{
raw = raw.Where(x =>
@@ -1615,229 +1830,215 @@ public class TaskRepository : RepositoryBase, ITaskRepository
IsDoneRequest = x.Task.IsDoneRequest,
});
- if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch))
- {
- query = query.Where(x =>
- (x.Description != null && x.Description.Contains(searchModel.GeneralSearch))
- || x.ContractingPartyName.Contains(searchModel.GeneralSearch)
- || x.Name.Contains(searchModel.GeneralSearch));
- }
var res = query.Select(x => new TaskViewModel()
- {
- Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
- {
- PositionValue = a.Position.PositionValue,
- Id = a.id,
- Fullname = a.Fullname,
- }).FirstOrDefault(a => a.Id == x.AssignerId),
+ {
+ Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel()
+ {
+ PositionValue = a.Position.PositionValue,
+ Id = a.id,
+ Fullname = a.Fullname,
+ }).FirstOrDefault(a => a.Id == x.AssignerId),
- SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
+ SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname,
- Assigned =
- x.AssignedId == accountId ?
- ExtraTools.AddAccountIdToList(_accountContext.Assigns.Where(a => a.TaskId == x.Id && a.AssignerId == accountId).Select(a => a.AssignedId).ToList(), accountId) : _accountContext.Assigns.Where(a => a.TaskId == x.Id)
- .Where(x => x.AssignedPositionValue > positionValue).Select(a => a.AssignedId)
- .ToList(),
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- });
- if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
- {
- var start = searchModel.StartDate.ToGeorgianDateTime();
- var end = searchModel.EndDate.ToGeorgianDateTime();
- res = res.Where(x =>
- ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id)
+ .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId)
+ .ToList(),
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ });
+ if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate))
+ {
+ var start = searchModel.StartDate.ToGeorgianDateTime();
+ var end = searchModel.EndDate.ToGeorgianDateTime();
+ res = res.Where(x =>
+ ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
- || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
+ (end > x.EndTaskDateGE && x.EndTaskDateGE > start))
+ || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) &&
- (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
- }
+ (end < x.EndTaskDateGE && x.EndTaskDateGE > end)));
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
- {
- bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
- res = res.Where(x => x.IsDoneRequest == isDoneReq);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest))
+ {
+ bool isDoneReq = bool.Parse(searchModel.IsDoneRequest);
+ res = res.Where(x => x.IsDoneRequest == isDoneReq);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
- {
- bool isDone = bool.Parse(searchModel.IsDone);
- res = res.Where(x => x.IsDone == isDone);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsDone))
+ {
+ bool isDone = bool.Parse(searchModel.IsDone);
+ res = res.Where(x => x.IsDone == isDone);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
- {
- bool isCancel = bool.Parse(searchModel.IsCanceled);
- res = res.Where(x => x.IsCancel == isCancel);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled))
+ {
+ bool isCancel = bool.Parse(searchModel.IsCanceled);
+ res = res.Where(x => x.IsCancel == isCancel);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
- {
- bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
- res = res.Where(x => x.RequestTime == isTimeRequest);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest))
+ {
+ bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest);
+ res = res.Where(x => x.RequestTime == isTimeRequest);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
- {
- res = res.Where(x => x.AcceptedTimeRequest > 0);
- }
+ if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted))
+ {
+ res = res.Where(x => x.AcceptedTimeRequest > 0);
+ }
- if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
- {
- bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
- res = res.Where(x => x.IsCancelRequest == isCancelReq);
+ if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest))
+ {
+ bool isCancelReq = bool.Parse(searchModel.IsCancelRequest);
+ res = res.Where(x => x.IsCancelRequest == isCancelReq);
- }
+ }
- var resEnum = res.AsEnumerable();
- var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
+ var resEnum = res.AsEnumerable();
+ var result = resEnum.GroupBy(x => x.Id).Select(x => x.First());
- if (searchModel.AccountId > 0)
- {
- result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
- }
+ if (searchModel.AccountId > 0)
+ {
+ result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId));
+ }
- var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
- .ThenBy(x => x.EndTaskDateGE);
+ var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0)
+ .ThenBy(x => x.EndTaskDateGE);
- var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
+ var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList();
- final = final.Select(x => new TaskViewModel()
- {
- AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id))
- .Select(a => new AssignViewModel()
- {
- AssignedName = a.Fullname,
- AssignedPositionValue = a.Position.PositionValue
- }).ToList(),
- Sender = x.Sender,
- SelfAssigner = x.Sender.Id == accountId ? true : false,
- Assigned = x.Assigned,
- SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- MediaCount = x.MediaCount,
- SelfName = x.SelfName,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
+ final = final.Select(x => new TaskViewModel()
+ {
+ AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id)
+ .Select(a => new AssignViewModel()
+ {
+ AssignedName = a.Fullname,
+ AssignedPositionValue = a.Position.PositionValue
+ }).ToList(),
+ Sender = x.Sender,
+ SelfAssigner = x.Sender.Id == accountId ? true : false,
+ Assigned = x.Assigned,
+ SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ MediaCount = x.MediaCount,
+ SelfName = x.SelfName,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !x.SelfAssigned && !x.SelfAssigner ? x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList()
- : x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
- {
- AssignViewModels = a.ToList(),
- PosValue = a.Key
- }).ToList(),
- Sender = x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
- MediaCount = x.MediaCount,
- HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
- SelfName = x.SelfName,
- SelfAssigned = x.SelfAssigned,
- SelfAssigner = x.SelfAssigner,
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest
- }).ToList();
+ AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList()
+ {
+ AssignViewModels = a.ToList(),
+ PosValue = a.Key
+ }).ToList(),
+ Sender = x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel),
+ MediaCount = x.MediaCount,
+ HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false,
+ SelfName = x.SelfName,
+ SelfAssigned = x.SelfAssigned,
+ SelfAssigner = x.SelfAssigner,
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest
+ }).ToList();
- final = final.Select(x => new TaskViewModel()
- {
+ final = final.Select(x => new TaskViewModel()
+ {
- AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
- Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
- {
- PositionValue = 0,
- Fullname = "-"
- } : x.Sender,
- Assigned = x.Assigned,
- CreateDate = x.CreateDate,
- EndTaskDateFA = x.EndTaskDateFA,
- IsDone = x.IsDone,
- EndTaskDateGE = x.EndTaskDateGE,
- Name = x.Name,
- RequestCancel = x.RequestCancel,
- RequestTime = x.RequestTime,
- Id = x.Id,
- CreateTaskDateGE = x.CreateTaskDateGE,
- IsCancel = x.IsCancel,
- AcceptedTimeRequest = x.AcceptedTimeRequest,
- IsCancelRequest = x.IsCancelRequest,
- ContractingPartyName = x.ContractingPartyName,
- Color = x.Color,
- MediaCount = x.MediaCount,
- HasAttachment = x.HasAttachment,
- SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
- EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
- ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
- : "",
- Description = x.Description,
- IsDoneRequest = x.IsDoneRequest,
- CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
- CanDelete = x.Sender.Id == accountId,
- CanEdit = x.Sender.Id == accountId,
- Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
+ AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList,
+ Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel()
+ {
+ PositionValue = 0,
+ Fullname = "-"
+ } : x.Sender,
+ Assigned = x.Assigned,
+ CreateDate = x.CreateDate,
+ EndTaskDateFA = x.EndTaskDateFA,
+ IsDone = x.IsDone,
+ EndTaskDateGE = x.EndTaskDateGE,
+ Name = x.Name,
+ RequestCancel = x.RequestCancel,
+ RequestTime = x.RequestTime,
+ Id = x.Id,
+ CreateTaskDateGE = x.CreateTaskDateGE,
+ IsCancel = x.IsCancel,
+ AcceptedTimeRequest = x.AcceptedTimeRequest,
+ IsCancelRequest = x.IsCancelRequest,
+ ContractingPartyName = x.ContractingPartyName,
+ Color = x.Color,
+ MediaCount = x.MediaCount,
+ HasAttachment = x.HasAttachment,
+ SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName,
+ EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59"
+ ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}"
+ : "",
+ Description = x.Description,
+ IsDoneRequest = x.IsDoneRequest,
+ CanAssign = _PositionRepository.GetLastPositionValue() != positionValue,
+ CanDelete = x.Sender.Id == accountId,
+ CanEdit = x.Sender.Id == accountId,
+ Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname
- }).ToList();
- return final;
- }
+ }).ToList();
+ return final;
+ }
}
diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs
index cd9b1ea0..368174f9 100644
--- a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs
+++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs
@@ -6,6 +6,7 @@ using AccountManagement.Application.Contracts.Media;
using AccountManagement.Application.Contracts.Ticket;
using AccountManagement.Domain.AdminResponseAgg;
using AccountManagement.Domain.ClientResponseAgg;
+using AccountManagement.Domain.ClientResponseMediaAgg;
using AccountManagement.Domain.TicketAgg;
using Microsoft.EntityFrameworkCore;
@@ -148,6 +149,33 @@ public class TicketRepository : RepositoryBase, ITicketRepository
Path = m.Media.Path,
Type = m.Media.Type,
}).ToList(),
+
+ ClientResponseViewModels = _accountContext.ClientResponses.Where(c => c.TicketId == x.id)
+ .Select(m => new ClientResponseViewModel()
+ {
+ Response = m.Response,
+ TicketId = m.TicketId,
+ MediaViewModels = _accountContext.ClientResponseMedias.Include(a => a.Media).Where(a => a.ClientResponseId == m.id).Select(cm => new MediaViewModel()
+ {
+ Category = cm.Media.Category,
+ Path = cm.Media.Path,
+ Id = cm.Media.id,
+ Type = cm.Media.Type,
+ }).ToList(),
+ }).ToList(),
+ AdminResponseViewModels = _accountContext.AdminResponses.Where(c => c.TicketId == x.id)
+ .Select(m => new AdminResponseViewModel()
+ {
+ Response = m.Response,
+ TicketId = m.TicketId,
+ MediaViewModels = _accountContext.AdminResponseMedias.Include(a => a.Media).Where(a => a.AdminResponseId == m.id).Select(cm => new MediaViewModel()
+ {
+ Category = cm.Media.Category,
+ Path = cm.Media.Path,
+ Id = cm.Media.id,
+ Type = cm.Media.Type,
+ }).ToList(),
+ }).ToList(),
}).FirstOrDefault(x => x.Id == id);
}
}
\ No newline at end of file
diff --git a/Company.Domain/empolyerAgg/IEmployerRepository.cs b/Company.Domain/empolyerAgg/IEmployerRepository.cs
index 6d79c06b..88973019 100644
--- a/Company.Domain/empolyerAgg/IEmployerRepository.cs
+++ b/Company.Domain/empolyerAgg/IEmployerRepository.cs
@@ -29,6 +29,12 @@ public interface IEmployerRepository : IRepository
bool ExistsEmployerAccountRegisterId(string commandRegisterId);
bool ExistsEmployerAccountLName(string commandLName);
+ #region Mahan
+
+ List GetEmployersHasWorkshop();
+
+ #endregion
+
#region NewByHeydari
OperationResult DeleteEmployer(long id);
List GetEmployerWithFNameOrLName(string searchText);
diff --git a/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs b/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs
index 9559b889..32e00882 100644
--- a/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs
+++ b/CompanyManagment.App.Contracts/Employer/IEmployerApplication.cs
@@ -32,7 +32,10 @@ public interface IEmployerApplication
OperationResult EditForClient(EditEmployer command);
OperationResult EditLegalForClient(EditEmployer command);
+ #region Mahan
+ List GetEmployersHasWorkshop();
+ #endregion
#region NewByHeydari
OperationResult DeleteEmployer(long id);
List GetEmployerWithFNameOrLName(string searchText);
diff --git a/CompanyManagment.Application/EmployerApplication.cs b/CompanyManagment.Application/EmployerApplication.cs
index 9a26118d..d3498c57 100644
--- a/CompanyManagment.Application/EmployerApplication.cs
+++ b/CompanyManagment.Application/EmployerApplication.cs
@@ -886,6 +886,14 @@ public class EmployerApplication : IEmployerApplication
return opration.Succcedded();
}
+
+ #region Mahan
+ public List GetEmployersHasWorkshop()
+ {
+ return _EmployerRepository.GetEmployersHasWorkshop();
+ }
+ #endregion
+
#region NewByHeydari
diff --git a/CompanyManagment.EFCore/Repository/EmployerRepository.cs b/CompanyManagment.EFCore/Repository/EmployerRepository.cs
index b514afd8..a5bdf2f6 100644
--- a/CompanyManagment.EFCore/Repository/EmployerRepository.cs
+++ b/CompanyManagment.EFCore/Repository/EmployerRepository.cs
@@ -17,17 +17,17 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
private readonly IAuthHelper _authHelper;
public DateTime initial = new DateTime(1922, 01, 01, 00, 00, 00, 0000000);
-
+
public EmployerRepository(CompanyContext context, IAuthHelper authHelper) : base(context)
{
_context = context;
_authHelper = authHelper;
-
+
}
public List GetEmployers()
{
- return _context.Employers.Where(x=>x.IsActive==true).Select(x => new EmployerViewModel
+ return _context.Employers.Where(x => x.IsActive == true).Select(x => new EmployerViewModel
{
Id = x.id,
@@ -63,8 +63,8 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address
- }).Where(x=> id.Contains(x.Id))
- .Where(x=>x.IsActive).ToList();
+ }).Where(x => id.Contains(x.Id))
+ .Where(x => x.IsActive).ToList();
//var empList = new List();
//foreach (var item in id)
//{
@@ -96,47 +96,47 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
public EditEmployer GetDetails(long id)
{
return _context.Employers.Select(x => new EditEmployer
- {
- Id = x.id,
- FName = x.FName,
- LName = x.LName,
- ContractingPartyId = x.ContractingPartyId,
- Gender = x.Gender,
- Nationalcode = x.Nationalcode,
- IdNumber = x.IdNumber,
- Nationality = x.Nationality,
- FatherName = x.FatherName,
- DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
- DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
- PlaceOfIssue = x.PlaceOfIssue,
- RegisterId = x.RegisterId,
- NationalId = x.NationalId,
- EmployerLName = x.EmployerLName,
- IsLegal = x.IsLegal,
- Phone = x.Phone,
- AgentPhone = x.AgentPhone,
- Address = x.Address,
- MclsUserName = x.MclsUserName,
- MclsPassword = x.MclsPassword,
- EserviceUserName = x.EserviceUserName,
- EservicePassword = x.EservicePassword,
- TaxOfficeUserName = x.EservicePassword,
- SanaUserName = x.SanaUserName,
- SanaPassword = x.SanaPassword,
- EmployerNo = x.EmployerNo,
- FullName = x.FullName
+ {
+ Id = x.id,
+ FName = x.FName,
+ LName = x.LName,
+ ContractingPartyId = x.ContractingPartyId,
+ Gender = x.Gender,
+ Nationalcode = x.Nationalcode,
+ IdNumber = x.IdNumber,
+ Nationality = x.Nationality,
+ FatherName = x.FatherName,
+ DateOfBirth = x.DateOfBirth == initial ? "" : x.DateOfBirth.ToFarsi(),
+ DateOfIssue = x.DateOfIssue == initial ? "" : x.DateOfIssue.ToFarsi(),
+ PlaceOfIssue = x.PlaceOfIssue,
+ RegisterId = x.RegisterId,
+ NationalId = x.NationalId,
+ EmployerLName = x.EmployerLName,
+ IsLegal = x.IsLegal,
+ Phone = x.Phone,
+ AgentPhone = x.AgentPhone,
+ Address = x.Address,
+ MclsUserName = x.MclsUserName,
+ MclsPassword = x.MclsPassword,
+ EserviceUserName = x.EserviceUserName,
+ EservicePassword = x.EservicePassword,
+ TaxOfficeUserName = x.EservicePassword,
+ SanaUserName = x.SanaUserName,
+ SanaPassword = x.SanaPassword,
+ EmployerNo = x.EmployerNo,
+ FullName = x.FullName
- })
+ })
.FirstOrDefault(x => x.Id == id);
}
public List GetEmployerByWorkshopId(long workshopId)
{
-
- var emps = _context.WorkshopEmployers.Where(x=>x.WorkshopId == workshopId)
+
+ var emps = _context.WorkshopEmployers.Where(x => x.WorkshopId == workshopId)
.Select(x => x.EmployerId).ToList();
var employerlist = _context.Employers.Where(x => emps.Contains(x.id)).ToList();
var employers = new List();
@@ -152,11 +152,11 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
IsLegal = element.IsLegal,
LName = element.LName,
IsBlockContractingParty = _context.PersonalContractingParties.FirstOrDefault(x => x.id == element.ContractingPartyId)?.IsBlock,
- };
+ };
employers.Add(employer);
}
-
+
return employers;
}
@@ -164,26 +164,26 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
public List GetEmployerByContracrtingPartyID(long contractingPartyId)
{
return _context.Employers.Select(x => new EmployerViewModel()
- {
- Id = x.id,
- FName = x.FName,
- LName = x.LName,
- ContractingPartyID = x.ContractingPartyId,
- EmployerNo = x.EmployerNo,
- Nationalcode = x.Nationalcode,
- IdNumber = x.IdNumber,
- Nationality = x.Nationality,
-
- RegisterId = x.RegisterId,
- NationalId = x.NationalId,
- EmployerLName = x.EmployerLName,
- IsLegal = x.IsLegal,
-
- FullName = x.FName + " " +x.LName,
+ {
+ Id = x.id,
+ FName = x.FName,
+ LName = x.LName,
+ ContractingPartyID = x.ContractingPartyId,
+ EmployerNo = x.EmployerNo,
+ Nationalcode = x.Nationalcode,
+ IdNumber = x.IdNumber,
+ Nationality = x.Nationality,
+
+ RegisterId = x.RegisterId,
+ NationalId = x.NationalId,
+ EmployerLName = x.EmployerLName,
+ IsLegal = x.IsLegal,
+
+ FullName = x.FName + " " + x.LName,
- }).Where(x=>x.ContractingPartyID==contractingPartyId)
+ }).Where(x => x.ContractingPartyID == contractingPartyId)
.ToList();
}
@@ -210,18 +210,18 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
Address = x.Address,
EmployerNo = x.EmployerNo,
HasContractingParty = x.ContractingPartyId == 30428 && workshopEmp.Any(n => n == x.id),
- HasBlockContractingParty = x.ContractingParty.IsBlock=="true",
+ HasBlockContractingParty = x.ContractingParty.IsBlock == "true",
});
if (searchModel.Id > 0)
query = query.Where(x => x.Id == searchModel.Id);
if (!string.IsNullOrWhiteSpace(searchModel.LName))
- query = query.Where(x => x.LName.Contains(searchModel.FName)|| x.FName.Contains(searchModel.LName));
-
+ query = query.Where(x => x.LName.Contains(searchModel.FName) || x.FName.Contains(searchModel.LName));
+
if (!string.IsNullOrWhiteSpace(searchModel.Nationalcode) && searchModel.Nationalcode != "0")
- query = query.Where(x => x.Nationalcode.Contains(searchModel.Nationalcode)|| x.NationalId.Contains(searchModel.Nationalcode));
+ query = query.Where(x => x.Nationalcode.Contains(searchModel.Nationalcode) || x.NationalId.Contains(searchModel.Nationalcode));
if (!string.IsNullOrWhiteSpace(searchModel.IdNumber) && searchModel.IdNumber != "0")
query = query.Where(x => x.IdNumber.Contains(searchModel.IdNumber) || x.RegisterId.Contains(searchModel.IdNumber));
@@ -238,7 +238,7 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
if (!string.IsNullOrEmpty(searchModel.ContactingPartyName))
{
- var personalContractingPIds = _context.PersonalContractingParties.Where(x => !string.IsNullOrEmpty(x.FName) && (x.FName+" "+x.LName).Contains(searchModel.ContactingPartyName)).Select(x => x.id).ToList();
+ var personalContractingPIds = _context.PersonalContractingParties.Where(x => !string.IsNullOrEmpty(x.FName) && (x.FName + " " + x.LName).Contains(searchModel.ContactingPartyName)).Select(x => x.id).ToList();
query = query.Where(x => personalContractingPIds.Contains(x.ContractingPartyID));
}
@@ -269,16 +269,16 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
public List GetEmployerByEmployerIds(List employerIds)
{
return _context.Employers.Select(x => new EmprViewModel()
- {
- Id = x.id,
- FName = x.FName,
- LName = x.LName,
- EmployerLName = x.EmployerLName,
- IsLegal = x.IsLegal,
+ {
+ Id = x.id,
+ FName = x.FName,
+ LName = x.LName,
+ EmployerLName = x.EmployerLName,
+ IsLegal = x.IsLegal,
- //FullName = x.FName + " " + x.LName,
+ //FullName = x.FName + " " + x.LName,
- }).Where(x => employerIds.Contains(x.Id))
+ }).Where(x => employerIds.Contains(x.Id))
.ToList();
}
@@ -556,6 +556,20 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
return false;
}
+ #region Mahan
+
+ public List GetEmployersHasWorkshop()
+ {
+ return _context.WorkshopEmployers.Include(x => x.Employer).Select(x =>
+ new EmployerViewModel()
+ {
+ FullName = x.Employer.FullName,
+ Id = x.Employer.id
+ }).ToList();
+ }
+
+ #endregion
+
#region NewByHeydari
public OperationResult DeleteEmployer(long id)
{
@@ -575,10 +589,10 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
public List GetEmployerWithFNameOrLName(string searchText)
{
- var result = _context.Employers.Where(x => (!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchText))||
+ var result = _context.Employers.Where(x => (!string.IsNullOrEmpty(x.FName) && x.FName.StartsWith(searchText)) ||
(!string.IsNullOrEmpty(x.LName) && x.LName.StartsWith(searchText)) ||
- (x.IsLegal== "حقیقی" && (!string.IsNullOrEmpty(x.FName)&& !string.IsNullOrEmpty(x.LName)) &&
- (x.FName +" "+ x.LName).Contains(searchText)))
+ (x.IsLegal == "حقیقی" && (!string.IsNullOrEmpty(x.FName) && !string.IsNullOrEmpty(x.LName)) &&
+ (x.FName + " " + x.LName).Contains(searchText)))
.Select(x => new EmployerViewModel
{
Id = x.id,
@@ -606,7 +620,7 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
.Select(x => new EmployerViewModel
{
Id = x.id,
- Nationalcode =(x.IsLegal== "حقیقی" ? x.Nationalcode:x.NationalId) ,
+ Nationalcode = (x.IsLegal == "حقیقی" ? x.Nationalcode : x.NationalId),
}).Take(100).ToList();
return result;
@@ -619,12 +633,12 @@ public class EmployerRepository : RepositoryBase, IEmployerRepos
{
try
{
-
+
var employer = _context.Employers.FirstOrDefault(x => x.id == id);
employer.DeActive();
- var workshopIds = _context.WorkshopEmployers.Where(x => x.EmployerId==id).Select(x => x.WorkshopId).ToList();
+ var workshopIds = _context.WorkshopEmployers.Where(x => x.EmployerId == id).Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.DeActive(x.ArchiveCode));
diff --git a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs
index 8011bfea..b0f9ac63 100644
--- a/CompanyManagment.EFCore/Repository/WorkshopRepository.cs
+++ b/CompanyManagment.EFCore/Repository/WorkshopRepository.cs
@@ -98,7 +98,7 @@ public class WorkshopRepository : RepositoryBase x.AccountId == AcountID)
// .Select(x => x.WorkshopId).ToList();
- var workshopAcountsList = _context.WorkshopAccounts.FromSqlInterpolated($"SelectQuery_WorkshopIdGetAccId {AcountID}").AsNoTracking().ToList();
+ var workshopAcountsList = _context.WorkshopAccounts.Where(x => x.AccountId == AcountID);
//var res = (e => contractData.Contains(e.Id))
var workshopAcounts = workshopAcountsList.Select(x => x.WorkshopId).ToList();
diff --git a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml
index 4e1473a6..3d50367e 100644
--- a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml
+++ b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml
@@ -698,7 +698,7 @@
ایجاد قرارداد
@**@
-
+
@*href="#showmodal=@Url.Page("./Index", "PrintAll", new {ids = idss})"*@
diff --git a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml.cs
index c71162b4..188ac642 100644
--- a/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml.cs
+++ b/ServiceHost/Areas/Admin/Pages/Company/InstitutionContracts/Index.cshtml.cs
@@ -1,4 +1,5 @@
-using _0_Framework.Application;
+using System.Diagnostics.CodeAnalysis;
+using _0_Framework.Application;
using AccountManagement.Application.Contracts.Account;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.InstitutionContract;
@@ -12,6 +13,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using PersianTools.Core;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
//using iText.Html2pdf;
//using iText.IO.Source;
//using iText.Kernel.Geom;
@@ -72,6 +74,8 @@ public class IndexModel : PageModel
public string Message { get; set; }
+ [SuppressMessage("ReSharper.DPA", "DPA0006: Large number of DB commands", MessageId = "count: 270")]
+ [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", MessageId = "count: 16092")]
public void OnGet(InstitutionContractSearchModel searchModel)
{
//var test = _institutionContract.NewSearch(searchModel);
@@ -96,7 +100,57 @@ public class IndexModel : PageModel
SumOfAmounts = totalAmounts.ToMoney();
TotalBalance = totalBalance.ToMoney();
}
+ // اصلاح شماره تماس ها
+ #region CorrectionContactInfo
+ public IActionResult OnGetCorrection()
+ {
+ var getNewContarcts = _institutionContract.NewSearch(new InstitutionContractSearchModel() { });
+ foreach (var newContracts in getNewContarcts)
+ {
+ var deActiveContracts = _institutionContract.NewSearch(new InstitutionContractSearchModel()
+ { ContractingPartyId = newContracts.ContractingPartyId, IsActiveString = "false" });
+ Thread.Sleep(100);
+ if (deActiveContracts.Count > 0)
+ {
+ var newContactInfo = _contactInfoApplication.GetContactInfolist(newContracts.Id);
+ foreach (var deactive in deActiveContracts)
+ {
+
+ _contactInfoApplication.RemoveContactInfo(deactive.Id);
+ foreach (var phone in newContactInfo)
+ {
+ if (phone.PhoneNumber != null)
+ {
+ var contactinfo = new CreateContactInfo
+ {
+ InstitutionContractId = deactive.Id,
+ PhoneType = phone.PhoneType,
+ Position = phone.Position,
+ PhoneNumber = phone.PhoneNumber,
+ FnameLname = phone.FnameLname,
+ SendSms = phone.SendSms,
+ };
+ _contactInfoApplication.Create(contactinfo);
+ Console.WriteLine(phone.PhoneNumber);
+ }
+
+ Thread.Sleep(100);
+ }
+ }
+ }
+
+
+
+ }
+
+ return new JsonResult(new
+ {
+ IsSuccedded = true,
+ });
+ }
+
+ #endregion
public IActionResult OnPostContractingParties(long id)
{
@@ -379,11 +433,39 @@ public class IndexModel : PageModel
//if (string.IsNullOrWhiteSpace(command.HasValueAddedTax))
// command.HasValueAddedTax = "false";
var result = _institutionContract.Edit(command);
+ var contractingPartyId = _institutionContract.GetDetails(result.SendId);
var counter = command.ContactInformationList.Count;
+ var getOldContarct = _institutionContract.NewSearch(new InstitutionContractSearchModel()
+ { ContractingPartyId = contractingPartyId.ContractingPartyId, IsActiveString = "both" }).Where(x=>x.IsActiveString == "false" || x.IsActiveString == "blue").ToList();
if (result.IsSuccedded && counter > 0)
{
- _contactInfoApplication.RemoveContactInfo(command.Id);
+
+ if (getOldContarct.Count > 0)
+ {
+ foreach (var item in getOldContarct)
+ {
+ _contactInfoApplication.RemoveContactInfo(item.Id);
+ foreach (var phone in command.ContactInformationList)
+ {
+ if (phone.PhoneNumber != null)
+ {
+ var contactinfo = new CreateContactInfo
+ {
+ InstitutionContractId = item.Id,
+ PhoneType = phone.PhoneType,
+ Position = phone.Position,
+ PhoneNumber = phone.PhoneNumber,
+ FnameLname = phone.FnameLname,
+ SendSms = phone.SendSmsString == "true" ? true : false
+ };
+ _contactInfoApplication.Create(contactinfo);
+ }
+ Thread.Sleep(500);
+ }
+ }
+ }
+ _contactInfoApplication.RemoveContactInfo(command.Id);
foreach (var item in command.ContactInformationList)
{
if (item.PhoneNumber != null)
@@ -585,6 +667,7 @@ public class IndexModel : PageModel
var result = _institutionContract.Extension(command);
if (result.IsSuccedded && counter > 0)
+ {
for (var i = 0; i <= counter - 1; i++)
{
if (command.ContactInformationList[i].PhoneNumber != null)
@@ -603,13 +686,47 @@ public class IndexModel : PageModel
Thread.Sleep(500);
}
+ }
+
if (result.IsSuccedded)
{
_institutionContract.DeActive(command.PrviousContractId);
_institutionContract.ReActiveAllAfterCreateNew(command.ContractingPartyId);
}
+ var contractingPartyId = _institutionContract.GetDetails(result.SendId);
+ var getOldContarct = _institutionContract.NewSearch(new InstitutionContractSearchModel()
+ { ContractingPartyId = contractingPartyId.ContractingPartyId, IsActiveString = "both" }).Where(x => x.IsActiveString == "false" || x.IsActiveString == "blue").ToList();
+ if (result.IsSuccedded && counter > 0)
+ {
+
+ if (getOldContarct.Count > 0)
+ {
+ foreach (var item in getOldContarct)
+ {
+ _contactInfoApplication.RemoveContactInfo(item.Id);
+ foreach (var phone in command.ContactInformationList)
+ {
+ if (phone.PhoneNumber != null)
+ {
+ var contactinfo = new CreateContactInfo
+ {
+ InstitutionContractId = item.Id,
+ PhoneType = phone.PhoneType,
+ Position = phone.Position,
+ PhoneNumber = phone.PhoneNumber,
+ FnameLname = phone.FnameLname,
+ SendSms = phone.SendSmsString == "true" ? true : false
+ };
+ _contactInfoApplication.Create(contactinfo);
+ }
+
+ Thread.Sleep(500);
+ }
+ }
+ }
+ }
return new JsonResult(result);
}
diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml
index 36a85b77..7f0059b8 100644
--- a/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml
+++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/Create.cshtml
@@ -1,258 +1,305 @@
@page
+@model ServiceHost.Areas.AdminNew.Pages.Company.Task.CreateModel
@using Version = _0_Framework.Application.Version
-@model CreateModel
@{
ViewData["title"] = " - وظیفه جدید";
}
-
@section Styles {
-
-
-
+
+
+
}
+
-
-
-
-

+
+
+
+

+
+
وظایف جدید
+
کارگاه نورداد مهر گستر کاسپین
+
+
-
وظایف جدید
-
کارگاه نورداد مهر گستر کاسپین
+
+ بازگشت
+
-
-
-
-