Äsch jag skiter i egna entiteter så länged. Jag kör med ett Typat dataset som DAL och har påbörjat arbetet med att skapa ett BLL till detta.
Såhär kan det se ut då
using wbDataTableAdapters;
[System.ComponentModel.DataObject]
public class AdminsBLL
{
private AdminsTableAdapter _adminsAdapter = null;
protected AdminsTableAdapter Adapter
{
get
{
if (_adminsAdapter == null)
_adminsAdapter = new AdminsTableAdapter();
return _adminsAdapter;
}
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
public wbData.AdminsDataTable GetAdmins()
{
return Adapter.GetAdmins();
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
public wbData.AdminsDataTable GetAdminsByID(int ID)
{
return Adapter.GetAdminsByID(ID);
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddProduct(string fullName, string password, string email, int? writeaccess, int? adminaccess, int? resultaccess,
string phone)
{
// Create a new ProductRow instance
wbData.AdminsDataTable admins = new wbData.AdminsDataTable();
wbData.AdminsRow admin = admins.NewAdminsRow();
admin.FullName = fullName;
if (password == null) admin.SetPasswordNull(); else admin.Password = password;
if (email == null) admin.SetEmailNull(); else admin.Email = email;
if (writeaccess == null) admin.SetWriteAccessNull(); else admin.WriteAccess = writeaccess.Value;
if (adminaccess == null) admin.SetAdminAccessNull(); else admin.AdminAccess = adminaccess.Value;
if (resultaccess == null) admin.SetResultAccessNull(); else admin.ResultAccess = resultaccess.Value;
if (phone == null) admin.SetPhoneNull(); else admin.Phone = phone;
// Add the new product
admins.AddAdminsRow(admin);
int rowsAffected = Adapter.Update(admins);
// Return true if precisely one row was inserted, otherwise false
return rowsAffected == 1;
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public bool UpdateAdmin(string fullName, string password, string email, int? writeaccess, int? adminaccess, int? resultaccess,
string phone, int ID)
{
wbData.AdminsDataTable admins = Adapter.GetAdminsByID(ID);
if (admins.Count == 0)
// no matching record found, return false
return false;
wbData.AdminsRow admin = admins[0];
admin.FullName = fullName;
if (password == null) admin.SetPasswordNull(); else admin.Password = password;
if (email == null) admin.SetEmailNull(); else admin.Email = email;
if (writeaccess == null) admin.SetWriteAccessNull(); else admin.WriteAccess = writeaccess.Value;
if (adminaccess == null) admin.SetAdminAccessNull(); else admin.AdminAccess = adminaccess.Value;
if (resultaccess == null) admin.SetResultAccessNull(); else admin.ResultAccess = resultaccess.Value;
if (phone == null) admin.SetPhoneNull(); else admin.Phone = phone;
// Update the product record
int rowsAffected = Adapter.Update(admin);
// Return true if precisely one row was updated, otherwise false
return rowsAffected == 1;
}
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Delete, true)]
public bool DeleteAdmin(int ID)
{
int rowsAffected = Adapter.Delete(ID);
// Return true if precisely one row was deleted, otherwise false
return rowsAffected == 1;
}
}

