using System;
using System.Data;
using System.Configuration;
using ASPNET.StarterKit.TimeTracker.DataAccessLayer;

namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer
{
	//****************************************************************************
	//
	// Roles Class
	//
	// The Roles class represents a list of custom Time Tracker roles.
	//
	//****************************************************************************

	public class Roles
	{
		private string _name;
		private int _roleID;

		public string Name
		{
			get {return _name;}
			set {_name = value;}
		}

		public int RoleID
		{
			get {return _roleID;}
			set {_roleID = value;}
		}

		public static RolesCollection GetRoles()
		{
			DataSet ds = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Web.Global.CfgKeyConnString], "TT_ListAllRoles");
			RolesCollection roleArray = new RolesCollection();

			// Separate Data into a collection of Roles
			foreach(DataRow r in ds.Tables[0].Rows)
			{
				Roles role = new Roles();
				role.RoleID = Convert.ToInt32(r["RoleID"]);
				role.Name = r["Name"].ToString();
				
				roleArray.Add(role);
			}
			return roleArray;
		}

	}
}
