public Int16 UpdateCustomer(Guid ID, String PastEmail, String firstName, String lastName, String email, String PhoneNumber, DateTime dateOfBirth)
 {
     using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString.ToString()))
     {
         Int16         result   = 0;
         CustomerClass tmpClass = new CustomerClass();
         tmpClass = tmpClass.SelectOneCustomer(PastEmail);
         using (SqlCommand cmd = new SqlCommand("UpdateCustomerParticulars", conn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@ID", ID);
             cmd.Parameters.AddWithValue("@PastEmail", PastEmail);
             cmd.Parameters.AddWithValue("@FirstName", tmpClass.generateEncryptor(firstName));
             cmd.Parameters.AddWithValue("@LastName", tmpClass.generateEncryptor(lastName));
             cmd.Parameters.AddWithValue("@NewEmail", email);
             cmd.Parameters.AddWithValue("@PhoneNumber", tmpClass.generateEncryptor(PhoneNumber));
             cmd.Parameters.AddWithValue("@BirthDate", tmpClass.generateEncryptor(dateOfBirth.ToString()));
             try
             {
                 conn.Open();
                 BlackListClass tmpPower = new BlackListClass();
                 result = tmpPower.UpdateBlacklistEmails(PastEmail, email);
                 if (result < 0)
                 {
                     throw new OverflowException();
                 }
                 result = (Int16)cmd.ExecuteNonQuery();
                 if (result != 1)
                 {
                     throw new OverflowException();
                 }
                 if (email != PastEmail)
                 {
                     result = UpdateCustomerStatus(ID, PastEmail, "emailStatus", false);
                 }
             }
             catch (SqlException err)
             {
                 Console.WriteLine(err);
                 result = -3;
             }
             catch (OverflowException err)
             {
                 result = -2;
             }
             catch
             {
                 result = -1;
             }
             finally
             {
                 conn.Close();
             }
             return(result);
         }
     }
 }
Example #2
0
 public Int16 UpdateBlacklist(Guid ID, String customerId, Boolean status)
 {
     using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString.ToString()))
     {
         Int16 result = 0;
         using (SqlCommand cmd = new SqlCommand("UpdateBlacklistDeleted", conn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@customerId", customerId);
             cmd.Parameters.AddWithValue("@valueOne", status);
             BlackListClass powerClass = SelectOneBlacklist(ID, customerId);
             if (DateTime.Now.CompareTo(powerClass.EndedAt) > 0)
             {
                 try
                 {
                     conn.Open();
                     result = (Int16)cmd.ExecuteNonQuery();
                 }
                 catch (SqlException err)
                 {
                     Console.WriteLine(err);
                     result = -3;
                 }
                 catch (OverflowException)
                 {
                     result = -2;
                 }
                 catch
                 {
                     result = -1;
                 }
                 finally
                 {
                     conn.Close();
                 }
                 return(result);
             }
             else
             {
                 return(-4);
             }
         }
     }
 }
Example #3
0
 public BlackListClass SelectOneBlacklist(Guid ID, String customerId)
 {
     using (SqlConnection connOne = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString.ToString()))
     {
         using (SqlCommand cmdOne = new SqlCommand("SelectOneBlackList", connOne))
         {
             BlackListClass tmpClass = new BlackListClass();
             cmdOne.CommandType = CommandType.StoredProcedure;
             cmdOne.Parameters.AddWithValue("@ID", ID);
             cmdOne.Parameters.AddWithValue("@customerId", customerId);
             CustomerClass powerClass = new CustomerClass();
             powerClass = powerClass.SelectOneCustomer(customerId);
             try
             {
                 connOne.Open();
                 using (SqlDataReader reader = cmdOne.ExecuteReader())
                 {
                     if (reader.Read())
                     {
                         tmpClass.CreatedAt    = (DateTime)reader["createdAt"];
                         tmpClass.EndedAt      = (DateTime)reader["endedAt"];
                         tmpClass.Reason       = (String)reader["reason"];
                         tmpClass.CustomerID   = (String)reader["customerId"];
                         tmpClass.CustomerName = powerClass.generateDecryptor((String)reader["customerName"]);
                         tmpClass.Deleted      = (Boolean)reader["deleted"];
                     }
                 }
             }
             catch (Exception err)
             {
                 Console.WriteLine(err);
                 return(null);
             }
             finally
             {
                 connOne.Close();
             }
             return(tmpClass);
         }
     }
 }
Example #4
0
 public List <BlackListClass> SelectAllBlacklist(String customerId)
 {
     using (SqlConnection connOne = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString.ToString()))
     {
         using (SqlConnection connTwo = new SqlConnection(ConfigurationManager.ConnectionStrings["MySecretDB"].ConnectionString.ToString()))
         {
             using (SqlDataAdapter cmdOne = new SqlDataAdapter("SelectAllBlackList", connOne))
             {
                 connOne.Open();
                 connTwo.Open();
                 cmdOne.SelectCommand.CommandType = CommandType.StoredProcedure;
                 cmdOne.SelectCommand.Parameters.AddWithValue("@customerId", customerId);
                 DataSet newDataSet = new DataSet();
                 cmdOne.Fill(newDataSet);
                 List <BlackListClass> blacklistList = new List <BlackListClass>();
                 int           rec_cnt    = newDataSet.Tables[0].Rows.Count;
                 CustomerClass powerClass = new CustomerClass();
                 powerClass = powerClass.SelectOneCustomer(customerId);
                 for (int i = 0; i < rec_cnt; i++)
                 {
                     DataRow        row      = newDataSet.Tables[0].Rows[i];
                     BlackListClass tmpClass = new BlackListClass();
                     tmpClass.ID           = (Guid)row["ID"];
                     tmpClass.CreatedAt    = (DateTime)row["createdAt"];
                     tmpClass.EndedAt      = (DateTime)row["endedAt"];
                     tmpClass.Reason       = (String)row["reason"];
                     tmpClass.CustomerID   = (String)row["customerId"];
                     tmpClass.CustomerName = powerClass.generateDecryptor((String)row["customerName"]);
                     tmpClass.Deleted      = (Boolean)row["deleted"];
                     blacklistList.Add(tmpClass);
                 }
                 connOne.Close();
                 connTwo.Close();
                 return(blacklistList);
             }
         }
     }
 }