2020-04-16 19:41:37 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
*
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
*
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2021-03-19 16:56:26 +00:00
|
|
|
|
2021-03-10 15:38:56 +00:00
|
|
|
using ASC.Api.CRM;
|
2021-03-19 16:56:26 +00:00
|
|
|
using ASC.Common.Web;
|
|
|
|
using ASC.CRM.ApiModels;
|
2021-06-28 09:42:42 +00:00
|
|
|
|
2021-03-10 15:38:56 +00:00
|
|
|
using ASC.CRM.Core;
|
|
|
|
using ASC.CRM.Core.Dao;
|
2021-03-19 16:56:26 +00:00
|
|
|
using ASC.CRM.Core.Entities;
|
2021-03-10 15:38:56 +00:00
|
|
|
using ASC.Web.Api.Models;
|
2021-03-19 16:56:26 +00:00
|
|
|
using ASC.Web.Api.Routing;
|
|
|
|
|
|
|
|
using AutoMapper;
|
2021-03-10 15:38:56 +00:00
|
|
|
|
2021-03-24 15:55:47 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2021-03-10 15:38:56 +00:00
|
|
|
namespace ASC.CRM.Api
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-10 15:38:56 +00:00
|
|
|
public class TaskTemplateController : BaseApiController
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-23 15:41:56 +00:00
|
|
|
private readonly EmployeeWraperHelper _employeeWraperHelper;
|
|
|
|
|
2021-05-05 14:09:05 +00:00
|
|
|
public TaskTemplateController(CrmSecurity crmSecurity,
|
2021-03-19 16:56:26 +00:00
|
|
|
DaoFactory daoFactory,
|
|
|
|
EmployeeWraperHelper employeeWraperHelper,
|
|
|
|
IMapper mapper)
|
|
|
|
: base(daoFactory, crmSecurity, mapper)
|
2021-03-10 15:38:56 +00:00
|
|
|
|
|
|
|
{
|
2021-03-23 15:41:56 +00:00
|
|
|
_employeeWraperHelper = employeeWraperHelper;
|
2021-03-10 15:38:56 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
|
2021-03-10 15:38:56 +00:00
|
|
|
|
2020-04-16 19:41:37 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new task template container with the type and title specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entityType">Type</param>
|
|
|
|
/// <param name="title">Title</param>
|
|
|
|
/// <short>Create task template container</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Task template container
|
|
|
|
/// </returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <visible>false</visible>
|
2021-03-02 16:29:07 +00:00
|
|
|
[Create(@"{entityType:regex(contact|person|company|opportunity|case)}/tasktemplatecontainer")]
|
2021-06-23 19:32:56 +00:00
|
|
|
public TaskTemplateContainerDto CreateTaskTemplateContainer([FromRoute] string entityType, [FromBody] string title)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(title)) throw new ArgumentException();
|
|
|
|
|
|
|
|
var taskTemplateContainer = new TaskTemplateContainer
|
2021-03-02 16:29:07 +00:00
|
|
|
{
|
|
|
|
EntityType = ToEntityType(entityType),
|
|
|
|
Title = title
|
|
|
|
};
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
taskTemplateContainer.ID = _daoFactory.GetTaskTemplateContainerDao().SaveOrUpdate(taskTemplateContainer);
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateContainerDto(taskTemplateContainer);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the complete list of all the task template containers available on the portal
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entityType">Type</param>
|
|
|
|
/// <short>Get task template container list</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Task template container list
|
|
|
|
/// </returns>
|
|
|
|
/// <visible>false</visible>
|
2021-03-02 16:29:07 +00:00
|
|
|
[Read(@"{entityType:regex(contact|person|company|opportunity|case)}/tasktemplatecontainer")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public IEnumerable<TaskTemplateContainerDto> GetTaskTemplateContainers(string entityType)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-19 16:56:26 +00:00
|
|
|
return ToTaskListTemplateContainerDto(_daoFactory.GetTaskTemplateContainerDao().GetItems(ToEntityType(entityType)));
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Deletes the task template container with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <short>Delete task template container</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Deleted task template container
|
|
|
|
/// </returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Delete(@"tasktemplatecontainer/{containerid:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateContainerDto DeleteTaskTemplateContainer(int containerid)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (containerid <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var result = ToTaskTemplateContainerDto(_daoFactory.GetTaskTemplateContainerDao().GetByID(containerid));
|
2020-04-16 19:41:37 +00:00
|
|
|
if (result == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
_daoFactory.GetTaskTemplateContainerDao().Delete(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates the task template container with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <param name="title">Title</param>
|
|
|
|
/// <short>Update task template container</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Task template container
|
|
|
|
/// </returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Update(@"tasktemplatecontainer/{containerid:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateContainerDto UpdateTaskTemplateContainer(int containerid, string title)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (containerid <= 0 || string.IsNullOrEmpty(title)) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var result = _daoFactory.GetTaskTemplateContainerDao().GetByID(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (result == null) throw new ItemNotFoundException();
|
|
|
|
|
|
|
|
result.Title = title;
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
_daoFactory.GetTaskTemplateContainerDao().SaveOrUpdate(result);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateContainerDto(result);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the detailed information on the task template container with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <short>Get task template container by ID</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Task template container
|
|
|
|
/// </returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Read(@"tasktemplatecontainer/{containerid:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateContainerDto GetTaskTemplateContainerByID(int containerid)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (containerid <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var item = _daoFactory.GetTaskTemplateContainerDao().GetByID(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (item == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateContainerDto(item);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the list of all tasks in the container with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <short>Get task template list by contaier ID</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>
|
|
|
|
/// Task template list
|
|
|
|
/// </returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Read(@"tasktemplatecontainer/{containerid:int}/tasktemplate")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public IEnumerable<TaskTemplateDto> GetTaskTemplates(int containerid)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (containerid <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var container = _daoFactory.GetTaskTemplateContainerDao().GetByID(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (container == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
return _daoFactory.GetTaskTemplateDao().GetList(containerid).ConvertAll(ToTaskTemplateDto);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new task template with the parameters specified in the request in the container with the selected ID
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <param name="title">Title</param>
|
|
|
|
/// <param name="description">Description</param>
|
|
|
|
/// <param name="responsibleid">Responsible ID</param>
|
|
|
|
/// <param name="categoryid">Category ID</param>
|
|
|
|
/// <param name="isNotify">Responsible notification: notify or not</param>
|
|
|
|
/// <param name="offsetTicks">Ticks offset</param>
|
|
|
|
/// <param name="deadLineIsFixed"></param>
|
|
|
|
/// <short>Create task template</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>Task template</returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Create(@"tasktemplatecontainer/{containerid:int}/tasktemplate")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateDto CreateTaskTemplate(
|
2021-03-24 15:55:47 +00:00
|
|
|
[FromRoute] int containerid,
|
2021-06-28 09:42:42 +00:00
|
|
|
[FromBody] CreateOrUpdateTaskTemplateRequestDto inDto)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-06-28 09:42:42 +00:00
|
|
|
var title = inDto.Title;
|
|
|
|
var categoryid = inDto.Categoryid;
|
|
|
|
var deadLineIsFixed = inDto.DeadLineIsFixed;
|
|
|
|
var description = inDto.Description;
|
|
|
|
var isNotify = inDto.isNotify;
|
|
|
|
var responsibleid = inDto.Responsibleid;
|
|
|
|
var offsetTicks = inDto.OffsetTicks;
|
|
|
|
|
2020-04-16 19:41:37 +00:00
|
|
|
if (containerid <= 0 || string.IsNullOrEmpty(title) || categoryid <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var container = _daoFactory.GetTaskTemplateContainerDao().GetByID(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (container == null) throw new ItemNotFoundException();
|
|
|
|
|
|
|
|
var item = new TaskTemplate
|
2021-03-02 16:29:07 +00:00
|
|
|
{
|
|
|
|
CategoryID = categoryid,
|
|
|
|
ContainerID = containerid,
|
|
|
|
DeadLineIsFixed = deadLineIsFixed,
|
|
|
|
Description = description,
|
|
|
|
isNotify = isNotify,
|
|
|
|
ResponsibleID = responsibleid,
|
|
|
|
Title = title,
|
|
|
|
Offset = TimeSpan.FromTicks(offsetTicks)
|
2021-06-28 09:42:42 +00:00
|
|
|
|
2021-03-02 16:29:07 +00:00
|
|
|
};
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
item.ID = _daoFactory.GetTaskTemplateDao().SaveOrUpdate(item);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateDto(item);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates the selected task template with the parameters specified in the request in the container with the selected ID
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Task template ID</param>
|
|
|
|
/// <param name="containerid">Task template container ID</param>
|
|
|
|
/// <param name="title">Title</param>
|
|
|
|
/// <param name="description">Description</param>
|
|
|
|
/// <param name="responsibleid">Responsible ID</param>
|
|
|
|
/// <param name="categoryid">Category ID</param>
|
|
|
|
/// <param name="isNotify">Responsible notification: notify or not</param>
|
|
|
|
/// <param name="offsetTicks">Ticks offset</param>
|
|
|
|
/// <param name="deadLineIsFixed"></param>
|
|
|
|
/// <short>Update task template</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>Task template</returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
2021-06-28 09:42:42 +00:00
|
|
|
[Update(@"tasktemplatecontainer/{containerid:int}/tasktemplate/{id:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateDto UpdateTaskTemplate(
|
2021-06-28 09:42:42 +00:00
|
|
|
[FromRoute] int id,
|
|
|
|
[FromRoute] int containerid,
|
|
|
|
[FromBody] CreateOrUpdateTaskTemplateRequestDto inDto)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-06-28 09:42:42 +00:00
|
|
|
|
|
|
|
var title = inDto.Title;
|
|
|
|
var categoryid = inDto.Categoryid;
|
|
|
|
var deadLineIsFixed = inDto.DeadLineIsFixed;
|
|
|
|
var description = inDto.Description;
|
|
|
|
var isNotify = inDto.isNotify;
|
|
|
|
var responsibleid = inDto.Responsibleid;
|
|
|
|
var offsetTicks = inDto.OffsetTicks;
|
|
|
|
|
2020-04-16 19:41:37 +00:00
|
|
|
if (containerid <= 0 || string.IsNullOrEmpty(title) || categoryid <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var updatingItem = _daoFactory.GetTaskTemplateDao().GetByID(id);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (updatingItem == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var container = _daoFactory.GetTaskTemplateContainerDao().GetByID(containerid);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (container == null) throw new ItemNotFoundException();
|
|
|
|
|
|
|
|
var item = new TaskTemplate
|
2021-03-02 16:29:07 +00:00
|
|
|
{
|
|
|
|
CategoryID = categoryid,
|
|
|
|
ContainerID = containerid,
|
|
|
|
DeadLineIsFixed = deadLineIsFixed,
|
|
|
|
Description = description,
|
|
|
|
isNotify = isNotify,
|
|
|
|
ResponsibleID = responsibleid,
|
|
|
|
Title = title,
|
|
|
|
ID = id,
|
|
|
|
Offset = TimeSpan.FromTicks(offsetTicks)
|
|
|
|
};
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
item.ID = _daoFactory.GetTaskTemplateDao().SaveOrUpdate(item);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateDto(item);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Deletes the task template with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Task template ID</param>
|
|
|
|
/// <short>Delete task template</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>Task template</returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Delete(@"tasktemplatecontainer/tasktemplate/{id:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateDto DeleteTaskTemplate(int id)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (id <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var taskTemplate = _daoFactory.GetTaskTemplateDao().GetByID(id);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (taskTemplate == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
var result = ToTaskTemplateDto(taskTemplate);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
_daoFactory.GetTaskTemplateDao().Delete(id);
|
2020-04-16 19:41:37 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Return the task template with the ID specified in the request
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Task template ID</param>
|
|
|
|
/// <short>Get task template by ID</short>
|
|
|
|
/// <category>Task Templates</category>
|
|
|
|
/// <returns>Task template</returns>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
/// <exception cref="ItemNotFoundException"></exception>
|
|
|
|
/// <visible>false</visible>
|
|
|
|
[Read(@"tasktemplatecontainer/tasktemplate/{id:int}")]
|
2021-03-09 15:37:16 +00:00
|
|
|
public TaskTemplateDto GetTaskTemplateByID(int id)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
if (id <= 0) throw new ArgumentException();
|
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var taskTemplate = _daoFactory.GetTaskTemplateDao().GetByID(id);
|
2020-04-16 19:41:37 +00:00
|
|
|
if (taskTemplate == null) throw new ItemNotFoundException();
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskTemplateDto(taskTemplate);
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
protected TaskTemplateDto ToTaskTemplateDto(TaskTemplate taskTemplate)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-10 15:38:56 +00:00
|
|
|
// TODO: set task template category
|
2021-03-09 15:37:16 +00:00
|
|
|
return new TaskTemplateDto
|
2021-03-02 16:29:07 +00:00
|
|
|
{
|
2021-03-19 16:56:26 +00:00
|
|
|
// Category = GetTaskCategoryByID(taskTemplate.CategoryID),
|
2021-03-02 16:29:07 +00:00
|
|
|
ContainerID = taskTemplate.ContainerID,
|
|
|
|
DeadLineIsFixed = taskTemplate.DeadLineIsFixed,
|
|
|
|
Description = taskTemplate.Description,
|
|
|
|
Id = taskTemplate.ID,
|
|
|
|
isNotify = taskTemplate.isNotify,
|
|
|
|
Title = taskTemplate.Title,
|
|
|
|
OffsetTicks = taskTemplate.Offset.Ticks,
|
2021-03-23 15:41:56 +00:00
|
|
|
Responsible = _employeeWraperHelper.Get(taskTemplate.ResponsibleID)
|
2021-03-02 16:29:07 +00:00
|
|
|
};
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
protected IEnumerable<TaskTemplateContainerDto> ToTaskListTemplateContainerDto(IEnumerable<TaskTemplateContainer> items)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-09 15:37:16 +00:00
|
|
|
var result = new List<TaskTemplateContainerDto>();
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2021-03-19 16:56:26 +00:00
|
|
|
var taskTemplateDictionary = _daoFactory.GetTaskTemplateDao().GetAll()
|
2020-04-16 19:41:37 +00:00
|
|
|
.GroupBy(item => item.ContainerID)
|
2021-03-09 15:37:16 +00:00
|
|
|
.ToDictionary(x => x.Key, y => y.Select(ToTaskTemplateDto));
|
2020-04-16 19:41:37 +00:00
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
{
|
2021-03-09 15:37:16 +00:00
|
|
|
var taskTemplateContainer = new TaskTemplateContainerDto
|
2021-03-02 16:29:07 +00:00
|
|
|
{
|
|
|
|
Title = item.Title,
|
|
|
|
EntityType = item.EntityType.ToString(),
|
|
|
|
Id = item.ID
|
|
|
|
};
|
2020-04-16 19:41:37 +00:00
|
|
|
|
2020-04-22 20:46:49 +00:00
|
|
|
if (taskTemplateDictionary.ContainsKey(taskTemplateContainer.Id))
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2020-04-22 20:46:49 +00:00
|
|
|
taskTemplateContainer.Items = taskTemplateDictionary[taskTemplateContainer.Id];
|
2020-04-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
result.Add(taskTemplateContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-03-09 15:37:16 +00:00
|
|
|
protected TaskTemplateContainerDto ToTaskTemplateContainerDto(TaskTemplateContainer item)
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
2021-03-09 15:37:16 +00:00
|
|
|
return ToTaskListTemplateContainerDto(new List<TaskTemplateContainer>
|
2020-04-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
item
|
|
|
|
}).FirstOrDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|