Ejemplo n.º 1
0
 public VictoriaDavydova.ThreeLayer.SSU.Entities.User GetUserByID(int idUser)
 {
     VictoriaDavydova.ThreeLayer.SSU.Entities.User newuser = null;
     foreach (var user in baseUsers.GetAllUsers())
     {
         if (user.idUser == idUser)
         {
             newuser = new VictoriaDavydova.ThreeLayer.SSU.Entities.User(user.idUser, user.fullName, user.dateOfBirth, user.age);
         }
     }
     return(newuser);
 }
Ejemplo n.º 2
0
 public VictoriaDavydova.ThreeLayer.SSU.Entities.User GetUserByID(int idUser)
 {
     VictoriaDavydova.ThreeLayer.SSU.Entities.User user = null;
     using (var connection = new SqlConnection(_myConnectionString))
     {
         connection.Open();
         SqlCommand command = connection.CreateCommand();
         command.CommandType = CommandType.StoredProcedure;
         command.CommandText = "FindUserByID";
         command.Parameters.Add("@IDUser", SqlDbType.NChar).Value = idUser;
         using (SqlDataReader dataReader = command.ExecuteReader())
         {
             while (dataReader.Read())
             {
                 user = new VictoriaDavydova.ThreeLayer.SSU.Entities.User((string)dataReader["FullName"], (string)dataReader["DateOfBirth"], (int)dataReader["Age"]);
             }
         }
     }
     return(user);
 }
Ejemplo n.º 3
0
 public string AddUser(VictoriaDavydova.ThreeLayer.SSU.Entities.User user)
 {
     using (var connection = new SqlConnection(_myConnectionString))
     {
         connection.Open();
         try
         {
             SqlCommand command = connection.CreateCommand();
             command.CommandType = CommandType.StoredProcedure;
             command.CommandText = "AddUser";
             command.Parameters.Add("FullName", SqlDbType.Char).Value    = user.fullName;
             command.Parameters.Add("DateOfBirth", SqlDbType.Char).Value = user.dateOfBirth;
             command.Parameters.Add("Age", SqlDbType.Char).Value         = user.age;
             var rowCount = command.ExecuteNonQuery();
             return("User successfully added. Rows Added = " + rowCount);
         }
         catch (Exception exception)
         {
             return(exception.StackTrace);
         }
     }
 }