You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

68 lines
1.7 KiB

using System;
using System.Collections.Generic;
using Pingchuan.BeijingSafeguard.DAL;
using Pingchuan.BeijingSafeguard.Model;
namespace Pingchuan.BeijingSafeguard.BLL
{
public class TagBLL
{
public static int Add(int userId, string taskId, string name)
{
return TagDAL.Add(ToModel(userId, taskId, name));
}
public static void Delete(int tagId)
{
TagDAL.Delete(tagId);
}
public static void DeleteByTagName(string userId, string tagName, string region)
{
List<Task> tasks = TaskBLL.GetTaskIdByRegion(region);
string taskIds = GetTaskIdsString(tasks);
TagDAL.DeleteByTagName(userId, taskIds, tagName);
}
public static void DeleteByTaskId(string id)
{
TagDAL.DeleteByTaskId(id);
}
public static List<Tag> GetList(int userId)
{
return TagDAL.GetList(userId);
}
public static List<Tag> GetTags(int userId, string taskId)
{
return TagDAL.GetList(userId, taskId);
}
public static Tag ToModel(int userId, string taskId, string name)
{
return new Tag
{
UserId = userId,
TaskId = taskId,
Name = name,
CreateTime = DateTime.Now
};
}
public static string GetTaskIdsString(List<Task> tasks)
{
List<string> taskIds = new List<string>();
if (taskIds != null)
{
foreach (Task task in tasks)
taskIds.Add(task.Id);
}
return string.Join(",", taskIds.ToArray());
}
}
}