using System;
using System.Data;
using SiteOffice.Data;
namespace SiteOffice.Business.PrivateMail{
/// <summary>
/// Author: Joe Audette
/// Created: 2006-08-02
/// Last Modified: 2007-11-15
///
/// The use and distribution terms for this software are covered by the
/// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
/// which can be found in the file CPL.TXT at the root of this distribution.
/// By using this software in any fashion, you are agreeing to be bound by
/// the terms of this license.
///
/// You must not remove this notice, or any other, from this software.
/// </summary>
public class PrivateMessagePriority
{
#region Constructors
public PrivateMessagePriority()
{ }
public PrivateMessagePriority(
Guid priorityId)
{
GetPrivateMessagePriority(
priorityId);
}
#endregion
#region Private Properties
private Guid priorityID = Guid.Empty;
private string priority;
#endregion
#region Public Properties
public Guid PriorityId
{
get { return priorityID; }
set { priorityID = value; }
}
public string Priority
{
get { return priority; }
set { priority = value; }
}
#endregion
#region Private Methods
private void GetPrivateMessagePriority(
Guid priorityId)
{
IDataReader reader = DBPrivateMessagePriority.GetPrivateMessagePriority(
priorityId);
if (reader.Read())
{
this.priorityID = new Guid(reader["PriorityID"].ToString());
this.priority = reader["Priority"].ToString();
}
reader.Close();
}
private bool Create()
{
Guid newID = Guid.NewGuid();
this.priorityID = newID;
int rowsAffected = DBPrivateMessagePriority.AddPrivateMessagePriority(
this.priorityID,
this.priority);
return (rowsAffected > 0);
}
private bool Update()
{
return DBPrivateMessagePriority.UpdatePrivateMessagePriority(
this.priorityID,
this.priority);
}
#endregion
#region Public Methods
public bool Save()
{
if (this.priorityID != Guid.Empty)
{
return Update();
}
else
{
return Create();
}
}
#endregion
}
}
|