public GetAllPermissionResponse GetAllPermission(GetAllPermissionRequest request)
{
GetAllPermissionResponse response = new DataContract.GetAllPermissionResponse();
try
{
Database db = DatabaseFactory.CreateDatabase(ConstantManager.CONNECTION_NAME);
using (DbCommand dbCommand = db.GetStoredProcCommand(ConstantManager.SP_PERMISSION_GETALL))
{
db.AddInParameter(dbCommand, "PageNumber", DbType.Int32, request.PageNumber);
db.AddInParameter(dbCommand, "Pagesize", DbType.Int32, request.Pagesize);
db.AddInParameter(dbCommand, "SortColumn", DbType.String, request.SortColumn);
db.AddInParameter(dbCommand, "SortOrder", DbType.String, request.SortOrder);
db.AddOutParameter(dbCommand, "RowCount", DbType.Int32, 5);
// db.AddOutParameter(dbCommand, "PageCount", DbType.Int32, 5);
PermissionCollection collection = new DataContract.PermissionCollection();
PermissionList list = new DataContract.PermissionList();
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
Permission obj = new DataContract.Permission();
if (dataReader["PermissionID"] != DBNull.Value) { obj.PermissionID = Convert.ToInt64(dataReader["PermissionID"]); }
if (dataReader["PermissionName"] != DBNull.Value) { obj.PermissionName = Convert.ToString(dataReader["PermissionName"]); }
if (dataReader["PermissionDescription"] != DBNull.Value) { obj.PermissionDescription = Convert.ToString(dataReader["PermissionDescription"]); }
if (dataReader["IsActive"] != DBNull.Value) { obj.IsActive = Convert.ToBoolean(dataReader["IsActive"]); }
if (dataReader["CreatedDate"] != DBNull.Value) { obj.CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]); }
if (dataReader["CreatedBy"] != DBNull.Value) { obj.CreatedBy = Convert.ToInt64(dataReader["CreatedBy"]); }
if (dataReader["UpdatedDate"] != DBNull.Value) { obj.UpdatedDate = Convert.ToDateTime(dataReader["UpdatedDate"]); }
if (dataReader["UpdatedBy"] != DBNull.Value) { obj.UpdatedBy = Convert.ToInt64(dataReader["UpdatedBy"]); }
collection.Add(obj);
}
}
var rowcount = Convert.ToInt32(db.GetParameterValue(dbCommand, "RowCount"));
// var pagecount = Convert.ToInt32(db.GetParameterValue(dbCommand, "PageCount"));
list.Rows = collection;
list.TotalRowCount = rowcount;
// list.NoOfPages = pagecount;
response.Response = list;
}
}
catch (Exception exception)
{
ExceptionManager.HandleDataException(exception, ConstantManager.DATA_EXCEPTIONPOLICY);
}
return response;
}
No comments:
Post a Comment