Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

using Models.

EntityFramework;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Models.DAO
{
class CategoryDb
{
private PHIASPDbContext context;
public CategoryDb()
{
context = new PHIASPDbContext();
}

public IEnumerable<tblUser> GetstblUsers(int iD)


{
var list = context.Database.SqlQuery<tblUser>
("PSP_User_Select @UserID", new SqlParameter("@UserID", iD)).ToList();
return list;
}

public tblUser GetstblUsersByID(int iD)


{
var tblusers = context.Database.SqlQuery<tblUser>
("PSP_User_Select @UserID", new SqlParameter("@UserID",
iD)).SingleOrDefault();
return tblusers;
}

public int InsertUpdatetblUsers(tblUser tbluserlist)


{
SqlParameter[] param = new SqlParameter[]{
new SqlParameter("@UserID",tbluserlist.UserID),
new SqlParameter("@Username",tbluserlist.Username),
new SqlParameter("@Userpass",tbluserlist.Userpass),
new SqlParameter("@Fullname",tbluserlist.Fullname),
new SqlParameter("@Status",tbluserlist.Status),
new SqlParameter("@Systemright",tbluserlist.Systemright),
new SqlParameter("@Address",tbluserlist.Address),
new SqlParameter("@Phone",tbluserlist.Phone),
};
int result = context.Database.ExecuteSqlCommand("PSP_User_InsertUpdate
@UserID, @Username, @Userpass, @Fullname, @Status, @Systemright, @Address,
@Phone", param);
return result;
}

public int DeletetblUsers(tblUser tbluserlist)


{
SqlParameter[] param = new SqlParameter[]{
new SqlParameter("@UserID",tbluserlist.UserID)
};
int result = context.Database.ExecuteSqlCommand("PSP_User_Delete", param);
return result;
}
}
}

You might also like