Beispiel #1
0
 /// <summary>
 /// It is used to register user.
 /// </summary>
 /// <param name="registrationModel"></param>
 /// <returns></returns>
 public string RegisterUser(RegistrationModel registrationModel)
 {
     DataLayer.UserModel userModel = registrationModel.GetMappedObject();
     if (!IsAlreadyRegistered(registrationModel))
     {
         using (SqlConnection connection = new SqlConnection(StringLiterals._connectionString))
         {
             connection.Open();
             using (SqlCommand cmd = new SqlCommand(StringLiterals._insertCommand, connection))
             {
                 Console.WriteLine(userModel.FirstName);
                 cmd.Parameters.AddWithValue("@FirstName", userModel.FirstName);
                 cmd.Parameters.AddWithValue("@LastName", userModel.LastName);
                 cmd.Parameters.AddWithValue("@EmailAddress", userModel.EmailAddress);
                 cmd.Parameters.AddWithValue("@Password", userModel.Password);
                 cmd.Parameters.AddWithValue("@IsStudent", userModel.IsStudent);
                 if (cmd.ExecuteNonQuery() >= 1)
                 {
                     return(StringLiterals._success);
                 }
             }
         }
     }
     return(StringLiterals._registrationFailed);
 }
Beispiel #2
0
 /// <summary>
 /// It is used to register user.
 /// </summary>
 /// <param name="registrationModel"></param>
 /// <returns></returns>
 public string RegisterUser(RegistrationModel registrationModel)
 {
     DataLayer.UserModel userModel = registrationModel.GetMappedObject();
     if (!DataSource._userList.Any(m => m.EmailAddress == userModel.EmailAddress))
     {
         DataSource._userList.Add(userModel);
         return(StringLiterals._success);
     }
     return(StringLiterals._registrationFailed);
 }