public User GetUser(string id) { User user = new User(); SqlService sql = new SqlService(_sqlConnection); sql.AddParameter("@pId", System.Data.SqlDbType.NVarChar, id); using (SqlDataReader reader = sql.ExecuteSPReader("ICMS_spGetUser")) { if (reader.HasRows) { while (reader.Read()) { user.Id = id; user.UserName = reader.SafeGetString(reader.GetOrdinal("UserName")); user.FirstName = reader.SafeGetString(reader.GetOrdinal("FirstName")); user.LastName = reader.SafeGetString(reader.GetOrdinal("LastName")); user.Email = reader.SafeGetString(reader.GetOrdinal("Email")); user.MobileNo = reader.SafeGetInt64(reader.GetOrdinal("MobileNo")); user.CompanyName = reader.SafeGetString(reader.GetOrdinal("CompanyName")); user.Role = reader.SafeGetString(reader.GetOrdinal("Role")); } } } return user; }
public void UpdateUser(User user) { CreateUpdateUser(user); }
private void CreateUpdateUser(User user) { //ICMS_spCreateUpdateUser SqlService sql = new SqlService(_sqlConnection); if (!string.IsNullOrEmpty(user.Id)) { sql.AddParameter("@pId", System.Data.SqlDbType.NVarChar, user.Id); } sql.AddParameter("@pUserName", System.Data.SqlDbType.VarChar , user.UserName); sql.AddParameter("@pFirstName", System.Data.SqlDbType.VarChar , user.FirstName); sql.AddParameter("@pLastName", System.Data.SqlDbType.VarChar , user.LastName); sql.AddParameter("@pEmail", System.Data.SqlDbType.VarChar , user.Email); sql.AddParameter("@pMobileNo", System.Data.SqlDbType.BigInt , user.MobileNo); sql.AddParameter("@pCompanyName", System.Data.SqlDbType.VarChar , user.CompanyName); //sql.AddParameter("@pCustomerKey", System.Data.SqlDbType.UniqueIdentifier , user.CustomerKey); sql.AddParameter("@pRole", System.Data.SqlDbType.VarChar, user.Role); sql.ExecuteSP("ICMS_spCreateUpdateUser"); }