C#.NET 2.0 class example for data acess layer using microsoft enterpise library

here is the data layer class example.....

///here is the enum


public enum OprationType
{
Add = 1,
Update = 2,
Delete = 3
}


//here is the Interfae
public interface IDataStatndard
{
void Operation(OperationType enumOperationType);
}



//here is the user data class
public class UserData : IDataStatndard
{
#region PrivateMemeber
private DashBoardCollection.UserCollection _objUserCol;
private Database _db;
private string _commandName;
private DbCommand _dbCommand;
#endregion
#region Constructors
public UserData()
{
}
public UserData(DashBoardCollection.UserCollection obj)
{
_objUserCol = obj;
}
#endregion
#region Methods
public void Operation(OpertaionType enumOperationType)
{
switch (enumOperationType)
{
case OperationType.Add:
this.Add();
break;
case OperationType.Update:
this.Update();
break;
case OperationType.Delete:
this.Delete();
break;
}
}
private void Add()
{
}
private void Update()
{
}
private void Delete()
{
}
public bool CheckUserLogin()
{
_db = DatabaseFactory.CreateDatabase("SopraConnect");
_commandName = "usp_CheckUserLogin";
_dbCommand = _db.GetStoredProcCommand(_commandName);
_db.AddInParameter(_dbCommand, "username", DbType.String, this._objUserCol.UserName);
_db.AddInParameter(_dbCommand, "password", DbType.String, this._objUserCol.Password);
_db.AddOutParameter(_dbCommand, "isvalid", DbType.Byte, 1);
_db.ExecuteNonQuery(_dbCommand);
Byte isValid = Convert.ToByte( _db.GetParameterValue(_dbCommand, "isvalid"));
if (isValid == 1)
return true;
else
return false;
}
#endregion
}

Comments

Popular posts from this blog

How to create Rest API(Web API) with ASP.NET Core 1.0

Creating PDF with ASP.Net MVC and RazorPDF

Solution: gulp is not recognized as internal or external command- Visual Studio