The SqlHelper class is intended to encapsulate high performance, scalable best practices for common uses of SqlClient
Beispiel #1
0
        //web config - centralno mjesto za pohranu
        public List <User> GetAllUsers()
        {
            List <User> users = new List <User>();

            //nadji sqlelper u nugget packagima microsoft
            DataSet dsUsers = SqlHelper.ExecuteDataset(cs, "GetUsers");

            //nezovi proceduru kako smo nazvali metodu
            //KUHARICA SPRANCA CESLJANJE PODATAKA OD STRANE SQL HELPERA TOE TO
            foreach (DataRow row in dsUsers.Tables[0].Rows)//dataset je kolekcija tablica, imat ce onoliko tablica koliko ima select upita
            //u nasem slucaju jedan, u slucaju vise slectova imali bi vise tablica
            {
                int  ID   = (int)row["IDUser"];
                User user = new User();
                user.IDUser    = ID;
                user.Firstname = row["Firstname"].ToString();
                user.Lastname  = row["Lastname"].ToString();
                user.Phone     = row["Phone"].ToString();
                user.City      = row["City"].ToString();
                user.Role      = row["Role"].ToString();
                user.Password  = row["Password"].ToString();
                user.Email     = row["Email"].ToString();

                users.Add(user);
            }
            return(users);
        }
Beispiel #2
0
 public void UpdateUser(int userId, string name, string lastname, string phone, string password, string city, string role, string email)
 {
     SqlHelper.ExecuteNonQuery(cs, "UpdateUser", userId, name, lastname, phone, password, city, role, email);
 }
Beispiel #3
0
 public void DeleteUser(int id)
 {
     SqlHelper.ExecuteNonQuery(cs, "DeleteUser", id);
 }
Beispiel #4
0
 public void AddUser(string name, string lastname, string phone, string password, string city, string role, string email)
 {
     SqlHelper.ExecuteNonQuery(cs, "AddUser", name, lastname, phone, password, city, role, email);
 }