EnVisageOnline/Main/Source/TimeTracker/WebSites/TimeTracker1/App_Code/BLL/Profiles.cs

138 lines
3.7 KiB
C#

using ASPNET.StarterKit.DataAccessLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace ASPNET.StarterKit.BusinessLogicLayer
{
public class Profiles
{
private string _setting;
private string _value;
private int _id;
private string _description;
private string _type;
private bool _canEdit;
private string _section;
public string Setting { get { return _setting; } }
public string Value
{
get
{
return _value;
}
}
public int Id
{
get
{
return _id;
}
}
public string SettingDescription
{
get
{
return _description;
}
}
public string SettingType
{
get
{
return _type;
}
}
public bool CanEdit
{
get
{
return _canEdit;
}
}
public string SettingSection
{
get
{
return _section;
}
}
public Profiles()
: this(null, null){ }
public Profiles(string setting, string value) : this(
setting, value, DefaultValues.GetProfileIdMinValue(), null, null, false, null)
{ }
public Profiles(string setting, string value, int id,string desc,string type, bool canEdit,string section)
{
this._setting = setting;
this._value = value;
this._description = desc;
this._id = id;
this._type = type;
this._canEdit = canEdit;
this._section = section;
}
/*** METHODS ***/
public bool Delete()
{
if (this._id > DefaultValues.GetProfileIdMinValue())
{
DataAccess DALLayer = DataAccessHelper.GetDataAccess();
return DALLayer.DeleteProfile(this._id);
}
else
return false;
}
public bool Save()
{
DataAccess DALLayer = DataAccessHelper.GetDataAccess();
if (this._id <= DefaultValues.GetTimeEntryIdMinValue())
{
int TempId = DALLayer.AddSetting(this);
if (TempId > DefaultValues.GetProfileIdMinValue())
{
this._id = TempId;
return true;
}
else
return false;
}
else
return (DALLayer.UpdateSetting(this.Setting,this.Value,this.Id));
}
/*** METHOD STATIC ***/
public static List<Profiles> GetAllSettings()
{
DataAccess DALLayer = DataAccessHelper.GetDataAccess();
return (DALLayer.GetAllSettings());
}
public static List<Profiles> GetAllSecurityLevels()
{
DataAccess DALLayer = DataAccessHelper.GetDataAccess();
List<Profiles> lps=(DALLayer.GetAllSecurityLevels());
return lps;
}
public static bool UpdateSetting(string setting,string value, int settingId)
{
if (settingId <= DefaultValues.GetProfileIdMinValue())
throw (new ArgumentOutOfRangeException("settingId"));
if (String.IsNullOrEmpty(setting))
throw (new NullReferenceException("setting"));
DataAccess DALLayer = DataAccessHelper.GetDataAccess();
return (DALLayer.UpdateSetting(setting, value,settingId));
}
}
}