⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 account.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 CS
字号:
using System;

//References to PetShop specific libraries
//PetShop busines entity library
using BookShop.Model;

//PetShop DAL interfaces
using BookShop.IDAL;

namespace BookShop.BLL {

	/// <summary>
	/// A business Component used to manage accounts
	/// The BookShop.Model.Account is used in most methods 
	/// and is used to store serializable information about an account
	/// </summary>
	public class Account {
		
		/// <summary>
		/// Method to login into the system. The user must supply a username and password
		/// </summary>
		/// <param name="userId">Unique identifier for a user</param>
		/// <param name="password">Password for a user</param>
		/// <returns>If the login is successful it returns information abount the account</returns>
		public AccountInfo SignIn(string userId, string password) {

			// Validate input
			if ((userId.Trim() == string.Empty) || (password.Trim() == string.Empty))
				return null;

			// Get an instance of the account DAL using the DALFactory
			IAccount dal = BookShop.DALFactory.Account.Create();

			// Try to sign in with the given credentials
			AccountInfo account = dal.SignIn(userId, password);

			// Return the account
			return account;
		}

		/// <summary>
		/// Returns the address information for a specific user
		/// </summary>
		/// <param name="userId">Unique identifier for an account/customer</param>
		/// <returns>Returns the address information for the user</returns>
		public AddressInfo GetAddress(string userId) {

			// Validate input
			if (userId.Trim() == string.Empty)
				return null;
			
			// Get an instance of the account DAL using the DALFactory
			IAccount dal = BookShop.DALFactory.Account.Create();

			// Return the address information for the given userId from the DAL
			return dal.GetAddress(userId); 
		}

		/// <summary>
		/// A method to insert a new Account
		/// </summary>
		/// <param name="account">An account entity with information about the new account</param>
		public void Insert(AccountInfo account) {

			// Validate input
			if (account.UserId.Trim() == string.Empty)
				return;

			// Get an instance of the account DAL using the DALFactory
			IAccount dal = BookShop.DALFactory.Account.Create();

			// Call the DAL to insert the account
			dal.Insert(account);
		}

		/// <summary>
		/// A method to update an existing account
		/// </summary>
		/// <param name="account">An account entity with information about the account to be updated</param>
		public void Update(AccountInfo account) {

			// Validate input
			if (account.UserId.Trim() == string.Empty)
				return;

			// Get an instance of the account DAL using the DALFactory
			IAccount dal = BookShop.DALFactory.Account.Create();

			// Send the udpated account information to the DAL
			dal.Update(account);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -