/// <summary> /// Remove Client /// </summary> /// <returns></returns> public int RemoveClient(int ClientId, int userId) { try { int rowsAffected; using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) { if (DbConnection.IsConnected()) { using (DbCommand) { DbCommand.CommandType = CommandType.StoredProcedure; DbCommand.CommandText = "uspRemoveClient"; DbCommand.Parameters.Clear(); DbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = ClientId; DbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId; DbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now; rowsAffected = DbConnection.ExecuteCommand(DbCommand); // ToDo Mark all Related Data Deleted using (ClientDAO contactDao = new ClientDAO()) { contactDao.RemoveContacts(ref dbConnection, ref dbCommand, ClientId, userId); } this.RemoveClientPricings(ref dbConnection, ref dbCommand, ClientId, userId); this.RemoveClientNotes(ref dbConnection, ref dbCommand, ClientId, userId); } }else { throw new Exception("Unable to Connect"); } } return rowsAffected; }catch { throw; } }