using System;
using System.Collections.Generic;
using System.Text;
namespace RoadFlow.Platform
{
public class Role
{
private RoadFlow.Data.Interface.IRole dataRole;
public Role()
{
this.dataRole = Data.Factory.Factory.GetRole();
}
///
/// 新增
///
public int Add(RoadFlow.Data.Model.Role model)
{
return dataRole.Add(model);
}
///
/// 更新
///
public int Update(RoadFlow.Data.Model.Role model)
{
return dataRole.Update(model);
}
///
/// 查询所有记录
///
public List GetAll()
{
return dataRole.GetAll();
}
///
/// 查询单条记录
///
public RoadFlow.Data.Model.Role Get(Guid id)
{
return dataRole.Get(id);
}
///
/// 删除
///
public int Delete(Guid id)
{
return dataRole.Delete(id);
}
///
/// 查询记录条数
///
public long GetCount()
{
return dataRole.GetCount();
}
///
/// 得到所有角色选项
///
///
/// 不显示的ID
///
public string GetRoleOptions(string value = "", string hideID = "", IEnumerable roleList = null)
{
var roles = roleList == null ? GetAll() : roleList;
StringBuilder options = new StringBuilder();
foreach (var role in roles)
{
if (string.Compare(role.ID.ToString(), hideID, true) == 0)
{
continue;
}
options.AppendFormat("", role.ID,
string.Compare(role.ID.ToString(), value, true) == 0 ? "selected=\"selected\"" : "", role.Name);
}
return options.ToString();
}
}
}